JGraph X 1.3.0.0

## com.mxgraph.swing.handler
Class mxConnectionHandler

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  com.mxgraph.swing.util.mxMouseControl
                      com.mxgraph.swing.handler.mxConnectionHandler

All Implemented Interfaces:
  java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.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
`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 javax.swing.ImageIcon` `connectIcon` Specifies the icon to be used for creating new connections.
`protected boolean` `createTarget` Specifies if the source should be cloned and used as a target if no target was selected.
`protected java.awt.Point` `current`
`static java.awt.Cursor` `DEFAULT_CURSOR`
`protected java.lang.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 javax.swing.JPanel` `preview`
`protected mxEventSource.mxIEventListener` `resetHandler`
`protected boolean` `select`
`protected mxCellState` `source`
`protected java.awt.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(java.lang.Object source, java.lang.Object target, java.awt.event.MouseEvent e)`
`java.lang.Object` `createTargetVertex(java.awt.event.MouseEvent e, java.lang.Object source)`
`javax.swing.ImageIcon` `getConnecIcon()`
`int` `getHandleSize()`
`mxCellMarker` `getMarker()`
`protected java.lang.Object` `insertEdge(java.lang.Object parent, java.lang.String id, java.lang.Object value, java.lang.Object source, java.lang.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(java.lang.Object cell)`
`boolean` `isValidTarget(java.lang.Object cell)` Returns true.
`void` `mouseDragged(java.awt.event.MouseEvent e)`
`void` `mouseMoved(java.awt.event.MouseEvent e)`
`void` `mousePressed(java.awt.event.MouseEvent e)`
`void` `mouseReleased(java.awt.event.MouseEvent e)`
`void` `paint(java.awt.Graphics g)`
`void` `reset()`
`void` `setConnectIcon(javax.swing.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)`
`java.lang.String` `validateConnection(java.lang.Object source, java.lang.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, 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, getPreferredSize, 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`

Field Detail

### DEFAULT_CURSOR

    public static java.awt.Cursor DEFAULT_CURSOR

### graphComponent

    protected mxGraphComponent graphComponent

### connectIcon

    protected javax.swing.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

  Specifies if the source should be cloned and used as a target if no target was selected. Default is false.

### keepOnTop

    protected boolean keepOnTop

  Appearance and event handling order wrt subhandles.

### start

    protected transient java.awt.Point start

### current

    protected transient java.awt.Point current

### source

    protected transient mxCellState source

### marker

    protected transient mxCellMarker marker

### error

    protected transient java.lang.String error

### preview

    protected transient javax.swing.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(javax.swing.ImageIcon connectIcon)

### getConnecIcon

    public javax.swing.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(java.lang.Object source,
                           java.lang.Object target,
                           java.awt.event.MouseEvent e)

  Parameters:
    `source` -
    `target` -
    `e` -

### insertEdge

    protected java.lang.Object insertEdge(java.lang.Object parent,
                                          java.lang.String id,
                                          java.lang.Object value,
                                          java.lang.Object source,
                                          java.lang.Object target)

  Creates, inserts and returns a new edge using mxGraph.insertEdge.

### createTargetVertex

    public java.lang.Object createTargetVertex(java.awt.event.MouseEvent e,
                                               java.lang.Object source)

### isValidSource

    public boolean isValidSource(java.lang.Object cell)

### isValidTarget

    public boolean isValidTarget(java.lang.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 java.lang.String validateConnection(java.lang.Object source,
                                               java.lang.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(java.awt.event.MouseEvent e)

  Specified by:
    `mousePressed` in interface `java.awt.event.MouseListener`
  Overrides:
    `mousePressed` in class `mxMouseControl`

### mouseDragged

    public void mouseDragged(java.awt.event.MouseEvent e)

  Specified by:
    `mouseDragged` in interface `java.awt.event.MouseMotionListener`
  Overrides:
    `mouseDragged` in class `mxMouseControl`

### mouseReleased

    public void mouseReleased(java.awt.event.MouseEvent e)

  Specified by:
    `mouseReleased` in interface `java.awt.event.MouseListener`
  Overrides:
    `mouseReleased` in class `mxMouseControl`

### mouseMoved

    public void mouseMoved(java.awt.event.MouseEvent e)

  Specified by:
    `mouseMoved` in interface `java.awt.event.MouseMotionListener`
  Overrides:
    `mouseMoved` in class `mxMouseControl`

### paint

    public void paint(java.awt.Graphics g)

  Overrides:
    `paint` in class `javax.swing.JComponent`

JGraph X 1.3.0.0

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