org.tigris.gef.graph.presentation
Class JGraph

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byorg.tigris.gef.graph.presentation.JGraph
All Implemented Interfaces:
javax.accessibility.Accessible, java.lang.Cloneable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JGraph
extends javax.swing.JPanel
implements java.lang.Cloneable

JGraph is a Swing component that displays a connected graph and allows interactive editing. In many ways this class serves as a simple front-end to class Editor, and other classes which do the real work.

See Also:
Serialized Form

Nested Class Summary
 
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
protected  java.lang.String _currentDiagramId
           
protected  java.awt.Dimension _defaultSize
           
protected  org.tigris.gef.graph.presentation.JGraphInternalPane _drawingPane
           
protected  Editor _editor
          The Editor object that is being shown in this panel
protected  javax.swing.JScrollPane _scroll
           
protected  java.util.Hashtable _viewPortPositions
           
 
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
JGraph()
          Make a new JGraph with a new DefaultGraphModel.
JGraph(Diagram d)
          Make a new JGraph with a the GraphModel and Layer from the given Diagram.
JGraph(Editor ed)
          Make a new JGraph with the given Editor.
JGraph(GraphModel gm)
          Make a new JGraph with the given GraphModel
 
Method Summary
 void addGraphSelectionListener(GraphSelectionListener listener)
          Add listener to the objects to notify whenever the Editor changes its current selection.
 void addKeyListener(java.awt.event.KeyListener listener)
           
 void addModeChangeListener(ModeChangeListener listener)
           
 void addMouseListener(java.awt.event.MouseListener listener)
           
 void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
           
 void bindKey(java.awt.event.ActionListener action, int keyCode, int modifiers)
          Utility function to bind a keystroke to a Swing Action.
 java.lang.Object clone()
          Make a copy of this JGraph so that it can be shown in another window.
 void deselect(org.tigris.gef.presentation.Fig f)
          Remove the given item from this editors selections.
 void deselectAll()
          Deslect everything that is currently selected.
 java.awt.Dimension getDefaultSize()
           
 Editor getEditor()
          Get the Editor that is being displayed
 GraphEdgeRenderer getGraphEdgeRenderer()
           
 GraphModel getGraphModel()
           
 GraphNodeRenderer getGraphNodeRenderer()
           
 void initKeys()
           
 boolean isFocusTraversable()
          Tell Swing/AWT that JGraph can be tabbed into.
 boolean isManagingFocus()
          Tell Swing/AWT that JGraph handles tab-order itself.
 void layoutGraph()
           
 void removeGraphSelectionListener(GraphSelectionListener listener)
           
 void removeModeChangeListener(ModeChangeListener listener)
           
 void select(org.tigris.gef.presentation.Fig f)
          Add the given item to this Editor's selections.
 void select(java.util.Vector items)
          Select a collection of Figs.
 void selectByOwner(java.lang.Object owner)
          Find the Fig that owns the given item and select it.
 void selectByOwnerOrFig(java.lang.Object owner)
          Find Fig that owns the given item, or the item if it is a Fig, and select it.
 void selectByOwnerOrNoChange(java.lang.Object owner)
          Add the Fig that owns the given item to this Editor's selections.
 java.util.Vector selectedFigs()
          reply a Vector of all selected Figs.
 void setDefaultSize(java.awt.Dimension dim)
           
 void setDefaultSize(int width, int height)
           
 void setDiagram(Diagram d)
          Set the Diagram that should be displayed by setting the GraphModel and Layer that the Editor is using.
 void setDrawingSize(java.awt.Dimension dim)
           
 void setDrawingSize(int width, int height)
           
 void setGraphEdgeRenderer(GraphEdgeRenderer r)
          Get and set the Renderer used to make FigEdges for edges in the GraphModel.
 void setGraphModel(GraphModel gm)
          Get and set the GraphModel the Editor is using.
 void setGraphNodeRenderer(GraphNodeRenderer r)
          Get and set the Renderer used to make FigNodes for nodes in the GraphModel.
 void setVisible(boolean b)
          When the JGraph is hidden, hide its internal pane
 void toggleItem(org.tigris.gef.presentation.Fig f)
          Select the given item if it was not already selected, and vis-a-versa.
 void toggleItems(java.util.Vector items)
          Toggle the selection of a collection of Figs.
protected  void updateDrawingSizeToIncludeAllFigs(java.util.Enumeration enum)
          Enlarges the JGraphInternalPane dimensions as necessary to insure that all the contained Figs are visible.
 
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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, 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, 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, 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, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_editor

protected Editor _editor
The Editor object that is being shown in this panel


_drawingPane

protected org.tigris.gef.graph.presentation.JGraphInternalPane _drawingPane

_scroll

protected javax.swing.JScrollPane _scroll

_defaultSize

protected java.awt.Dimension _defaultSize

_viewPortPositions

protected java.util.Hashtable _viewPortPositions

_currentDiagramId

protected java.lang.String _currentDiagramId
Constructor Detail

JGraph

public JGraph()
Make a new JGraph with a new DefaultGraphModel.

See Also:
DefaultGraphModel

JGraph

public JGraph(Diagram d)
Make a new JGraph with a the GraphModel and Layer from the given Diagram.


JGraph

public JGraph(GraphModel gm)
Make a new JGraph with the given GraphModel


JGraph

public JGraph(Editor ed)
Make a new JGraph with the given Editor. All JGraph contructors eventually call this contructor.

Method Detail

addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener listener)

addKeyListener

public void addKeyListener(java.awt.event.KeyListener listener)

clone

public java.lang.Object clone()
Make a copy of this JGraph so that it can be shown in another window.


initKeys

public void initKeys()

bindKey

public void bindKey(java.awt.event.ActionListener action,
                    int keyCode,
                    int modifiers)
Utility function to bind a keystroke to a Swing Action. Note that GEF Cmds are subclasses of Swing's Actions.


getEditor

public Editor getEditor()
Get the Editor that is being displayed


setDiagram

public void setDiagram(Diagram d)
Set the Diagram that should be displayed by setting the GraphModel and Layer that the Editor is using.


updateDrawingSizeToIncludeAllFigs

protected void updateDrawingSizeToIncludeAllFigs(java.util.Enumeration enum)
Enlarges the JGraphInternalPane dimensions as necessary to insure that all the contained Figs are visible.


setDrawingSize

public void setDrawingSize(int width,
                           int height)

setDrawingSize

public void setDrawingSize(java.awt.Dimension dim)

setGraphModel

public void setGraphModel(GraphModel gm)
Get and set the GraphModel the Editor is using.


getGraphModel

public GraphModel getGraphModel()

setGraphNodeRenderer

public void setGraphNodeRenderer(GraphNodeRenderer r)
Get and set the Renderer used to make FigNodes for nodes in the GraphModel.


getGraphNodeRenderer

public GraphNodeRenderer getGraphNodeRenderer()

setGraphEdgeRenderer

public void setGraphEdgeRenderer(GraphEdgeRenderer r)
Get and set the Renderer used to make FigEdges for edges in the GraphModel.


getGraphEdgeRenderer

public GraphEdgeRenderer getGraphEdgeRenderer()

setVisible

public void setVisible(boolean b)
When the JGraph is hidden, hide its internal pane


isManagingFocus

public boolean isManagingFocus()
Tell Swing/AWT that JGraph handles tab-order itself.


isFocusTraversable

public boolean isFocusTraversable()
Tell Swing/AWT that JGraph can be tabbed into.


addGraphSelectionListener

public void addGraphSelectionListener(GraphSelectionListener listener)
Add listener to the objects to notify whenever the Editor changes its current selection.


removeGraphSelectionListener

public void removeGraphSelectionListener(GraphSelectionListener listener)

addModeChangeListener

public void addModeChangeListener(ModeChangeListener listener)

removeModeChangeListener

public void removeModeChangeListener(ModeChangeListener listener)

layoutGraph

public void layoutGraph()

select

public void select(org.tigris.gef.presentation.Fig f)
Add the given item to this Editor's selections.


selectByOwner

public void selectByOwner(java.lang.Object owner)
Find the Fig that owns the given item and select it.


selectByOwnerOrFig

public void selectByOwnerOrFig(java.lang.Object owner)
Find Fig that owns the given item, or the item if it is a Fig, and select it.


selectByOwnerOrNoChange

public void selectByOwnerOrNoChange(java.lang.Object owner)
Add the Fig that owns the given item to this Editor's selections.


deselect

public void deselect(org.tigris.gef.presentation.Fig f)
Remove the given item from this editors selections.


toggleItem

public void toggleItem(org.tigris.gef.presentation.Fig f)
Select the given item if it was not already selected, and vis-a-versa.


deselectAll

public void deselectAll()
Deslect everything that is currently selected.


select

public void select(java.util.Vector items)
Select a collection of Figs.


toggleItems

public void toggleItems(java.util.Vector items)
Toggle the selection of a collection of Figs.


selectedFigs

public java.util.Vector selectedFigs()
reply a Vector of all selected Figs. Used in many Cmds.


setDefaultSize

public void setDefaultSize(int width,
                           int height)

setDefaultSize

public void setDefaultSize(java.awt.Dimension dim)

getDefaultSize

public java.awt.Dimension getDefaultSize()