Class mxConnectionHandler
java.lang.Object
com.mxgraph.swing.util.mxMouseAdapter
com.mxgraph.swing.handler.mxConnectionHandler
- All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener
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.
mxEvent.CONNECT fires between begin- and endUpdate in mouseReleased. The
cell
property contains the inserted edge, the event and target
properties contain the respective arguments that were passed to mouseReleased.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Rectanglestatic Cursorprotected ImageIconSpecifies the icon to be used for creating new connections.protected mxConnectPreviewprotected booleanSpecifies if the source should be cloned and used as a target if no target was selected.protected booleanprotected Stringprotected mxEventSourceHolds the event source.protected Pointprotected mxGraphComponentprotected booleanSpecifies if a handle should be used for creating new connections.protected intSpecifies the size of the handle to be used for creating new connections.protected booleanAppearance and event handling order wrt subhandles.protected mxCellMarkerprotected mxEventSource.mxIEventListenerprotected booleanprotected mxCellState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddGraphListeners(mxGraph graph) Installs the listeners to update the handles after any changes.voidaddListener(String eventName, mxEventSource.mxIEventListener listener) Adds the given event listener.protected mxConnectPreviewcreateTargetVertex(MouseEvent e, Object source) intbooleanisActive()booleanReturns true if the source terminal has been clicked and a new connection is currently being previewed.booleanbooleanbooleanbooleanReturns true if no connectIcon is specified and handleEnabled is false.booleanbooleanisSelect()booleanisValidSource(Object cell) booleanisValidTarget(Object cell) Returns true.voidvoidvoidvoidvoidprotected voidremoveGraphListeners(mxGraph graph) Removes all installed listeners.voidremoveListener(mxEventSource.mxIEventListener listener) Removes the given event listener.voidremoveListener(mxEventSource.mxIEventListener listener, String eventName) Removes the given event listener for the specified event name.voidreset()voidvoidsetConnectIcon(ImageIcon value) voidvoidsetCreateTarget(boolean value) voidsetEnabled(boolean value) voidsetHandleEnabled(boolean value) voidsetHandleSize(int value) voidsetKeepOnTop(boolean value) voidsetMarker(mxCellMarker value) voidsetSelect(boolean value) voidstart(MouseEvent e, mxCellState state) 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 mxMouseAdapter
mouseClicked, mouseEntered, mouseExited
-
Field Details
-
CONNECT_CURSOR
-
graphComponent
-
eventSource
Holds the event source. -
connectPreview
-
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 handleSizeSpecifies the size of the handle to be used for creating new connections. Default is mxConstants.CONNECT_HANDLE_SIZE. -
handleEnabled
protected boolean handleEnabledSpecifies 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 createTargetSpecifies if the source should be cloned and used as a target if no target was selected. Default is false. -
keepOnTop
protected boolean keepOnTopAppearance and event handling order wrt subhandles. -
enabled
protected boolean enabled -
first
-
active
protected transient boolean active -
bounds
-
source
-
marker
-
error
-
resetHandler
-
-
Constructor Details
-
mxConnectionHandler
- Parameters:
graphComponent-
-
-
Method Details
-
addGraphListeners
Installs the listeners to update the handles after any changes. -
removeGraphListeners
Removes all installed listeners. -
createConnectPreview
-
getConnectPreview
-
setConnectPreview
-
isConnecting
public boolean isConnecting()Returns true if the source terminal has been clicked and a new connection is currently being previewed. -
isActive
public boolean isActive() -
isHighlighting
public boolean isHighlighting()Returns true if no connectIcon is specified and handleEnabled is false. -
isEnabled
public boolean isEnabled() -
setEnabled
public void setEnabled(boolean value) -
isKeepOnTop
public boolean isKeepOnTop() -
setKeepOnTop
public void setKeepOnTop(boolean value) -
setConnectIcon
-
getConnecIcon
-
setHandleEnabled
public void setHandleEnabled(boolean value) -
isHandleEnabled
public boolean isHandleEnabled() -
setHandleSize
public void setHandleSize(int value) -
getHandleSize
public int getHandleSize() -
getMarker
-
setMarker
-
setCreateTarget
public void setCreateTarget(boolean value) -
isCreateTarget
public boolean isCreateTarget() -
setSelect
public void setSelect(boolean value) -
isSelect
public boolean isSelect() -
reset
public void reset() -
createTargetVertex
-
isValidSource
-
isValidTarget
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
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classmxMouseAdapter
-
start
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classmxMouseAdapter
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin classmxMouseAdapter
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin classmxMouseAdapter
-
setBounds
-
addListener
Adds the given event listener. -
removeListener
Removes the given event listener. -
removeListener
Removes the given event listener for the specified event name. -
paint
-