templates.presentation
Class TemplateConsistencyCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by templates.presentation.TemplateCanvas
                  extended by templates.presentation.TemplateEditableCanvas
                      extended by templates.presentation.TemplateConsistencyCanvas
All Implemented Interfaces:
ides.api.plugin.presentation.Presentation, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, TemplateDiagramSubscriber

public class TemplateConsistencyCanvas
extends TemplateEditableCanvas

A TemplateEditableCanvas which highlights the elements which contribute to consistency issues in the template design.

Author:
Lenko Grigorov
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class templates.presentation.TemplateEditableCanvas
TemplateEditableCanvas.CanvasSettings
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static java.lang.String CONSISTENCY_CANVAS_SETTINGS
          The key to be used to annotate a TemplateModel with the appearance settings of the consistency canvas (zoom level and viewport position).
 
Fields inherited from class templates.presentation.TemplateEditableCanvas
CANVAS_SETTINGS, connectorOrigin, drawConnector, hilitedElement, ignoreNextMouseEvent, interpreter, selectionBox, SELECTIONBOX_STROKE
 
Fields inherited from class templates.presentation.TemplateCanvas
diagram, DIAGRAM, graphics, model, scaleFactor, scaleToFit
 
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
TemplateConsistencyCanvas(TemplateModel model)
          Construct a new consistency canvas to enable the editing of the given template design and the visualization of consistency issues in the design.
 
Method Summary
protected  void autoScroll()
          Scroll the viewport of the canvas to the rectangle stored as an annotation in the template design.
protected  void autoZoom()
          Set the scaling factor according to the zoom level setting stored as an annotation in the template design.
protected  void paintCore(java.awt.Graphics2D g2d)
          Paint the template diagram so that diagram elements contributing to consistency issues are color-highlighted.
 void scrollTo(java.util.Collection<DiagramElement> elements)
          Scroll the viewport of the consistency canvas so that the specified diagram elements come to view.
protected  void storeCanvasInfo()
          Create a descriptor of the appearance settings of the consistency canvas and create an annotation with it in the template design.
 
Methods inherited from class templates.presentation.TemplateEditableCanvas
componentToLocal, finishConnector, getGUI, getHighlightedElement, getSelectionBox, highlight, isDrawingConnector, localToComponent, localToScreen, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, paint, refresh, release, removeHighlight, setSelectionBox, setUIInteraction, startConnector, templateDiagramChanged, transformMouseCoords
 
Methods inherited from class templates.presentation.TemplateCanvas
forceRepaint, getDiagram, getModel, getPreferredSize, setTrackModel, templateDiagramSelectionChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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
 
Methods inherited from interface ides.api.plugin.presentation.Presentation
getName
 

Field Detail

CONSISTENCY_CANVAS_SETTINGS

protected static final java.lang.String CONSISTENCY_CANVAS_SETTINGS
The key to be used to annotate a TemplateModel with the appearance settings of the consistency canvas (zoom level and viewport position). This annotation is used to restore the last appearance of the template diagram when the user re-activates the diagram in the workspace.

There has to be an annotation separate from the annotation of the TemplateEditableCanvas associated with the model to prevent the settings overwriting.

See Also:
Annotable, TemplateEditableCanvas.CANVAS_SETTINGS, TemplateEditableCanvas.CanvasSettings, Constant Field Values
Constructor Detail

TemplateConsistencyCanvas

public TemplateConsistencyCanvas(TemplateModel model)
Construct a new consistency canvas to enable the editing of the given template design and the visualization of consistency issues in the design.

Parameters:
model - the template design which the user will manipulate and whose consistency issues will be visualized
Method Detail

autoZoom

protected void autoZoom()
Set the scaling factor according to the zoom level setting stored as an annotation in the template design. If this annotation cannot be found, set the scaling factor to 1.

Overrides:
autoZoom in class TemplateEditableCanvas
See Also:
TemplateEditableCanvas.CanvasSettings, Annotable

autoScroll

protected void autoScroll()
Scroll the viewport of the canvas to the rectangle stored as an annotation in the template design. After the scrolling, the annotation is removed. If the annotation cannot be found, do nothing.

Overrides:
autoScroll in class TemplateEditableCanvas
See Also:
TemplateEditableCanvas.CanvasSettings, Annotable

storeCanvasInfo

protected void storeCanvasInfo()
Create a descriptor of the appearance settings of the consistency canvas and create an annotation with it in the template design.

Overrides:
storeCanvasInfo in class TemplateEditableCanvas
See Also:
TemplateEditableCanvas.CanvasSettings, Annotable

paintCore

protected void paintCore(java.awt.Graphics2D g2d)
Paint the template diagram so that diagram elements contributing to consistency issues are color-highlighted.

Overrides:
paintCore in class TemplateEditableCanvas
Parameters:
g2d - the graphics context where the template diagram should be painted

scrollTo

public void scrollTo(java.util.Collection<DiagramElement> elements)
Scroll the viewport of the consistency canvas so that the specified diagram elements come to view. If all elements do not fit in the viewport, scroll to the top-left corner of the area containing the element. If the list of elements is empty, do nothing.

Parameters:
elements - the list of diagram elements which should come into view