ptolemy.plot.plotml
Class PlotMLParser

java.lang.Object
  |
  +--com.microstar.xml.HandlerBase
        |
        +--ptolemy.plot.plotml.PlotBoxMLParser
              |
              +--ptolemy.plot.plotml.PlotMLParser
Direct Known Subclasses:
HistogramMLParser

public class PlotMLParser
extends PlotBoxMLParser

This class constructs a plot from specifications in PlotML (Plot Markup Language), which is an XML language. This class supports extends the base class to support the subset that applies to the Plot class. It ignores unrecognized elements in the DTD. The class contains an instance of the Microstar Ælfred XML parser and implements callback methods to interpret the parsed XML. The way to use this class is to construct it with a reference to a Plot object and then call its parse() method.

Version:
$Id: PlotMLParser.java,v 1.5 1999/08/19 01:44:18 cxh Exp $
Author:
Edward A. Lee

Field Summary
protected  boolean _bars
          The default bars state.
protected  boolean _connected
          The default connected state.
protected  int _currentDataset
          The current dataset number in a "dataset" element.
protected  double _currentPointCount
          A count within the current dataset, in case no x value is given.
 
Fields inherited from class ptolemy.plot.plotml.PlotBoxMLParser
_attributes, _currentCharData, _parser, _plot
 
Constructor Summary
protected PlotMLParser()
          Protected constructor allows derived classes to set _plot differently.
  PlotMLParser(Plot plot)
          Construct an parser to parse commands for the specified plot object.
 
Method Summary
protected  void _addPoint(boolean connected, java.lang.String element)
          Add a point based on the current attributes.
 void endElement(java.lang.String elementName)
          End an element.
 void startDocument()
          Start a document.
 void startElement(java.lang.String elementName)
          Start an element.
 
Methods inherited from class ptolemy.plot.plotml.PlotBoxMLParser
_checkForNull, _currentExternalEntity, attribute, charData, endDocument, error, parse, resolveEntity, startExternalEntity
 
Methods inherited from class com.microstar.xml.HandlerBase
doctypeDecl, endExternalEntity, ignorableWhitespace, processingInstruction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_bars

protected boolean _bars
The default bars state.

_connected

protected boolean _connected
The default connected state.

_currentDataset

protected int _currentDataset
The current dataset number in a "dataset" element.

_currentPointCount

protected double _currentPointCount
A count within the current dataset, in case no x value is given.
Constructor Detail

PlotMLParser

public PlotMLParser(Plot plot)
Construct an parser to parse commands for the specified plot object.
Parameters:
plot - The plot object to which to apply the commands.

PlotMLParser

protected PlotMLParser()
Protected constructor allows derived classes to set _plot differently.
Method Detail

endElement

public void endElement(java.lang.String elementName)
                throws java.lang.Exception
End an element. This method calls the appropriate Plot methods. Ælfred will call this method at the end of each element (including EMPTY elements).
Overrides:
endElement in class PlotBoxMLParser
Parameters:
elementName - The element type name.

startDocument

public void startDocument()
Start a document. This method is called just before the parser attempts to read the first entity (the root of the document). It is guaranteed that this will be the first method called.
Overrides:
startDocument in class PlotBoxMLParser
Tags copied from class: HandlerBase
Throws:
java.lang.Exception - Derived methods may throw exceptions.
See Also:
XmlHandler.startDocument()

startElement

public void startElement(java.lang.String elementName)
                  throws XmlException
Start an element. This is called at the beginning of each XML element. By the time it is called, all of the attributes for the element will already have been reported using the attribute() method. Unrecognized elements are ignored.
Overrides:
startElement in class PlotBoxMLParser
Parameters:
elementName - The element type name.
Throws:
XmlException - If the element produces an error in constructing the model.

_addPoint

protected void _addPoint(boolean connected,
                         java.lang.String element)
                  throws java.lang.Exception
Add a point based on the current attributes. If the first argument is true, connect it to the previous point. The second argument is the element name, used for error reporting.
Parameters:
connected - If true, connect to the previous point.
element - The name of the element.