Software Secret Weapons™


 
How To Use Linguine Maps From Ant Build Files
by Pavel Simakov on 2005-11-18 16:48:49 under Linguine Maps, view comments
Bookmark and Share
 


Index  •  Intro  •  WSDL  •  Apache Ant  •  DTD's for XML  •  ObJectRelationalBridge  •  Hibernate  •  Gallery  •  FAQ  •  Help  •  JavaDoc  •  Download
Hibernate Configuration  •  Object Relational Impedance Mismatch  

Linguine Maps provides clean object-oriented diagramming API for graph visualization. This is how it works:

  • run our Java code from command line or from a custom Ant task
  • specify two parameters
    • the name of the input source file to visualize
    • the name of the output GIF to be created
Our Java code parses the input file and creates the drawing.

Here is a smallest working Apache Ant build file for programmatic visualization:


<project name="Test" default="build" basedir=".">

  <property name="doc" location="doc"/>
  <property name="bin" location="bin"/>
  <property name="dot.exe" location="${bin}/graphviz-2.4/bin/dot.exe" />
	
  <taskdef 
    name="ant2gif" 
    classname="com.oy.shared.lm.ant.ANTtoGIFTask" 
    classpath="${dist}/lib/oy-lm-1.3.jar"
  />	
		
  <target name="build" >		
    <ant2gif  
	caption="XML file for launching Catalina 5.0.25 applications using Apache Ant."
	rotated="true"
	colors="cyan, lightcyan, orange, black, black"
	inFile="${src}/com/oy/shared/lm/test/ant/catalina-5.0.25.xml" 
	dotFile="${doc}/test/ant/catalina-5.0.25.dot" 
	outFile="${doc}/test/ant/catalina-5.0.25.gif"
	exeFile="${dot.exe}"
	/>
  </target>		
</project>

There are several tasks for programmatic visualization of various files types. Before using them, you would need to define a custom Ant task. You can define custom tasks as follows:


<taskdef 
  name="ant2gif" 
  classname="com.oy.shared.lm.ant.ANTtoGIFTask" 
  classpath="${dist}/lib/oy-lm-1.3.jar"
/>	
<taskdef 
  name="ojb2gif" 
  classname="com.oy.shared.lm.ant.OJBtoGIFTask" 
  classpath="${dist}/lib/oy-lm-1.3.jar"
/>	
<taskdef 
  name="hbm2gif" 
  classname="com.oy.shared.lm.ant.HBMtoGIFTask" 
  classpath="${dist}/lib/oy-lm-1.3.jar"
/>	
<taskdef 
  name="dtd2gif" 
  classname="com.oy.shared.lm.ant.DTDtoGIFTask" 
  classpath="${dist}/lib/oy-lm-1.3.jar"
/>
<taskdef 
  name="wsdl2gif" 
  classname="com.oy.shared.lm.ant.WSDLtoGIFTask" 
  classpath="${dist}/lib/oy-lm-1.3.jar"
/>			

After new tasks have been defined you can use them in the Ant build files as shown in the example above. All tasks have identical set of parameters, with following usage:

Parameter NameDescriptionRequired
inFilequalified name for the input file (depends on the task)required
dotFilequalified name for the intermediate output filerequired
outFilequalified name for the images output filerequired; can end with .gif, .png, .jpg, etc.
exeFilequalified name for the Graphviz 2.4 executablerequired
colorscomma separated list of colors (depends on the task)optional; can use #RRGGBB format
includescomma separated list of entity names that are included into the diagramoptional
excludescomma separated list of entity names that are excluded from the diagramoptional
rotated"true|false"; controls page orientationoptional, default "false"
detailed"true|false"; controls amount of details in the diagramoptional, default "true"
captiontitle of the diagramoptional
fontNamefont name for the diagramoptional, default "Helvetica"
fontSizebase font size for the diagramoptional, default "10"
attrcustom Graphviz attributes for the diagramoptional
nodeAttrcustom Graphviz attributes for the nodesoptional
edgeAttrcustom Graphviz attributes for the edgesoptional
qualifiedNames"true|false"; strips package names class from namesdefault "true"; optional
expandEntityRef"true|false"; forces processing of XML ENTITYdefault "false"; optional

Starting with release 1.3 HBM2GIF task in addition to a inFile attribute supports nested <fileset> elements. In this case a single diagram is produced reflecting contents of all mapping files contained in the <fileset>. For example:


<hbm2gif  
  caption="HIBERNATE - Animal & Beings"
  rotated="true"
  colors="#FF5937, black, black"
  dotFile="${doc}/test/hbm/AnimalBeings.dot" 
  outFile="${doc}/test/hbm/AnimalBeings.png"
  exeFile="${dot.exe}"
>
	<fileset dir="${src}/com/oy/shared/lm/test/hbm/">
		<include name="Animal.hbm.xml"/>
		<include name="Beings.hbm.xml"/>
	</fileset>
</hbm2gif>

Please review runme.xml or runme-adv.xml files for more examples of use of these Ant tasks and their parameters.

Comments (2)

  • Comment by Kolorowanki — June 28, 2009 @ 6:15 pm

    nice API:)
    Cheers for that!
    M.K.

  • Comment by JRS — December 15, 2009 @ 7:36 am

    Looks promising. For a first test: what is the commandline syntax for dot.exe?


Leave a comment


 
Dog Emotional 2010 Calendar Dog Emotional Mousepad Dog Fashionable 2010 Calendar Dog Fashionable Mousepad

Copyright © 2004-2010 by Pavel Simakov
any conclusions, recommendations, ideas, thoughts or the source code presented on this site are my own and do not reflect a official opinion of my current or past employers, partners or clients
SourceForge.net Logo