templates.presentation
Class TemplateCanvas

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by templates.presentation.TemplateCanvas
All Implemented Interfaces:
ides.api.plugin.presentation.Presentation, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, TemplateDiagramSubscriber
Direct Known Subclasses:
TemplateEditableCanvas

public class TemplateCanvas
extends javax.swing.JComponent
implements ides.api.plugin.presentation.Presentation, TemplateDiagramSubscriber

The UI element which renders the graphical representation of a TemplateModel.

Author:
Lenko Grigorov
See Also:
Serialized Form

Nested Class Summary
 
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  TemplateDiagram diagram
          The template diagram for the TemplateModel rendered by this canvas.
protected static java.lang.String DIAGRAM
          The key to be used to annotate a TemplateModel with the TemplateDiagram for the model.
protected static java.awt.Graphics graphics
          The graphics context for rendering the template diagram.
protected  TemplateModel model
          The template design to be rendered.
protected  float scaleFactor
          The scaling factor when rendering the diagram.
protected  boolean scaleToFit
          Information about whether to scale the diagram to fit the size of the component containing the canvas.
 
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
TemplateCanvas(TemplateModel model)
          Construct and set up a new canvas to render the given template design.
 
Method Summary
 void forceRepaint()
           
 TemplateDiagram getDiagram()
          Retrieve the template diagram rendered by this canvas.
 javax.swing.JComponent getGUI()
           
 ides.api.plugin.model.DESModel getModel()
           
 java.awt.Dimension getPreferredSize()
           
 void paint(java.awt.Graphics g)
           
protected  void paintCore(java.awt.Graphics2D g2d)
          Paint only the template diagram itself.
 void refresh()
          Refresh the rendering of the diagram.
 void release()
           
 void setTrackModel(boolean arg0)
           
 void templateDiagramChanged(TemplateDiagramMessage message)
          Refresh the rendering of the diagram.
 void templateDiagramSelectionChanged(TemplateDiagramMessage message)
          Refresh the rendering of the diagram.
 
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

DIAGRAM

protected static final java.lang.String DIAGRAM
The key to be used to annotate a TemplateModel with the TemplateDiagram for the model.

See Also:
Annotable, Constant Field Values

graphics

protected static java.awt.Graphics graphics
The graphics context for rendering the template diagram.


model

protected TemplateModel model
The template design to be rendered.


diagram

protected TemplateDiagram diagram
The template diagram for the TemplateModel rendered by this canvas.


scaleFactor

protected float scaleFactor
The scaling factor when rendering the diagram.


scaleToFit

protected boolean scaleToFit
Information about whether to scale the diagram to fit the size of the component containing the canvas. Set to true if the diagram should be scaled, set to false otherwise.

Constructor Detail

TemplateCanvas

public TemplateCanvas(TemplateModel model)
Construct and set up a new canvas to render the given template design.

Parameters:
model - the template design to be rendered
Method Detail

getDiagram

public TemplateDiagram getDiagram()
Retrieve the template diagram rendered by this canvas.

Returns:
the template diagram rendered by this canvas

forceRepaint

public void forceRepaint()
Specified by:
forceRepaint in interface ides.api.plugin.presentation.Presentation

getGUI

public javax.swing.JComponent getGUI()
Specified by:
getGUI in interface ides.api.plugin.presentation.Presentation

getModel

public ides.api.plugin.model.DESModel getModel()
Specified by:
getModel in interface ides.api.plugin.presentation.Presentation

release

public void release()
Specified by:
release in interface ides.api.plugin.presentation.Presentation

setTrackModel

public void setTrackModel(boolean arg0)
Specified by:
setTrackModel in interface ides.api.plugin.presentation.Presentation

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

paintCore

protected void paintCore(java.awt.Graphics2D g2d)
Paint only the template diagram itself. This method can be used by subclasses to augment the graphics context before the painting of the diagram.

Parameters:
g2d - the graphics context where the template diagram should be painted

templateDiagramChanged

public void templateDiagramChanged(TemplateDiagramMessage message)
Refresh the rendering of the diagram.

Specified by:
templateDiagramChanged in interface TemplateDiagramSubscriber
Parameters:
message - the description of the change

templateDiagramSelectionChanged

public void templateDiagramSelectionChanged(TemplateDiagramMessage message)
Refresh the rendering of the diagram.

Specified by:
templateDiagramSelectionChanged in interface TemplateDiagramSubscriber
Parameters:
message - the description of the new collection of selected DiagramElements

refresh

public void refresh()
Refresh the rendering of the diagram. Compute the new scaling factor and repaint.