net.clackrouter.gui
Class ClackDocument

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by net.clackrouter.gui.ClackDocument
All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, java.util.Observer, javax.accessibility.Accessible

public class ClackDocument
extends javax.swing.JPanel
implements java.awt.event.ComponentListener, java.awt.print.Printable, java.beans.PropertyChangeListener, java.util.Observer

A ClackDocument represents a single router instance in Clack.

A router instance is what is placed in a tab, and includes all different views that can be zoomed between (ie: Network View, Router View, Hierarchical View) and manages which one of these views is currently displayed.

The document also deals with a lot of the listening required on the graph.

This class is a modified version of the GPDocument class from JGraphpad.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  Rule columnRule
          The column rule for the graph
protected  javax.swing.JScrollPane currentScroll
          the scrollpane containg the current view
protected  ClackView currentView
           
protected  boolean enableTooltips
           
protected  javax.swing.Action fitAction
          Action used for fitting the size
protected  GraphUndoManager graphUndoManager
          The graphUndoManager manager for the joint graph.
protected  boolean inTopoRouteTableViewMode
          flag telling whether this document is currently visible (ie: is the selected tab)
protected  ClackFramework mFramework
          A reference to the top level component
protected  Rule rowRule
          The row rule for the graph
protected  GPStatusBar statusbar
           
protected  ClackTab tab
          a reference to the tab holding this document
protected  TopologyView topologyView
          the topology view for this router
protected  UndoHandler undoHandler
          The graphUndoManager handler for the current document.
 
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.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ClackDocument(ClackFramework graphpad, int topology)
          Constructor for ClackDocument.
 
Method Summary
 void addRouter(Router router)
           
 void componentHidden(java.awt.event.ComponentEvent e)
           
 void componentMoved(java.awt.event.ComponentEvent e)
           
 void componentResized(java.awt.event.ComponentEvent e)
           
 void componentShown(java.awt.event.ComponentEvent e)
           
 ConnectivityTestWindow getConnectivityTestWin()
           
 JGraph getCurrentGraph()
          Returns the graph associated with the ClackView that the document is currently displaying
 Router getCurrentRouter()
           
 RouterGraph getCurrentRouterGraph()
           
 RouterView getCurrentRouterView()
           
protected  java.lang.String getDocumentTitle()
           
 ClackFramework getFramework()
          Returns the graphpad.
 ClackTab getGPTab()
           
 GraphUndoManager getGraphUndoManager()
          Returns the graphUndoManager.
 Router getRouter(java.lang.String name)
           
 RouterGraph getRouterGraph(java.lang.String name)
           
 RouterView getRouterView(java.lang.String name)
           
 int getTopology()
           
 TopologyView getTopologyView()
           
 void gpgraphWindowResized(int newWidth, int newHeight)
          this is a hack to take care of the bug when the router window and scrollbar would not properly resize after resizing the outer window.
 void graphChanged(GraphModelEvent e)
          Important method that responds to removals of components or wires from the graph by informing the underlying router and components
 boolean inTopoRouteTableViewMode()
           
 boolean isClackVisible()
           
 boolean isEnableTooltips()
           
 int print(java.awt.Graphics g, java.awt.print.PageFormat pF, int page)
          Prints the router graph
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void pushNewView(ClackView newView)
          Used to implement zoom in using the zoomStack.
 void redrawTopoView()
           
protected  void registerListeners(JGraph graph)
           
 void setConnectivityTestWin(ConnectivityTestWindow win)
           
protected  void setDocumentTitle(java.lang.String s)
           
 void setEnableTooltips(boolean enableTooltips, RouterGraph graph)
          Sets the enableTooltips.
 void setIsClackVisible(boolean b)
           
 void setModified(boolean modified)
           
 void setResizeAction(javax.swing.AbstractAction e)
           
 void setSelectionAttributes(java.util.Map map)
          Sets the attributes of the selected cells.
 void setTab(ClackTab tab)
           
 void toogleTopoRouteTableViewMode()
           
protected  void unregisterListeners(JGraph graph)
           
protected  void update()
          update this graphpad and tab title
 void update(java.util.Observable obs, java.lang.Object arg)
           
 void updatePageFormat()
          not from Printable interface, but related
protected  void updateTabTitle()
           
 void valueChanged(GraphSelectionEvent e)
           
 void zoomIn()
          Handles zoom in behavior for any view in this document.
 void zoomIntoRouter(java.lang.String router_name)
           
 void zoomOut()
          Implements zoom out based on the contents of the zoomStack.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

enableTooltips

protected boolean enableTooltips

mFramework

protected ClackFramework mFramework
A reference to the top level component


columnRule

protected Rule columnRule
The column rule for the graph


rowRule

protected Rule rowRule
The row rule for the graph


graphUndoManager

protected GraphUndoManager graphUndoManager
The graphUndoManager manager for the joint graph.

See Also:
#graph

undoHandler

protected UndoHandler undoHandler
The graphUndoManager handler for the current document. Each document has his own handler. So you can make an graphUndoManager seperate for each document.


fitAction

protected javax.swing.Action fitAction
Action used for fitting the size


statusbar

protected GPStatusBar statusbar

tab

protected ClackTab tab
a reference to the tab holding this document


currentScroll

protected javax.swing.JScrollPane currentScroll
the scrollpane containg the current view


topologyView

protected TopologyView topologyView
the topology view for this router


currentView

protected ClackView currentView

inTopoRouteTableViewMode

protected boolean inTopoRouteTableViewMode
flag telling whether this document is currently visible (ie: is the selected tab)

Constructor Detail

ClackDocument

public ClackDocument(ClackFramework graphpad,
                     int topology)
Constructor for ClackDocument.

Method Detail

getTopology

public int getTopology()

addRouter

public void addRouter(Router router)

zoomIntoRouter

public void zoomIntoRouter(java.lang.String router_name)

zoomIn

public void zoomIn()
Handles zoom in behavior for any view in this document.

If the current view is the topology, we simply zoom into the router view corresponding to the router zoomed in on

Otherwise, we get the current graph and using the CompDoubleClickHandler to fine the right behavior for zooming into this component


getCurrentGraph

public JGraph getCurrentGraph()
Returns the graph associated with the ClackView that the document is currently displaying


pushNewView

public void pushNewView(ClackView newView)
Used to implement zoom in using the zoomStack.

Pushes the current view onto the stack and displays the specified view in the document.

Parameters:
newView -

zoomOut

public void zoomOut()
Implements zoom out based on the contents of the zoomStack.

Pops the last view off of the stack and puts it as the current view for this document


registerListeners

protected void registerListeners(JGraph graph)

unregisterListeners

protected void unregisterListeners(JGraph graph)

setModified

public void setModified(boolean modified)

getDocumentTitle

protected java.lang.String getDocumentTitle()

setDocumentTitle

protected void setDocumentTitle(java.lang.String s)

setSelectionAttributes

public void setSelectionAttributes(java.util.Map map)
Sets the attributes of the selected cells.


gpgraphWindowResized

public void gpgraphWindowResized(int newWidth,
                                 int newHeight)

this is a hack to take care of the bug when the router window and scrollbar would not properly resize after resizing the outer window.

unfortunately this does not work in Java 1.5


setResizeAction

public void setResizeAction(javax.swing.AbstractAction e)

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Specified by:
componentShown in interface java.awt.event.ComponentListener

updatePageFormat

public void updatePageFormat()
not from Printable interface, but related


print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pF,
                 int page)
Prints the router graph

Specified by:
print in interface java.awt.print.Printable

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

valueChanged

public void valueChanged(GraphSelectionEvent e)

update

public void update(java.util.Observable obs,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer

graphChanged

public void graphChanged(GraphModelEvent e)
Important method that responds to removals of components or wires from the graph by informing the underlying router and components


update

protected void update()
update this graphpad and tab title


getGraphUndoManager

public GraphUndoManager getGraphUndoManager()
Returns the graphUndoManager.

Returns:
GraphUndoManager

getFramework

public ClackFramework getFramework()
Returns the graphpad.

Returns:
GPGraphpad

isEnableTooltips

public boolean isEnableTooltips()

setEnableTooltips

public void setEnableTooltips(boolean enableTooltips,
                              RouterGraph graph)
Sets the enableTooltips.

Parameters:
enableTooltips - The enableTooltips to set

setIsClackVisible

public void setIsClackVisible(boolean b)

isClackVisible

public boolean isClackVisible()

getTopologyView

public TopologyView getTopologyView()

getCurrentRouterView

public RouterView getCurrentRouterView()

getCurrentRouter

public Router getCurrentRouter()

getCurrentRouterGraph

public RouterGraph getCurrentRouterGraph()

getRouter

public Router getRouter(java.lang.String name)

getRouterGraph

public RouterGraph getRouterGraph(java.lang.String name)

getRouterView

public RouterView getRouterView(java.lang.String name)

getGPTab

public ClackTab getGPTab()

setTab

public void setTab(ClackTab tab)

inTopoRouteTableViewMode

public boolean inTopoRouteTableViewMode()

toogleTopoRouteTableViewMode

public void toogleTopoRouteTableViewMode()

redrawTopoView

public void redrawTopoView()

getConnectivityTestWin

public ConnectivityTestWindow getConnectivityTestWin()

setConnectivityTestWin

public void setConnectivityTestWin(ConnectivityTestWindow win)

updateTabTitle

protected void updateTabTitle()