|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
EDU.utwente.CoCompose.gui.ModelCanvas
A window class for editing and displaying CoCompose design models. Based on EDU.auburn.VGJ.gui.GraphCanvas. Adapted for Swing.
GraphCanvas
,
Serialized FormNested 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 |
protected static final int MOUSE_NONE
protected static final int MOUSE_NODE
protected static final int MOUSE_EDGE
protected static final int MOUSE_SELECT
protected static final int MOUSE_MSELECT
public static final int SELECT_BOTH
public static final int CREATE_EDGES
public static final int CREATE_CONCEPTS
public static final int CREATE_SOLROLE
public static final int CREATE_COMPOSITES
public static final int CREATE_ROLES
public static final int CREATE_PUBLISHED
public static final int CREATE_REPOS
protected int currentMouseAction
protected Matrix44 viewTransform
protected Matrix44 moveTransform
protected transient javax.swing.event.ChangeEvent changeEvent
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 |
public ModelCanvas(Model model_in, java.awt.Frame frame_in)
model_in
- The Model object that will be edited.frame_in
- The parent frame that contains this object.public ModelCanvas(java.awt.Frame frame_in)
frame_in
- The parent frame that contains this object.public ModelCanvas()
Method Detail |
protected boolean getEnabled()
protected void paintComponent(java.awt.Graphics g)
g
- The graphics context.protected void paintComponentBuffer(java.awt.Graphics g)
g
- The graphics context.protected void fireStateChanged()
EventListenerList
protected java.lang.String getLabel(double x, double y, double z, boolean mousein)
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.
protected void drawObjects(boolean selected, java.awt.Graphics graphics)
selected
- If true, draws selected elements, otherwise unselected.graphics
- The graphics contextprotected void drawAxes(java.awt.Graphics graphics)
graphics
- The graphics contextprotected Node findNearestNode(double x, double y)
x
- The X mouse coordinate.y
- The Y mouse coordinate.
protected java.awt.Point findNearestLink(double x, double y)
x
- The X mouse coordinate.y
- The Y mouse coordinate.
protected Composite findNearestComposite(int x_in, int y_in)
x_in
- The X part of the coordinates to look at.y_in
- The Y part of the coordinates to look at.
protected CompositeRole findNearestCompositeRole(int x_in, int y_in)
x_in
- The X part of the coordinates to look at.y_in
- The Y part of the coordinates to look at.
protected PublishedConcept findNearestPublishedConcept(int x_in, int y_in)
x_in
- The X part of the coordinates to look at.y_in
- The Y part of the coordinates to look at.
protected void dispatchMouseClickAction(java.awt.event.MouseEvent e)
e
- The mouse event.protected void dispatchMouseDoubleClickAction(java.awt.event.MouseEvent e)
e
- The mouse event.protected void dispatchMouseReleaseAction(java.awt.event.MouseEvent e)
e
- The mouse event.protected void dispatchMouseDragAction(java.awt.event.MouseEvent e)
e
- The mouse event.protected void dispatchMouseRightClick(java.awt.event.MouseEvent e)
e
- The mouse event.protected void dispatchNodeCreation(java.awt.event.MouseEvent e) throws CoComposeException
e
- The mouse event.
CoComposeException
- if a node could not be created.protected void insertNode(int x_in, int y_in)
x_in
- The mouse X coordinate.y_in
- The mouse Y coordinate.dispatchNodeCreation(java.awt.event.MouseEvent)
,
Node
protected void insertLink(int x_in, int y_in)
x_in
- The mouse X coordinate.y_in
- The mouse Y coordinate.Link
protected void select(int x_in, int y_in, boolean multiple)
x_in
- The mouse X coordinate.y_in
- The mouse Y coordinate.multiple
- If true, adds the new selection to the current selection.protected void multiSelect()
protected DPoint3 clip(DPoint3 pos)
protected void getDrawBounds(DPoint width, DPoint height)
width
- The DPoint to store the width in.height
- The DPoint to store the height in.protected void updateUndo()
public void setEnabled(boolean enabled)
setEnabled
in interface ModelUpdate
enabled
- If true, canvas is enabled, otherwise disabled.public java.awt.Frame getFrame()
getFrame
in interface GraphUpdate
public double getHSpacing()
getHSpacing
in interface GraphUpdate
public double getVSpacing()
getVSpacing
in interface GraphUpdate
public Node getSelectedNode()
getSelectedNode
in interface GraphUpdate
public java.awt.Point getSelectedLink()
public void selectNode(int node_id)
node_id
- The node id.public double getScale()
public void setScale(double new_scale)
new_scale
- The new viewing scale.public void scale(double scaleval)
GraphUpdate
scale
in interface GraphUpdate
setScale(double)
public void selectAll()
public void unselectItems()
public void deleteSelected()
public void setWireframe(boolean wireframe)
wireframe
- If true, draws only wireframe.public void update(boolean adjust_bounds)
update
in interface GraphUpdate
adjust_bounds
- If true, re-computes bounds.public DPoint getOffset()
public void setOffset(double xoffset, double yoffset, boolean redraw)
xoffset
- The X offset coordinate.yoffset
- The Y offset coordinate.redraw
- If true, redraws the canvas.public void setViewAngles(double theta, double phi)
theta
- The theta viewing angle.phi
- The phi viewing angle.public DRect windowRect()
windowRect
in interface GraphUpdate
public void center()
center
in interface GraphUpdate
public DDimension getContentSize()
public void changeNodeClass(java.lang.String newClassName) throws CoComposeException
newClassName
- New class name.
CoComposeException
- if node class could not be changed.public void changeNode(AbstractConcept newConcept) throws CoComposeException
newConcept
- New abtract concept to put in place.
CoComposeException
- if node class could not be changed.public void setRepositoryContainer(RepositoryContainer repositoryContainer)
repositoryContainer
- The object that contains the repository tree.public void setMouseMode(int mode)
mode
- The new mode (CREATE_NODES | .. | CREATE_ROLES)public int getMouseMode()
public void setNodeProperties()
public void reportError(CoComposeException error)
reportError
in interface ErrorReporter
error
- - the error to reportpublic void notify(java.lang.Object sender)
notify
in interface ErrorReporter
sender
- The message sender.public java.awt.Color getBackColor()
public void setBackColor(java.awt.Color color)
color
- The background drawing color.public java.awt.Color getLineColor()
public void setLineColor(java.awt.Color color)
color
- The line drawing color.public void addChangeListener(javax.swing.event.ChangeListener l)
l
- the listener to be addedpublic void removeChangeListener(javax.swing.event.ChangeListener l)
l
- the listener to be removedpublic Model getModel()
public void setModel(Model model)
model
- The model being edited.public void undo()
public void redo()
public boolean canUndo()
public boolean canRedo()
public java.lang.String toEPS()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |