ilog.views.interactor
Class IlvMakePolyPointsInteractor

java.lang.Object
  extended by ilog.views.IlvManagerViewInteractor
      extended by ilog.views.interactor.IlvMakePolyPointsInteractor
All Implemented Interfaces:
IlvPermanentInteractorInterface, Serializable
Direct Known Subclasses:
IlvMakeLineInteractor, IlvMakeLinkInteractor, IlvMakePolygonInteractor, IlvMakePolylineInteractor, IlvMakeSplineInteractor

public class IlvMakePolyPointsInteractor
extends IlvManagerViewInteractor
implements IlvPermanentInteractorInterface

An Interactor that enables you to create a graphic object defined with several points. This interactor allows several points to be selected and then creates a graphic object. To create the graphic object, the method makePolyPoint(ilog.views.IlvPoint[]) is called. This method will create an IlvPolyline. You can customize the class by setting a factory to create your own type of graphic object (note that the object must implement the interface IlvPolyPointsInterface).

See Also:
Serialized Form

Constructor Summary
IlvMakePolyPointsInteractor()
          Creates and initializes the interactor.
 
Method Summary
protected  boolean accept(IlvPoint p)
          Checks whether a point may be added at this location.
protected  void addPolyPoints(IlvGraphic obj)
          Adds the object to the manager.
 boolean allowsMultiplePoints()
          Deprecated. Use isAllowingMultiplePoints.
 void allowsMultiplePoints(boolean allow)
          Deprecated. Use setAllowingMultiplePoints.
protected  void attach(IlvManagerView v)
          This method is called when the interactor is attached to the manager view.
 int count()
          Returns the number of points actually created.
protected  void detach()
          This method is called when the interactor is detached from the view.
protected  void doIt()
          Called when all points are selected.
protected  void drawGhost(Graphics g)
          Draws a polyline as the points are being selected.
protected  boolean endOnDoubleClick()
          Returns true if the interactor will stop requesting points when the user performs a double-click.
 Color getBackground()
          Returns the background color that is used when creating the polypoint.
 Cursor getCursor()
          Returns the cursor used for editing.
 Color getForeground()
          Returns the foreground color used when creating the polypoint.
 float getMinPointsDistance()
          Returns the minimum distance between two created points.
 IlvPolyPointsObjectFactory getObjectFactory()
          Returns the factory installed, if any.
protected  IlvPoint[] getPoints(boolean transformed)
          Returns an array of the points that have already been created.
 boolean isAllowingMultiplePoints()
          Returns true if the interactor allows more than two points to be entered.
 boolean isCreationInSubManagersAllowed()
          Returns true if the creation of objects in submanagers is allowed, and false otherwise.
 boolean isGrapherMode()
          Returns true if the interactor is in grapher mode.
 boolean isGridMode()
          Returns true if the interactor snaps the points to the grid of the view; false otherwise.
 boolean isOpaqueMode()
          Returns an indication of whether the interactor is in Opaque mode or not.
 boolean isPermanent()
          Returns false if the interactor will be removed from the view once the object is created.
 boolean isSelectionMode()
          Returns true if the graphic object is selected after creation, while the other objects are deselected.
 boolean isXORGhost()
          Returns the ghost drawing mode.
protected  IlvGraphic makePolyPoint(IlvPoint[] points)
          Called to create the polypoint object.
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 motion events.
protected  void react(IlvPoint p)
          Allows you to implement an interaction when the user moves the mouse to add a point to the polypoint.
protected  void reInitialize()
          Reinitializes the interactor.
 void setAllowingMultiplePoints(boolean allow)
          Changes the number of points the user can select with the interactor.
 void setBackground(Color color)
          Changes the background color that is used when creating the polypoint.
 void setCreationInSubManagersAllowed(boolean set)
          Allows objects to be created in submanagers (see IlvManager.getManagers()).
 void setCursor(Cursor cursor)
          Changes the cursor used for editing.
 void setForeground(Color color)
          Changes the foreground color that is used when creating the polypoint.
 void setGrapherMode(boolean value)
          Sets the grapher mode value.
 void setGridMode(boolean value)
          Changes the way the interactor works with the grid.
 void setMinPointsDistance(float minDist)
          Sets the minimum distance between two consecutive points.
 void setObjectFactory(IlvPolyPointsObjectFactory factory)
          Installs a factory for the creation of the graphic object.
 void setOpaqueMode(boolean set)
          Sets the interactor in Opaque mode.
 void setPermanent(boolean permanent)
          Specifies if the interactor will be removed from the view once the object is created.
 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.
 
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

IlvMakePolyPointsInteractor

public IlvMakePolyPointsInteractor()
Creates and initializes the interactor.

Method Detail

isGridMode

public boolean isGridMode()
Returns true if the interactor snaps the points to the grid of the view; false otherwise. The default value is true.

See Also:
IlvGrid

setGridMode

public final void setGridMode(boolean value)
Changes the way the interactor works with the grid.

Parameters:
value - Must be set to false if you do not want the interactor to snap the points to the grid of the view; true otherwise. The default value is true.
See Also:
IlvGrid

isPermanent

public final boolean isPermanent()
Returns false if the interactor will be removed from the view once the object is created. The default value is false.

Specified by:
isPermanent in interface IlvPermanentInteractorInterface

setPermanent

public final void setPermanent(boolean permanent)
Specifies if the interactor will be removed from the view once the object is created. The default value is false.

Specified by:
setPermanent in interface IlvPermanentInteractorInterface
Parameters:
permanent - the new mode.

setMinPointsDistance

public final void setMinPointsDistance(float minDist)
Sets the minimum distance between two consecutive points. The interactor ensures that the distance between any two consecutive points of the created polypoint is larger than or equal to this value. The value of the parameter is in manager view (screen) coordinates. This parameter does not apply to the distance between the first and the last point.

The default value is 5.

Since:
JViews 5.0
See Also:
getMinPointsDistance()

getMinPointsDistance

public final float getMinPointsDistance()
Returns the minimum distance between two created points.

The default value is 5.

Since:
JViews 5.0
See Also:
setMinPointsDistance(float)

attach

protected void attach(IlvManagerView v)
This method is called when the interactor is attached to the manager view.

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

detach

protected void detach()
This method is called when the interactor is detached from the view.

Overrides:
detach in class IlvManagerViewInteractor
See Also:
IlvManagerViewInteractor.attach(ilog.views.IlvManagerView)

reInitialize

protected void reInitialize()
Reinitializes the interactor. You do not have to use this method.


getCursor

public Cursor getCursor()
Returns the cursor used for editing.


setCursor

public void setCursor(Cursor cursor)
Changes the cursor used for editing.


allowsMultiplePoints

public boolean allowsMultiplePoints()
Deprecated. Use isAllowingMultiplePoints.

Returns true if the interactor allows more than two points to be entered. The default implementation returns true.


isAllowingMultiplePoints

public boolean isAllowingMultiplePoints()
Returns true if the interactor allows more than two points to be entered. The default value is true.

See Also:
setAllowingMultiplePoints(boolean)

allowsMultiplePoints

public void allowsMultiplePoints(boolean allow)
Deprecated. Use setAllowingMultiplePoints.

Changes the number of points the user can select with the interactor.

Parameters:
allow - If true then the interactor allows selecting several points; otherwise only two points are allowed.

setAllowingMultiplePoints

public void setAllowingMultiplePoints(boolean allow)
Changes the number of points the user can select with the interactor.

Parameters:
allow - If true then the interactor allows selecting several points; otherwise only two points are allowed.
See Also:
isAllowingMultiplePoints()

count

public final int count()
Returns the number of points actually created.


getPoints

protected IlvPoint[] getPoints(boolean transformed)
Returns an array of the points that have already been created. It returns null if no points have been created.

Parameters:
transformed - If true the points are transformed by the current transformer of the manager view.

numberOfPointsReached

protected boolean numberOfPointsReached()
Returns true if the number of desired points is reached. This method returns true if the interactor allows only two points to be selected (see the isAllowingMultiplePoints member function) and two points have been selected.

See Also:
isAllowingMultiplePoints()

endOnDoubleClick

protected boolean endOnDoubleClick()
Returns true if the interactor will stop requesting points when the user performs a double-click. The default implementation returns true when the interactor allows more than two points to be entered; otherwise it returns false.

See Also:
isAllowingMultiplePoints()

accept

protected boolean accept(IlvPoint p)
Checks whether a point may be added at this location. The current implementation returns true.

Parameters:
p - The point, in manager coordinates.

react

protected void react(IlvPoint p)
Allows you to implement an interaction when the user moves the mouse to add a point to the polypoint. The point is given in the object's coordinate system. The default implementation does nothing.


processMouseEvent

protected void processMouseEvent(MouseEvent event)
Processes the mouse events.

Overrides:
processMouseEvent in class IlvManagerViewInteractor
Parameters:
event - The event.
See Also:
IlvManagerViewInteractor.addMouseListener(java.awt.event.MouseListener)

processMouseMotionEvent

protected void processMouseMotionEvent(MouseEvent event)
Processes the mouse motion events.

Overrides:
processMouseMotionEvent in class IlvManagerViewInteractor
Parameters:
event - The event.
See Also:
IlvManagerViewInteractor.addMouseMotionListener(java.awt.event.MouseMotionListener)

getForeground

public Color getForeground()
Returns the foreground color used when creating the polypoint.


setForeground

public void setForeground(Color color)
Changes the foreground color that is used when creating the polypoint.


getBackground

public Color getBackground()
Returns the background color that is used when creating the polypoint.


setBackground

public void setBackground(Color color)
Changes the background color that is used when creating the polypoint.


setOpaqueMode

public void setOpaqueMode(boolean set)
Sets the interactor in Opaque mode. The interactor has two modes: the Opaque mode and the Ghost mode. In Opaque mode, the polypoints object that the user creates is drawn for each drag event. In Ghost mode, the object is drawn only when the user releases the mouse button.

The default mode is the Ghost mode.

Note that if you change the mode during the interaction, the interaction is stopped by a call to the method reInitialize(). You should set the Opaquemode before the interactor is activated.

Since:
JViews 5.0
See Also:
isOpaqueMode(), IlvManagerViewInteractor.setXORGhost(boolean)

isOpaqueMode

public boolean isOpaqueMode()
Returns an indication of whether the interactor is in Opaque mode or not.

Since:
JViews 5.0
See Also:
setOpaqueMode(boolean), IlvManagerViewInteractor.setXORGhost(boolean)

isXORGhost

public boolean isXORGhost()
Returns the ghost drawing mode. It overrides the method of the superclass to force the Paint mode (not XOR mode) when the method isOpaqueMode() returns true.

Overrides:
isXORGhost in class IlvManagerViewInteractor
Returns:
true if the drawing needs to be performed in XOR mode, false otherwise.
Since:
JViews 5.0
See Also:
IlvManagerViewInteractor.setXORGhost(boolean), IlvManagerViewInteractor.handleExpose(java.awt.Graphics), IlvManagerViewInteractor.drawGhost(java.awt.Graphics)

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.

Since:
JViews 5.0
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.

Since:
JViews 5.0
See Also:
addPolyPoints(ilog.views.IlvGraphic)

setObjectFactory

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

See Also:
getObjectFactory()

getObjectFactory

public final IlvPolyPointsObjectFactory getObjectFactory()
Returns the factory installed, if any.

See Also:
setObjectFactory(ilog.views.interactor.IlvPolyPointsObjectFactory)

makePolyPoint

protected IlvGraphic makePolyPoint(IlvPoint[] points)
Called to create the polypoint object. The default implementation uses the factory object to create the graphic object. If no factory is installed, then an IlvPolyline object is created. The foreground and background colors are set on the object.

Parameters:
points - The selected points in the object's coordinate space.
See Also:
setObjectFactory(ilog.views.interactor.IlvPolyPointsObjectFactory), setBackground(java.awt.Color), setForeground(java.awt.Color)

doIt

protected void doIt()
Called when all points are selected. In opaque mode, it calls makePolyPoint(ilog.views.IlvPoint[]) to create the object. In ghost mode, it uses the object that has already been created. The method adds the created object to the manager using the method addPolyPoints(ilog.views.IlvGraphic).

See Also:
setOpaqueMode(boolean), makePolyPoint(ilog.views.IlvPoint[]), addPolyPoints(ilog.views.IlvGraphic)

drawGhost

protected void drawGhost(Graphics g)
Draws a polyline as the points are being selected. In opaque mode, it draws the created object. In ghost mode, it draws a polyline passing through the selected points.

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

setCreationInSubManagersAllowed

public void setCreationInSubManagersAllowed(boolean set)
Allows objects to be created in submanagers (see IlvManager.getManagers()). If creation in submanagers is not allowed, the object is always created in the IlvManager displayed by the IlvManagerView to which this interactor is attached.

The default value is true

Since:
JViews 5.0

isCreationInSubManagersAllowed

public boolean isCreationInSubManagersAllowed()
Returns true if the creation of objects in submanagers is allowed, and false otherwise.

Since:
JViews 5.0

addPolyPoints

protected void addPolyPoints(IlvGraphic obj)
Adds the object to the manager. This method is called by the interactor to add the newly created object in the manager. It calls addObject on the manager in default mode. The method calls addNode on the grapher in grapher mode if the interactor is attached to a grapher view.

If the method isSelectionMode() returns true and the created object is selectable (IlvManager.isSelectable(IlvGraphic)), the created object is selected (see IlvManager.setSelected(IlvGraphic, boolean, boolean)) and all the other objects are deselected (see IlvManager.deSelectAll(boolean, boolean)).

Parameters:
obj - The polypoint object.
See Also:
setGrapherMode(boolean)

isGrapherMode

public boolean isGrapherMode()
Returns true if the interactor is in grapher mode. The default is false.

See Also:
setGrapherMode(boolean)

setGrapherMode

public void setGrapherMode(boolean value)
Sets the grapher mode value. If true, created objects will be added to the grapher of the attached view with IlvGrapher.addNode(ilog.views.IlvGraphic, boolean) method. If false, they will be added with IlvManager.addObject(ilog.views.IlvGraphic, int, boolean).

Parameters:
value - The value to be set.
See Also:
isGrapherMode()


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