ptolemy.plot.plotml
Class HistogramMLParser

java.lang.Object
  extended by com.microstar.xml.HandlerBase
      extended by ptolemy.plot.plotml.PlotBoxMLParser
          extended by ptolemy.plot.plotml.PlotMLParser
              extended by ptolemy.plot.plotml.HistogramMLParser
All Implemented Interfaces:
XmlHandler

public class HistogramMLParser
extends PlotMLParser

This class constructs a histogram from specifications in PlotML (Plot Markup Language), which is an XML language. This class supports extends the base class to ensure that the associated plotter is an instance of Histogram. 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.

Since:
Ptolemy II 0.4
Version:
$Id: HistogramMLParser.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Edward A. Lee
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (eal)

Field Summary
 
Fields inherited from class ptolemy.plot.plotml.PlotMLParser
_connected, _currentDataset, _currentPointCount
 
Fields inherited from class ptolemy.plot.plotml.PlotBoxMLParser
_attributes, _currentCharData, _parser, _plot, PlotML_DTD_1
 
Constructor Summary
HistogramMLParser(Histogram 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 startElement(java.lang.String elementName)
          Start an element.
 
Methods inherited from class ptolemy.plot.plotml.PlotMLParser
startDocument
 
Methods inherited from class ptolemy.plot.plotml.PlotBoxMLParser
_checkForNull, _currentExternalEntity, attribute, charData, endDocument, error, parse, parse, 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
 

Constructor Detail

HistogramMLParser

public HistogramMLParser(Histogram plot)
Construct an parser to parse commands for the specified plot object.

Parameters:
plot - The plot object to which to apply the commands.
Method Detail

endElement

public void endElement(java.lang.String elementName)
                throws java.lang.Exception
End an element. Override the base class to ignore non-histogram operations. Ælfred will call this method at the end of each element (including EMPTY elements).

Specified by:
endElement in interface XmlHandler
Overrides:
endElement in class PlotMLParser
Parameters:
elementName - The element type name.
Throws:
java.lang.Exception - If thrown by the base class.
See Also:
XmlHandler.endElement(java.lang.String)

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.

Specified by:
startElement in interface XmlHandler
Overrides:
startElement in class PlotMLParser
Parameters:
elementName - The element type name.
Throws:
XmlException - If the element produces an error in constructing the model.
See Also:
XmlHandler.startElement(java.lang.String)

_addPoint

protected void _addPoint(boolean connected,
                         java.lang.String element)
                  throws java.lang.Exception
Add a point based on the current attributes. The second argument is the element name, used for error reporting.

Overrides:
_addPoint in class PlotMLParser
Parameters:
connected - Ignored.
element - The name of the element.
Throws:
java.lang.Exception - if thrown whil parsing the y attribute.