JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart3d.data
Class JCXML3dDataSource

java.lang.Object
  |
  +--com.klg.jclass.chart3d.event.Chart3dDataSupport
        |
        +--com.klg.jclass.chart3d.data.Base3dDataSource
              |
              +--com.klg.jclass.chart3d.data.Base3dGridDataSource
                    |
                    +--com.klg.jclass.chart3d.data.JCDefault3dGridDataSource
                          |
                          +--com.klg.jclass.chart3d.data.JCXML3dDataSource
All Implemented Interfaces:
Chart3dDataManager, Chart3dDataModel, Chart3dGridDataModel, Cloneable, HoleValueChart3dDataModel, LabelledChart3dDataModel, LabelledChart3dGridDataModel, Serializable

public class JCXML3dDataSource
extends JCDefault3dGridDataSource

This class parses data from an XML file. Specification for the xml data can be found in the chart3d.dtd file.

An example XML file would have the following appearance:

<?xml version="1.0"?>
<!DOCTYPE data SYSTEM "chart3d.dtd">

<data hole="-100" name="my data">
  <xgrid>
    <xval>0.78</xval>
    <xval>1.565</xval>
    <xval>2.00</xval>
  </xgrid>

  <ygrid>
    <yval>1.00</yval>
    <yval>2.0</yval>
    <yval>3.0</yval>
    <yval>4.0</yval>
    <yval>5.0</yval>
   </ygrid>

  <zgrid>
    <zval>15.64</zval>
    <zval>23.4546</zval>
    <zval>45.4545</zval>
    <zval>20.4546</zval>
    <zval>14.4545</zval>
  </zgrid>

  <zgrid>
    <zval>18.5656</zval>
    <zval>23.884</zval>
    <zval>35.6454</zval>
    <zval>21.47</zval>
    <zval>37.45</zval>
  </zgrid>

  <zgrid>
    <zval>16.58</zval>
    <zval>10.5656</zval>
    <zval>17.65</zval>
    <zval>19.645</zval>
    <zval>34.4561</zval>
  </zgrid>

  <xlabel>January</xlabel>
  <xlabel>February</xlabel>
  <xlabel>March</xlabel>

  <ylabel>Orcs</ylabel>
  <ylabel>Zombies</ylabel>
  <ylabel>Skeletons</ylabel>
  <ylabel>Vampires</ylabel>
  <ylabel>Werewolves</ylabel>

</data>

See Also:
Serialized Form

Field Summary
static String XML_DS_ATT_HOLE
          Static string for hole attribute of top level tag in the chart XML datasource.
static String XML_DS_ATT_NAME
          Static string for datasource name of chart XML datasource.
static String XML_DS_XDATA
          Static string for x data tag of chart XML datasource.
static String XML_DS_XLABEL
          Static string for x Labels of chart XML datasource.
static String XML_DS_YDATA
          Static string for y data tag of chart XML datasource.
static String XML_DS_YLABEL
          Static string for series label tag of chart XML datasource.
static String XML_DS_ZGRID
          Static string for z grid tag of chart XML datasource.
static String XML_DS_ZVAL
          Static string for z data tag of chart XML datasource.
 
Fields inherited from class com.klg.jclass.chart3d.data.Base3dGridDataSource
chartDataListeners, dataSourceName, xGrid, xLabels, yGrid, yLabels, zValues
 
Fields inherited from class com.klg.jclass.chart3d.data.Base3dDataSource
holeValue
 
Fields inherited from class com.klg.jclass.chart3d.event.Chart3dDataSupport
source
 
Fields inherited from interface com.klg.jclass.chart3d.HoleValueChart3dDataModel
DEFAULT_HOLE_VALUE
 
Constructor Summary
JCXML3dDataSource(File xmlFile)
          This constructor takes an xml file as an argument.
JCXML3dDataSource(InputSource inSource)
          This constructor takes an InputSource .
JCXML3dDataSource(InputStream inStream)
          This constructor takes an InputStream in XML form.
JCXML3dDataSource(Reader reader)
          This constructor takes a Reader which contains xml.
JCXML3dDataSource(String xmlString)
          This constructor takes xml in String form .
 
Method Summary
protected  double convertDoubleValue(String toConvert)
          Convenience method to convert a String to a double .
 DocumentBuilder getDocBuilder()
          Creates a DocumentBuilder object which parses the XML into a Document object, which can then be parsed into a Chart3d dataSource.
protected  void parseDoc(Document doc)
          This is the workhorse of this class which parses the document .
protected  double[] parseDoubles(NodeList dat)
          Convenience method for pulling double[] out of NodeLists.
protected  String[] parseLabels(NodeList labs)
          Convenience method for pulling String[] out of NodeLists This method assumes that the NodeList contains bottom-level Elements which contain text.
 
Methods inherited from class com.klg.jclass.chart3d.data.JCDefault3dGridDataSource
getXGridSize, getYGridSize, getZArray, setZArray
 
Methods inherited from class com.klg.jclass.chart3d.data.Base3dGridDataSource
clone, getDataSourceName, getNumX, getNumY, getXGrid, getXLabels, getYGrid, getYLabels, getZValues, setDataSourceName, setXGrid, setXLabels, setYGrid, setYLabels, setZValues
 
Methods inherited from class com.klg.jclass.chart3d.data.Base3dDataSource
getHoleValue, setHoleValue
 
Methods inherited from class com.klg.jclass.chart3d.event.Chart3dDataSupport
addChart3dDataListener, fireChart3dDataEvent, fireChart3dDataEvent, removeChart3dDataListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_DS_ATT_HOLE

public static final String XML_DS_ATT_HOLE
Static string for hole attribute of top level tag in the chart XML datasource.

See Also:
Constant Field Values

XML_DS_ATT_NAME

public static final String XML_DS_ATT_NAME
Static string for datasource name of chart XML datasource.

See Also:
Constant Field Values

XML_DS_XLABEL

public static final String XML_DS_XLABEL
Static string for x Labels of chart XML datasource.

See Also:
Constant Field Values

XML_DS_YLABEL

public static final String XML_DS_YLABEL
Static string for series label tag of chart XML datasource.

See Also:
Constant Field Values

XML_DS_XDATA

public static final String XML_DS_XDATA
Static string for x data tag of chart XML datasource.

See Also:
Constant Field Values

XML_DS_YDATA

public static final String XML_DS_YDATA
Static string for y data tag of chart XML datasource.

See Also:
Constant Field Values

XML_DS_ZGRID

public static final String XML_DS_ZGRID
Static string for z grid tag of chart XML datasource.

See Also:
Constant Field Values

XML_DS_ZVAL

public static final String XML_DS_ZVAL
Static string for z data tag of chart XML datasource.

See Also:
Constant Field Values
Constructor Detail

JCXML3dDataSource

public JCXML3dDataSource(String xmlString)
This constructor takes xml in String form .

Parameters:
xmlString - String containing xml data

JCXML3dDataSource

public JCXML3dDataSource(InputStream inStream)
This constructor takes an InputStream in XML form.

Parameters:
inStream - an xml InputStream

JCXML3dDataSource

public JCXML3dDataSource(Reader reader)
This constructor takes a Reader which contains xml.

Parameters:
reader - a Reader object

JCXML3dDataSource

public JCXML3dDataSource(InputSource inSource)
This constructor takes an InputSource .

Parameters:
inSource - InputSource

JCXML3dDataSource

public JCXML3dDataSource(File xmlFile)
This constructor takes an xml file as an argument.

Parameters:
xmlFile - The xml file object
Method Detail

getDocBuilder

public DocumentBuilder getDocBuilder()
Creates a DocumentBuilder object which parses the XML into a Document object, which can then be parsed into a Chart3d dataSource.

Returns:
DocumentBuilder object

parseDoc

protected void parseDoc(Document doc)
This is the workhorse of this class which parses the document . This is protected only in case we need to subclass later. This method is not meant to be called on its own.

Parameters:
doc - The document object created from the xml file.

parseDoubles

protected double[] parseDoubles(NodeList dat)
Convenience method for pulling double[] out of NodeLists. This method assumes that the NodeList contains bottom-level Elements which only contain doubles.

Parameters:
dat - The NodeList we want returned as an array of doubles
Returns:
the array of doubles we got

convertDoubleValue

protected double convertDoubleValue(String toConvert)
Convenience method to convert a String to a double .

Parameters:
toConvert - the String we wish made double
Returns:
the double value of the String

parseLabels

protected String[] parseLabels(NodeList labs)
Convenience method for pulling String[] out of NodeLists This method assumes that the NodeList contains bottom-level Elements which contain text.

Parameters:
labs - The NodeList we want returned as an array of Strings
Returns:
the array of Strings we got.

Copyright © 2004 Quest Software Inc..
All rights reserved.