Class ExtendedTGPanel

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class ExtendedTGPanel
    extends com.touchgraph.graphlayout.TGPanel
    TGPanel contains code for drawing the graph, and storing which nodes are selected, and which ones the mouse is over. It houses methods to activate TGLayout, which performs dynamic layout. Whenever the graph is moved, or repainted, TGPanel fires listner methods on associated objects.

    Parts of this code build upon Sun's Graph Layout example. http://java.sun.com/applets/jdk/1.1/demo/GraphLayout/Graph.java

    Author:
    Alexander Shapiro, Murray Altheim (2001-11-06; 2002-01-14 cleanup)
    See Also:
    Serialized Form
    • Field Detail

      • BACK_COLOR

        public static Color BACK_COLOR
      • basicMML

        protected net.ontopia.topicmaps.viz.ExtendedTGPanel.BasicMouseMotionListener basicMML
      • mouseOverE

        protected com.touchgraph.graphlayout.Edge mouseOverE
      • mouseOverN

        protected com.touchgraph.graphlayout.Node mouseOverN
      • maintainMouseOver

        protected boolean maintainMouseOver
      • select

        protected com.touchgraph.graphlayout.Node select
      • mousePos

        protected Point mousePos
      • image

        public Image image
    • Constructor Detail

      • ExtendedTGPanel

        public ExtendedTGPanel​(String imageSource)
        Default constructor.
    • Method Detail

      • setLensSet

        public void setLensSet​(com.touchgraph.graphlayout.TGLensSet lensSet)
        Overrides:
        setLensSet in class com.touchgraph.graphlayout.TGPanel
      • setTGLayout

        public void setTGLayout​(com.touchgraph.graphlayout.TGLayout tgl)
        Overrides:
        setTGLayout in class com.touchgraph.graphlayout.TGPanel
      • setGraphEltSet

        public void setGraphEltSet​(com.touchgraph.graphlayout.graphelements.GraphEltSet ges)
        Overrides:
        setGraphEltSet in class com.touchgraph.graphlayout.TGPanel
      • getAdjustOriginLens

        public com.touchgraph.graphlayout.TGPanel.AdjustOriginLens getAdjustOriginLens()
        Overrides:
        getAdjustOriginLens in class com.touchgraph.graphlayout.TGPanel
      • getSwitchSelectUI

        public com.touchgraph.graphlayout.TGPanel.SwitchSelectUI getSwitchSelectUI()
        Overrides:
        getSwitchSelectUI in class com.touchgraph.graphlayout.TGPanel
      • setBackColor

        public void setBackColor​(Color color)
        Overrides:
        setBackColor in class com.touchgraph.graphlayout.TGPanel
      • getAllNodes

        public Iterator getAllNodes()
        Returns an Iterator over all nodes in the complete graph.
        Overrides:
        getAllNodes in class com.touchgraph.graphlayout.TGPanel
      • getGES

        public com.touchgraph.graphlayout.graphelements.ImmutableGraphEltSet getGES()
        Return the current visible locality.
        Overrides:
        getGES in class com.touchgraph.graphlayout.TGPanel
      • getNodeCount

        public int getNodeCount()
        Returns the current node count.
        Overrides:
        getNodeCount in class com.touchgraph.graphlayout.TGPanel
      • nodeNum

        public int nodeNum()
        Deprecated.
        this method has been replaced by the visibleNodeCount() method.
        Returns the current node count within the VisibleLocality.
        Overrides:
        nodeNum in class com.touchgraph.graphlayout.TGPanel
      • visibleNodeCount

        public int visibleNodeCount()
        Returns the current node count within the VisibleLocality.
        Overrides:
        visibleNodeCount in class com.touchgraph.graphlayout.TGPanel
      • findNode

        public com.touchgraph.graphlayout.Node findNode​(String id)
        Return the Node whose ID matches the String id, null if no match is found.
        Overrides:
        findNode in class com.touchgraph.graphlayout.TGPanel
        Parameters:
        id - The ID identifier used as a query.
        Returns:
        The Node whose ID matches the provided 'id', null if no match is found.
      • findNodesByLabel

        public Collection findNodesByLabel​(String label)
        Return a Collection of all Nodes whose label matches the String label, null if no match is found.
        Overrides:
        findNodesByLabel in class com.touchgraph.graphlayout.TGPanel
      • findNodeLabelContaining

        public com.touchgraph.graphlayout.Node findNodeLabelContaining​(String substring)
        Return the first Nodes whose label contains the String substring, null if no match is found.
        Overrides:
        findNodeLabelContaining in class com.touchgraph.graphlayout.TGPanel
        Parameters:
        substring - The Substring used as a query.
      • addNode

        public com.touchgraph.graphlayout.Node addNode()
                                                throws com.touchgraph.graphlayout.TGException
        Adds a Node, with its ID and label being the current node count plus 1.
        Overrides:
        addNode in class com.touchgraph.graphlayout.TGPanel
        Throws:
        com.touchgraph.graphlayout.TGException
        See Also:
        Node
      • addNode

        public com.touchgraph.graphlayout.Node addNode​(String label)
                                                throws com.touchgraph.graphlayout.TGException
        Adds a Node, provided its label. The node is assigned a unique ID.
        Overrides:
        addNode in class com.touchgraph.graphlayout.TGPanel
        Throws:
        com.touchgraph.graphlayout.TGException
        See Also:
        GraphEltSet
      • addNode

        public com.touchgraph.graphlayout.Node addNode​(String id,
                                                       String label)
                                                throws com.touchgraph.graphlayout.TGException
        Adds a Node, provided its ID and label.
        Overrides:
        addNode in class com.touchgraph.graphlayout.TGPanel
        Throws:
        com.touchgraph.graphlayout.TGException
        See Also:
        Node
      • addNode

        public void addNode​(com.touchgraph.graphlayout.Node node)
                     throws com.touchgraph.graphlayout.TGException
        Add the Node node to the visibleLocality, checking for ID uniqueness.
        Overrides:
        addNode in class com.touchgraph.graphlayout.TGPanel
        Throws:
        com.touchgraph.graphlayout.TGException
      • deleteNodeById

        public boolean deleteNodeById​(String id)
        Remove the Node object matching the ID id, returning true if the deletion occurred, false if a Node matching the ID does not exist (or if the ID value was null).
        Overrides:
        deleteNodeById in class com.touchgraph.graphlayout.TGPanel
        Parameters:
        id - The ID identifier used as a query.
        Returns:
        true if the deletion occurred.
      • deleteNode

        public boolean deleteNode​(com.touchgraph.graphlayout.Node node)
        Overrides:
        deleteNode in class com.touchgraph.graphlayout.TGPanel
      • clearAll

        public void clearAll()
        Overrides:
        clearAll in class com.touchgraph.graphlayout.TGPanel
      • getSelect

        public com.touchgraph.graphlayout.Node getSelect()
        Overrides:
        getSelect in class com.touchgraph.graphlayout.TGPanel
      • getMouseOverN

        public com.touchgraph.graphlayout.Node getMouseOverN()
        Overrides:
        getMouseOverN in class com.touchgraph.graphlayout.TGPanel
      • setMouseOverN

        public void setMouseOverN​(com.touchgraph.graphlayout.Node node)
        Overrides:
        setMouseOverN in class com.touchgraph.graphlayout.TGPanel
      • getAllEdges

        public Iterator getAllEdges()
        Returns an Iterator over all edges in the complete graph.
        Overrides:
        getAllEdges in class com.touchgraph.graphlayout.TGPanel
      • deleteEdge

        public void deleteEdge​(com.touchgraph.graphlayout.Edge edge)
        Overrides:
        deleteEdge in class com.touchgraph.graphlayout.TGPanel
      • deleteEdge

        public void deleteEdge​(com.touchgraph.graphlayout.Node from,
                               com.touchgraph.graphlayout.Node to)
        Overrides:
        deleteEdge in class com.touchgraph.graphlayout.TGPanel
      • getEdgeCount

        public int getEdgeCount()
        Returns the current edge count in the complete graph.
        Overrides:
        getEdgeCount in class com.touchgraph.graphlayout.TGPanel
      • edgeNum

        public int edgeNum()
        Deprecated.
        this method has been replaced by the visibleEdgeCount() method.
        Return the number of Edges in the Locality.
        Overrides:
        edgeNum in class com.touchgraph.graphlayout.TGPanel
      • visibleEdgeCount

        public int visibleEdgeCount()
        Return the number of Edges in the Locality.
        Overrides:
        visibleEdgeCount in class com.touchgraph.graphlayout.TGPanel
      • findEdge

        public com.touchgraph.graphlayout.Edge findEdge​(com.touchgraph.graphlayout.Node f,
                                                        com.touchgraph.graphlayout.Node t)
        Overrides:
        findEdge in class com.touchgraph.graphlayout.TGPanel
      • addEdge

        public void addEdge​(com.touchgraph.graphlayout.Edge e)
        Overrides:
        addEdge in class com.touchgraph.graphlayout.TGPanel
      • addEdge

        public com.touchgraph.graphlayout.Edge addEdge​(com.touchgraph.graphlayout.Node f,
                                                       com.touchgraph.graphlayout.Node t,
                                                       int tens)
        Overrides:
        addEdge in class com.touchgraph.graphlayout.TGPanel
      • getMouseOverE

        public com.touchgraph.graphlayout.Edge getMouseOverE()
        Overrides:
        getMouseOverE in class com.touchgraph.graphlayout.TGPanel
      • setMouseOverE

        public void setMouseOverE​(com.touchgraph.graphlayout.Edge edge)
        Overrides:
        setMouseOverE in class com.touchgraph.graphlayout.TGPanel
      • fireResetEvent

        public void fireResetEvent()
        Overrides:
        fireResetEvent in class com.touchgraph.graphlayout.TGPanel
      • addGraphListener

        public void addGraphListener​(com.touchgraph.graphlayout.GraphListener gl)
        Overrides:
        addGraphListener in class com.touchgraph.graphlayout.TGPanel
      • removeGraphListener

        public void removeGraphListener​(com.touchgraph.graphlayout.GraphListener gl)
        Overrides:
        removeGraphListener in class com.touchgraph.graphlayout.TGPanel
      • addPaintListener

        public void addPaintListener​(com.touchgraph.graphlayout.TGPaintListener pl)
        Overrides:
        addPaintListener in class com.touchgraph.graphlayout.TGPanel
      • removePaintListener

        public void removePaintListener​(com.touchgraph.graphlayout.TGPaintListener pl)
        Overrides:
        removePaintListener in class com.touchgraph.graphlayout.TGPanel
      • setMaintainMouseOver

        public void setMaintainMouseOver​(boolean maintain)
        Overrides:
        setMaintainMouseOver in class com.touchgraph.graphlayout.TGPanel
      • clearSelect

        public void clearSelect()
        Overrides:
        clearSelect in class com.touchgraph.graphlayout.TGPanel
      • selectFirstNode

        public void selectFirstNode()
        A convenience method that selects the first node of a graph, so that hiding works.
        Overrides:
        selectFirstNode in class com.touchgraph.graphlayout.TGPanel
      • setSelect

        public void setSelect​(com.touchgraph.graphlayout.Node node)
        Overrides:
        setSelect in class com.touchgraph.graphlayout.TGPanel
      • multiSelect

        public void multiSelect​(com.touchgraph.graphlayout.TGPoint2D from,
                                com.touchgraph.graphlayout.TGPoint2D to)
        Overrides:
        multiSelect in class com.touchgraph.graphlayout.TGPanel
      • updateLocalityFromVisibility

        public void updateLocalityFromVisibility()
                                          throws com.touchgraph.graphlayout.TGException
        Overrides:
        updateLocalityFromVisibility in class com.touchgraph.graphlayout.TGPanel
        Throws:
        com.touchgraph.graphlayout.TGException
      • setLocale

        public void setLocale​(com.touchgraph.graphlayout.Node node,
                              int radius,
                              int maxAddEdgeCount,
                              int maxExpandEdgeCount,
                              boolean unidirectional)
                       throws com.touchgraph.graphlayout.TGException
        Overrides:
        setLocale in class com.touchgraph.graphlayout.TGPanel
        Throws:
        com.touchgraph.graphlayout.TGException
      • fastFinishAnimation

        public void fastFinishAnimation()
        Overrides:
        fastFinishAnimation in class com.touchgraph.graphlayout.TGPanel
      • setLocale

        public void setLocale​(com.touchgraph.graphlayout.Node node,
                              int radius)
                       throws com.touchgraph.graphlayout.TGException
        Overrides:
        setLocale in class com.touchgraph.graphlayout.TGPanel
        Throws:
        com.touchgraph.graphlayout.TGException
      • expandNode

        public void expandNode​(com.touchgraph.graphlayout.Node node)
        Overrides:
        expandNode in class com.touchgraph.graphlayout.TGPanel
      • hideNode

        public void hideNode​(com.touchgraph.graphlayout.Node hideNode)
        Overrides:
        hideNode in class com.touchgraph.graphlayout.TGPanel
      • collapseNode

        public void collapseNode​(com.touchgraph.graphlayout.Node collapseNode)
        Overrides:
        collapseNode in class com.touchgraph.graphlayout.TGPanel
      • hideEdge

        public void hideEdge​(com.touchgraph.graphlayout.Edge hideEdge)
        Overrides:
        hideEdge in class com.touchgraph.graphlayout.TGPanel
      • setDragNode

        public void setDragNode​(com.touchgraph.graphlayout.Node node)
        Overrides:
        setDragNode in class com.touchgraph.graphlayout.TGPanel
      • getDragNode

        public com.touchgraph.graphlayout.Node getDragNode()
        Overrides:
        getDragNode in class com.touchgraph.graphlayout.TGPanel
      • getMousePos

        public Point getMousePos()
        Overrides:
        getMousePos in class com.touchgraph.graphlayout.TGPanel
      • startDamper

        public void startDamper()
        Start and stop the damper. Should be placed in the TGPanel too.
        Overrides:
        startDamper in class com.touchgraph.graphlayout.TGPanel
      • stopDamper

        public void stopDamper()
        Overrides:
        stopDamper in class com.touchgraph.graphlayout.TGPanel
      • resetDamper

        public void resetDamper()
        Makes the graph mobile, and slowly slows it down.
        Overrides:
        resetDamper in class com.touchgraph.graphlayout.TGPanel
      • stopMotion

        public void stopMotion()
        Gently stops the graph from moving
        Overrides:
        stopMotion in class com.touchgraph.graphlayout.TGPanel
      • findMouseOver

        protected void findMouseOver()
        Overrides:
        findMouseOver in class com.touchgraph.graphlayout.TGPanel
      • getTopLeftDraw

        public com.touchgraph.graphlayout.TGPoint2D getTopLeftDraw()
        Overrides:
        getTopLeftDraw in class com.touchgraph.graphlayout.TGPanel
      • getBottomRightDraw

        public com.touchgraph.graphlayout.TGPoint2D getBottomRightDraw()
        Overrides:
        getBottomRightDraw in class com.touchgraph.graphlayout.TGPanel
      • getCenter

        public com.touchgraph.graphlayout.TGPoint2D getCenter()
        Overrides:
        getCenter in class com.touchgraph.graphlayout.TGPanel
      • getDrawCenter

        public com.touchgraph.graphlayout.TGPoint2D getDrawCenter()
        Overrides:
        getDrawCenter in class com.touchgraph.graphlayout.TGPanel
      • updateGraphSize

        public void updateGraphSize()
        Overrides:
        updateGraphSize in class com.touchgraph.graphlayout.TGPanel
      • processGraphMove

        public void processGraphMove()
        Overrides:
        processGraphMove in class com.touchgraph.graphlayout.TGPanel
      • repaintAfterMove

        public void repaintAfterMove()
        Overrides:
        repaintAfterMove in class com.touchgraph.graphlayout.TGPanel
      • updateDrawPos

        public void updateDrawPos​(com.touchgraph.graphlayout.Node node)
        Overrides:
        updateDrawPos in class com.touchgraph.graphlayout.TGPanel
      • updatePosFromDraw

        public void updatePosFromDraw​(com.touchgraph.graphlayout.Node node)
        Overrides:
        updatePosFromDraw in class com.touchgraph.graphlayout.TGPanel
      • updateDrawPositions

        public void updateDrawPositions()
        Overrides:
        updateDrawPositions in class com.touchgraph.graphlayout.TGPanel
      • paint

        public void paint​(Graphics g)
        Overrides:
        paint in class com.touchgraph.graphlayout.TGPanel
      • getImage

        public Image getImage​(String imageSource)
      • update

        public void update​(Graphics g)
        Overrides:
        update in class com.touchgraph.graphlayout.TGPanel
      • main

        public static void main​(String[] args)