turingmachine
Class CTMComponentLink

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by turingmachine.CTMComponent
                  extended by turingmachine.CTMComponentLink
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

class CTMComponentLink
extends CTMComponent

Manages the link component that is draw between states.


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
private  CTMPoint arrowLeft
          Arrows heads left hand edge on curve end.
private  CTMPoint arrowRight
          Arrows heads right hand edge on curve end.
private  java.awt.geom.QuadCurve2D.Double curve1
          The curve that makes up half of the link.
private  java.awt.geom.QuadCurve2D.Double curve2
          The curve that makes up half of the link.
 javax.swing.JPanel panelTransitionComponents
          Transition component.
 java.awt.geom.AffineTransform transform
          Transform from local to view coords ( and back via inverse ).
 
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
CTMComponentLink(CTMDataLink linkData)
          Constructor.
 
Method Summary
 boolean contains(int x, int y)
          Is the point x,y roughly on the link curve.
 CTMComponent getComponentByData(CTMData aData)
          Get the Component that data is referred to in.
 CTMDataLink getLinkData()
          Get the data for this link component belongs to.
private  void jbInit()
          Initalise the components used for the link.
 void paint(java.awt.Graphics g)
          Paint link arrow.
 void removeNotify()
          Catchs the link being removed from the view and updates the controlComponent if need be.
private  void setCurve()
          Set the curves parametrics depending on the location of the states it links.
 void showControl()
          Show the adjustment control on the curve.
 void sync()
          Synchronize this link with it's data component.
private  void this_mouseClicked(java.awt.event.MouseEvent e)
          Handle mouse clicked on link.
private  void updateControls()
          Update the curve controls, if the curve is focus.
 
Methods inherited from class turingmachine.CTMComponent
getData, getDocument, getModificationCount, getViewComponent, requiresSync, setData, toBack, toFront
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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
 

Field Detail

curve1

private java.awt.geom.QuadCurve2D.Double curve1
The curve that makes up half of the link.


curve2

private java.awt.geom.QuadCurve2D.Double curve2
The curve that makes up half of the link.


arrowLeft

private CTMPoint arrowLeft
Arrows heads left hand edge on curve end.


arrowRight

private CTMPoint arrowRight
Arrows heads right hand edge on curve end.


transform

public java.awt.geom.AffineTransform transform
Transform from local to view coords ( and back via inverse ).


panelTransitionComponents

public javax.swing.JPanel panelTransitionComponents
Transition component.

Constructor Detail

CTMComponentLink

public CTMComponentLink(CTMDataLink linkData)
Constructor.

Parameters:
linkData - The link data this link component represents.
Method Detail

jbInit

private void jbInit()
Initalise the components used for the link.


this_mouseClicked

private void this_mouseClicked(java.awt.event.MouseEvent e)
Handle mouse clicked on link.

Parameters:
e - The mouse click event.

showControl

public void showControl()
Show the adjustment control on the curve.


removeNotify

public void removeNotify()
Catchs the link being removed from the view and updates the controlComponent if need be.

Overrides:
removeNotify in class javax.swing.JComponent

contains

public boolean contains(int x,
                        int y)
Is the point x,y roughly on the link curve.

Overrides:
contains in class javax.swing.JComponent
Parameters:
x - The x coordinate to test.
y - The y coordinate to test.
Returns:
true - it does contain this point
false - it does not contain the point

paint

public void paint(java.awt.Graphics g)
Paint link arrow.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - The graphics context to paint it on.

sync

public void sync()
Synchronize this link with it's data component.

Overrides:
sync in class CTMComponent

getComponentByData

public CTMComponent getComponentByData(CTMData aData)
Get the Component that data is referred to in.

Parameters:
aData - The data the defines a components parameters.
Returns:
The component if found, else null.

updateControls

private void updateControls()
Update the curve controls, if the curve is focus.


setCurve

private void setCurve()
Set the curves parametrics depending on the location of the states it links. + controlPoint + controlPoint1 + controlPoint2 + startpoint + endPoint A bezier is draw between these points. controlPoint1 = midPoint(endPoint->controlPoint) + (midPoint(endPoint->controlPoint) rotated 90degrees)/2 controlPoint2 = midPoint(endPoint->controlPoint) + (midPoint(endPoint->controlPoint) anti-rotated 90degrees)/2


getLinkData

public CTMDataLink getLinkData()
Get the data for this link component belongs to.

Returns:
The data for this link component.