public class IltMakeLinkInteractor extends IlvManagerViewInteractor implements IlvPermanentInteractorInterface
By default, this interactor creates a straight link between the two nodes. However the following configuration is also available:
setSelfLinkAllowed(boolean)
you
can specify that self-links can be created by this interactor.
Self-links are links where the from
and
to
nodes are the same. Please note that with
some link layout algorithms, such as IltShortLinkLayout
,
self-links are not well displayed.setLinkConnectionPortMode(boolean)
you can specify link connection ports on each node. However, if the user
has the Shift
key pressed while pressing or releasing the mouse button,
the created link connects to the default link connection ports. Note that link
connection ports are only available when the link layout specified for the
Network component is IltShortLinkLayout
,
therefore this mode is incompatible with the previous two modes.Modifier and Type | Class and Description |
---|---|
static class |
IltMakeLinkInteractor.Gesture
This class enumerates the possible gestures recognized by this interactor.
|
Constructor and Description |
---|
IltMakeLinkInteractor()
Creates the interactor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(IltCompositeGraphic graphic)
This method tests if an object can be the origin or destination of
the link.
|
protected boolean |
acceptDestination(IltCompositeGraphic node)
This method tests if a composite object can be the destination
of the link.
|
protected boolean |
acceptOrigin(IltCompositeGraphic node)
This method tests if a composite object can be the origin of the link.
|
protected void |
drawGhost(Graphics g)
Draws an outline of the link to be created.
|
protected boolean |
endOnDoubleClick()
Returns
true if the interactor will stop
requesting points when the user performs a double-click. |
Color |
getPortsColor()
Returns the color of the ports.
|
protected void |
handleExpose(Graphics g)
Called by the view when the view
is drawn.
|
protected boolean |
isEnoughDistance(IlvPoint p1,
IlvPoint p2)
Checks the distance between two consecutive points that are created.
|
boolean |
isLinkConnectionPortMode()
Returns
true if the interactor allows the end-user to select
the link connection ports. |
boolean |
isPermanent()
Returns
false if this interactor removes itself after
processing an event. |
boolean |
isSelfLinkAllowed()
Returns
true if the creation of self-links is allowed,
and returns false otherwise. |
protected boolean |
numberOfPointsReached()
Returns
true if the number of desired points is reached. |
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(MouseEvent event)
Allows you to implement an interaction when the user moves the
mouse to add a point to the polypoint.
|
void |
setLinkConnectionPortMode(boolean portMode)
Allows or disallows the selection of link connection ports.
|
void |
setPermanent(boolean set)
Changes the mode of this interactor.
|
void |
setPortsColor(Color color)
Changes the color of the ports.
|
void |
setSelfLinkAllowed(boolean allow)
Enables or disables the creation of self-links.
|
void |
trigger(AWTEvent event,
IltObject origin,
IltObject destination,
IltCompositeGrapher grapher)
This method is called when the user has released the mouse, thus finishing
a drag operation.
|
void |
trigger(AWTEvent event,
IltObject origin,
IltObject destination,
IltLinkPort originPort,
IltLinkPort destinationPort,
IltCompositeGrapher grapher)
This method is called when the user has released the mouse, thus finishing
a drag operation.
|
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, attach, detach, disableEvents, drawGhost, enableEvents, ensureVisible, ensureVisible, getManager, getManagerView, getTransformer, isXORGhost, processEvent, processFocusEvent, processKeyEvent, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, setXORGhost
public boolean isPermanent()
false
if this interactor removes itself after
processing an event.isPermanent
in interface IlvPermanentInteractorInterface
public void setPermanent(boolean set)
setPermanent
in interface IlvPermanentInteractorInterface
set
- the new mode.public boolean isLinkConnectionPortMode()
true
if the interactor allows the end-user to select
the link connection ports.public void setLinkConnectionPortMode(boolean portMode)
public Color getPortsColor()
public void setPortsColor(Color color)
public final void setSelfLinkAllowed(boolean allow)
true
.isSelfLinkAllowed()
public final boolean isSelfLinkAllowed()
true
if the creation of self-links is allowed,
and returns false
otherwise.setSelfLinkAllowed(boolean)
,
acceptDestination(ilog.tgo.graphic.IltCompositeGraphic)
protected void handleExpose(Graphics g)
IlvManagerViewInteractor
IlvManagerViewInteractor.drawGhost(java.awt.Graphics)
.
If the interactor is in XOR Ghost drawing mode, the
default XOR color of the view is set on the Graphics
before calling drawGhost(Graphics)
.handleExpose
in class IlvManagerViewInteractor
g
- The graphics.IlvManagerViewInteractor.drawGhost(java.awt.Graphics)
,
IlvManagerViewInteractor.isXORGhost()
,
IlvManagerView.getDefaultXORColor()
protected boolean isEnoughDistance(IlvPoint p1, IlvPoint p2)
This method returns always true
, as this interactor
does not support links with multiple points.
IltMakePolyLinkInteractor
protected boolean numberOfPointsReached()
true
if the number of desired points is reached.
This method returns always false
, as this interactor
does not support links with multiple points.
IltMakePolyLinkInteractor
protected boolean endOnDoubleClick()
true
if the interactor will stop
requesting points when the user performs a double-click.
This method returns always false
as this interactor
does not support links with multiple points.
protected boolean accept(IltCompositeGraphic graphic)
graphic
- the graphic object to testprotected boolean acceptOrigin(IltCompositeGraphic node)
The default implementation calls accept
.
node
- the node to testprotected boolean acceptDestination(IltCompositeGraphic node)
The default implementation calls accept
. This
method also verifies if self-links can be created or not.
node
- the node to testprotected void drawGhost(Graphics g)
drawGhost
in class IlvManagerViewInteractor
g
- a graphics context in XOR modeIlvManagerViewInteractor.handleExpose(java.awt.Graphics)
,
IlvManagerViewInteractor.setXORGhost(boolean)
public void trigger(AWTEvent event, IltObject origin, IltObject destination, IltCompositeGrapher grapher)
This implementation creates an IltLink
with the
IltSONET.State.Active
state and adds it in the given
grapher.
As this method instantiates an IltObject, any subclass which overrides this method to instantiate its own IltObject should never call super.trigger.
event
- the event that launched the method.origin
- the start node of the linkdestination
- the end node of the linkgrapher
- the grapher in which the link should be displayedpublic void trigger(AWTEvent event, IltObject origin, IltObject destination, IltLinkPort originPort, IltLinkPort destinationPort, IltCompositeGrapher grapher)
This implementation creates an IltLink
with the
IltSONET.State.Active
state and adds it in the given
grapher.
As this method instantiates an IltObject, any subclass which overrides this method to instantiate its own IltObject should never call super.trigger.
event
- the event that launched the method.origin
- the start node of the linkdestination
- the end node of the linkoriginPort
- the IltLinkPort
to connect at, or null
destinationPort
- the IltLinkPort
to connect at, or null
grapher
- the grapher in which the link should be displayedprotected void react(MouseEvent event)
event
- Mouse eventprotected void processMouseEvent(MouseEvent event)
IlvManagerViewInteractor
MouseListener
registered with this interactor (if any).processMouseEvent
in class IlvManagerViewInteractor
event
- The event.IlvManagerViewInteractor.addMouseListener(java.awt.event.MouseListener)
protected void processMouseMotionEvent(MouseEvent event)
IlvManagerViewInteractor
MouseMotionListener
registered with this interactor (if any).processMouseMotionEvent
in class IlvManagerViewInteractor
event
- The event.IlvManagerViewInteractor.addMouseMotionListener(java.awt.event.MouseMotionListener)
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.