JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.chart.data
Class JCXMLDataInterpreter

java.lang.Object
  |
  +--com.klg.jclass.chart.data.JCDataInterpreter
        |
        +--com.klg.jclass.chart.data.JCXMLDataInterpreter
All Implemented Interfaces:
Serializable

public class JCXMLDataInterpreter
extends JCDataInterpreter
implements Serializable

Implements a interpreter for the chart XML data format. Relies on input from some reader to populate the specified BaseDataSource class.

Format Information

Data can be loaded either by series or by point. data-point-label and data-series-label tags are optional with either method. To represent virtual hole values in an x-data or y-data tag, use the word HOLE.

Here is an example of an XML data file loading by series. This can be used to represent both the array and general style data sources that are used by the default chart data source. If only one data-series tag contains x-data tags, that x data will be used for every series. Otherwise, each series uses its own x-data tags to define its x data.

 <?xml version="1.0"?>
 <!DOCTYPE chart-data SYSTEM "chart-data.dtd">
 <chart-data name="My Chart" hole="MAX">
   <data-point-label> Point Label 1 </data-point-label>
   <data-point-label> Point Label 2 </data-point-label>
   <data-point-label> Point Label 3 </data-point-label>
   <data-point-label> Point Label 4 </data-point-label>
   <data-series>
     <data-series-label> Y Axis #1 Data </data-series-label>
     <x-data>1</x-data>
     <x-data>2</x-data>
     <x-data>3</x-data>
     <x-data>4</x-data>
     <y-data>1</y-data>
     <y-data>2</y-data>
     <y-data>3</y-data>
     <y-data>4</y-data>
    </data-series>
 
    <data-series>
      <data-series-label> Y Axis #2 Data </data-series-label>
      <y-data>1</y-data>
      <y-data>4</y-data>
      <y-data>9</y-data>
      <y-data>16</y-data>
    </data-series>
  </chart-data>
 
Here is an example of an XML data file loading by point. This format is similar to the transposed array format of the default chart data source. No more than one x-data tag can be used per data-point tag. If no x-data tags are present at all, x data will be generated automatically staring at 1 in increments of 1. If some data-point tags contain an x-data tags and others do not, the missing pieces of x data will be filled with the hole value.
  <?xml version="1.0"?>
  <!DOCTYPE chart-data SYSTEM "chart-data.dtd">
  <chart-data name="MyChart">
    <data-series-label> Y Data </data-series-label>
    <data-series-label> Y 2 Data </data-series-label>
    <data-point>
      <data-point-label> Point Label 1 </data-point-label>
      <x-data>1</x-data>
      <y-data>1</y-data>
      <y-data>1</y-data>
    </data-point>
    <data-point>
      <data-point-label> Point Label 2 </data-point-label>
      <x-data>2</x-data>
      <y-data>2</y-data>
      <y-data>4</y-data>
    </data-point>
    <data-point>
      <data-point-label> Point Label 3 </data-point-label>
      <x-data>3</x-data>
      <y-data>3</y-data>
      <y-data>9</y-data>
    </data-point>
    <data-point>
      <data-point-label> Point Label 4 </data-point-label>
      <x-data>4</x-data>
      <y-data>4</y-data>
      <y-data>16</y-data>
    </data-point>
  </chart-data>
 

See Also:
Serialized Form

Field Summary
static String DATA_DTD_NAME
           
protected  com.klg.jclass.util.io.LoadProperties loadProperties
           
 
Fields inherited from class com.klg.jclass.chart.data.JCDataInterpreter
baseDS
 
Constructor Summary
JCXMLDataInterpreter()
          Default no-argument constructor.
JCXMLDataInterpreter(com.klg.jclass.chart.data.BaseDataSource bds)
          This constructor creates an instance of a data interpreter and associates it with a data source.
JCXMLDataInterpreter(com.klg.jclass.chart.data.BaseDataSource bds, com.klg.jclass.util.io.LoadProperties lp)
          This constructor creates an instance of a data interpreter and associates it with a data source.
JCXMLDataInterpreter(com.klg.jclass.util.io.LoadProperties lp)
          Constructor specifying LoadProperties class.
 
Method Summary
protected  void ctor(Reader r)
          Parses the specified input stream according to the XML chart data format and populates the previously set data source.
 void loadData(InputSource inSource, boolean validate)
          Internal use only.
 
Methods inherited from class com.klg.jclass.chart.data.JCDataInterpreter
setBaseDataSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_DTD_NAME

public static String DATA_DTD_NAME

loadProperties

protected com.klg.jclass.util.io.LoadProperties loadProperties
Constructor Detail

JCXMLDataInterpreter

public JCXMLDataInterpreter()
Default no-argument constructor.


JCXMLDataInterpreter

public JCXMLDataInterpreter(com.klg.jclass.util.io.LoadProperties lp)
Constructor specifying LoadProperties class.


JCXMLDataInterpreter

public JCXMLDataInterpreter(com.klg.jclass.chart.data.BaseDataSource bds)
                     throws IOException
This constructor creates an instance of a data interpreter and associates it with a data source. It does not yet do any interpreting.

Parameters:
bds - the data source to eventually populate with the interpreted data
Throws:
IOException

JCXMLDataInterpreter

public JCXMLDataInterpreter(com.klg.jclass.chart.data.BaseDataSource bds,
                            com.klg.jclass.util.io.LoadProperties lp)
                     throws IOException
This constructor creates an instance of a data interpreter and associates it with a data source. It does not yet do any interpreting.

Parameters:
bds - the data source to eventually populate with the interpreted data
lp - an instance of LoadProperties which contains attributes related to XML parsing of files.
Throws:
IOException
Method Detail

ctor

protected void ctor(Reader r)
             throws IOException
Parses the specified input stream according to the XML chart data format and populates the previously set data source. Called by the other ctor() method, and also used for String input where you cannot have an input stream.

Specified by:
ctor in class JCDataInterpreter
Parameters:
r - the Reader object used to read data
Throws:
IOException

loadData

public void loadData(InputSource inSource,
                     boolean validate)
              throws IOException,
                     JCParseException
Internal use only. Method creates data objects from an XML InputSource.

We are not sure if synchronized is really necessary, but would hate for someone to be in the middle of init still when they decide they want to start drawing the chart.

Parameters:
inSource - the InputSource that contains the data file
validate - true if validation should be turned on
Throws:
IOException
JCParseException

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