ilog.views
Class IlvPolyPointsEdition

java.lang.Object
  extended by ilog.views.IlvObjectInteractor
      extended by ilog.views.IlvPolyPointsEdition
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
IlvLinkImageEditInteractor, IlvMapPolyPointEdition, IlvSplineEdition

public class IlvPolyPointsEdition
extends IlvObjectInteractor

IlvPolyPointsEdition is an object interactor used to edit graphic objects that implement the interface IlvPolyPointsInterface, such as IlvPolyPoints, IlvPolyline, and so forth.

This interactor lets you move the points of the polypoints. You can also add or remove a point. By default, Ctrl+Click on a point removes the point. Ctrl+Click on the object will add a point. The modifier can be changed using setAddRemovePointModifier(int).

See Also:
Serialized Form

Constructor Summary
IlvPolyPointsEdition()
          Creates and initializes the interactor.
 
Method Summary
 boolean allowPointAddition()
          Returns true if the interactor lets the user add points.
 void allowPointAddition(boolean v)
          Allows or prohibits point insertion.
 boolean allowPointRemoval()
          Returns true if the interactor lets the user remove points.
 void allowPointRemoval(boolean v)
          Allows or prohibits point removal.
protected  boolean allowsPointInsertion(IlvPolyPointsInterface obj)
          Returns whether it is allowed to insert a point into the input object.
protected  boolean allowsPointMove(IlvPolyPointsInterface obj, int index)
          Returns whether it is allowed to move the point of the input object.
protected  boolean allowsPointRemoval(IlvPolyPointsInterface obj)
          Returns whether it is allowed to remove a point into the input object.
protected  void drawGhost(IlvPolyPointsSelection obj, Graphics g, IlvObjectInteractorContext context)
          Draws a polyline when a point of the polypoint is moved.
protected  void drawGhost(IlvPolyPointsSelection obj, IlvObjectInteractorContext context)
          Deprecated. Beginning with ILOG JViews 5.0, use the method drawGhost(IlvPolyPointsSelection, Graphics, IlvObjectInteractorContext) instead.
static int getAddRemovePointModifier()
          Returns the modifier for the addition or removal of points.
static int getAddRemovePointModifierEx()
          Returns the extended modifier for the addition or removal of points.
 Cursor getCursor()
          Returns the cursor used for editing.
 int getIndex()
          Returns the index of the currently edited point, or -1 if none.
protected  boolean handleButtonDown(IlvPolyPointsSelection sel, MouseEvent event, IlvObjectInteractorContext context)
          Handles MOUSE_PRESSED events.
protected  boolean handleButtonDragged(IlvPolyPointsSelection obj, MouseEvent event, IlvObjectInteractorContext context)
          Handles MOUSE_DRAGGED events.
protected  boolean handleButtonUp(IlvPolyPointsSelection obj, MouseEvent event, IlvObjectInteractorContext context)
          Handles MOUSE_RELEASED events.
 void handleExpose(IlvGraphic obj, Graphics g, IlvObjectInteractorContext context)
          Called when the view that draws the polypoints object is drawn.
protected  boolean handleMouseMoved(IlvPolyPointsSelection obj, MouseEvent event, IlvObjectInteractorContext context)
          Handles MOUSE_MOVED events.
protected  void insertPoint(IlvPolyPointsInterface obj, IlvPoint p, IlvObjectInteractorContext context)
          Called when a point is inserted.
protected  boolean isAddRemovePointModifierDown(InputEvent event)
          Tests if the mouse event modifier for the addition or removal of points is currently down.
 boolean isOpaqueMode()
          Returns whether the interactor is in Opaque mode or not.
protected  void movePoint(IlvPolyPointsInterface obj, IlvObjectInteractorContext context, IlvPoint p)
          Called when a point is moved.
 void onEnter(IlvGraphic sel, IlvObjectInteractorContext context)
          Called when the selection is entered.
 void onExit(IlvGraphic sel, IlvObjectInteractorContext context)
          Called when the selection is exited.
 boolean processEvent(IlvGraphic obj, AWTEvent event, IlvObjectInteractorContext context)
          Processes the events.
protected  void removePoint(IlvPolyPointsInterface obj, IlvObjectInteractorContext context)
          Called when a point is removed.
static void setAddRemovePointModifier(int modifier)
          Sets the modifier for the addition and removal of points.
 void setCursor(Cursor cursor)
          Changes the cursor used for editing.
 void setOpaqueMode(boolean set)
          Sets the interactor to Opaque mode.
 
Methods inherited from class ilog.views.IlvObjectInteractor
Get, Put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvPolyPointsEdition

public IlvPolyPointsEdition()
Creates and initializes the interactor.

Method Detail

getIndex

public int getIndex()
Returns the index of the currently edited point, or -1 if none. It is used in movePoint and removePoint to indicate which point is modified.


getCursor

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


setCursor

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


allowPointAddition

public final boolean allowPointAddition()
Returns true if the interactor lets the user add points.


allowPointAddition

public final void allowPointAddition(boolean v)
Allows or prohibits point insertion.


allowPointRemoval

public final boolean allowPointRemoval()
Returns true if the interactor lets the user remove points.


allowPointRemoval

public final void allowPointRemoval(boolean v)
Allows or prohibits point removal.


setOpaqueMode

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

The default mode is the Ghost mode.

Since:
JViews 5.0
See Also:
isOpaqueMode(), IlvSelectInteractor.setOpaquePolyPointsEdition(boolean)

isOpaqueMode

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

Since:
JViews 5.0
See Also:
setOpaqueMode(boolean), IlvSelectInteractor.setOpaquePolyPointsEdition(boolean)

handleButtonDown

protected boolean handleButtonDown(IlvPolyPointsSelection sel,
                                   MouseEvent event,
                                   IlvObjectInteractorContext context)
Handles MOUSE_PRESSED events.

Returns:
true if the event has been processed, false otherwise.

handleButtonDragged

protected boolean handleButtonDragged(IlvPolyPointsSelection obj,
                                      MouseEvent event,
                                      IlvObjectInteractorContext context)
Handles MOUSE_DRAGGED events.

Returns:
true if the event has been processed, false otherwise.

allowsPointMove

protected boolean allowsPointMove(IlvPolyPointsInterface obj,
                                  int index)
Returns whether it is allowed to move the point of the input object. The default implementation calls IlvPolyPointsInterface.allowsPointMove(int).

Parameters:
obj - The object to modify.
index - The index of the point of the input object.
Since:
JViews 8.1

allowsPointInsertion

protected boolean allowsPointInsertion(IlvPolyPointsInterface obj)
Returns whether it is allowed to insert a point into the input object. The default implementation calls IlvPolyPointsInterface.allowsPointInsertion().

Parameters:
obj - The object to modify.
Since:
JViews 8.1

allowsPointRemoval

protected boolean allowsPointRemoval(IlvPolyPointsInterface obj)
Returns whether it is allowed to remove a point into the input object. The default implementation calls IlvPolyPointsInterface.allowsPointRemoval().

Parameters:
obj - The object to modify.
Since:
JViews 8.1

removePoint

protected void removePoint(IlvPolyPointsInterface obj,
                           IlvObjectInteractorContext context)
Called when a point is removed. You can get the index of the point using getIndex.

Parameters:
obj - The object to modify.
context - The interactor context.

insertPoint

protected void insertPoint(IlvPolyPointsInterface obj,
                           IlvPoint p,
                           IlvObjectInteractorContext context)
Called when a point is inserted.

Parameters:
obj - The object to modify.
p - The position of the point in untransformed IlvManager coordinates.
context - The interactor context.

setAddRemovePointModifier

public static void setAddRemovePointModifier(int modifier)
Sets the modifier for the addition and removal of points. This is used by the interactor to determine if a mouse pressed over a point must delete it, and a mouse pressed over an area with no point must add a point. The default modifier is InputEvent.CTRL_MASK. This method can be used to set normal modifiers and extended modifiers (see java.awt.event.InputEvent.getModifiersEx() since JDK 1.4).

Note: In the mask, InputEvent.ALT_DOWN_MASK should be used instead of InputEvent.ALT_MASK, and InputEvent.META_DOWN_MASK should be used instead of InputEvent.META_MASK, because the values of ALT_MASK/BUTTON2_MASK and META_MASK/BUTTON3_MASK overlap.

Since JViews 8.1, the modifier bitmask is checked exactly. Before JViews 8.1, specifying for instance CTRL became active when pressed alone or in combination with any other modifier key. Since JViews 8.1, it becomes active only when pressed alone. This allows for a greater range of modifier combinations to be used at the same time for different purposes.

Since:
JViews 8.1
See Also:
getAddRemovePointModifier(), getAddRemovePointModifierEx(), isAddRemovePointModifierDown(java.awt.event.InputEvent)

getAddRemovePointModifier

public static int getAddRemovePointModifier()
Returns the modifier for the addition or removal of points. The default modifier is InputEvent.CTRL_MASK.

Since:
JViews 8.1
See Also:
setAddRemovePointModifier(int), isAddRemovePointModifierDown(java.awt.event.InputEvent)

getAddRemovePointModifierEx

public static int getAddRemovePointModifierEx()
Returns the extended modifier for the addition or removal of points. The default modifier is InputEvent.CTRL_DOWN_MASK. See java.awt.event.InputEvent.getModifiersEx() since JDK 1.4 for information about extended modifiers. This mask is computed from setAddRemovePointModifier(int).

Since:
JViews 8.1
See Also:
setAddRemovePointModifier(int), isAddRemovePointModifierDown(java.awt.event.InputEvent)

isAddRemovePointModifierDown

protected boolean isAddRemovePointModifierDown(InputEvent event)
Tests if the mouse event modifier for the addition or removal of points is currently down. The method compares the current modifiers of the event with the modifier returned by the method getAddRemovePointModifierEx(). This is used by the interactor to determine if a mouse pressed corresponds to the addition or removal of a point. The default modifier is InputEvent.CTRL_DOWN_MASK.

Since:
JViews 8.1
See Also:
setAddRemovePointModifier(int)

movePoint

protected void movePoint(IlvPolyPointsInterface obj,
                         IlvObjectInteractorContext context,
                         IlvPoint p)
Called when a point is moved. You can obtain the index of the removed point using getIndex.

Parameters:
obj - The object to modify.
context - The interactor context.
p - The new position of the point in untransformed IlvManager coordinates.

handleButtonUp

protected boolean handleButtonUp(IlvPolyPointsSelection obj,
                                 MouseEvent event,
                                 IlvObjectInteractorContext context)
Handles MOUSE_RELEASED events. Moves the selected point of the polypoint by calling movePoint.

Returns:
true if the event has been processed, false otherwise.
See Also:
movePoint(ilog.views.IlvPolyPointsInterface, ilog.views.IlvObjectInteractorContext, ilog.views.IlvPoint)

handleMouseMoved

protected boolean handleMouseMoved(IlvPolyPointsSelection obj,
                                   MouseEvent event,
                                   IlvObjectInteractorContext context)
Handles MOUSE_MOVED events.

Returns:
true if the event has been processed, false otherwise.
Since:
JViews 8.0

processEvent

public boolean processEvent(IlvGraphic obj,
                            AWTEvent event,
                            IlvObjectInteractorContext context)
Processes the events. The events are dispatched to the following methods depending on the type of the event: handleButtonDown for a MOUSE_PRESSED event, handleButtonUp for a MOUSE_RELEASED event, or handleButtonDragged for a MOUSE_DRAGGED event.

Specified by:
processEvent in class IlvObjectInteractor
Parameters:
obj - The graphic object.
event - The event to process.
context - The context in which the event occurred.
Returns:
true if the event was handled by this processEvent invocation, false otherwise.
See Also:
handleButtonDown(ilog.views.IlvPolyPointsSelection, java.awt.event.MouseEvent, ilog.views.IlvObjectInteractorContext), handleButtonUp(ilog.views.IlvPolyPointsSelection, java.awt.event.MouseEvent, ilog.views.IlvObjectInteractorContext), handleButtonDragged(ilog.views.IlvPolyPointsSelection, java.awt.event.MouseEvent, ilog.views.IlvObjectInteractorContext)

handleExpose

public void handleExpose(IlvGraphic obj,
                         Graphics g,
                         IlvObjectInteractorContext context)
Called when the view that draws the polypoints object is drawn. It actually calls the method drawGhost(IlvPolyPointsSelection, Graphics, IlvObjectInteractorContext) if the interactor is in opaque mode, and does nothing otherwise.

Overrides:
handleExpose in class IlvObjectInteractor
Parameters:
obj - The graphic object to which the object interactor is associated.
g - The Graphics where obj is drawn.
context - The interactor context.
Since:
JViews 5.0
See Also:
drawGhost(IlvPolyPointsSelection, Graphics, IlvObjectInteractorContext)

drawGhost

protected void drawGhost(IlvPolyPointsSelection obj,
                         IlvObjectInteractorContext context)
Deprecated. Beginning with ILOG JViews 5.0, use the method drawGhost(IlvPolyPointsSelection, Graphics, IlvObjectInteractorContext) instead.

Draws a polyline in Xor mode when a point of the polypoint is moved. Does nothing if the interactor is in opaque mode.


drawGhost

protected void drawGhost(IlvPolyPointsSelection obj,
                         Graphics g,
                         IlvObjectInteractorContext context)
Draws a polyline when a point of the polypoint is moved. The color and XOR mode are those determined by the context.

This method does nothing if the interactor is in opaque mode.

Since:
JViews 5.0
See Also:
isOpaqueMode()

onEnter

public void onEnter(IlvGraphic sel,
                    IlvObjectInteractorContext context)
Called when the selection is entered. This is used if the object interactor is associated with a selection object (see IlvSelection.onEnter(ilog.views.IlvObjectInteractorContext)). The selection is entered if the select interactor moves the mouse over the selection so that mouse events are dispatched to the object interactor of this selection.

Overrides:
onEnter in class IlvObjectInteractor
Parameters:
sel - The selection object.
context - The context for the object interactor.
Since:
JViews 8.0

onExit

public void onExit(IlvGraphic sel,
                   IlvObjectInteractorContext context)
Called when the selection is exited. This is used if the object interactor is associated with a selection object (see IlvSelection.onExit(ilog.views.IlvObjectInteractorContext)). The selection is exited if the select interactor moves the mouse to a blanc area of the view, or to another selection so that mouse events are no longer dispatched to the object interactor of this selection.

Overrides:
onExit in class IlvObjectInteractor
Parameters:
sel - The selection object.
context - The context for the object interactor.
Since:
JViews 8.0


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