public abstract class IlvMoveRectangleInteractor extends IlvAbstractScrollInteractor
IlvMoveRectangleInteractor
interactor is an abstract
interactor class that lets you move a rectangle, triggering a
method when it is done.Constructor and Description |
---|
IlvMoveRectangleInteractor(IlvRect rect)
Constructs and initializes a new instance of a move rectangle
interactor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
attach(IlvManagerView v)
Called when the interactor
is attached to the specified manager view.
|
protected void |
detach()
Called when the interactor
is detached from the current manager view.
|
protected boolean |
dragscroll(MouseEvent event)
Called by the dragging scroll timer to scroll the view.
|
void |
drawGhost(Graphics g)
Draws the rectangle as it moves.
|
Cursor |
getCursor()
Returns the cursor used for editing.
|
float[] |
getLineStyle()
Returns the dash array used when moving
the rectangle.
|
int |
getMoveThreshold()
Returns the threshold after which the rectangle
starts to move.
|
IlvRect |
getRectangle()
Returns the rectangle that is moved, in the view coordinate system.
|
protected boolean |
handleButtonDown(MouseEvent event)
Processes the button down events.
|
protected boolean |
handleButtonDragged(MouseEvent event)
Processes the button dragged events.
|
protected boolean |
handleButtonUp(MouseEvent event)
Processes the button up events.
|
protected boolean |
isDragging()
Returns
true if the
interactor is currently dragging a rectangle. |
boolean |
isGridMode()
Returns
true if the interactor snaps the moved rectangle
to the grid of the view; false otherwise. |
boolean |
isOpaqueMode()
Returns whether the interactor is in Opaque
mode or not.
|
boolean |
isXORGhost()
Returns the ghost drawing mode.
|
protected void |
processMouseEvent(MouseEvent event)
Processes the mouse events.
|
protected void |
processMouseMotionEvent(MouseEvent event)
Processes the mouse motion events.
|
protected void |
rectangleDragged(AWTEvent event,
double dx,
double dy)
Called each time the rectangle is dragged.
|
void |
setCursor(Cursor cursor)
Changes the cursor used for editing.
|
void |
setGridMode(boolean value)
Changes the way the interactor works with the grid.
|
void |
setLineStyle(float[] lineStyle)
Changes the dash array used when moving
the rectangle.
|
void |
setMoveThreshold(int threshold)
Changes the threshold after which the rectangle
starts to move.
|
void |
setOpaqueMode(boolean set)
Sets the interactor in Opaque mode.
|
void |
setRectangle(IlvRect rect)
Changes the rectangle that is moved.
|
protected void |
snapRectangleToGrid(IlvRect rectangle)
This method is called to snap the given rectangle to the
IlvManagerView grid. |
protected boolean |
trigger(AWTEvent event,
double dx,
double dy)
Called when the user releases the mouse button.
|
adjustPointIfOutsideView, doAutoScroll, getMaximumScrollDistance, getScrollTiming, isProgressiveScroll, setMaximumScrollDistance, setProgressiveScroll, setScrollTiming, startDraggingScrollTimer, stopDraggingScrollTimer
addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, allowEnsureVisible, allowEnsureVisible, disableEvents, drawGhost, enableEvents, ensureVisible, ensureVisible, getManager, getManagerView, getTransformer, handleExpose, processEvent, processFocusEvent, processKeyEvent, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, setXORGhost
public IlvMoveRectangleInteractor(IlvRect rect)
rect
- The rectangle that will be moved in the view
coordinate system.public final boolean isGridMode()
true
if the interactor snaps the moved rectangle
to the grid of the view; false
otherwise.IlvGrid
public final void setGridMode(boolean value)
value
- Must be set to true
if you want the interactor to snap the moved rectangle
to the grid of the view; false
otherwise.IlvGrid
public int getMoveThreshold()
setMoveThreshold(int)
public void setMoveThreshold(int threshold)
threshold
- The threshold in pixels.getMoveThreshold()
public void setOpaqueMode(boolean set)
In Opaque mode, while the user drags the rectangle,
the previous rectangle is erased by invalidating
the corresponding regions of the view using
IlvManagerView.invalidateRect(ilog.views.IlvRect)
and requesting a redraw using IlvManagerView.reDrawViews()
.
This mode may be slower because it requires partial redraws of the
manager, but it is safer because it behaves well if animated
gif
images are used (inside IlvIcon
graphic objects).
In Ghost mode, the previous rectangle is erased by drawing it again (in XOR mode). This mode is quicker because there is no redraw of the manager contents.
The default mode is the Ghost mode.
isOpaqueMode()
public boolean isOpaqueMode()
setOpaqueMode(boolean)
public boolean isXORGhost()
isOpaqueMode()
returns false
and to
force the Paint
mode when the method isOpaqueMode()
returns true
.isXORGhost
in class IlvManagerViewInteractor
true
if the drawing will be performed in
XOR
mode, false
otherwiseIlvManagerViewInteractor.setXORGhost(boolean)
,
IlvManagerViewInteractor.handleExpose(java.awt.Graphics)
,
IlvManagerViewInteractor.drawGhost(java.awt.Graphics)
protected void attach(IlvManagerView v)
attach
in class IlvManagerViewInteractor
v
- The manager view.IlvManagerViewInteractor.detach()
protected void detach()
detach
in class IlvAbstractScrollInteractor
IlvManagerViewInteractor.attach(ilog.views.IlvManagerView)
public Cursor getCursor()
public void setCursor(Cursor cursor)
cursor
- The new cursor.public final IlvRect getRectangle()
public final void setRectangle(IlvRect rect)
rect
- The new rectangle in the view coordinate system.public void setLineStyle(float[] lineStyle)
null
, meaning
that the dragged rectangle is drawn as a solid line.lineStyle
- The new line style, or null
to remove the
line style.getLineStyle()
public float[] getLineStyle()
null
if no line style was specified.setLineStyle(float[])
protected void snapRectangleToGrid(IlvRect rectangle)
IlvManagerView
grid. By default it calls
IlvManagerView.snapToGrid(IlvPoint)
to snap the
top left corner of the rectangle to the grid. This method
can be redefined to snap the rectangle differently (like
snapping the center of it instead of the top left corner).
The dimensions of the rectangle must not be changed by
this method; it can only modify the x and y attributes.rectangle
- The rectangle to be snapped.protected boolean isDragging()
true
if the
interactor is currently dragging a rectangle.
This means the mouse was pressed and not released.protected void processMouseEvent(MouseEvent event)
MOUSE_PRESSED
, the method handleButtonDown(java.awt.event.MouseEvent)
is
called. Otherwise, if the type of the event is MOUSE_RELEASED
,
the method handleButtonUp(java.awt.event.MouseEvent)
is called. In all cases, the
method processMouseEvent
of the superclass is called.processMouseEvent
in class IlvManagerViewInteractor
event
- The event.IlvManagerViewInteractor.addMouseListener(java.awt.event.MouseListener)
protected boolean handleButtonDown(MouseEvent event)
event
- The event.true
if the event has been processed,
false
otherwise.protected boolean handleButtonUp(MouseEvent event)
event
- The event.true
if the event has been processed,
false
otherwise.protected void processMouseMotionEvent(MouseEvent event)
processMouseMotionEvent
in class IlvManagerViewInteractor
event
- The event.IlvManagerViewInteractor.addMouseMotionListener(java.awt.event.MouseMotionListener)
protected boolean handleButtonDragged(MouseEvent event)
event
- The event.true
if the event has been processed,
false
otherwise.protected boolean dragscroll(MouseEvent event)
handleButtonDragged(java.awt.event.MouseEvent)
.dragscroll
in class IlvAbstractScrollInteractor
public void drawGhost(Graphics g)
drawGhost
in class IlvManagerViewInteractor
g
- The Graphics.IlvManagerViewInteractor.handleExpose(java.awt.Graphics)
,
IlvManagerViewInteractor.setXORGhost(boolean)
protected boolean trigger(AWTEvent event, double dx, double dy)
event
- The event that launches the method.dx
- The x translation of the rectangle.dy
- The y translation of the rectangle.protected void rectangleDragged(AWTEvent event, double dx, double dy)
event
- The event that launches the method.dx
- The x translation of the rectangle.dy
- The y translation of the rectangle.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.