EDU.utwente.CoCompose.gui
Class ModelCanvas

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byEDU.utwente.CoCompose.gui.ModelCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, ErrorReporter, GraphUpdate, java.awt.image.ImageObserver, java.awt.MenuContainer, ModelUpdate, java.io.Serializable

public class ModelCanvas
extends javax.swing.JPanel
implements ErrorReporter, ModelUpdate

A window class for editing and displaying CoCompose design models. Based on EDU.auburn.VGJ.gui.GraphCanvas. Adapted for Swing.

Version:
0.1.22, 12 May 2004
Author:
Dennis Wagelaar, Larry Barowski
See Also:
GraphCanvas, 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  javax.swing.event.ChangeEvent changeEvent
          Only one ChangeEvent is needed per instance since the event's only state is the source property.
static int CREATE_COMPOSITES
          The create composites mode value.
static int CREATE_CONCEPTS
          The create concepts mode value.
static int CREATE_EDGES
          The create concepts mode value.
static int CREATE_PUBLISHED
          The create published concepts mode value.
static int CREATE_REPOS
          The create composites from repository mode value.
static int CREATE_ROLES
          The create composite roles mode value.
static int CREATE_SOLROLE
          The create solution roles mode value.
protected  int currentMouseAction
          The current mouse action being performed
protected static int MOUSE_EDGE
          Mouse action value if an edge is being created.
protected static int MOUSE_MSELECT
          Mouse action value if a multiple selection is being made.
protected static int MOUSE_NODE
          Mouse action value if a node is being created.
protected static int MOUSE_NONE
          Mouse action value if no action currently in progress.
protected static int MOUSE_SELECT
          Mouse action value if a selection is being made.
protected  Matrix44 moveTransform
          The coordinate transformation matrix to transform from viewing coordinates to graph coordinates.
static int SELECT_BOTH
          The select mode value.
protected  Matrix44 viewTransform
          The coordinate transformation matrix to transform from graph coordinates to viewing coordinates.
 
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
ModelCanvas()
          Constructs a ModelCanvas.
ModelCanvas(java.awt.Frame frame_in)
          Constructs a ModelCanvas.
ModelCanvas(Model model_in, java.awt.Frame frame_in)
          Constructs a ModelCanvas.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to the viewport scroller.
 boolean canRedo()
          Checks whether redo is possible.
 boolean canUndo()
          Checks whether undo is possible.
 void center()
          Update the display and boundaries, and center the graph in the display window.
 void changeNode(AbstractConcept newConcept)
          Replaces the selected node, if any.
 void changeNodeClass(java.lang.String newClassName)
          Changes the class of a selected node, if any.
protected  DPoint3 clip(DPoint3 pos)
          Clips a point to a raster of 10 pixels.
 void deleteSelected()
          Deletes all selected graph elements.
protected  void dispatchMouseClickAction(java.awt.event.MouseEvent e)
          Mouse click dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).
protected  void dispatchMouseDoubleClickAction(java.awt.event.MouseEvent e)
          Mouse double click dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).
protected  void dispatchMouseDragAction(java.awt.event.MouseEvent e)
          Mouse drag dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).
protected  void dispatchMouseReleaseAction(java.awt.event.MouseEvent e)
          Mouse release dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).
protected  void dispatchMouseRightClick(java.awt.event.MouseEvent e)
          Mouse right click dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).
protected  void dispatchNodeCreation(java.awt.event.MouseEvent e)
          Mouse click dispatcher, that creates a model node at the given mouse coordinates.
protected  void drawAxes(java.awt.Graphics graphics)
          Draws the coordinate axes.
protected  void drawObjects(boolean selected, java.awt.Graphics graphics)
          Draw selected or unselected objects.
protected  Composite findNearestComposite(int x_in, int y_in)
          Search for nearest Composite under given coordinates.
protected  CompositeRole findNearestCompositeRole(int x_in, int y_in)
          Search for nearest CompositeRole under given coordinates.
protected  java.awt.Point findNearestLink(double x, double y)
          Finds the edge that lies nearest to the given coordinates, if any.
protected  Node findNearestNode(double x, double y)
          Finds the node that lies nearest to the given coordinates, if any.
protected  PublishedConcept findNearestPublishedConcept(int x_in, int y_in)
          Search for nearest PublishedConcept under given coordinates.
protected  void fireStateChanged()
          Notifies all listeners that have registered interest for notification on this event type.
 java.awt.Color getBackColor()
          Gets the background drawing color.
 DDimension getContentSize()
          Gets the size of the canvas contents.
protected  void getDrawBounds(DPoint width, DPoint height)
          Get bounds of drawing with current transform.
protected  boolean getEnabled()
          Gets whether or not this canvas is enabled.
 java.awt.Frame getFrame()
          Gets the parent frame.
 double getHSpacing()
          Gets the horizontal spacing.
protected  java.lang.String getLabel(double x, double y, double z, boolean mousein)
          Gets the label text, e.g. for printing on a panel.
 java.awt.Color getLineColor()
          Gets the line drawing color.
 Model getModel()
          Gets the model that is being edited in this canvas.
 int getMouseMode()
          Gets the behaviour of the mouse.
 DPoint getOffset()
          Gets the offset coordinates.
 double getScale()
          Gets the viewing scale.
 java.awt.Point getSelectedLink()
          Gets the selected link.
 Node getSelectedNode()
          Gets the selected node.
 double getVSpacing()
          Gets the vertical spacing
protected  void insertLink(int x_in, int y_in)
          Inserts a new link into the model.
protected  void insertNode(int x_in, int y_in)
          Inserts the node that was prepared using dispatchNodeCreation or insert a basic Node.
protected  void multiSelect()
          Makes a multiple selection of all elements within the drawn box.
 void notify(java.lang.Object sender)
          Accepts generic notification message.
protected  void paintComponent(java.awt.Graphics g)
          Paints the canvas elements on top of the panel.
protected  void paintComponentBuffer(java.awt.Graphics g)
          Paints the viewport elements on top of the panel.
 void redo()
          Roll back undo on last operation (re-do).
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from the viewport scroller.
 void reportError(CoComposeException error)
          Reports an error.
 void scale(double scaleval)
          Set the scale value for display, and update the display. scaleval is interpreted as follows: screen_distance = physical_distance * scaleval.
protected  void select(int x_in, int y_in, boolean multiple)
          Makes a selection.
 void selectAll()
          Selects all nodes.
 void selectNode(int node_id)
          Selects a node.
 void setBackColor(java.awt.Color color)
          Sets the background drawing color.
 void setEnabled(boolean enabled)
          Sets whether or not this canvas is enabled.
 void setLineColor(java.awt.Color color)
          Sets the line drawing color.
 void setModel(Model model)
          Sets the model that is being edited in this canvas.
 void setMouseMode(int mode)
          Sets the behaviour of the mouse.
 void setNodeProperties()
          Invokes a properties dialog for concepts, if a Concept object is selected.
 void setOffset(double xoffset, double yoffset, boolean redraw)
          Sets the offset coordinates.
 void setRepositoryContainer(RepositoryContainer repositoryContainer)
          Sets the repository container to get composites from.
 void setScale(double new_scale)
          Sets the viewing scale.
 void setViewAngles(double theta, double phi)
          Sets the viewing angles.
 void setWireframe(boolean wireframe)
          Sets wireframe only drawing.
 java.lang.String toEPS()
          Returns an Encapsulated PostScript representation of the model.
 void undo()
          Performs undo on last operation.
 void unselectItems()
          Unselects all graph elements.
 void update(boolean adjust_bounds)
          Does canvas update.
protected  void updateUndo()
          Updates the undo state just before a new action will be performed.
 DRect windowRect()
          Get the position and dimensions of the display window.
 
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, paint, paintBorder, paintChildren, 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, 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

MOUSE_NONE

protected static final int MOUSE_NONE
Mouse action value if no action currently in progress.

See Also:
Constant Field Values

MOUSE_NODE

protected static final int MOUSE_NODE
Mouse action value if a node is being created.

See Also:
Constant Field Values

MOUSE_EDGE

protected static final int MOUSE_EDGE
Mouse action value if an edge is being created.

See Also:
Constant Field Values

MOUSE_SELECT

protected static final int MOUSE_SELECT
Mouse action value if a selection is being made.

See Also:
Constant Field Values

MOUSE_MSELECT

protected static final int MOUSE_MSELECT
Mouse action value if a multiple selection is being made.

See Also:
Constant Field Values

SELECT_BOTH

public static final int SELECT_BOTH
The select mode value.

See Also:
Constant Field Values

CREATE_EDGES

public static final int CREATE_EDGES
The create concepts mode value.

See Also:
Constant Field Values

CREATE_CONCEPTS

public static final int CREATE_CONCEPTS
The create concepts mode value.

See Also:
Constant Field Values

CREATE_SOLROLE

public static final int CREATE_SOLROLE
The create solution roles mode value.

See Also:
Constant Field Values

CREATE_COMPOSITES

public static final int CREATE_COMPOSITES
The create composites mode value.

See Also:
Constant Field Values

CREATE_ROLES

public static final int CREATE_ROLES
The create composite roles mode value.

See Also:
Constant Field Values

CREATE_PUBLISHED

public static final int CREATE_PUBLISHED
The create published concepts mode value.

See Also:
Constant Field Values

CREATE_REPOS

public static final int CREATE_REPOS
The create composites from repository mode value.

See Also:
Constant Field Values

currentMouseAction

protected int currentMouseAction
The current mouse action being performed


viewTransform

protected Matrix44 viewTransform
The coordinate transformation matrix to transform from graph coordinates to viewing coordinates.


moveTransform

protected Matrix44 moveTransform
The coordinate transformation matrix to transform from viewing coordinates to graph coordinates.


changeEvent

protected transient javax.swing.event.ChangeEvent changeEvent
Only one ChangeEvent is needed per instance since the event's only state is the source property. The source of events generated is always "this".

Constructor Detail

ModelCanvas

public ModelCanvas(Model model_in,
                   java.awt.Frame frame_in)
Constructs a ModelCanvas.

Parameters:
model_in - The Model object that will be edited.
frame_in - The parent frame that contains this object.

ModelCanvas

public ModelCanvas(java.awt.Frame frame_in)
Constructs a ModelCanvas.

Parameters:
frame_in - The parent frame that contains this object.

ModelCanvas

public ModelCanvas()
Constructs a ModelCanvas. This constructor is only for the JBuilder Designer, do not use it!

Method Detail

getEnabled

protected boolean getEnabled()
Gets whether or not this canvas is enabled. A canvas that is enabled may respond to user input, while a canvas that is not enabled cannot respond to user input.

Returns:
True if canvas is enabled, otherwise false.

paintComponent

protected void paintComponent(java.awt.Graphics g)
Paints the canvas elements on top of the panel.

Parameters:
g - The graphics context.

paintComponentBuffer

protected void paintComponentBuffer(java.awt.Graphics g)
Paints the viewport elements on top of the panel. Does a partial paint by using the backbuffer.

Parameters:
g - The graphics context.

fireStateChanged

protected void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList

getLabel

protected java.lang.String getLabel(double x,
                                    double y,
                                    double z,
                                    boolean mousein)
Gets the label text, e.g. for printing on a panel.

Parameters:
x - The X coordinate to print.
y - The X coordinate to print.
z - The X coordinate to print.
mousein - If true, the mouse is over this canvas.
Returns:
The label text.

drawObjects

protected void drawObjects(boolean selected,
                           java.awt.Graphics graphics)
Draw selected or unselected objects.

Parameters:
selected - If true, draws selected elements, otherwise unselected.
graphics - The graphics context

drawAxes

protected void drawAxes(java.awt.Graphics graphics)
Draws the coordinate axes.

Parameters:
graphics - The graphics context

findNearestNode

protected Node findNearestNode(double x,
                               double y)
Finds the node that lies nearest to the given coordinates, if any.

Parameters:
x - The X mouse coordinate.
y - The Y mouse coordinate.
Returns:
The nearest node or null.

findNearestLink

protected java.awt.Point findNearestLink(double x,
                                         double y)
Finds the edge that lies nearest to the given coordinates, if any.

Parameters:
x - The X mouse coordinate.
y - The Y mouse coordinate.
Returns:
The node indexes that the nearest edge connects or null.

findNearestComposite

protected Composite findNearestComposite(int x_in,
                                         int y_in)
Search for nearest Composite under given coordinates.

Parameters:
x_in - The X part of the coordinates to look at.
y_in - The Y part of the coordinates to look at.
Returns:
The composite if found, null otherwise.

findNearestCompositeRole

protected CompositeRole findNearestCompositeRole(int x_in,
                                                 int y_in)
Search for nearest CompositeRole under given coordinates.

Parameters:
x_in - The X part of the coordinates to look at.
y_in - The Y part of the coordinates to look at.
Returns:
The composite role if found, null otherwise.

findNearestPublishedConcept

protected PublishedConcept findNearestPublishedConcept(int x_in,
                                                       int y_in)
Search for nearest PublishedConcept under given coordinates.

Parameters:
x_in - The X part of the coordinates to look at.
y_in - The Y part of the coordinates to look at.
Returns:
The composite role if found, null otherwise.

dispatchMouseClickAction

protected void dispatchMouseClickAction(java.awt.event.MouseEvent e)
Mouse click dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).

Parameters:
e - The mouse event.

dispatchMouseDoubleClickAction

protected void dispatchMouseDoubleClickAction(java.awt.event.MouseEvent e)
Mouse double click dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).

Parameters:
e - The mouse event.

dispatchMouseReleaseAction

protected void dispatchMouseReleaseAction(java.awt.event.MouseEvent e)
Mouse release dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).

Parameters:
e - The mouse event.

dispatchMouseDragAction

protected void dispatchMouseDragAction(java.awt.event.MouseEvent e)
Mouse drag dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).

Parameters:
e - The mouse event.

dispatchMouseRightClick

protected void dispatchMouseRightClick(java.awt.event.MouseEvent e)
Mouse right click dispatcher, that dispatches to handlers depending on the current action being performed with the mouse (e.g. creating an edge).

Parameters:
e - The mouse event.

dispatchNodeCreation

protected void dispatchNodeCreation(java.awt.event.MouseEvent e)
                             throws CoComposeException
Mouse click dispatcher, that creates a model node at the given mouse coordinates.

Parameters:
e - The mouse event.
Throws:
CoComposeException - if a node could not be created.

insertNode

protected void insertNode(int x_in,
                          int y_in)
Inserts the node that was prepared using dispatchNodeCreation or insert a basic Node.

Parameters:
x_in - The mouse X coordinate.
y_in - The mouse Y coordinate.
See Also:
dispatchNodeCreation(java.awt.event.MouseEvent), Node

insertLink

protected void insertLink(int x_in,
                          int y_in)
Inserts a new link into the model.

Parameters:
x_in - The mouse X coordinate.
y_in - The mouse Y coordinate.
See Also:
Link

select

protected void select(int x_in,
                      int y_in,
                      boolean multiple)
Makes a selection.

Parameters:
x_in - The mouse X coordinate.
y_in - The mouse Y coordinate.
multiple - If true, adds the new selection to the current selection.

multiSelect

protected void multiSelect()
Makes a multiple selection of all elements within the drawn box.


clip

protected DPoint3 clip(DPoint3 pos)
Clips a point to a raster of 10 pixels.


getDrawBounds

protected void getDrawBounds(DPoint width,
                             DPoint height)
Get bounds of drawing with current transform.

Parameters:
width - The DPoint to store the width in.
height - The DPoint to store the height in.

updateUndo

protected void updateUndo()
Updates the undo state just before a new action will be performed.


setEnabled

public void setEnabled(boolean enabled)
Sets whether or not this canvas is enabled. A canvas that is enabled may respond to user input, while a canvas that is not enabled cannot respond to user input.

Specified by:
setEnabled in interface ModelUpdate
Parameters:
enabled - If true, canvas is enabled, otherwise disabled.

getFrame

public java.awt.Frame getFrame()
Gets the parent frame.

Specified by:
getFrame in interface GraphUpdate
Returns:
The parent frame.

getHSpacing

public double getHSpacing()
Gets the horizontal spacing.

Specified by:
getHSpacing in interface GraphUpdate
Returns:
The horizontal spacing.

getVSpacing

public double getVSpacing()
Gets the vertical spacing

Specified by:
getVSpacing in interface GraphUpdate

getSelectedNode

public Node getSelectedNode()
Gets the selected node.

Specified by:
getSelectedNode in interface GraphUpdate
Returns:
The selected node.

getSelectedLink

public java.awt.Point getSelectedLink()
Gets the selected link.

Returns:
The selected link (node indexes).

selectNode

public void selectNode(int node_id)
Selects a node.

Parameters:
node_id - The node id.

getScale

public double getScale()
Gets the viewing scale.

Returns:
The viewing scale.

setScale

public void setScale(double new_scale)
Sets the viewing scale.

Parameters:
new_scale - The new viewing scale.

scale

public void scale(double scaleval)
Description copied from interface: GraphUpdate
Set the scale value for display, and update the display. scaleval is interpreted as follows: screen_distance = physical_distance * scaleval.

Specified by:
scale in interface GraphUpdate
See Also:
setScale(double)

selectAll

public void selectAll()
Selects all nodes.


unselectItems

public void unselectItems()
Unselects all graph elements.


deleteSelected

public void deleteSelected()
Deletes all selected graph elements.


setWireframe

public void setWireframe(boolean wireframe)
Sets wireframe only drawing.

Parameters:
wireframe - If true, draws only wireframe.

update

public void update(boolean adjust_bounds)
Does canvas update.

Specified by:
update in interface GraphUpdate
Parameters:
adjust_bounds - If true, re-computes bounds.

getOffset

public DPoint getOffset()
Gets the offset coordinates.

Returns:
The offset coordinates.

setOffset

public void setOffset(double xoffset,
                      double yoffset,
                      boolean redraw)
Sets the offset coordinates.

Parameters:
xoffset - The X offset coordinate.
yoffset - The Y offset coordinate.
redraw - If true, redraws the canvas.

setViewAngles

public void setViewAngles(double theta,
                          double phi)
Sets the viewing angles.

Parameters:
theta - The theta viewing angle.
phi - The phi viewing angle.

windowRect

public DRect windowRect()
Get the position and dimensions of the display window.

Specified by:
windowRect in interface GraphUpdate
Returns:
The position and dimensions of the display window.

center

public void center()
Update the display and boundaries, and center the graph in the display window.

Specified by:
center in interface GraphUpdate

getContentSize

public DDimension getContentSize()
Gets the size of the canvas contents.

Returns:
The size of the canvas contents.

changeNodeClass

public void changeNodeClass(java.lang.String newClassName)
                     throws CoComposeException
Changes the class of a selected node, if any. Note that the class of the selected node and the given class name must refer to subclasses of AbstractConcept!

Parameters:
newClassName - New class name.
Throws:
CoComposeException - if node class could not be changed.

changeNode

public void changeNode(AbstractConcept newConcept)
                throws CoComposeException
Replaces the selected node, if any.

Parameters:
newConcept - New abtract concept to put in place.
Throws:
CoComposeException - if node class could not be changed.

setRepositoryContainer

public void setRepositoryContainer(RepositoryContainer repositoryContainer)
Sets the repository container to get composites from.

Parameters:
repositoryContainer - The object that contains the repository tree.

setMouseMode

public void setMouseMode(int mode)
Sets the behaviour of the mouse.

Parameters:
mode - The new mode (CREATE_NODES | .. | CREATE_ROLES)

getMouseMode

public int getMouseMode()
Gets the behaviour of the mouse.

Returns:
mode The new mode (CREATE_NODES | .. | CREATE_ROLES)

setNodeProperties

public void setNodeProperties()
Invokes a properties dialog for concepts, if a Concept object is selected. Returns otherwise.


reportError

public void reportError(CoComposeException error)
Reports an error.

Specified by:
reportError in interface ErrorReporter
Parameters:
error - - the error to report

notify

public void notify(java.lang.Object sender)
Accepts generic notification message.

Specified by:
notify in interface ErrorReporter
Parameters:
sender - The message sender.

getBackColor

public java.awt.Color getBackColor()
Gets the background drawing color.

Returns:
The background drawing color.

setBackColor

public void setBackColor(java.awt.Color color)
Sets the background drawing color.

Parameters:
color - The background drawing color.

getLineColor

public java.awt.Color getLineColor()
Gets the line drawing color.

Returns:
The line drawing color.

setLineColor

public void setLineColor(java.awt.Color color)
Sets the line drawing color.

Parameters:
color - The line drawing color.

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to the viewport scroller.

Parameters:
l - the listener to be added

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from the viewport scroller.

Parameters:
l - the listener to be removed

getModel

public Model getModel()
Gets the model that is being edited in this canvas.

Returns:
The model being edited.

setModel

public void setModel(Model model)
Sets the model that is being edited in this canvas.

Parameters:
model - The model being edited.

undo

public void undo()
Performs undo on last operation.


redo

public void redo()
Roll back undo on last operation (re-do).


canUndo

public boolean canUndo()
Checks whether undo is possible.

Returns:
True if and only if undo is possible.

canRedo

public boolean canRedo()
Checks whether redo is possible.

Returns:
True if and only if redo is possible.

toEPS

public java.lang.String toEPS()
Returns an Encapsulated PostScript representation of the model.

Returns:
An Encapsulated PostScript representation of the model.