public class IlvMakeSegmentedHyperEdgeInteractor extends IlvMakeHyperEdgeInteractor
IlvSegmentedHyperEdge
.
This interactor must be attached to a view that is attached to
an IlvHyperGrapher
.
Clicking on a start node and on an end node with the left mouse button creates a new hyperedge that has the start node as source and the end node as target. Clicking on a start node and on an existing hyperedge extends this hyperedge with the start node as new source node. Clicking on an existing hyperedge and on an end node extends this hyperedge with the end node as new target node. Pressing the Control-key while clicking on a node inverses the source and target notion of the node.
Clicking on a start hyperedge and on an end hyperedge combines both
hyperedges into one hyperedge. This means, one of both hyperedges
survives and the other is removed. The surviving hyperedge receives all
ends of the removed hyperedge. This works only if both hyperedges
have the same type, and if IlvMakeHyperEdgeInteractor.isCombiningHyperEdgesAllowed()
returns
true
.
Clicking on the right mouse button cancels the current interaction. Clicking on the middle mouse button shortens the hyperedge ghost by one segment.
Segmented hyperedges can have two types of segments: those with fixed angle and those with variable angle. By default, this interactor creates segments with fixed orthogonal angle (i.e. horizontal and vertical segments). The mode can be changed any time by pressing the tab key or the backspace key, even in the middle of a hyperedge creation. Then it changes the mode from segments with fixed angle to segments with variable angle, and vice versa. You can also customize the keys that should toggle this mode.
When creating segments with fixed angle, it is possible to change the angle of the currently created segment by pressing the space key. By default, the angle changes in steps of 45 degree. You can also customize the step size and which keys should change the angle.
Pressing the escape key during the interaction cancels the current
interaction. You can also customize the keys that should cancel the
current interaction. See setCancelKeyCodes(int[])
.
IlvSegmentedHyperEdge
,
IlvHyperGrapher
,
Serialized FormConstructor and Description |
---|
IlvMakeSegmentedHyperEdgeInteractor()
Creates a new interactor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
acceptBend(IlvPoint p)
Tests if creating a bend for the hyperedge when clicking in the space
is allowed.
|
protected boolean |
acceptContinuation(IlvPoint p,
IlvHyperEdge hyperedge)
Tests if a hyperedge can be extended towards a new origin or destination
end.
|
protected boolean |
allowEnd(IlvGraphic obj)
Returns whether the object can be end of the interaction.
|
protected boolean |
allowStart(IlvGraphic obj)
Returns whether the object can be start of the interaction.
|
protected void |
attach(IlvManagerView v)
This method is called when the interactor is attached to the manager view.
|
protected void |
createGhost()
Creates the ghost.
|
double |
getBendThreshold()
Returns the threshold for creating bends.
|
int[] |
getCancelKeyCodes()
Returns the key codes for canceling the current operation.
|
double |
getDeltaAngle()
Returns the change of the segment angle when the space key is pressed.
|
int[] |
getDeltaAngleKeyCodes()
Returns the key codes for changing the segment angle.
|
double |
getEndThreshold()
Returns the threshold for the last segment that connects to the node.
|
int[] |
getFixedAngleModeKeyCodes()
Returns the key codes for toggling the fixed angle mode.
|
double |
getGap()
Returns the gap width of the hyperedge crossings at the newly created
edge.
|
int |
getLayerOfCrossingGraphic()
Returns the default layer of the graphic object that draws the crossings
at the newly created edge.
|
Paint |
getSelectedSegmentsPaint()
Returns the stroke paint of selected segments of the newly created
hyperedge.
|
protected void |
initGhost(IlvHyperEdge hyperedge)
Initializes the ghost with the properties of the original edge.
|
boolean |
isCrossingEnabled()
Returns whether the crossing mode should be enabled at the newly created
edge.
|
boolean |
isCurrentFixedAngleMode()
Returns
true if the interactor is currently creating segments
with fixed angle, and false if the interactor is currently
creating segments with variable angle. |
boolean |
isFixedAngleMode()
Returns
true if the interactor creates segments
with fixed angle, and false if the interactor
creates segments with variable angle. |
boolean |
isGapZoomable()
Returns
true if the gap of the link crossings is zoomable
at the newly created edge. |
protected boolean |
isNearlyHorizontal(IlvSegmentedHyperEdge.Segment seg)
Returns whether the segment is nearly horizontal.
|
protected boolean |
isNearlyVertical(IlvSegmentedHyperEdge.Segment seg)
Returns whether the segment is nearly vertical.
|
protected boolean |
isShortenClick(MouseEvent event)
Returns
true if the mouse event was a segment shorten click. |
protected void |
moveGhost(IlvPoint p)
Move the ghost when moving the mouse to point p.
|
protected boolean |
onChangeDeltaAngle()
Called when the space character was pressed.
|
protected void |
onEndOrContinuationCreation(IlvPoint p,
boolean arrowAtEnd)
Called on the second mouse click that might finish the creation of
a hyperedge or might create a bend of the hyperedge.
|
protected boolean |
onToggleFixedAngleMode()
Called when the tab or backspace key was pressed.
|
protected void |
processKeyEvent(KeyEvent e)
Processes the key events.
|
protected void |
processMouseEvent(MouseEvent event)
Processes the mouse events.
|
protected void |
reInitialize()
Reinitializes the interactor.
|
void |
setBendThreshold(double value)
Sets the threshold for creating bends.
|
void |
setCancelKeyCodes(int[] keycodes)
Set the key codes for canceling the current operation.
|
void |
setCrossingEnabled(boolean enable)
Sets whether the crossing mode should be enabled at the newly created
edge.
|
void |
setDeltaAngle(double delta)
Sets the change of the segment angle when the space key is pressed.
|
void |
setDeltaAngleKeyCodes(int[] keycodes)
Set the key codes for changing the angle of the currently edited
segment.
|
void |
setEndThreshold(double value)
Sets the threshold for the last segment that connects to the node.
|
void |
setFixedAngleMode(boolean enable)
Sets whether the interactor creates segments with
fixed angle or with variable angle.
|
void |
setFixedAngleModeKeyCodes(int[] keycodes)
Set the key codes for toggling the fixed angle mode.
|
void |
setGap(double gap)
Sets the gap width of the hyperedge crossings at the newly created
edge.
|
void |
setGapZoomable(boolean zoomable)
Sets whether the gap of the hyperedge crossings is zoomable at the newly
created edge.
|
void |
setLayerOfCrossingGraphic(int layerNumber)
Sets the default layer of the graphic object that draws the crossings
at the newly created edge.
|
void |
setSelectedSegmentsPaint(Paint paint)
Sets the stroke paint of selected segments of the newly created
hyperedge.
|
acceptDestination, acceptOrigin, afterChange, afterChange, beforeChange, beforeChange, drawGhost, eraseGhost, getLineStyle, getLineWidth, getMaximumLineWidth, getStrokePaint, isCancelClick, isCombiningHyperEdgesAllowed, isNormalClick, isSelectionMode, needsChangeGraphicBag, onEndCreation, onStartCreation, processMouseMotionEvent, react, refreshGhost, selectIfNecessary, setCombiningHyperEdgesAllowed, setLineStyle, setLineWidth, setMaximumLineWidth, setSelectionMode, setStrokePaint
detach, getCursor, getHighlightedGraphic, getHighlightedPin, getObjectDrawingTransformer, getObjectToBeHighlighted, getPin, getPinCursor, getPinMargin, highlightObject, highlightPin, isCreationInSubManagersAllowed, isGridMode, isHyperEdge, isManagerToBeHighlighted, isNode, isPermanent, setCreationInSubManagersAllowed, setCursor, setGridMode, setPermanent, setPinCursor, setPinMargin, setPinSelected
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, disableEvents, drawGhost, enableEvents, ensureVisible, ensureVisible, getManager, getManagerView, getTransformer, handleExpose, isXORGhost, processEvent, processFocusEvent, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, setXORGhost
public IlvMakeSegmentedHyperEdgeInteractor()
public void setCancelKeyCodes(int[] keycodes)
By default, the escape key cancels the current operation.
keycodes
- An array of key codes, as defined in
java.awt.event.KeyEvent
Passing null
is allowed to disable
the possibility to toggle the mode with key presses.getCancelKeyCodes()
public int[] getCancelKeyCodes()
setCancelKeyCodes(int[])
public void setFixedAngleModeKeyCodes(int[] keycodes)
isFixedAngleMode()
returns true or
false. The mode can be changed any time by a key press, even in the
middle of a hyperedge creation. You can specify with this method
which keys toggle the fixed angle mode.
By default, the tab key and the backspace key toggle the mode.
keycodes
- An array of key codes, as defined in
java.awt.event.KeyEvent
Passing null
is allowed to disable
the possibility to toggle the mode with key presses.setFixedAngleMode(boolean)
,
getFixedAngleModeKeyCodes()
public int[] getFixedAngleModeKeyCodes()
setFixedAngleModeKeyCodes(int[])
public void setFixedAngleMode(boolean enable)
public boolean isFixedAngleMode()
true
if the interactor creates segments
with fixed angle, and false
if the interactor
creates segments with variable angle.public boolean isCurrentFixedAngleMode()
true
if the interactor is currently creating segments
with fixed angle, and false
if the interactor is currently
creating segments with variable angle.
During the interaction, you can change the mode by pressing the tab
key or the backspace key (or the keys specified with
setFixedAngleModeKeyCodes(int[])
).public void setBendThreshold(double value)
If the user clicks in the white space, usually a bend is created. If the last segment before the click point is smaller than the bend threshold, the interactor assumes that only one segment is created, otherwise two segments are created. This avoids that the user accidently creates tiny segments.
If the last segment before the click point is smaller than the bend threshold, the real bend will be close, but not exactly at the click point. If the last segment before the click point is larger than the threshold, the bend is created exactly at the click point.
The default value is 5.
getBendThreshold()
,
setFixedAngleMode(boolean)
public double getBendThreshold()
public void setEndThreshold(double value)
If the user clicks on a node, the edge is connected to the node. If the last segment of the edge at the node is smaller then the end threshold, it is ignored, and the second last segment is connected to the node. This avoids that the user accidently creates tiny segments.
The default value is 5.
getEndThreshold()
,
setFixedAngleMode(boolean)
public double getEndThreshold()
public void setDeltaAngleKeyCodes(int[] keycodes)
By default, the space key changes the angle.
keycodes
- An array of key codes, as defined in
java.awt.event.KeyEvent
Passing null
is allowed to disable
the possibility to change the angle with key presses.setDeltaAngle(double)
,
getDeltaAngleKeyCodes()
public int[] getDeltaAngleKeyCodes()
setDeltaAngleKeyCodes(int[])
public void setDeltaAngle(double delta)
public double getDeltaAngle()
public void setSelectedSegmentsPaint(Paint paint)
public Paint getSelectedSegmentsPaint()
setSelectedSegmentsPaint(java.awt.Paint)
public boolean isCrossingEnabled()
setCrossingEnabled(boolean)
public void setCrossingEnabled(boolean enable)
isCrossingEnabled()
,
IlvSegmentedHyperEdge.setCrossingEnabled(boolean)
public void setGap(double gap)
getGap()
public final double getGap()
setGap(double)
,
IlvSegmentedHyperEdge.setGap(double)
public void setGapZoomable(boolean zoomable)
If the gap is zoomable, the gap width follows the zoom level. If the gap is not zoomable, the gap width is the same for all zoom levels. In particular in nested graphers where hyperedges of different graphers cross each other, it is visually more appealing if the gap is not zoomable.
The option is enabled by default.
isGapZoomable()
public final boolean isGapZoomable()
true
if the gap of the link crossings is zoomable
at the newly created edge.setGapZoomable(boolean)
,
IlvSegmentedHyperEdge.setGapZoomable(boolean)
public void setLayerOfCrossingGraphic(int layerNumber)
-1
, an appropriate layer is
automatically calculated.getLayerOfCrossingGraphic()
,
IlvSegmentedHyperEdge.setLayerOfCrossingGraphic(int)
public final int getLayerOfCrossingGraphic()
-1
if the layer is automatically calculated.setLayerOfCrossingGraphic(int)
protected void attach(IlvManagerView v)
attach
in class IlvMakeHyperEdgeBaseInteractor
v
- The manager view.IlvMakeHyperEdgeBaseInteractor.detach()
protected void reInitialize()
reInitialize
in class IlvMakeHyperEdgeInteractor
protected void initGhost(IlvHyperEdge hyperedge)
initGhost
in class IlvMakeHyperEdgeInteractor
hyperedge
- The original hyperedge.protected void createGhost()
createGhost
in class IlvMakeHyperEdgeInteractor
protected void moveGhost(IlvPoint p)
// rerases the drawing of the old ghost position eraseGhost(); moveGhost(p); // draws the new ghost position refreshGhost();
moveGhost
in class IlvMakeHyperEdgeInteractor
p
- The point in the coordinate space of the view.protected void processKeyEvent(KeyEvent e)
processKeyEvent
in class IlvManagerViewInteractor
e
- The event.IlvManagerViewInteractor.addKeyListener(java.awt.event.KeyListener)
protected boolean onChangeDeltaAngle()
true
if the key event was handled,
false
if the key event was not handled and
should be forwarded to other key event listeners.getDeltaAngle()
protected boolean onToggleFixedAngleMode()
true
if the key event was handled,
false
if the key event was not handled and
should be forwarded to other key event listeners.isCurrentFixedAngleMode()
protected void processMouseEvent(MouseEvent event)
processMouseEvent
in class IlvMakeHyperEdgeInteractor
event
- The event.IlvManagerViewInteractor.addMouseListener(java.awt.event.MouseListener)
protected boolean isShortenClick(MouseEvent event)
true
if the mouse event was a segment shorten click.
On segment cancel click, the hyperedge branch currently edited is
shortened by one segment.
By default, this is a middle mouse click.protected boolean acceptContinuation(IlvPoint p, IlvHyperEdge hyperedge)
If creation in submanagers is not allowed
(see IlvMakeHyperEdgeBaseInteractor.isCreationInSubManagersAllowed()
) and the
hyperege
is not in the topmost grapher, the method returns
false
.
acceptContinuation
in class IlvMakeHyperEdgeInteractor
p
- The clicked point, in view coordinates.hyperedge
- The hyperedge to test.protected boolean acceptBend(IlvPoint p)
true
.p
- The clicked point in view coordinates.protected void onEndOrContinuationCreation(IlvPoint p, boolean arrowAtEnd)
p
- The click point in view coordinatesarrowAtEnd
- Whether we try to select an end target or an end source.protected boolean isNearlyHorizontal(IlvSegmentedHyperEdge.Segment seg)
protected boolean isNearlyVertical(IlvSegmentedHyperEdge.Segment seg)
protected boolean allowStart(IlvGraphic obj)
allowStart
in class IlvMakeHyperEdgeInteractor
protected boolean allowEnd(IlvGraphic obj)
allowEnd
in class IlvMakeHyperEdgeInteractor
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.