|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--javax.swing.JPanel
|
+--viceroy.GUI.GraphPanel
This class actually displays the graph. Each node is assigned a virtual position starting from 0,0 and continuing down. The actual paint() function iterates through all the nodes and draws them.
| Nested Class Summary | |
class |
GraphPanel.MouseHandler
handles the mouse events sent on the panel |
(package private) class |
GraphPanel.PoolObject
a pool object |
| Nested classes inherited from class javax.swing.JPanel |
javax.swing.JPanel.AccessibleJPanel |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
private static int |
ARROWHEAD_SIZE
size (in pixels of the arrow head size) |
static int |
BFS_BUILDMODE
|
private int |
buildMode
BFS/DFS/RING/LINE |
private int |
curMode
Current mode we are using |
static int |
DEFAULT_LINE_LENGTH
defualt line length |
private int |
depthLevel
The depth we will enter in the recursion for displaying child nodes. |
static int |
DFS_BUILDMODE
|
private boolean |
doingLookup
If we are on a lookup request |
static int |
LINE_BUILDMODE
Modes for the building the graph |
static java.awt.Color[] |
LINE_COLOR_MAP
colors |
private int |
lineLength
line length |
private java.util.List |
listeners
A vector of listener classes implementing the GraphElementListener interface |
private static org.apache.log4j.Logger |
logger
|
private MessagePath |
lookupPath
The path that a lookup message has gone through |
private java.lang.String |
lookupVal
The value to lookup |
private int |
maxHeight
Used to determine the max. |
private int |
maxWidth
Used to determine the max. |
private java.util.Map |
nextInRow
|
private java.util.Map |
nodes
Hashtable of all the nodes traveresed. |
private int |
numberOfNodes
How many nodes to add |
static double |
PEER_RADIUS
Peer radios |
static int |
RING_BUILDMODE
|
static int |
RING_CENTER_X
ring center x |
static int |
RING_CENTER_Y
ring center y |
static int |
RING_RADIUS
the radius of the ring |
private int |
ringRadius
ring radius |
private ViewController |
root
Root node to display |
private boolean |
showConnections
if true, will always display the edges between nodes |
private static int |
SIZE
size (in pixels) of a single node |
private boolean |
stickyDisplay
After clicking a node, its exit lines will be colored in light-gray, its input in gray. |
private ViewController |
stickyNode
Will hold the node that was last clicked |
private static int |
X_MARGIN
margin to keep from sides of window |
private static int |
Y_MARGIN
|
private double |
zoomRatio
display zoomRatio |
| Fields inherited from class javax.swing.JPanel |
|
| 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.Container |
|
| 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 | |
GraphPanel()
constructs the panel |
|
| Method Summary | |
void |
addListener(GraphElementListener listener)
Adds a listener |
private void |
addNodeToTableLine(ViewController node)
Add node and all his children to the ring table |
private void |
addNodeToTableRing(ViewController node)
Add node and all his children to the ring table |
(package private) void |
addToTableBFS(ViewController node,
int y)
Adds noses as in BFS form: the level defines the node's row |
(package private) void |
addToTableDFS(ViewController node,
int y)
Adds a node to the hashtable |
void |
buildGraph(ViewController root)
Will re-build the graph for the specified root |
java.awt.Dimension |
calculateNodePosOnLine(ViewController node)
Calculates a node position on the ring sorted by its id |
java.awt.Dimension |
calculateNodePosOnRing(ViewController node)
Calculates a node position on the ring sorted by its id |
(package private) void |
drawArrowLine(java.awt.Graphics g,
int x0,
int y0,
int x1,
int y1)
Draws a line from (x0,y0) to (x1, y1) and adds an arrow head to the line's end. |
void |
drawLinesFrom(java.awt.Graphics g,
java.lang.Object node,
java.awt.Color lineColor)
Draws all the edges leaving a certain node |
void |
drawLinesTo(java.awt.Graphics g,
java.lang.Object baseNode,
java.awt.Color lineColor)
Draws all the edges entering a certain node |
void |
drawNode(java.awt.Graphics g,
java.lang.Object node,
int x,
int y,
int w,
int h)
Draws the node in the specified place |
(package private) void |
drawStickyNodeFrame(java.awt.Graphics g,
java.lang.Object stickyNode,
java.awt.Color c)
Handles sticky |
(package private) void |
fireClicked(java.lang.Object node)
Triggers the GraphElementClicked event on all listeners |
(package private) void |
fireDoubleClicked(java.lang.Object node)
Triggers the GraphElementDoubleClicked event on all listeners |
(package private) void |
fireReleased()
Triggers the GraphElementReleased event on all listeners |
(package private) int |
getArrowHeadSize()
Return the size of the arrow head |
int |
getBuildMode()
Gets the build mode |
private static java.awt.Color |
getColorByType(LookupState state)
Gets a color by a node's type |
int |
getDepthLevel()
Gets the depth level |
(package private) int |
getElementSize()
Returns the number of pixels each element takes in the current display ratio |
java.lang.String |
getLookupVal()
Gets the lookup value |
int |
getMode()
Gets the mode |
(package private) int |
getNextInRow(int y)
Get next available col in a given row, and updates the lastInRow vector |
(package private) ViewController |
getNodeFromPoint(int x,
int y)
Returns the node at a givel (pixel) coordinate |
int |
getNumberOfNodes()
Gets the number of nodes |
java.lang.Object |
getRoot()
gets the root |
boolean |
getShowConnections()
Gets the connections |
boolean |
getStickyDisplay()
Gets the sticky display |
java.lang.Object |
getStickyNode()
Gets the sticky node |
double |
getZoomRatio()
Gets the zoom ratio |
void |
paint(java.awt.Graphics g)
Paint |
void |
refresh()
Refresh |
void |
removeNode(ViewController node)
Removes a node from the list of nodes |
void |
setBuildMode(int buildMode)
Sets the build mode |
void |
setDepthLevel(int depthLevel)
Sets the depth level |
void |
setDoingLookup(boolean lookup)
Sets the lookup field |
void |
setLookupPath(MessagePath path)
Sets the lookup path |
void |
setLookupVal(java.lang.String val)
Sets the lookup value |
void |
setMode(int mode)
Sets the mode |
void |
setNumberOfNodes(int num)
Sets the number of nodes |
void |
setRingRadius(int radius)
Sets the ring radius |
void |
setShowConnections(boolean showConnections)
Sets the connections |
void |
setStickyDisplay(boolean stickyDisplay)
|
void |
setZoomRatio(double ratio)
Sets the zoom ratio |
(package private) int |
xPos(int x)
Returns the pixel x-position of the input coordinate |
(package private) int |
yPos(int y)
Returns the pixel x-position of the input coordinate |
| Methods inherited from class javax.swing.JPanel |
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private static final org.apache.log4j.Logger logger
private static final int SIZE
private static final int ARROWHEAD_SIZE
private static final int X_MARGIN
private static final int Y_MARGIN
public static final int RING_RADIUS
public static final double PEER_RADIUS
public static final int RING_CENTER_X
public static final int RING_CENTER_Y
public static final int DEFAULT_LINE_LENGTH
private int ringRadius
private int lineLength
private double zoomRatio
private java.util.Map nodes
private ViewController root
private boolean showConnections
private boolean stickyDisplay
private ViewController stickyNode
private java.util.List listeners
private int maxWidth
private int maxHeight
private int depthLevel
private int curMode
private int buildMode
private int numberOfNodes
private java.lang.String lookupVal
private MessagePath lookupPath
private boolean doingLookup
public static final int LINE_BUILDMODE
public static final int RING_BUILDMODE
public static final int BFS_BUILDMODE
public static final int DFS_BUILDMODE
public static final java.awt.Color[] LINE_COLOR_MAP
private java.util.Map nextInRow
| Constructor Detail |
public GraphPanel()
| Method Detail |
public void setNumberOfNodes(int num)
num - public void setDoingLookup(boolean lookup)
lookup - public void setLookupPath(MessagePath path)
path - public int getNumberOfNodes()
public void setLookupVal(java.lang.String val)
val - public java.lang.String getLookupVal()
int xPos(int x)
x - the x coordinate
int yPos(int y)
y - the x coordinate
int getElementSize()
int getArrowHeadSize()
ViewController getNodeFromPoint(int x,
int y)
x - y -
int getNextInRow(int y)
y - row to check on
void addToTableBFS(ViewController node,
int y)
node - y - private void addNodeToTableRing(ViewController node)
node - private void addNodeToTableLine(ViewController node)
node -
void addToTableDFS(ViewController node,
int y)
node - y -
void drawStickyNodeFrame(java.awt.Graphics g,
java.lang.Object stickyNode,
java.awt.Color c)
g - stickyNode - c -
void drawArrowLine(java.awt.Graphics g,
int x0,
int y0,
int x1,
int y1)
g - x0 - y0 - x1 - y1 -
public void drawLinesFrom(java.awt.Graphics g,
java.lang.Object node,
java.awt.Color lineColor)
g - node - private static java.awt.Color getColorByType(LookupState state)
state -
public void drawLinesTo(java.awt.Graphics g,
java.lang.Object baseNode,
java.awt.Color lineColor)
g -
public void drawNode(java.awt.Graphics g,
java.lang.Object node,
int x,
int y,
int w,
int h)
g - node - x - y - w - h - public void paint(java.awt.Graphics g)
paint in class javax.swing.JComponentg - void fireClicked(java.lang.Object node)
node - void fireReleased()
void fireDoubleClicked(java.lang.Object node)
node - public void addListener(GraphElementListener listener)
listener - public void buildGraph(ViewController root)
root - element to set as rootpublic void refresh()
public void setShowConnections(boolean showConnections)
showConnections - public boolean getShowConnections()
public void setStickyDisplay(boolean stickyDisplay)
public boolean getStickyDisplay()
public void setDepthLevel(int depthLevel)
depthLevel - public int getDepthLevel()
public java.lang.Object getRoot()
public void setMode(int mode)
mode - public int getMode()
public double getZoomRatio()
public void setZoomRatio(double ratio)
public void setRingRadius(int radius)
radius - public void setBuildMode(int buildMode)
buildMode - public int getBuildMode()
public java.lang.Object getStickyNode()
public void removeNode(ViewController node)
node - the node to be removespublic java.awt.Dimension calculateNodePosOnRing(ViewController node)
public java.awt.Dimension calculateNodePosOnLine(ViewController node)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||