Class GraphicElement


  • public class GraphicElement
    extends java.lang.Object
    An GraphicElement is an atomic piece of a graphical representation. i.e. a line, box, textbox, etc.
    Since:
    Ptolemy II 1.0
    Version:
    $Id$
    Author:
    Steve Neuendorffer, John Reekie
    Pt.AcceptedRating:
    Red (johnr)
    Pt.ProposedRating:
    Yellow (neuendor)
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphicElement​(java.lang.String type)
      Create a new GraphicElement with the given type.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Set attributeNameSet()
      Return a set of all the attribute names, where each element of the set is a String.
      boolean containsAttribute​(java.lang.String name)
      Test if this element has an attribute with the given name.
      void exportMoML​(java.io.Writer out, java.lang.String prefix)
      Write the GraphicElement in XML format to the given writer.
      java.lang.String getAttribute​(java.lang.String name)
      Return the value of the attribute with the given name.
      java.lang.String getLabel()
      Return the label of this graphic element.
      PaintedObject getPaintedObject()
      Return a new painted object that looks like this graphic element.
      java.lang.String getType()
      Return the type of this graphic element.
      void removeAttribute​(java.lang.String name)
      Remove an attribute from this element.
      void setAttribute​(java.lang.String name, java.lang.String value)
      Set the attribute with the given name to the given value.
      void setLabel​(java.lang.String name)
      Set the label for this graphic element.
      java.lang.String toString()
      Return a string this representing this GraphicElement.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GraphicElement

        public GraphicElement​(java.lang.String type)
        Create a new GraphicElement with the given type. By default, the GraphicElement contains no attributes and an empty label
        Parameters:
        type - The type.
    • Method Detail

      • attributeNameSet

        public java.util.Set attributeNameSet()
        Return a set of all the attribute names, where each element of the set is a String.
        Returns:
        The set of all attribute names
      • exportMoML

        public void exportMoML​(java.io.Writer out,
                               java.lang.String prefix)
                        throws java.io.IOException
        Write the GraphicElement in XML format to the given writer.
        Parameters:
        out - The writer.
        prefix - The prefix, usually a string of spaces.
        Throws:
        java.io.IOException - If there is a problem writing the MoML.
      • getAttribute

        public java.lang.String getAttribute​(java.lang.String name)
        Return the value of the attribute with the given name. Throw an exception if there is no attribute with the given name in this schematic.
        Parameters:
        name - The name of the attribute.
        Returns:
        The value of the attribute with the given name.
        See Also:
        setAttribute(String, String)
      • getLabel

        public java.lang.String getLabel()
        Return the label of this graphic element. This is primarily useful for textual elements, but may be used for other objects that have a label.
        Returns:
        The label.
        See Also:
        setLabel(String)
      • getPaintedObject

        public PaintedObject getPaintedObject()
        Return a new painted object that looks like this graphic element. If the attributes are not consistent, or another error occurs, then return a painted string containing "Error!".
        Returns:
        The painted object.
      • getType

        public java.lang.String getType()
        Return the type of this graphic element. The type is immutably set when the element is created.
        Returns:
        The type.
      • containsAttribute

        public boolean containsAttribute​(java.lang.String name)
        Test if this element has an attribute with the given name.
        Parameters:
        name - The name.
        Returns:
        true if this element contains an attribute with the given name.
      • removeAttribute

        public void removeAttribute​(java.lang.String name)
        Remove an attribute from this element.
        Parameters:
        name - The name of the attribute to remove
      • setAttribute

        public void setAttribute​(java.lang.String name,
                                 java.lang.String value)
        Set the attribute with the given name to the given value.
        Parameters:
        name - The name of the attribute.
        value - The value of the attribute.
        See Also:
        getAttribute(String)
      • setLabel

        public void setLabel​(java.lang.String name)
        Set the label for this graphic element.
        Parameters:
        name - The name.
        See Also:
        getLabel()
      • toString

        public java.lang.String toString()
        Return a string this representing this GraphicElement.
        Overrides:
        toString in class java.lang.Object