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)
.
Constructor and Description |
---|
IlvPolyPointsEdition()
Creates and initializes the interactor.
|
Modifier and Type | Method and Description |
---|---|
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 Perforce 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.
|
Get, Put
public IlvPolyPointsEdition()
public int getIndex()
-1
if
none. It is used in movePoint
and removePoint
to
indicate which point is modified.public Cursor getCursor()
public void setCursor(Cursor cursor)
public final boolean allowPointAddition()
true
if the interactor lets the user add points.public final void allowPointAddition(boolean v)
public final boolean allowPointRemoval()
true
if the interactor lets the user remove points.public final void allowPointRemoval(boolean v)
public void setOpaqueMode(boolean set)
The default mode is the Ghost mode.
isOpaqueMode()
,
IlvSelectInteractor.setOpaquePolyPointsEdition(boolean)
public boolean isOpaqueMode()
setOpaqueMode(boolean)
,
IlvSelectInteractor.setOpaquePolyPointsEdition(boolean)
protected boolean handleButtonDown(IlvPolyPointsSelection sel, MouseEvent event, IlvObjectInteractorContext context)
MOUSE_PRESSED
events.true
if the event has been processed,
false
otherwise.protected boolean handleButtonDragged(IlvPolyPointsSelection obj, MouseEvent event, IlvObjectInteractorContext context)
MOUSE_DRAGGED
events.true
if the event has been processed,
false
otherwise.protected boolean allowsPointMove(IlvPolyPointsInterface obj, int index)
IlvPolyPointsInterface.allowsPointMove(int)
.obj
- The object to modify.index
- The index of the point of the input object.protected boolean allowsPointInsertion(IlvPolyPointsInterface obj)
IlvPolyPointsInterface.allowsPointInsertion()
.obj
- The object to modify.protected boolean allowsPointRemoval(IlvPolyPointsInterface obj)
IlvPolyPointsInterface.allowsPointRemoval()
.obj
- The object to modify.protected void removePoint(IlvPolyPointsInterface obj, IlvObjectInteractorContext context)
getIndex
.obj
- The object to modify.context
- The interactor context.protected void insertPoint(IlvPolyPointsInterface obj, IlvPoint p, IlvObjectInteractorContext context)
obj
- The object to modify.p
- The position of the point in untransformed IlvManager
coordinates.context
- The interactor context.public static void setAddRemovePointModifier(int modifier)
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.
getAddRemovePointModifier()
,
getAddRemovePointModifierEx()
,
isAddRemovePointModifierDown(java.awt.event.InputEvent)
public static int getAddRemovePointModifier()
InputEvent.CTRL_MASK
.
setAddRemovePointModifier(int)
,
isAddRemovePointModifierDown(java.awt.event.InputEvent)
public static int getAddRemovePointModifierEx()
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)
.
setAddRemovePointModifier(int)
,
isAddRemovePointModifierDown(java.awt.event.InputEvent)
protected boolean isAddRemovePointModifierDown(InputEvent event)
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
.setAddRemovePointModifier(int)
protected void movePoint(IlvPolyPointsInterface obj, IlvObjectInteractorContext context, IlvPoint p)
getIndex
.obj
- The object to modify.context
- The interactor context.p
- The new position of the point in untransformed
IlvManager
coordinates.protected boolean handleButtonUp(IlvPolyPointsSelection obj, MouseEvent event, IlvObjectInteractorContext context)
MOUSE_RELEASED
events.
Moves the selected point of the polypoint by calling
movePoint
.true
if the event has been processed,
false
otherwise.movePoint(ilog.views.IlvPolyPointsInterface, ilog.views.IlvObjectInteractorContext, ilog.views.IlvPoint)
protected boolean handleMouseMoved(IlvPolyPointsSelection obj, MouseEvent event, IlvObjectInteractorContext context)
MOUSE_MOVED
events.true
if the event has been processed,
false
otherwise.public boolean processEvent(IlvGraphic obj, AWTEvent event, IlvObjectInteractorContext context)
handleButtonDown
for a MOUSE_PRESSED event,
handleButtonUp
for a MOUSE_RELEASED event, or
handleButtonDragged
for a MOUSE_DRAGGED event.processEvent
in class IlvObjectInteractor
obj
- The graphic object.event
- The event to process.context
- The context in which the event occurred.true
if the event was handled
by this processEvent
invocation,
false
otherwise.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)
public void handleExpose(IlvGraphic obj, Graphics g, IlvObjectInteractorContext context)
drawGhost(IlvPolyPointsSelection, Graphics, IlvObjectInteractorContext)
if the interactor is in opaque mode, and does nothing otherwise.handleExpose
in class IlvObjectInteractor
obj
- The graphic object to which the object interactor is associated.g
- The Graphics
where obj
is drawn.context
- The interactor context.drawGhost(IlvPolyPointsSelection, Graphics, IlvObjectInteractorContext)
@Deprecated protected void drawGhost(IlvPolyPointsSelection obj, IlvObjectInteractorContext context)
drawGhost(IlvPolyPointsSelection, Graphics, IlvObjectInteractorContext)
instead.protected void drawGhost(IlvPolyPointsSelection obj, Graphics g, IlvObjectInteractorContext context)
This method does nothing if the interactor is in opaque mode.
isOpaqueMode()
public void onEnter(IlvGraphic sel, IlvObjectInteractorContext context)
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.
onEnter
in class IlvObjectInteractor
sel
- The selection object.context
- The context for the object interactor.IlvSelection.onEnter(ilog.views.IlvObjectInteractorContext)
public void onExit(IlvGraphic sel, IlvObjectInteractorContext context)
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.
onExit
in class IlvObjectInteractor
sel
- The selection object.context
- The context for the object interactor.IlvSelection.onExit(ilog.views.IlvObjectInteractorContext)
© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.