|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.touchgraph.graphlayout.TGPanel
public class 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 listener 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
| Nested Class Summary | |
|---|---|
protected class |
TGPanel.AdjustOriginLens
A lens that adjusts the location of the provided point to a midpoint within the panel. |
class |
TGPanel.BasicMouseListener
|
class |
TGPanel.BasicMouseMotionListener
|
class |
TGPanel.SwitchSelectUI
|
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static Color |
BACK_COLOR
|
protected TGPanel.BasicMouseMotionListener |
basicMML
|
protected Point2D.Double |
bottomRightDraw
|
protected GraphEltSet |
completeEltSet
|
protected Node |
dragNode
|
static boolean |
fixedIsPinned
Flag indicating when true that fixed nodes are "pinned" and not removed on locality shifts. |
protected Vector |
graphListeners
|
protected static Cursor |
handCursor
|
protected LocalityUtils |
localityUtils
|
protected boolean |
maintainMouseOver
|
protected Edge |
mouseOverE
|
protected Node |
mouseOverN
|
protected Point |
mousePos
|
protected static Cursor |
moveCursor
|
protected Graphics |
offgraphics
|
protected Image |
offscreen
|
protected Dimension |
offscreensize
|
protected Vector |
paintListeners
|
protected Node |
select
|
static String |
TG_THREADGROUP_ID
The ThreadGroup identifier for all TouchGraph Threads. |
TGLayout |
tgLayout
|
protected ThreadGroup |
threadgroup
|
protected Point2D.Double |
topLeftDraw
|
protected VisibleLocality |
visibleLocality
|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
TGPanel()
Default constructor. |
|
| Method Summary | |
|---|---|
protected void |
activateMMListener(boolean activate)
Activates or deactivate the MouseMotionListener. |
void |
addEdge(Edge e)
|
Edge |
addEdge(Node f,
Node t,
int tens)
|
void |
addGraphListener(GraphListener gl)
|
Node |
addNode()
Adds a Node, with its ID and label being the current node count plus 1. |
void |
addNode(Node node)
Add the Node node to the visibleLocality, checking for ID uniqueness. |
void |
addNode(Node node,
Point2D.Double p)
Add the Node node to the visibleLocality, checking for ID uniqueness. |
Node |
addNode(String label)
Adds a Node, provided its label. |
Node |
addNode(String id,
String label)
Adds a Node, provided its ID and label. |
void |
addPaintListener(TGPaintListener pl)
|
void |
clearAll()
|
void |
clearSelect()
|
void |
collapseNode(Node node)
|
Point2D.Double |
convertDrawToReal(double x,
double y)
Returns the conversion between real position and visual position for the point described by x,y. |
Point2D.Double |
convertDrawToReal(Point p)
Returns the conversion between real position and visual position for the Point p. |
Point2D.Double |
convertDrawToReal(Point2D.Double p)
Returns the conversion between real position and visual position for the Point2D.Double p. |
Point2D.Double |
convertRealToDraw(double x,
double y)
Returns the conversion between visual position and real position for the point described by x,y. |
Point2D.Double |
convertRealToDraw(Point p)
Returns the conversion between visual position and real position for the Point p. |
Point2D.Double |
convertRealToDraw(Point2D.Double p)
Returns the conversion between visual position and real position for the Point2D.Double p. |
void |
deleteEdge(Edge edge)
|
void |
deleteEdge(Node from,
Node to)
|
boolean |
deleteNode(Node node)
Delete the Node node from the visibleLocality. |
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). |
int |
edgeNum()
Deprecated. this method has been replaced by the visibleEdgeCount() method. |
void |
expandNode(Node node)
|
void |
fastFinishAnimation()
Quickly wraps up the add node animation. |
Edge |
findEdge(Node f,
Node t)
|
protected void |
findMouseOver()
|
Node |
findNode(String id)
Return the Node whose ID matches the String id, null if no match is found. |
Node |
findNodeLabelContaining(String substring)
Return the first Nodes whose label contains the String substring, null if no match is found. |
Collection |
findNodesByLabel(String label)
Return a Collection of all Nodes whose label matches the String label, null if no match is found. |
Collection |
findNodesByLabel(String label,
boolean ignoreCase)
Return a Collection of all Nodes whose label matches the String label, null if no match is found. |
protected void |
fireMovedEvent()
|
void |
fireResetEvent()
|
TGPanel.AdjustOriginLens |
getAdjustOriginLens()
|
Iterator |
getAllEdges()
Returns an Iterator over all edges in the complete graph. |
Iterator |
getAllNodes()
Returns an Iterator over all nodes in the complete graph. |
GraphEltSet |
getAllNodesAsSet()
Returns all nodes in the complete graph as a GraphEltSet (used by various utilities). |
Point2D.Double |
getBottomRightDraw()
|
Point2D.Double |
getCenter()
|
Node |
getDragNode()
|
Point2D.Double |
getDrawCenter()
|
int |
getEdgeCount()
Returns the current edge count in the complete graph. |
ImmutableGraphEltSet |
getGES()
Return the current visible locality. |
Edge |
getMouseOverE()
|
Node |
getMouseOverN()
|
Point |
getMousePos()
|
int |
getNodeCount()
Returns the current node count. |
Image |
getOffscreenImage()
Returns the offscreen Image serving as the fundamental drawing area. |
Dimension |
getOffscreenImageSize()
Returns the size (as a Dimension) of the offscreen Image serving as the fundamental drawing area. |
Node |
getSelect()
|
TGPanel.SwitchSelectUI |
getSwitchSelectUI()
|
ThreadGroup |
getThreadGroup()
Returns the ThreadGroup used with TouchGraph threads. |
Point2D.Double |
getTopLeftDraw()
|
void |
handleMouseEvent(MouseEvent e)
Processes mouse entered or exited events from the BasicMouseListener. |
void |
handleMouseMotionEvent(MouseEvent e)
Processes motion dragged or moved events from the BasicMouseMotionListener, mouseDragged() if mouseDragged is true, mouseMoved() if false. |
void |
hideEdge(Edge edge)
|
void |
hideNode(Node node)
|
boolean |
isShiftingLocality()
Returns true if the locality shifting thread is active. |
static void |
main(String[] args)
|
void |
multiSelect(Point2D.Double from,
Point2D.Double to)
|
Color |
myBrighter(Color c)
|
int |
nodeNum()
Deprecated. this method has been replaced by the visibleNodeCount() method. |
void |
paint(Graphics g)
|
void |
paintBackground(Graphics g,
Dimension d)
|
void |
paintForeground(Graphics g,
Dimension d)
|
void |
processGraphMove()
|
protected void |
redraw()
|
void |
removeGraphListener(GraphListener gl)
|
void |
removePaintListener(TGPaintListener pl)
|
void |
repaintAfterMove()
Called by TGLayout and others to indicate that graph has moved. |
void |
resetDamper()
Makes the graph mobile, and slowly slows it down. |
void |
selectFirstNode()
A convenience method that selects the first node of a graph, so that hiding works. |
void |
setBackColor(Color color)
|
void |
setDragNode(Node node)
|
void |
setGraphEltSet(GraphEltSet ges)
|
void |
setLensSet(TGLensSet lensSet)
|
void |
setLocale(Node node,
int radius)
|
void |
setLocale(Node node,
int radius,
int maxAddEdgeCount,
int maxExpandEdgeCount,
boolean unidirectional)
|
void |
setMaintainMouseOver(boolean maintain)
|
void |
setMouseOverE(Edge edge)
|
void |
setMouseOverN(Node node)
|
void |
setMousePos(Point p)
|
void |
setSelect(Node node)
|
void |
setTGLayout(TGLayout tgl)
|
void |
sleepTGThread(int millis)
Causes the current thread to sleep for the specified number of milliseconds, if it is a thread in the "TouchGraph" ThreadGroup. |
void |
startDamper()
Start and stop the damper. |
void |
stopDamper()
|
void |
stopMotion()
Gently stops the graph from moving |
void |
update(Graphics g)
|
void |
updateDrawPos(Node node)
Sets the visual position from the real position. |
void |
updateDrawPositions()
|
void |
updateGraphSize()
|
void |
updateLocalityFromVisibility()
|
void |
updatePosFromDraw(Node node)
Sets the real position from the visual position. |
int |
visibleEdgeCount()
Return the number of Edges in the Locality. |
int |
visibleNodeCount()
Returns the current node count within the VisibleLocality. |
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String TG_THREADGROUP_ID
public static Color BACK_COLOR
public TGLayout tgLayout
public static boolean fixedIsPinned
protected Point2D.Double topLeftDraw
protected Point2D.Double bottomRightDraw
protected GraphEltSet completeEltSet
protected VisibleLocality visibleLocality
protected LocalityUtils localityUtils
protected ThreadGroup threadgroup
protected TGPanel.BasicMouseMotionListener basicMML
protected Edge mouseOverE
protected Node mouseOverN
protected boolean maintainMouseOver
protected Node select
protected Node dragNode
protected Point mousePos
protected Image offscreen
protected Dimension offscreensize
protected Graphics offgraphics
protected Vector graphListeners
protected Vector paintListeners
protected static Cursor handCursor
protected static Cursor moveCursor
| Constructor Detail |
|---|
public TGPanel()
| Method Detail |
|---|
public ThreadGroup getThreadGroup()
public Image getOffscreenImage()
public Dimension getOffscreenImageSize()
public void sleepTGThread(int millis)
public boolean isShiftingLocality()
public void setLensSet(TGLensSet lensSet)
public void setTGLayout(TGLayout tgl)
public void setGraphEltSet(GraphEltSet ges)
public TGPanel.AdjustOriginLens getAdjustOriginLens()
public TGPanel.SwitchSelectUI getSwitchSelectUI()
public void setBackColor(Color color)
public GraphEltSet getAllNodesAsSet()
public Iterator getAllNodes()
public ImmutableGraphEltSet getGES()
public int getNodeCount()
public int nodeNum()
public int visibleNodeCount()
public Node findNode(String id)
id - The ID identifier used as a query.
public Collection findNodesByLabel(String label)
public Collection findNodesByLabel(String label,
boolean ignoreCase)
public Node findNodeLabelContaining(String substring)
substring - The Substring used as a query.
public Node addNode()
throws TGException
TGExceptionNode
public Node addNode(String label)
throws TGException
TGExceptionGraphEltSet
public Node addNode(String id,
String label)
throws TGException
TGExceptionNode
public void addNode(Node node)
throws TGException
TGException
public void addNode(Node node,
Point2D.Double p)
throws TGException
TGExceptionpublic boolean deleteNodeById(String 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).
id - The ID identifier used as a query.
public boolean deleteNode(Node node)
public void clearAll()
public Node getSelect()
public Node getMouseOverN()
public void setMouseOverN(Node node)
public Iterator getAllEdges()
public void deleteEdge(Edge edge)
public void deleteEdge(Node from,
Node to)
public int getEdgeCount()
public int edgeNum()
public int visibleEdgeCount()
public Edge findEdge(Node f,
Node t)
public void addEdge(Edge e)
public Edge addEdge(Node f,
Node t,
int tens)
public Edge getMouseOverE()
public void setMouseOverE(Edge edge)
protected void fireMovedEvent()
public void fireResetEvent()
public void addGraphListener(GraphListener gl)
public void removeGraphListener(GraphListener gl)
public void addPaintListener(TGPaintListener pl)
public void removePaintListener(TGPaintListener pl)
protected void redraw()
public void setMaintainMouseOver(boolean maintain)
public void clearSelect()
public void selectFirstNode()
public void setSelect(Node node)
public void multiSelect(Point2D.Double from,
Point2D.Double to)
public void updateLocalityFromVisibility()
throws TGException
TGException
public void setLocale(Node node,
int radius,
int maxAddEdgeCount,
int maxExpandEdgeCount,
boolean unidirectional)
throws TGException
TGExceptionpublic void fastFinishAnimation()
public void setLocale(Node node,
int radius)
throws TGException
TGExceptionpublic void expandNode(Node node)
public void hideNode(Node node)
public void collapseNode(Node node)
public void hideEdge(Edge edge)
public void setDragNode(Node node)
public Node getDragNode()
public void setMousePos(Point p)
public Point getMousePos()
public void startDamper()
public void stopDamper()
public void resetDamper()
public void stopMotion()
protected void activateMMListener(boolean activate)
public void handleMouseEvent(MouseEvent e)
public void handleMouseMotionEvent(MouseEvent e)
protected void findMouseOver()
public Point2D.Double getTopLeftDraw()
public Point2D.Double getBottomRightDraw()
public Point2D.Double getCenter()
public Point2D.Double getDrawCenter()
public void updateGraphSize()
public void processGraphMove()
public void repaintAfterMove()
public Point2D.Double convertRealToDraw(Point2D.Double p)
public Point2D.Double convertRealToDraw(Point p)
public Point2D.Double convertRealToDraw(double x,
double y)
public Point2D.Double convertDrawToReal(Point2D.Double p)
public Point2D.Double convertDrawToReal(Point p)
public Point2D.Double convertDrawToReal(double x,
double y)
public void updateDrawPos(Node node)
public void updatePosFromDraw(Node node)
public void updateDrawPositions()
public Color myBrighter(Color c)
public void paint(Graphics g)
paint in class JComponent
public void paintForeground(Graphics g,
Dimension d)
public void paintBackground(Graphics g,
Dimension d)
public void update(Graphics g)
update in class JComponentpublic static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||