JGraph X 1.2.0.8


com.mxgraph.swing.handler
Class mxConnectionHandler

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.mxgraph.swing.util.mxMouseControl
                  extended by com.mxgraph.swing.handler.mxConnectionHandler
All Implemented Interfaces:
MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener

public class mxConnectionHandler
extends mxMouseControl

Connection handler creates new connections between cells. This control is used to display the connector icon, while the preview is used to draw the line.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  ImageIcon connectIcon
          Specifies the icon to be used for creating new connections.
protected  boolean createTarget
           
protected  Point current
           
static Cursor DEFAULT_CURSOR
           
protected  String error
           
protected  mxGraphComponent graphComponent
           
protected  boolean handleEnabled
          Specifies if a handle should be used for creating new connections.
protected  int handleSize
          Specifies the size of the handle to be used for creating new connections.
protected  boolean keepOnTop
          Appearance and event handling order wrt subhandles.
protected  mxCellMarker marker
           
protected  JPanel preview
           
protected  mxEventSource.mxIEventListener resetHandler
           
protected  boolean select
           
protected  mxCellState source
           
protected  Point start
           
 
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
mxConnectionHandler(mxGraphComponent graphComponent)
           
 
Method Summary
protected  void connect(Object source, Object target, MouseEvent e)
           
 Object createTargetVertex(MouseEvent e, Object source)
           
 ImageIcon getConnecIcon()
           
 int getHandleSize()
           
 mxCellMarker getMarker()
           
protected  Object insertEdge(Object parent, String id, Object value, Object source, Object target)
          Creates, inserts and returns a new edge using mxGraph.insertEdge.
 boolean isConnecting()
          Returns true if the source terminal has been clicked and a new connection is currently being previewed.
 boolean isCreateTarget()
           
 boolean isHandleEnabled()
           
 boolean isHighlighting()
          Returns true if no connectIcon is specified and handleEnabled is false.
 boolean isKeepOnTop()
           
 boolean isSelect()
           
 boolean isValidSource(Object cell)
           
 boolean isValidTarget(Object cell)
          Returns true.
 void mouseDragged(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void paint(Graphics g)
           
 void reset()
           
 void setConnectIcon(ImageIcon connectIcon)
           
 void setCreateTarget(boolean createTarget)
           
 void setHandleEnabled(boolean handleEnabled)
           
 void setHandleSize(int size)
           
 void setKeepOnTop(boolean keepOnTop)
           
 void setMarker(mxCellMarker marker)
           
 void setSelect(boolean select)
           
 String validateConnection(Object source, Object target)
          Returns the error message or an empty string if the connection for the given source target pair is not valid.
 
Methods inherited from class com.mxgraph.swing.util.mxMouseControl
mouseClicked, mouseEntered, mouseExited
 
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, 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, 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
 

Field Detail

DEFAULT_CURSOR

public static Cursor DEFAULT_CURSOR

graphComponent

protected mxGraphComponent graphComponent

connectIcon

protected ImageIcon connectIcon
Specifies the icon to be used for creating new connections. If this is specified then it is used instead of the handle. Default is null.


handleSize

protected int handleSize
Specifies the size of the handle to be used for creating new connections. Default is mxConstants.CONNECT_HANDLE_SIZE.


handleEnabled

protected boolean handleEnabled
Specifies if a handle should be used for creating new connections. This is only used if no connectIcon is specified. If this is false, then the source cell will be highlighted when the mouse is over the hotspot given in the marker. Default is mxConstants.CONNECT_HANDLE_ENABLED.


select

protected boolean select

createTarget

protected boolean createTarget

keepOnTop

protected boolean keepOnTop
Appearance and event handling order wrt subhandles.


start

protected transient Point start

current

protected transient Point current

source

protected transient mxCellState source

marker

protected transient mxCellMarker marker

error

protected transient String error

preview

protected transient JPanel preview

resetHandler

protected transient mxEventSource.mxIEventListener resetHandler
Constructor Detail

mxConnectionHandler

public mxConnectionHandler(mxGraphComponent graphComponent)
Parameters:
graphComponent -
Method Detail

isConnecting

public boolean isConnecting()
Returns true if the source terminal has been clicked and a new connection is currently being previewed.


isHighlighting

public boolean isHighlighting()
Returns true if no connectIcon is specified and handleEnabled is false.


isKeepOnTop

public boolean isKeepOnTop()

setKeepOnTop

public void setKeepOnTop(boolean keepOnTop)

setConnectIcon

public void setConnectIcon(ImageIcon connectIcon)

getConnecIcon

public ImageIcon getConnecIcon()

setHandleEnabled

public void setHandleEnabled(boolean handleEnabled)

isHandleEnabled

public boolean isHandleEnabled()

setHandleSize

public void setHandleSize(int size)

getHandleSize

public int getHandleSize()

getMarker

public mxCellMarker getMarker()

setMarker

public void setMarker(mxCellMarker marker)

setCreateTarget

public void setCreateTarget(boolean createTarget)

isCreateTarget

public boolean isCreateTarget()

setSelect

public void setSelect(boolean select)

isSelect

public boolean isSelect()

reset

public void reset()

connect

protected void connect(Object source,
                       Object target,
                       MouseEvent e)
Parameters:
source -
target -
e -

insertEdge

protected Object insertEdge(Object parent,
                            String id,
                            Object value,
                            Object source,
                            Object target)
Creates, inserts and returns a new edge using mxGraph.insertEdge.


createTargetVertex

public Object createTargetVertex(MouseEvent e,
                                 Object source)

isValidSource

public boolean isValidSource(Object cell)

isValidTarget

public boolean isValidTarget(Object cell)
Returns true. The call to mxGraph.isValidTarget is implicit by calling mxGraph.getEdgeValidationError in validateConnection. This is an additional hook for disabling certain targets in this specific handler.


validateConnection

public String validateConnection(Object source,
                                 Object target)
Returns the error message or an empty string if the connection for the given source target pair is not valid. Otherwise it returns null.


mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class mxMouseControl

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class mxMouseControl

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class mxMouseControl

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class mxMouseControl

paint

public void paint(Graphics g)
Overrides:
paint in class JComponent

JGraph X 1.2.0.8


Copyright (c) 2008 Gaudenz Alder. All rights reserved.