Package ptolemy.graph

Class Element

  • Direct Known Subclasses:
    Edge, Node

    public abstract class Element
    extends java.lang.Object
    A base class for graph elements (nodes and edges). A graph element consists of an optional weight (an arbitrary object that is associated with the element). We say that an element is unweighted if it does not have an assigned weight. It is an error to attempt to access the weight of an unweighted element. Element weights must be non-null objects.
    Since:
    Ptolemy II 2.0
    Version:
    $Id$
    Author:
    Shuvra S. Bhattacharyya
    See Also:
    Edge, Node
    Pt.AcceptedRating:
    Red (cxh)
    Pt.ProposedRating:
    Red (cxh)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Object _weight
      The weight that is associated with the element if the element is weighted.
    • Constructor Summary

      Constructors 
      Constructor Description
      Element()
      Construct an unweighted element.
      Element​(java.lang.Object weight)
      Construct an element with a given weight.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String descriptor()
      A one-word description of the type of this graph element.
      java.lang.Object getWeight()
      Return the weight that has been associated with this element.
      boolean hasWeight()
      Return true if and only if this is a weighted element.
      void removeWeight()
      Make the element unweighted.
      void setWeight​(java.lang.Object weight)
      Set or change the weight of an element.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _weight

        protected java.lang.Object _weight
        The weight that is associated with the element if the element is weighted. If the element is not weighted, the value of this field is null.
    • Constructor Detail

      • Element

        public Element()
        Construct an unweighted element.
      • Element

        public Element​(java.lang.Object weight)
        Construct an element with a given weight.
        Parameters:
        weight - The given weight.
        Throws:
        java.lang.IllegalArgumentException - If the specified weight is null.
    • Method Detail

      • descriptor

        public java.lang.String descriptor()
        A one-word description of the type of this graph element.
        Returns:
        The description.
      • getWeight

        public final java.lang.Object getWeight()
        Return the weight that has been associated with this element.
        Returns:
        The associated weight.
        Throws:
        java.lang.IllegalStateException - If this is an unweighted element.
        See Also:
        setWeight(Object)
      • hasWeight

        public final boolean hasWeight()
        Return true if and only if this is a weighted element.
        Returns:
        True if and only if this is a weighted element.