Class DefaultGraphCell

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode, GraphCell
    Direct Known Subclasses:
    DefaultEdge, DefaultPort

    public class DefaultGraphCell
    extends javax.swing.tree.DefaultMutableTreeNode
    implements GraphCell, java.lang.Cloneable
    The default implementation for the GraphCell interface.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected AttributeMap attributes
      Hashtable for properties.
      • Fields inherited from class javax.swing.tree.DefaultMutableTreeNode

        allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultGraphCell()
      Creates an empty cell.
      DefaultGraphCell​(java.lang.Object userObject)
      Creates a graph cell and initializes it with the specified user object.
      DefaultGraphCell​(java.lang.Object userObject, AttributeMap storageMap)
      Constructs a cell that holds a reference to the specified user object and contains the specified array of children and sets default values for the bounds attribute.
      DefaultGraphCell​(java.lang.Object userObject, AttributeMap storageMap, javax.swing.tree.MutableTreeNode[] children)
      Creates a graph cell and initializes it with the specified user object.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Object addPort()
      Utility method to create a port for this cell.
      java.lang.Object addPort​(java.awt.geom.Point2D offset)
      Utility method to create a port for this cell.
      java.lang.Object addPort​(java.awt.geom.Point2D offset, java.lang.Object userObject)
      Utility method to create a port for this cell.
      java.util.Map changeAttributes​(java.util.Map change)
      Deprecated.
      Use getAttributes().applyMap
      java.lang.Object clone()
      Create a clone of the cell.
      AttributeMap getAttributes()
      Returns the properies of the cell.
      java.util.List getChildren()
      Provides access to the children list to change ordering.
      void setAttributes​(AttributeMap attributes)
      Sets the attributes.
      • Methods inherited from class javax.swing.tree.DefaultMutableTreeNode

        add, breadthFirstEnumeration, children, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
      • Methods inherited from class java.lang.Object

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

      • attributes

        protected AttributeMap attributes
        Hashtable for properties. Initially empty
    • Constructor Detail

      • DefaultGraphCell

        public DefaultGraphCell()
        Creates an empty cell.
      • DefaultGraphCell

        public DefaultGraphCell​(java.lang.Object userObject)
        Creates a graph cell and initializes it with the specified user object.
        Parameters:
        userObject - an Object provided by the user that constitutes the cell's data
      • DefaultGraphCell

        public DefaultGraphCell​(java.lang.Object userObject,
                                AttributeMap storageMap)
        Constructs a cell that holds a reference to the specified user object and contains the specified array of children and sets default values for the bounds attribute.
        Parameters:
        userObject - reference to the user object
        storageMap - the storage attribute map for this cell
      • DefaultGraphCell

        public DefaultGraphCell​(java.lang.Object userObject,
                                AttributeMap storageMap,
                                javax.swing.tree.MutableTreeNode[] children)
        Creates a graph cell and initializes it with the specified user object. The GraphCell allows children only if specified.
        Parameters:
        userObject - an Object provided by the user that constitutes the cell's data
        storageMap - the storage attribute map for this cell
        children - array of children
    • Method Detail

      • getChildren

        public java.util.List getChildren()
        Provides access to the children list to change ordering. This method returns a Collections.EMPTY_LIST if the list of childrenpoints to null.
      • changeAttributes

        public java.util.Map changeAttributes​(java.util.Map change)
        Deprecated.
        Use getAttributes().applyMap
        Changes the attributes of the cell.
        Specified by:
        changeAttributes in interface GraphCell
      • setAttributes

        public void setAttributes​(AttributeMap attributes)
        Sets the attributes.
        Specified by:
        setAttributes in interface GraphCell
        Parameters:
        attributes - The attributes to set
      • addPort

        public java.lang.Object addPort()
        Utility method to create a port for this cell. This method adds a floating port.
        Returns:
        the port created
      • addPort

        public java.lang.Object addPort​(java.awt.geom.Point2D offset)
        Utility method to create a port for this cell. The method adds a port at a fixed relative offset within the cell. If the offset is null then a floating port is added.
        Parameters:
        offset - the offset of the port within the cell
        Returns:
        the port created
      • addPort

        public java.lang.Object addPort​(java.awt.geom.Point2D offset,
                                        java.lang.Object userObject)
        Utility method to create a port for this cell. The method adds a port at a fixed relative offset within the cell. If the offset is null then a floating port is added.
        Parameters:
        offset - the offset of the port within the cell
        userObject - the user object of the port cell
        Returns:
        the port created
      • clone

        public java.lang.Object clone()
        Create a clone of the cell. This method uses the superclass implementation (which does not clone the children), then uses clone on the attribute map. This method does not clone the user object. You should override the cloneUserObject in the graph model to implement cloning of custom user objects.
        Overrides:
        clone in class javax.swing.tree.DefaultMutableTreeNode
        Returns:
        Object a clone of this object.