uci.gef
Class JGraph

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--uci.gef.JGraph

public class JGraph
extends JPanel
implements 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

Inner classes inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
protected  uci.gef.JGraphInternalPane _drawingPane
           
protected  Editor _editor
          The Editor object that is being shown in this panel
protected  JScrollPane _scroll
           
 
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
 
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(KeyListener listener)
           
 void addModeChangeListener(ModeChangeListener listener)
           
 void addMouseListener(MouseListener listener)
           
 void addMouseMotionListener(MouseMotionListener listener)
           
 void bindKey(ActionListener action, int keyCode, int modifiers)
          Utility function to bind a keystroke to a Swing Action.
 Object clone()
          Make a copy of this JGraph so that it can be shown in another window.
 void deselect(Fig f)
          Remove the given item from this editors selections.
 void deselectAll()
          Deslect everything that is currently selected.
 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(Fig f)
          Add the given item to this Editor's selections.
 void select(Vector items)
          Select a collection of Figs.
 void selectByOwner(Object owner)
          Find the Fig that owns the given item and select it.
 void selectByOwnerOrFig(Object owner)
          Find Fig that owns the given item, or the item if it is a Fig, and select it.
 void selectByOwnerOrNoChange(Object owner)
          Add the Fig that owns the given item to this Editor's selections.
 Vector selectedFigs()
          reply a Vector of all selected Figs.
 void setDiagram(Diagram d)
          Set the Diagram that should be displayed by setting the GraphModel and Layer that the Editor is using.
 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(Fig f)
          Select the given item if it was not already selected, and vis-a-versa.
 void toggleItems(Vector items)
          Toggle the selection of a collection of Figs.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
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 uci.gef.JGraphInternalPane _drawingPane

_scroll

protected JScrollPane _scroll
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(MouseListener listener)
Overrides:
addMouseListener in class Component

addMouseMotionListener

public void addMouseMotionListener(MouseMotionListener listener)
Overrides:
addMouseMotionListener in class Component

addKeyListener

public void addKeyListener(KeyListener listener)
Overrides:
addKeyListener in class Component

clone

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

initKeys

public void initKeys()

bindKey

public void bindKey(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.

setDrawingSize

public void setDrawingSize(int width,
                           int height)

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
Overrides:
setVisible in class JComponent

isManagingFocus

public boolean isManagingFocus()
Tell Swing/AWT that JGraph handles tab-order itself.
Overrides:
isManagingFocus in class JComponent

isFocusTraversable

public boolean isFocusTraversable()
Tell Swing/AWT that JGraph can be tabbed into.
Overrides:
isFocusTraversable in class JComponent

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(Fig f)
Add the given item to this Editor's selections.

selectByOwner

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

selectByOwnerOrFig

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

selectByOwnerOrNoChange

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

deselect

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

toggleItem

public void toggleItem(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(Vector items)
Select a collection of Figs.

toggleItems

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

selectedFigs

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