Class PlotMLParser

  • All Implemented Interfaces:
    XmlHandler
    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.
    Since:
    Ptolemy II 0.4
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Yellow (eal)
    • Field Detail

      • _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​(PlotInterface 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).
        Specified by:
        endElement in interface XmlHandler
        Overrides:
        endElement in class PlotBoxMLParser
        Parameters:
        elementName - The element type name.
        Throws:
        java.lang.Exception - If thrown by the superclass or while calling setConnected().
        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 PlotBoxMLParser
        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. 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.
        Throws:
        java.lang.Exception - If there is a problem adding the point.