public class IlvMakeLinkInteractor extends IlvMakePolyPointsInteractor
IlvGrapher
with an
IlvLinkImage
.
This interactor must be attached to an IlvGrapher
.
You can change the type of link that is created by this interactor by
setting a link factory on the interactor.IlvLinkImage
,
IlvGrapher
,
Serialized FormConstructor and Description |
---|
IlvMakeLinkInteractor()
Creates and initializes the interactor.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
accept(IlvPoint p)
Checks whether a point may be added at this location.
|
protected boolean |
acceptDestination(IlvPoint p,
IlvGraphic toNode)
Tests if a node can be the destination of the link.
|
protected boolean |
acceptOrigin(IlvPoint p,
IlvGraphic fromNode)
Tests if a node can be the origin of the link.
|
protected void |
addPolyPoints(IlvGraphic obj)
Adds the new link inside the grapher.
|
protected void |
attach(IlvManagerView view)
Called when the interactor is attached to the manager view.
|
protected void |
doIt()
This method is called when all points are selected.
|
protected void |
drawGhost(Graphics g)
Draws the polyline ghost while the object is being created, and eventually
the ghost of the link connector.
|
protected boolean |
endOnDoubleClick()
Returns
false , since the selection is finished
when the destination of the link is selected. |
IlvGraphic |
getFrom()
Returns the origin node for the link, or
null
if it has not already been selected. |
IlvGrapher |
getGrapher()
Returns the grapher where the interactor is attached.
|
protected Class<?> |
getLinkClass()
Returns the class created by this interactor.
|
IlvLinkImageFactory |
getLinkFactory()
Returns the factory installed, if any.
|
IlvGraphic |
getTo()
Returns the destination node for the link, or
null
if it has not already been selected. |
protected void |
highlight(IlvGraphic obj)
Highlights a node when moving over it.
|
boolean |
isGridMode()
Returns
true if the interactor is
in the grid mode. |
boolean |
isOriented()
Returns
true if the created link will be oriented. |
boolean |
isSelectionMode()
Returns
true if the graphic object is
selected after creation, while the other objects are
deselected. |
boolean |
isSelfLinkAllowed()
Returns
true if the creation of self-links is allowed,
and returns false otherwise. |
protected IlvGraphic |
makePolyPoint(IlvPoint[] points)
Called to create the link instance.
|
protected boolean |
numberOfPointsReached()
Returns
true when the origin and destination of
the link are selected. |
protected void |
react(IlvPoint p)
Highlights or unhighlights the node
under the specified point.
|
protected void |
reInitialize()
Reinitializes the interactor.
|
void |
setLinkFactory(IlvLinkImageFactory factory)
Installs a factory for the creation of the link.
|
void |
setOriented(boolean oriented)
Specifies the creation of an oriented or
a non-oriented link.
|
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 |
setSelfLinkAllowed(boolean allow)
Enables or disables the creation of self-links.
|
protected void |
unHighlight(IlvGraphic obj)
Removes the highlight from a node when moving over another node.
|
allowsMultiplePoints, allowsMultiplePoints, count, detach, getBackground, getCursor, getForeground, getMinPointsDistance, getObjectFactory, getPoints, isAllowingMultiplePoints, isCreationInSubManagersAllowed, isGrapherMode, isOpaqueMode, isPermanent, isXORGhost, processMouseEvent, processMouseMotionEvent, setAllowingMultiplePoints, setBackground, setCreationInSubManagersAllowed, setCursor, setForeground, setGrapherMode, setGridMode, setMinPointsDistance, setObjectFactory, setOpaqueMode, setPermanent
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, disableEvents, drawGhost, enableEvents, ensureVisible, ensureVisible, getManager, getManagerView, getTransformer, handleExpose, processEvent, processFocusEvent, processKeyEvent, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, setXORGhost
public IlvMakeLinkInteractor()
Note that the method IlvMakePolyPointsInteractor.isAllowingMultiplePoints()
returns
false
by default, while it returns true
by
default in the superclass.
protected void attach(IlvManagerView view)
view
is
attached.attach
in class IlvMakePolyPointsInteractor
view
- The manager view.IlvMakePolyPointsInteractor.detach()
protected void reInitialize()
reInitialize
in class IlvMakePolyPointsInteractor
public final IlvGrapher getGrapher()
public boolean isOriented()
true
if the created link will be oriented.
An oriented link has an arrow drawn at the end.
The default value is false
.public final void setOriented(boolean oriented)
false
.public final void setLinkFactory(IlvLinkImageFactory factory)
createObject
method of the factory is called to create the object.getLinkFactory()
public final IlvLinkImageFactory getLinkFactory()
protected IlvGraphic makePolyPoint(IlvPoint[] points)
IlvLinkImage
is created. You can change the type of link that is created
by setting a link factory on the interactor.
The foreground and background colors are set on the object.makePolyPoint
in class IlvMakePolyPointsInteractor
points
- The selected points in the object's coordinate space.IlvLinkImage
(or a subclass), or null
if the factory
returns a null
object.setLinkFactory(ilog.views.interactor.IlvLinkImageFactory)
,
IlvMakePolyPointsInteractor.setBackground(java.awt.Color)
,
IlvMakePolyPointsInteractor.setForeground(java.awt.Color)
public final IlvGraphic getFrom()
null
if it has not already been selected.public final IlvGraphic getTo()
null
if it has not already been selected.protected Class<?> getLinkClass()
IlvLinkImageFactory.getLinkImageClass()
on the object factory if a factory is installed.
Otherwise, if no factory is installed, it returns the class
IlvLinkImage
which is the class of link created by the
interactor.protected void doIt()
makePolyPoint(ilog.views.IlvPoint[])
to create the object.
The method adds the created object to the manager using
the method addPolyPoints(ilog.views.IlvGraphic)
.
It calls makePolyPoint(ilog.views.IlvPoint[])
to create the object
and then addPolyPoints(ilog.views.IlvGraphic)
to add it into the manager.doIt
in class IlvMakePolyPointsInteractor
makePolyPoint(ilog.views.IlvPoint[])
,
addPolyPoints(ilog.views.IlvGraphic)
protected void react(IlvPoint p)
react
in class IlvMakePolyPointsInteractor
p
- The point in the coordinate space of the manager.protected void highlight(IlvGraphic obj)
IlvLinkConnector.getGhostBoundingBox(IlvTransformer)
) if any.
Otherwise, it uses the selection mechanism.
(IlvManager.setSelected(IlvGraphic, boolean, boolean)
), except
if the object is non-selectable
{IlvManager.isSelectable(IlvGraphic)
)).protected void unHighlight(IlvGraphic obj)
IlvLinkConnector.getGhostBoundingBox(IlvTransformer)
) if any.
Otherwise, it uses the selection mechanism
(IlvManager.setSelected(IlvGraphic, boolean, boolean)
), except
if the object is non-selectable
{IlvManager.isSelectable(IlvGraphic)
)).protected boolean numberOfPointsReached()
true
when the origin and destination of
the link are selected.numberOfPointsReached
in class IlvMakePolyPointsInteractor
IlvMakePolyPointsInteractor.isAllowingMultiplePoints()
protected boolean endOnDoubleClick()
false
, since the selection is finished
when the destination of the link is selected.endOnDoubleClick
in class IlvMakePolyPointsInteractor
IlvMakePolyPointsInteractor.isAllowingMultiplePoints()
protected boolean acceptOrigin(IlvPoint p, IlvGraphic fromNode)
If creation in submanagers is not allowed
(see IlvMakePolyPointsInteractor.isCreationInSubManagersAllowed()
) and the fromNode
is not in the topmost grapher, the method returns false
.
p
- The clicked point, in manager 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 IlvMakePolyPointsInteractor.isCreationInSubManagersAllowed()
) and the toNode
is not in the topmost grapher, the method returns false
.
If self-links are not allowed (that is, the method
isSelfLinkAllowed()
returns false
)
and the toNode
is the same as the origin node
(see getFrom()
), the method returns false
.
If there is no common grapher of the origin and destination nodes,
that is if the method IlvGrapher.getLowestCommonGrapher(ilog.views.IlvGraphic, ilog.views.IlvGraphic)
returns
null
, the method returns false
.
Otherwise, before returning true
, if an
IlvLinkConnector
is attached to the toNode
, the method
moves the point p
to the closest connection point
(see IlvLinkConnector.getClosestConnectionPoint(ilog.views.IlvPoint, java.lang.Object, java.lang.Object, java.lang.Object, boolean, ilog.views.IlvTransformer)
).
p
- The clicked point, in manager coordinates.toNode
- The destination node to test.isSelfLinkAllowed()
,
getFrom()
protected boolean accept(IlvPoint p)
accept
in class IlvMakePolyPointsInteractor
p
- The point, in manager coordinates.acceptOrigin(ilog.views.IlvPoint, ilog.views.IlvGraphic)
,
acceptDestination(ilog.views.IlvPoint, ilog.views.IlvGraphic)
public final void setSelfLinkAllowed(boolean allow)
true
.isSelfLinkAllowed()
,
acceptDestination(ilog.views.IlvPoint, ilog.views.IlvGraphic)
public final boolean isSelfLinkAllowed()
true
if the creation of self-links is allowed,
and returns false
otherwise.setSelfLinkAllowed(boolean)
,
acceptDestination(ilog.views.IlvPoint, ilog.views.IlvGraphic)
protected void addPolyPoints(IlvGraphic obj)
If the method isSelectionMode()
returns
true
and the link is selectable
(IlvManager.isSelectable(IlvGraphic)
), the created link is selected
(see IlvManager.setSelected(IlvGraphic, boolean, boolean)
)
and all the other objects are deselected
(see IlvManager.deSelectAll(boolean, boolean)
).
addPolyPoints
in class IlvMakePolyPointsInteractor
obj
- The polypoint object.IlvMakePolyPointsInteractor.setGrapherMode(boolean)
public void setSelectionMode(boolean select)
The default value is true
.
setSelectionMode
in class IlvMakePolyPointsInteractor
addPolyPoints(ilog.views.IlvGraphic)
public boolean isSelectionMode()
true
if the graphic object is
selected after creation, while the other objects are
deselected. Returns false
otherwise.
Objects that are not selectable
(see IlvManager.isSelectable(IlvGraphic)
are
not selected.
isSelectionMode
in class IlvMakePolyPointsInteractor
addPolyPoints(ilog.views.IlvGraphic)
public boolean isGridMode()
true
if the interactor is
in the grid mode.
It overrides the superclass method to avoid grid mode
for the origin and destination point.isGridMode
in class IlvMakePolyPointsInteractor
IlvGrid
protected void drawGhost(Graphics g)
drawGhost
in class IlvMakePolyPointsInteractor
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()
.IlvMakePolyPointsInteractor.setOpaqueMode(boolean)
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.