ilog.views.interactor
Class IlvMakeLinkInteractor

java.lang.Object
  extended by ilog.views.IlvManagerViewInteractor
      extended by ilog.views.interactor.IlvMakePolyPointsInteractor
          extended by ilog.views.interactor.IlvMakeLinkInteractor
All Implemented Interfaces:
IlvPermanentInteractorInterface, Serializable
Direct Known Subclasses:
IlvMakeDoubleLinkImageInteractor, IlvMakeEnhancedPolyLinkInteractor, IlvMakeOneLinkImageInteractor, IlvMakePolyLinkInteractor

public class IlvMakeLinkInteractor
extends IlvMakePolyPointsInteractor

An interactor to link two nodes of an 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.

See Also:
IlvLinkImage, IlvGrapher, Serialized Form

Constructor Summary
IlvMakeLinkInteractor()
          Creates and initializes the interactor.
 
Method Summary
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)
          Unhighlights a node when moving over another node.
 
Methods inherited from class ilog.views.interactor.IlvMakePolyPointsInteractor
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
 
Methods inherited from class ilog.views.IlvManagerViewInteractor
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, disableEvents, drawGhost, enableEvents, ensureVisible, ensureVisible, getManager, getManagerView, getTransformer, handleExpose, processEvent, processFocusEvent, processKeyEvent, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, setXORGhost
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvMakeLinkInteractor

public IlvMakeLinkInteractor()
Creates and initializes the interactor.

Note that the method IlvMakePolyPointsInteractor.isAllowingMultiplePoints() returns false by default, while it returns true by default in the superclass.

Method Detail

attach

protected void attach(IlvManagerView view)
Called when the interactor is attached to the manager view. The method of the superclass is overridden in order to deselect all the objects contained in the manager to which the view view is attached.

Overrides:
attach in class IlvMakePolyPointsInteractor
Parameters:
view - The manager view.
See Also:
IlvMakePolyPointsInteractor.detach()

reInitialize

protected void reInitialize()
Reinitializes the interactor.

Overrides:
reInitialize in class IlvMakePolyPointsInteractor

getGrapher

public final IlvGrapher getGrapher()
Returns the grapher where the interactor is attached.


isOriented

public boolean isOriented()
Returns true if the created link will be oriented. An oriented link has an arrow drawn at the end. The default value is false.


setOriented

public final void setOriented(boolean oriented)
Specifies the creation of an oriented or a non-oriented link. The default value is false.


setLinkFactory

public final void setLinkFactory(IlvLinkImageFactory factory)
Installs a factory for the creation of the link. If a factory is installed, then the createObject method of the factory is called to create the object.

See Also:
getLinkFactory()

getLinkFactory

public final IlvLinkImageFactory getLinkFactory()
Returns the factory installed, if any.

See Also:
setLinkFactory(ilog.views.interactor.IlvLinkImageFactory)

makePolyPoint

protected IlvGraphic makePolyPoint(IlvPoint[] points)
Called to create the link instance. The default implementation uses the link factory to create the link. If no factory is installed, then an 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.

Overrides:
makePolyPoint in class IlvMakePolyPointsInteractor
Parameters:
points - The selected points in the object's coordinate space.
Returns:
The created link object, of type IlvLinkImage (or a subclass), or null if the factory returns a null object.
See Also:
setLinkFactory(ilog.views.interactor.IlvLinkImageFactory), IlvMakePolyPointsInteractor.setBackground(java.awt.Color), IlvMakePolyPointsInteractor.setForeground(java.awt.Color)

getFrom

public final IlvGraphic getFrom()
Returns the origin node for the link, or null if it has not already been selected.


getTo

public final IlvGraphic getTo()
Returns the destination node for the link, or null if it has not already been selected.


getLinkClass

protected Class getLinkClass()
Returns the class created by this interactor. The default implementation returns the result of the call of 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.

See Also:
setLinkFactory(ilog.views.interactor.IlvLinkImageFactory), makePolyPoint(ilog.views.IlvPoint[])

doIt

protected void doIt()
This method is called when all points are selected. It calls 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.

Overrides:
doIt in class IlvMakePolyPointsInteractor
See Also:
makePolyPoint(ilog.views.IlvPoint[]), addPolyPoints(ilog.views.IlvGraphic)

react

protected void react(IlvPoint p)
Highlights or unhighlights the node under the specified point.

Overrides:
react in class IlvMakePolyPointsInteractor
Parameters:
p - The point in the coordinate space of the manager.

highlight

protected void highlight(IlvGraphic obj)
Highlights a node when moving over it. The default implementation draws the ghost of the link connector (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))).


unHighlight

protected void unHighlight(IlvGraphic obj)
Unhighlights a node when moving over another node. The default implementation erases the ghost of the link connector (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))).


numberOfPointsReached

protected boolean numberOfPointsReached()
Returns true when the origin and destination of the link are selected.

Overrides:
numberOfPointsReached in class IlvMakePolyPointsInteractor
See Also:
IlvMakePolyPointsInteractor.isAllowingMultiplePoints()

endOnDoubleClick

protected boolean endOnDoubleClick()
Returns false, since the selection is finished when the destination of the link is selected.

Overrides:
endOnDoubleClick in class IlvMakePolyPointsInteractor
See Also:
IlvMakePolyPointsInteractor.isAllowingMultiplePoints()

acceptOrigin

protected boolean acceptOrigin(IlvPoint p,
                               IlvGraphic fromNode)
Tests if a node can be the origin of the link.

If creation in submanagers is not allowed (see IlvMakePolyPointsInteractor.isCreationInSubManagersAllowed()) and the fromNode is not in the topmost grapher, the method returns false.

Parameters:
p - The clicked point, in manager coordinates.
fromNode - The origin node to test.
See Also:
acceptDestination(ilog.views.IlvPoint, ilog.views.IlvGraphic)

acceptDestination

protected boolean acceptDestination(IlvPoint p,
                                    IlvGraphic toNode)
Tests if a node can be the destination of the link.

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)).

Parameters:
p - The clicked point, in manager coordinates.
toNode - The destination node to test.
See Also:
isSelfLinkAllowed(), getFrom()

accept

protected boolean accept(IlvPoint p)
Checks whether a point may be added at this location.

Overrides:
accept in class IlvMakePolyPointsInteractor
Parameters:
p - The point, in manager coordinates.
See Also:
acceptOrigin(ilog.views.IlvPoint, ilog.views.IlvGraphic), acceptDestination(ilog.views.IlvPoint, ilog.views.IlvGraphic)

setSelfLinkAllowed

public final void setSelfLinkAllowed(boolean allow)
Enables or disables the creation of self-links. A self-link is a link with the same origin and destination node. The default value is true.

Since:
JViews 3.5
See Also:
isSelfLinkAllowed(), acceptDestination(ilog.views.IlvPoint, ilog.views.IlvGraphic)

isSelfLinkAllowed

public final boolean isSelfLinkAllowed()
Returns true if the creation of self-links is allowed, and returns false otherwise.

Since:
JViews 3.5
See Also:
setSelfLinkAllowed(boolean), acceptDestination(ilog.views.IlvPoint, ilog.views.IlvGraphic)

addPolyPoints

protected void addPolyPoints(IlvGraphic obj)
Adds the new link inside the grapher.

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)).

Overrides:
addPolyPoints in class IlvMakePolyPointsInteractor
Parameters:
obj - The polypoint object.
See Also:
IlvMakePolyPointsInteractor.setGrapherMode(boolean)

setSelectionMode

public 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.

The default value is true.

Overrides:
setSelectionMode in class IlvMakePolyPointsInteractor
Since:
JViews 7.5
See Also:
addPolyPoints(ilog.views.IlvGraphic)

isSelectionMode

public boolean isSelectionMode()
Returns 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.

Overrides:
isSelectionMode in class IlvMakePolyPointsInteractor
Since:
JViews 7.5
See Also:
addPolyPoints(ilog.views.IlvGraphic)

isGridMode

public boolean isGridMode()
Returns true if the interactor is in the grid mode. It overrides the superclass method to avoid grid mode for the origin and destination point.

Overrides:
isGridMode in class IlvMakePolyPointsInteractor
See Also:
IlvGrid

drawGhost

protected void drawGhost(Graphics g)
Draws the polyline ghost while the object is being created, and eventually the ghost of the link connector.

Overrides:
drawGhost in class IlvMakePolyPointsInteractor
Parameters:
g - The graphics.
See Also:
IlvMakePolyPointsInteractor.setOpaqueMode(boolean)


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.