jcreek.gui.conceptmap
Class ConceptMapView

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjcreek.gui.conceptmap.ConceptMapView
All Implemented Interfaces:
GraphChangeListener, java.awt.image.ImageObserver, java.awt.MenuContainer, SelectionChangeListener, java.io.Serializable
Direct Known Subclasses:
SubModelView

public class ConceptMapView
extends javax.swing.JComponent
implements GraphChangeListener, SelectionChangeListener

See Also:
Serialized Form

Nested Class Summary
 
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.awt.image.BufferedImage backImage
           
protected  java.awt.Rectangle bounds
           
protected  ConceptMapModel concepMapModel
           
protected  ConceptMapController conceptMapController
           
protected  java.awt.Point offset
           
protected  double scale
           
 
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
ConceptMapView(ConceptMapModel model)
          Creates a new ConceptMap using the supplied ConceptMapmodel as the model and the default ConceptMapController as the configuration.
ConceptMapView(ConceptMapModel model, ConceptMapController configuration)
          Creates a new ConceptMap using the supplied ConceptMapModel as the model of this view.
 
Method Summary
 void calculateBounds()
          (Re)calculates the outer boundaries of the ConceptMap.
 void centerOn(Node node)
          Centers the view on a node in the graph.
 void centerOn(java.awt.geom.Point2D p)
          Change the center position of the ConceptMap view to match this coordinate in model space.
 void drawEdge(java.awt.Graphics2D graphics, VisualRelation relation, int cnt)
           
 void drawNode(java.awt.Graphics2D graphics, VisualEntity entity)
           
 void drawObjects(java.awt.Graphics2D graphics, java.awt.Rectangle clipArea)
           
 void edgeAdded(GraphChangeEvent e)
           
 void edgeChanged(GraphChangeEvent e)
           
 void edgeRemoved(GraphChangeEvent e)
           
 VisualEntity findVisualEntity(java.awt.Point viewPoint)
           
 VisualRelation findVisualRelation(java.awt.Point p)
           
 java.awt.Rectangle getBoundingBox()
          Returns the bounding box, in model space coordinates of all the nodes.
 java.awt.Point getCenterPoint()
          Returns the point located closest to the center of this view, in model space coordinates.
 ConceptMapController getController()
          Returns the controller (ConceptMapController object) for this ConceptMap.
 ConceptMapTool getCurrentTool()
          Returns the current tools used on this view.
 ConceptMapModel getModel()
          Returns the model (ConceptMapModel object) this ConceptMap is a display of.
 java.awt.Rectangle getModelVisibleRect()
          Returns the rectangle in model space coordinates that represents what this view displays of the model.
 double getScale()
          Returns the current scale as a double larger than 0.0.
 java.awt.Point intersectWithLineTo(java.awt.Point to, java.awt.Point from)
           
 java.awt.Point modelToViewTransform(java.awt.Point modelSpacePoint)
          Transforms a point in model space to a point in view space.
 void nodeAdded(GraphChangeEvent e)
           
 void nodeChanged(GraphChangeEvent e)
           
 void nodeMoved(GraphChangeEvent e)
           
 void nodeRemoved(GraphChangeEvent e)
           
 void paintComponent(java.awt.Graphics g)
          (Re)paints this component.
 void selectionAdd(SelectionChangeEvent e)
           
 void selectionClear(SelectionChangeEvent e)
           
 void selectionRemove(SelectionChangeEvent e)
           
 void setBounds(int x, int y, int a, int b)
          Overrides the standard setSize() to maintain the center point when the size is changed.
 void setController(ConceptMapController controller)
          Sets the controlle (ConceptMapController object) for this ConceptMap.
 void setDropEnable(boolean b)
           
 void setScale(double newScale)
          Changes the scale of the view.
 void setTool(ConceptMapTool tool)
          Sets the current tool of this view.
 void suspendBoundingBoxUpdate(boolean susp)
          Suspends or restarts the recalculation of the bounding box when a node is added or removed from the model.
 java.awt.Point viewToModelTransform(java.awt.Point viewSpacePoint)
          Transforms a point in view space to a point in model space.
 
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, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getWidth, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, setVisible, unregisterKeyboardAction, update, updateUI
 
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, 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

concepMapModel

protected ConceptMapModel concepMapModel

conceptMapController

protected ConceptMapController conceptMapController

scale

protected double scale

bounds

protected java.awt.Rectangle bounds

offset

protected java.awt.Point offset

backImage

protected java.awt.image.BufferedImage backImage
Constructor Detail

ConceptMapView

public ConceptMapView(ConceptMapModel model,
                      ConceptMapController configuration)
Creates a new ConceptMap using the supplied ConceptMapModel as the model of this view.

Parameters:
configuration - The ConceptMapController as the configuration of the view.

ConceptMapView

public ConceptMapView(ConceptMapModel model)
Creates a new ConceptMap using the supplied ConceptMapmodel as the model and the default ConceptMapController as the configuration.

Method Detail

getModel

public ConceptMapModel getModel()
Returns the model (ConceptMapModel object) this ConceptMap is a display of.

Returns:
concepMapModel The ConceptMapModel object.

getController

public ConceptMapController getController()
Returns the controller (ConceptMapController object) for this ConceptMap.


setController

public void setController(ConceptMapController controller)
Sets the controlle (ConceptMapController object) for this ConceptMap. This object serves as a configuration-object for the view.

Parameters:
controller - The ConceptMapController object.

calculateBounds

public void calculateBounds()
(Re)calculates the outer boundaries of the ConceptMap. This is done based on the highest and lowest x and y positions on visible nodes in the graph. In addition a constand is added in each direction. This method should not normally be required to called from the outside of this class.


suspendBoundingBoxUpdate

public void suspendBoundingBoxUpdate(boolean susp)
Suspends or restarts the recalculation of the bounding box when a node is added or removed from the model.


getModelVisibleRect

public java.awt.Rectangle getModelVisibleRect()
Returns the rectangle in model space coordinates that represents what this view displays of the model.


getBoundingBox

public java.awt.Rectangle getBoundingBox()
Returns the bounding box, in model space coordinates of all the nodes.


centerOn

public void centerOn(java.awt.geom.Point2D p)
Change the center position of the ConceptMap view to match this coordinate in model space.

Parameters:
p - A point in the model space.

centerOn

public void centerOn(Node node)
Centers the view on a node in the graph.


getCenterPoint

public java.awt.Point getCenterPoint()
Returns the point located closest to the center of this view, in model space coordinates.


modelToViewTransform

public java.awt.Point modelToViewTransform(java.awt.Point modelSpacePoint)
Transforms a point in model space to a point in view space.

Parameters:
modelSpacePoint - A point in the model space.
Returns:
The corresponding point in the view space.

viewToModelTransform

public java.awt.Point viewToModelTransform(java.awt.Point viewSpacePoint)
Transforms a point in view space to a point in model space.

Parameters:
viewSpacePoint - A point in the view space.
Returns:
The corresponding point in the model space.

setScale

public void setScale(double newScale)
Changes the scale of the view. The scale is given as a double larger than 0.0.

Parameters:
newScale - The new scale to set this view to.

getScale

public double getScale()
Returns the current scale as a double larger than 0.0.

Returns:
The current scale.

setBounds

public void setBounds(int x,
                      int y,
                      int a,
                      int b)
Overrides the standard setSize() to maintain the center point when the size is changed.


findVisualEntity

public VisualEntity findVisualEntity(java.awt.Point viewPoint)

findVisualRelation

public VisualRelation findVisualRelation(java.awt.Point p)

setTool

public void setTool(ConceptMapTool tool)
Sets the current tool of this view. This is usually done automatically by the tool's constructor.

Parameters:
tool - The new current tool

getCurrentTool

public ConceptMapTool getCurrentTool()
Returns the current tools used on this view.


paintComponent

public void paintComponent(java.awt.Graphics g)
(Re)paints this component.


drawObjects

public void drawObjects(java.awt.Graphics2D graphics,
                        java.awt.Rectangle clipArea)

drawNode

public void drawNode(java.awt.Graphics2D graphics,
                     VisualEntity entity)

drawEdge

public void drawEdge(java.awt.Graphics2D graphics,
                     VisualRelation relation,
                     int cnt)

intersectWithLineTo

public java.awt.Point intersectWithLineTo(java.awt.Point to,
                                          java.awt.Point from)

nodeMoved

public void nodeMoved(GraphChangeEvent e)
Specified by:
nodeMoved in interface GraphChangeListener

nodeChanged

public void nodeChanged(GraphChangeEvent e)
Specified by:
nodeChanged in interface GraphChangeListener

nodeAdded

public void nodeAdded(GraphChangeEvent e)
Specified by:
nodeAdded in interface GraphChangeListener

nodeRemoved

public void nodeRemoved(GraphChangeEvent e)
Specified by:
nodeRemoved in interface GraphChangeListener

edgeAdded

public void edgeAdded(GraphChangeEvent e)
Specified by:
edgeAdded in interface GraphChangeListener

edgeRemoved

public void edgeRemoved(GraphChangeEvent e)
Specified by:
edgeRemoved in interface GraphChangeListener

edgeChanged

public void edgeChanged(GraphChangeEvent e)
Specified by:
edgeChanged in interface GraphChangeListener

selectionClear

public void selectionClear(SelectionChangeEvent e)
Specified by:
selectionClear in interface SelectionChangeListener

selectionRemove

public void selectionRemove(SelectionChangeEvent e)
Specified by:
selectionRemove in interface SelectionChangeListener

selectionAdd

public void selectionAdd(SelectionChangeEvent e)
Specified by:
selectionAdd in interface SelectionChangeListener

setDropEnable

public void setDropEnable(boolean b)


Created at IDI, NTNU by the Artificial Intelligence and Learning group