<project name="ySVG-Demos" default="help" basedir=".">

  <target name="help">
    <echo>Demo specific targets:</echo>
    <echo>RenderingPerformanceDemo  - runs demo demo.yext.svg.RenderingPerformanceDemo
    </echo>
    <echo>GraphMLDemo               - runs demo demo.yext.svg.GraphMLDemo</echo>
    <echo>HighlightConnectionsDemo  - runs demo demo.yext.svg.HighlightConnectionsDemo</echo>
    <echo>HtmlTooltipDemo           - runs demo demo.yext.svg.HtmlTooltipDemo</echo>
    <echo>HyperlinkDemo             - runs demo demo.yext.svg.HyperlinkDemo</echo>
    <echo>RolloverDemo              - runs demo demo.yext.svg.RolloverDemo</echo>
    <echo>SVGExportDemo             - runs demo demo.yext.svg.SVGExportDemo</echo>
    <echo>SimpleSVGNodeRealizerDemo - runs demo demo.yext.svg.SimpleSVGNodeRealizerDemo
    </echo>
    <echo>SVGNodeRealizerDemo       - runs demo demo.yext.svg.SVGNodeRealizerDemo</echo>
    <echo/>
    <echo/>
    <echo>General targets:</echo>
    <echo>touch     touches all demo .java files</echo>
    <echo>clean     removes all that has been built</echo>
    <echo>compile   compiles the demo packages</echo>
  </target>

  <target name="-init">
    <property
     name="demo.src.dir"
     value=".."/>
    <property
     name="demo.class.dir"
     value="../../classes"/>
    <property
     name="ysvg.jar"
     value="../../lib/ysvg.jar"/>
    <property
     name="batik.jar"
     value="../../lib/batik.jar"/>

    <property file="build.properties"/>

    <condition property="yfiles.available">
      <and>
        <isset property="yfiles"/>
        <available
         classname="y.view.Graph2D"
         classpath="${yfiles}"/>
      </and>
    </condition>
    <fail
     unless="yfiles.available">yFiles unavailable.
      Please specify the path to yFiles classes. This can be done in two ways:
      Either create a file called 'build.properties' which contains the line
          yfiles=[path to jar or directory]
      or specify the appropriate System property
          -Dyfiles=[path to jar or directory]</fail>

    <path id="democlasspath">
      <pathelement location="${demo.class.dir}"/>
      <pathelement location="${demo.src.dir}"/>
      <pathelement location="${yfiles}"/>
      <pathelement location="${ysvg.jar}"/>
      <pathelement location="${batik.jar}"/>
    </path>
  </target>

  <target name="-init.graphml">
    <condition property="graphml.available">
      <and>
        <isset property="graphml"/>
        <available
         classname="yext.graphml.graph2D.AbstractNodeRealizerSerializer"
         classpath="${graphml}"/>
      </and>
    </condition>
    <condition
     property="graphml.available.humanreadable"
     value="yes"
     else="no">
      <isset property="graphml.available"/>
    </condition>
    <condition
     property="sources"
     value="sources+graphml"
     else="sources-graphml">
      <isset property="graphml.available"/>
    </condition>
    <condition
     property="libs"
     value="libs+graphml"
     else="libs-graphml">
      <isset property="graphml.available"/>
    </condition>

    <path id="libs-graphml">
      <pathelement location="${yfiles}"/>
      <pathelement location="${ysvg.jar}"/>
      <pathelement location="${batik.jar}"/>
    </path>

    <path id="libs+graphml">
      <path refid="libs-graphml"/>
      <pathelement location="${graphml}"/>
    </path>

    <patternset id="sources+graphml">
      <include name="**/*.java"/>
    </patternset>

    <patternset id="sources-graphml">
      <include name="**/*.java"/>
      <exclude name="**/GraphMLDemo.java"/>
    </patternset>

    <echo message="GraphML Support: ${graphml.available.humanreadable}"/>
  </target>

  <target
   name="compile"
   depends="-init,-init.graphml"
   description="Compiles the demo files">
    <mkdir dir="${demo.class.dir}"/>
    <javac
     debug="true"
     destdir="${demo.class.dir}"
     srcdir="${demo.src.dir}"
     includeAntRuntime="false">
      <classpath>
        <path refid="${libs}"/>
      </classpath>
      <patternset refid="${sources}"/>
    </javac>
  </target>

  <target
   name="touch-demo"
   depends="-init"
   description="Touches the .java files of the demos.">
    <touch>
      <fileset dir="${demo.src.dir}" includes="**/*.java"/>
    </touch>
  </target>

  <target
   name="clean"
   depends="-init"
   description="Removes all that has been built.">
    <delete dir="${demo.class.dir}" includeEmptyDirs="true"/>
  </target>



  <target name="RenderingPerformanceDemo" depends="compile">
    <java
     classname="demo.yext.svg.RenderingPerformanceDemo"
     fork="true"
     failonerror="true">
      <classpath refid="democlasspath"/>
    </java>
  </target>
  <target name="GraphMLDemo" depends="compile">
    <fail unless="graphml.available">GraphML unavailable.
      Please specify the path to GraphML classes. This can be done in two ways:
      Either create a file called 'build.properties' which contains the line
          graphml=[path to jar or directory]
      or specify the appropriate System property
          -Dgraphml=[path to jar or directory]</fail>
    <java
     classname="demo.yext.svg.GraphMLDemo"
     fork="true"
     failonerror="true">
      <classpath>
        <path refid="democlasspath"/>
        <pathelement location="${graphml}"/>
      </classpath>
    </java>
  </target>
  <target name="HighlightConnectionsDemo" depends="compile">
    <java
     classname="demo.yext.svg.HighlightConnectionsDemo"
     fork="true"
     failonerror="true">
      <classpath refid="democlasspath"/>
    </java>
  </target>
  <target name="HtmlTooltipDemo" depends="compile">
    <java
     classname="demo.yext.svg.HtmlTooltipDemo"
     fork="true"
     failonerror="true">
      <classpath refid="democlasspath"/>
    </java>
  </target>
  <target name="HyperlinkDemo" depends="compile">
    <java
     classname="demo.yext.svg.HyperlinkDemo"
     fork="true"
     failonerror="true">
      <classpath refid="democlasspath"/>
    </java>
  </target>
  <target name="RolloverDemo" depends="compile">
    <java
     classname="demo.yext.svg.RolloverDemo"
     fork="true"
     failonerror="true">
      <classpath refid="democlasspath"/>
    </java>
  </target>
  <target name="SVGExportDemo" depends="compile">
    <java
     classname="demo.yext.svg.SVGExportDemo"
     fork="true"
     failonerror="true">
      <classpath refid="democlasspath"/>
    </java>
  </target>
  <target name="SimpleSVGNodeRealizerDemo" depends="compile">
    <java
     classname="demo.yext.svg.SimpleSVGNodeRealizerDemo"
     fork="true"
     failonerror="true">
      <classpath refid="democlasspath"/>
    </java>
  </target>
  <target name="SVGNodeRealizerDemo" depends="compile">
    <java
     classname="demo.yext.svg.SVGNodeRealizerDemo"
     fork="true"
     failonerror="true">
      <classpath refid="democlasspath"/>
    </java>
  </target>

</project>