ilog.views.interactor
Class IlvMoveRectangleInteractor

java.lang.Object
  extended by ilog.views.IlvManagerViewInteractor
      extended by ilog.views.interactor.IlvMoveRectangleInteractor
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
IlvSelectInteractorMoveSelection

public abstract class IlvMoveRectangleInteractor
extends IlvManagerViewInteractor

The IlvMoveRectangleInteractor interactor is an abstract interactor class that lets you move a rectangle, triggering a method when it is done.

See Also:
Serialized Form

Constructor Summary
IlvMoveRectangleInteractor(IlvRect rect)
          Constructs and initializes a new instance of a move rectangle interactor.
 
Method Summary
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.
 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, float dx, float 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, float dx, float dy)
          Called when the user releases the mouse button.
 
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

IlvMoveRectangleInteractor

public IlvMoveRectangleInteractor(IlvRect rect)
Constructs and initializes a new instance of a move rectangle interactor.

Parameters:
rect - The rectangle that will be moved in the view coordinate system.
Method Detail

isGridMode

public final boolean isGridMode()
Returns true if the interactor snaps the moved rectangle to the grid of the view; false otherwise.

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 true if you want the interactor to snap the moved rectangle to the grid of the view; false otherwise.
See Also:
IlvGrid

getMoveThreshold

public int getMoveThreshold()
Returns the threshold after which the rectangle starts to move. The rectangle will start to move only if the user moves it at a distance greater than this threshold. Note that the threshold is in pixels and that the default value is 0.

See Also:
setMoveThreshold(int)

setMoveThreshold

public void setMoveThreshold(int threshold)
Changes the threshold after which the rectangle starts to move. The rectangle will start to move only if the user moves it at a distance greater than this threshold. Note that the threshold is in pixels and that the default value is 0.

Parameters:
threshold - The threshold in pixels.
See Also:
getMoveThreshold()

setOpaqueMode

public void setOpaqueMode(boolean set)
Sets the interactor in Opaque mode. The interactor has two modes to drag a rectangle: The Opaque mode and the Ghost mode.

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.

Since:
JViews 5.0
See Also:
isOpaqueMode()

isOpaqueMode

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

Since:
JViews 5.0
See Also:
setOpaqueMode(boolean)

isXORGhost

public boolean isXORGhost()
Returns the ghost drawing mode. Overrides the method of the superclass to force the XOR mode when the method isOpaqueMode() returns false and to force the Paint mode when the method isOpaqueMode() returns true.

Overrides:
isXORGhost in class IlvManagerViewInteractor
Returns:
true if the drawing will 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)

attach

protected void attach(IlvManagerView v)
Called when the interactor is attached to the specified manager view.

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

detach

protected void detach()
Called when the interactor is detached from the current manager view.

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

getCursor

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


setCursor

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

Parameters:
cursor - The new cursor.

getRectangle

public final IlvRect getRectangle()
Returns the rectangle that is moved, in the view coordinate system.


setRectangle

public final void setRectangle(IlvRect rect)
Changes the rectangle that is moved.

Parameters:
rect - The new rectangle in the view coordinate system.

setLineStyle

public void setLineStyle(float[] lineStyle)
Changes the dash array used when moving the rectangle. The default value is null, meaning that the dragged rectangle is drawn as a solid line.

Parameters:
lineStyle - The new line style, or null to remove the line style.
See Also:
getLineStyle()

getLineStyle

public float[] getLineStyle()
Returns the dash array used when moving the rectangle. This method returns null if no line style was specified.

See Also:
setLineStyle(float[])

snapRectangleToGrid

protected void snapRectangleToGrid(IlvRect rectangle)
This method is called to snap the given rectangle to the 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.

Parameters:
rectangle - the rectangle to be snapped
Since:
JViews 6.5

isDragging

protected boolean isDragging()
Returns true if the interactor is currently dragging a rectangle. This means the mouse was pressed and not released.


processMouseEvent

protected void processMouseEvent(MouseEvent event)
Processes the mouse events. If the type of the event is 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.

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

handleButtonDown

protected boolean handleButtonDown(MouseEvent event)
Processes the button down events.

Parameters:
event - The event.
Returns:
true if the event has been processed, false otherwise.
Since:
JViews 5.0

handleButtonUp

protected boolean handleButtonUp(MouseEvent event)
Processes the button up events.

Parameters:
event - The event.
Returns:
true if the event has been processed, false otherwise.
Since:
JViews 5.0

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)

handleButtonDragged

protected boolean handleButtonDragged(MouseEvent event)
Processes the button dragged events.

Parameters:
event - The event.
Returns:
true if the event has been processed, false otherwise.
Since:
JViews 5.0

drawGhost

public void drawGhost(Graphics g)
Draws the rectangle as it moves.

Overrides:
drawGhost in class IlvManagerViewInteractor
Parameters:
g - The Graphics.
See Also:
IlvManagerViewInteractor.handleExpose(java.awt.Graphics), IlvManagerViewInteractor.setXORGhost(boolean)

trigger

protected boolean trigger(AWTEvent event,
                          float dx,
                          float dy)
Called when the user releases the mouse button.

Parameters:
event - The event that launches the method.
dx - The x translation of the rectangle.
dy - The y translation of the rectangle.

rectangleDragged

protected void rectangleDragged(AWTEvent event,
                                float dx,
                                float dy)
Called each time the rectangle is dragged.

Parameters:
event - The event that launches the method.
dx - The x translation of the rectangle.
dy - The y translation of the rectangle.


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