public class IlvMakeHyperEdgeInteractor extends IlvMakeHyperEdgeBaseInteractor
IlvHyperEdge
.
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 isCombiningHyperEdgesAllowed()
returns
true
.
Clicking on the right mouse button cancels the current interaction.
IlvHyperEdge
,
IlvHyperGrapher
,
Serialized FormConstructor and Description |
---|
IlvMakeHyperEdgeInteractor()
Creates a new interactor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
acceptContinuation(IlvPoint p,
IlvHyperEdge hyperedge)
Tests if a hyperedge can be extended towards a new origin or destination
end.
|
protected boolean |
acceptDestination(IlvPoint p,
IlvGraphic toNode)
Tests if a node can be the destination of the hyperedge.
|
protected boolean |
acceptOrigin(IlvPoint p,
IlvGraphic fromNode)
Tests if a node can be the origin of the hyperedge.
|
protected void |
afterChange(IlvHyperEdge edge1,
IlvHyperEdge edge2,
UndoableEdit[] edit)
Called after two hyperedges are combined.
|
protected void |
afterChange(IlvHyperEdge hyperedge,
UndoableEdit edit)
Called after the hyperedge is extended.
|
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 UndoableEdit |
beforeChange(IlvHyperEdge hyperedge)
Called before the hyperedge is extended.
|
protected UndoableEdit[] |
beforeChange(IlvHyperEdge edge1,
IlvHyperEdge edge2)
Called before two hyperedges are combined.
|
protected void |
createGhost()
Creates the ghost.
|
protected void |
drawGhost(Graphics g)
Draws the ghost of the object being created.
|
protected void |
eraseGhost()
Erases the drawing of the ghost of the object being created.
|
float[] |
getLineStyle()
Returns the line style of the newly created hyperedge.
|
double |
getLineWidth()
Returns the line width of the newly created hyperedge.
|
double |
getMaximumLineWidth()
Returns the maximum line width of the newly created hyperedge.
|
Paint |
getStrokePaint()
Returns the stroke paint of the newly created hyperedge.
|
protected void |
initGhost(IlvHyperEdge hyperedge)
Initializes the ghost with the properties of the original hyperedge.
|
protected boolean |
isCancelClick(MouseEvent event)
Returns
true if the mouse event was a cancel click. |
boolean |
isCombiningHyperEdgesAllowed()
Returns
true if combining hyperedges is allowed,
and false otherwise. |
protected boolean |
isNormalClick(MouseEvent event)
Returns
true if the mouse event was a normal click. |
boolean |
isSelectionMode()
Returns
true if the graphic object is
selected after creation, while the other objects are
deselected. |
protected void |
moveGhost(IlvPoint p)
Move the ghost when moving the mouse to point p.
|
protected boolean |
needsChangeGraphicBag(IlvHyperEdge hyperedge1,
IlvHyperEdge hyperedge2,
IlvGraphic node)
Returns
true if the input hyperedge must change its current
graphic bag if it is combined with the second hyperedge and with the
input node. |
protected void |
onEndCreation(IlvPoint p,
boolean arrowAtEnd)
Called on the second mouse click that might finish the creation of
a hyperedge.
|
protected void |
onStartCreation(IlvPoint p)
Called on the first mouse click that starts the creation of a hyperedge.
|
protected void |
processMouseEvent(MouseEvent event)
Processes the mouse events.
|
protected void |
processMouseMotionEvent(MouseEvent event)
Processes the mouse moved and mouse dragged events.
|
protected void |
react(IlvPoint p)
Highlights or unhighlights the node under the specified point.
|
protected void |
refreshGhost()
Refreshs the drawing of the ghost of the object being created.
|
protected void |
reInitialize()
Reinitializes the interactor.
|
protected void |
selectIfNecessary(IlvGraphic obj)
Selects the input object if the selection mode is enabled.
|
void |
setCombiningHyperEdgesAllowed(boolean set)
Allows to combine hyperedges, by creating a segment branch that starts
at the one hyperedge and ends at the other hyperedge.
|
void |
setLineStyle(float[] style)
Sets the line style of the newly created hyperedge.
|
void |
setLineWidth(double width)
Sets the line width of the newly created hyperedge.
|
void |
setMaximumLineWidth(double width)
Sets the maximum line width of the newly created hyperedge.
|
void |
setSelectionMode(boolean select)
Enables the selection of the created graphic object and
the deselection of the other graphic objects contained
in the manager after the creation.
|
void |
setStrokePaint(Paint paint)
Sets the stroke paint of the newly created hyperedge.
|
attach, 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, processKeyEvent, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, setXORGhost
public IlvMakeHyperEdgeInteractor()
public boolean isCombiningHyperEdgesAllowed()
true
if combining hyperedges is allowed,
and false
otherwise.setCombiningHyperEdgesAllowed(boolean)
public void setCombiningHyperEdgesAllowed(boolean set)
The default value is true
isCombiningHyperEdgesAllowed()
public boolean isSelectionMode()
true
if the graphic object is
selected after creation, while the other objects are
deselected. Returns false
otherwise.setSelectionMode(boolean)
public void setSelectionMode(boolean select)
The default value is true
.
isSelectionMode()
public Paint getStrokePaint()
setStrokePaint(java.awt.Paint)
public void setStrokePaint(Paint paint)
public double getLineWidth()
setLineWidth(double)
public void setLineWidth(double width)
getLineWidth()
,
IlvHyperEdge.setLineWidth(double)
public double getMaximumLineWidth()
setMaximumLineWidth(double)
public void setMaximumLineWidth(double width)
public float[] getLineStyle()
setLineStyle(float[])
public void setLineStyle(float[] style)
getLineStyle()
,
IlvHyperEdge.setLineStyle(float[])
protected void reInitialize()
reInitialize
in class IlvMakeHyperEdgeBaseInteractor
protected void eraseGhost()
protected void refreshGhost()
protected void drawGhost(Graphics g)
drawGhost
in class IlvManagerViewInteractor
g
- The graphics context.
Its current color is already set to the view's default ghost
color, see IlvManagerView.getDefaultGhostColor()
.
Also, in XOR ghost drawing mode, the graphics context is already
set to XOR mode, with the view's default XOR color, see
IlvManagerView.getDefaultXORColor()
.IlvManagerViewInteractor.handleExpose(java.awt.Graphics)
,
IlvManagerViewInteractor.setXORGhost(boolean)
protected void initGhost(IlvHyperEdge hyperedge)
hyperedge
- The original hyperedge.protected void createGhost()
protected void moveGhost(IlvPoint p)
// rerases the drawing of the old ghost position eraseGhost(); moveGhost(p); // draws the new ghost position refreshGhost();
p
- The point in the coordinate space of the view.protected void processMouseEvent(MouseEvent event)
processMouseEvent
in class IlvManagerViewInteractor
event
- The event.IlvManagerViewInteractor.addMouseListener(java.awt.event.MouseListener)
protected boolean isNormalClick(MouseEvent event)
true
if the mouse event was a normal click.
On a normal click, the start node, end node or the hyperedge to be
extended is selected.
By default, this is a left mouse click.protected boolean isCancelClick(MouseEvent event)
true
if the mouse event was a cancel click.
On a cancel click, the current operation is canceled.
By default, this is a right mouse click.protected void onStartCreation(IlvPoint p)
p
- The click point in view coordinatesprotected boolean acceptOrigin(IlvPoint p, IlvGraphic fromNode)
If creation in submanagers is not allowed
(see IlvMakeHyperEdgeBaseInteractor.isCreationInSubManagersAllowed()
) and the fromNode
is not in the topmost grapher, the method returns false
.
p
- The clicked point, in view coordinates.fromNode
- The origin node to test.acceptDestination(ilog.views.IlvPoint, ilog.views.IlvGraphic)
protected boolean acceptDestination(IlvPoint p, IlvGraphic toNode)
If creation in submanagers is not allowed
(see IlvMakeHyperEdgeBaseInteractor.isCreationInSubManagersAllowed()
) and the toNode
is not in the topmost grapher, the method returns false
.
p
- The clicked point, in view coordinates.toNode
- The destination node to test.acceptOrigin(ilog.views.IlvPoint, ilog.views.IlvGraphic)
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
.
p
- The clicked point, in view coordinates.hyperedge
- The hyperedge to test.protected void onEndCreation(IlvPoint p, boolean arrowAtEnd)
p
- The click point in view coordinatesarrowAtEnd
- Whether we try to select an end target or an end source.protected void selectIfNecessary(IlvGraphic obj)
obj
- The object to be selected.protected UndoableEdit beforeChange(IlvHyperEdge hyperedge)
protected void afterChange(IlvHyperEdge hyperedge, UndoableEdit edit)
protected UndoableEdit[] beforeChange(IlvHyperEdge edge1, IlvHyperEdge edge2)
protected void afterChange(IlvHyperEdge edge1, IlvHyperEdge edge2, UndoableEdit[] edit)
protected boolean needsChangeGraphicBag(IlvHyperEdge hyperedge1, IlvHyperEdge hyperedge2, IlvGraphic node)
true
if the input hyperedge must change its current
graphic bag if it is combined with the second hyperedge and with the
input node.
By combining the input hyperedge with the second hyperedge or with
the node, the hyperedge might become an intergraph hyperedge that
must be contained in an ancestor hypergraph.hyperedge1
- The input hyperedge whose graphic bag is checked.hyperedge2
- The hyperedge to be combined with the first hyperedge.
Can be null
node
- The node to become an end node of the first hyperedge.
Can be null
protected void processMouseMotionEvent(MouseEvent event)
MouseMotionListener
registered with this interactor (if any).processMouseMotionEvent
in class IlvManagerViewInteractor
event
- The event.IlvManagerViewInteractor.addMouseMotionListener(java.awt.event.MouseMotionListener)
protected void react(IlvPoint p)
p
- The point in the coordinate space of the view.protected boolean allowStart(IlvGraphic obj)
protected boolean allowEnd(IlvGraphic obj)
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.