Package com.mxgraph.swing.handler
Class mxEdgeHandler
- java.lang.Object
-
- com.mxgraph.swing.handler.mxCellHandler
-
- com.mxgraph.swing.handler.mxEdgeHandler
-
- Direct Known Subclasses:
mxElbowEdgeHandler
public class mxEdgeHandler extends mxCellHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancloneEnabledprotected booleanconstrainedEventWorkaround for shift-key-state not correct in mouseReleased.protected java.lang.Stringerrorprotected booleangridEnabledEventWorkaround for alt-key-state not correct in mouseReleased.protected mxCellMarkermarkerprotected java.awt.Point[]p-
Fields inherited from class com.mxgraph.swing.handler.mxCellHandler
bounds, first, graphComponent, handles, handlesVisible, index, preview, state
-
-
Constructor Summary
Constructors Constructor Description mxEdgeHandler(mxGraphComponent graphComponent, mxCellState state)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidconnect(java.lang.Object edge, java.lang.Object terminal, boolean isSource, boolean isClone)Connects the given edge to the given source or target terminal.protected mxPointconvertPoint(mxPoint point, boolean gridEnabled)protected java.awt.RectanglecreateHandle(java.awt.Point center)protected java.awt.RectanglecreateHandle(java.awt.Point center, int size)protected java.awt.Rectangle[]createHandles()Creates the rectangles that define the handles.protected java.awt.Point[]createPoints(mxCellState s)protected javax.swing.JComponentcreatePreview()Creates the preview for this handler.protected java.awt.CursorgetCursor(java.awt.event.MouseEvent e, int index)Returns the cursor for the given event and handle.protected java.awt.ColorgetHandleFillColor(int index)Returns the color to be used to fill the handle at the specified index.intgetIndexAt(int x, int y)Returns the index of the handle at the given location.protected java.awt.RectanglegetPreviewBounds()java.awt.ColorgetSelectionColor()Returns the color used to draw the selection border.java.awt.StrokegetSelectionStroke()Returns the stroke used to draw the selection border.protected booleanisCellBendable()booleanisCloneEnabled()protected booleanisFlipEvent(java.awt.event.MouseEvent e)protected booleanisHandleVisible(int index)Hides the middle handle if the edge is not bendable.protected booleanisIgnoredEvent(java.awt.event.MouseEvent e)No flip event is ignored.booleanisSource(int index)Returns true if the current index is 0.booleanisTarget(int index)Returns true if the current index is the last index.voidmouseDragged(java.awt.event.MouseEvent e)Processes the given event.voidmousePressed(java.awt.event.MouseEvent e)Processes the given event.voidmouseReleased(java.awt.event.MouseEvent e)Processes the given event.protected voidmoveLabelTo(mxCellState edgeState, double x, double y)Moves the label to the given position.protected voidmovePoint(java.lang.Object edge, int pointIndex, mxPoint point)Moves the edges control point with the given index to the given point.voidpaint(java.awt.Graphics g)Paints the visible handles of this handler.voidreset()Extends the implementation to reset the current error and marker.voidsetCloneEnabled(boolean cloneEnabled)java.lang.StringvalidateConnection(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.handler.mxCellHandler
destroy, getBounds, getGraphComponent, getHandleBorderColor, getHandleCount, getIndex, getState, getToolTipText, isActive, isHandleEnabled, isHandlesVisible, isLabel, isLabelMovable, mouseMoved, refresh, setHandlesVisible, start
-
-
-
-
Field Detail
-
cloneEnabled
protected boolean cloneEnabled
-
p
protected java.awt.Point[] p
-
error
protected transient java.lang.String error
-
gridEnabledEvent
protected transient boolean gridEnabledEvent
Workaround for alt-key-state not correct in mouseReleased.
-
constrainedEvent
protected transient boolean constrainedEvent
Workaround for shift-key-state not correct in mouseReleased.
-
marker
protected mxCellMarker marker
-
-
Constructor Detail
-
mxEdgeHandler
public mxEdgeHandler(mxGraphComponent graphComponent, mxCellState state)
- Parameters:
graphComponent-state-
-
-
Method Detail
-
setCloneEnabled
public void setCloneEnabled(boolean cloneEnabled)
-
isCloneEnabled
public boolean isCloneEnabled()
-
isIgnoredEvent
protected boolean isIgnoredEvent(java.awt.event.MouseEvent e)
No flip event is ignored.- Overrides:
isIgnoredEventin classmxCellHandler
-
isFlipEvent
protected boolean isFlipEvent(java.awt.event.MouseEvent e)
-
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.
-
isSource
public boolean isSource(int index)
Returns true if the current index is 0.
-
isTarget
public boolean isTarget(int index)
Returns true if the current index is the last index.
-
isHandleVisible
protected boolean isHandleVisible(int index)
Hides the middle handle if the edge is not bendable.- Overrides:
isHandleVisiblein classmxCellHandler
-
isCellBendable
protected boolean isCellBendable()
-
createHandles
protected java.awt.Rectangle[] createHandles()
Description copied from class:mxCellHandlerCreates the rectangles that define the handles.- Overrides:
createHandlesin classmxCellHandler
-
getHandleFillColor
protected java.awt.Color getHandleFillColor(int index)
Description copied from class:mxCellHandlerReturns the color to be used to fill the handle at the specified index.- Overrides:
getHandleFillColorin classmxCellHandler
-
getIndexAt
public int getIndexAt(int x, int y)Description copied from class:mxCellHandlerReturns the index of the handle at the given location.- Overrides:
getIndexAtin classmxCellHandler- Parameters:
x-y-- Returns:
- Returns the inde of the handle at the given location.
-
createHandle
protected java.awt.Rectangle createHandle(java.awt.Point center)
-
createHandle
protected java.awt.Rectangle createHandle(java.awt.Point center, int size)
-
createPoints
protected java.awt.Point[] createPoints(mxCellState s)
-
createPreview
protected javax.swing.JComponent createPreview()
Description copied from class:mxCellHandlerCreates the preview for this handler.- Overrides:
createPreviewin classmxCellHandler
-
convertPoint
protected mxPoint convertPoint(mxPoint point, boolean gridEnabled)
- Parameters:
point-gridEnabled-- Returns:
- Returns the scaled, translated and grid-aligned point.
-
getPreviewBounds
protected java.awt.Rectangle getPreviewBounds()
- Returns:
- Returns the bounds of the preview.
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
Description copied from class:mxCellHandlerProcesses the given event.- Overrides:
mousePressedin classmxCellHandler
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
Description copied from class:mxCellHandlerProcesses the given event.- Overrides:
mouseDraggedin classmxCellHandler
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
Description copied from class:mxCellHandlerProcesses the given event.- Overrides:
mouseReleasedin classmxCellHandler
-
reset
public void reset()
Extends the implementation to reset the current error and marker.- Overrides:
resetin classmxCellHandler
-
movePoint
protected void movePoint(java.lang.Object edge, int pointIndex, mxPoint point)Moves the edges control point with the given index to the given point.
-
connect
protected void connect(java.lang.Object edge, java.lang.Object terminal, boolean isSource, boolean isClone)Connects the given edge to the given source or target terminal.- Parameters:
edge-terminal-isSource-
-
moveLabelTo
protected void moveLabelTo(mxCellState edgeState, double x, double y)
Moves the label to the given position.
-
getCursor
protected java.awt.Cursor getCursor(java.awt.event.MouseEvent e, int index)Description copied from class:mxCellHandlerReturns the cursor for the given event and handle.- Overrides:
getCursorin classmxCellHandler
-
getSelectionColor
public java.awt.Color getSelectionColor()
Description copied from class:mxCellHandlerReturns the color used to draw the selection border. This implementation returns null.- Overrides:
getSelectionColorin classmxCellHandler
-
getSelectionStroke
public java.awt.Stroke getSelectionStroke()
Description copied from class:mxCellHandlerReturns the stroke used to draw the selection border. This implementation returns null.- Overrides:
getSelectionStrokein classmxCellHandler
-
paint
public void paint(java.awt.Graphics g)
Description copied from class:mxCellHandlerPaints the visible handles of this handler.- Overrides:
paintin classmxCellHandler
-
-