Array Tags
The array tag is used to define data. The id argument is used to name the array. Array tags can be nested to form multidimensional arrays. At the inner-most level the following tags are allowed.
<String value=
string/>
<Color value=
color/>
The value of color can be either a red, green, blue triple in the range [0,255] or color names. For example
"255,215,0" or
"gold". See this
Color page for information on usable values.
<Date value=date style=
style locale=
locale/>
If the argument locale is specified, it is parsed the same as the locale argument in the tag Attribute as described above. If the locale is not specified, then the default locale is used.
If the argument style is
SHORT,
MEDIUM,
LONG or
FULL, then the date is parsed using the object
DateFormat.getDateInstance(int, Locale). If style is not specified, then
SHORT is assumed.
Style can also be a pattern used to construct a
SimpleDateFormat(int, Locale).
<Number value=
number/>
Numbers are parsed using
Double.valueOf(number).
<NumberList>
number,...,number</NumberList> | <NumberList value=
list/>
The body of this tag is a comma separated list of numbers. Each number is parsed using
Double.valueOf(number).
The value arguments are optional. If omitted, the tag’s body is used instead.
Array Tag Examples
The first example is of a three-dimensional array called foo.
<Array id="foo">
<Array>
<Array><NumberList value="1,2,3"/></Array>
<Array><NumberList value="4,5,6"/></Array>
</Array>
<Array>
<Array><NumberList value="11,12,13"/></Array>
<Array><NumberList value="14,15,16"/></Array>
</Array>
</Array>
This corresponds to the Java declaration
double foo[][][] = {{{1,2,3},{4,5,6}},{{11,12,13},{14,15,16}}}
The second example is an array of three strings called states.
<Array id="states">
<String value="NJ"/>
<String value="TX"/>
<String value="CO"/>
</Array>
The final example is an array of four colors, called bg.
<Array id="bg">
<Color value="yellow"/>
<Color value="0,128,64"/>
<Color value="lightblue"/>
<Color value="yellow"/>
</Array>
Creating a Chart from XML
The class
ChartXML creates a chart tree from an XML file. It can be used directly as an application to view an XML file. The following command displays the chart described by the XML file
filename. (This assumes that the CLASSPATH is correctly set.)
java com.imsl.chart.xml.ChartXML filename
Interacting with an XML Created Chart
The class
ChartXML can also be used to create a chart tree within a larger Java program. The object’s
getChart() method is used to retrieve the created chart object. The
get(String) method is used to obtain objects created by array tags.