ilog.views.objectinteractor
Class IlvMoveObjectInteractor

java.lang.Object
  extended by ilog.views.IlvObjectInteractor
      extended by ilog.views.objectinteractor.IlvMoveObjectInteractor
All Implemented Interfaces:
Serializable

public class IlvMoveObjectInteractor
extends IlvObjectInteractor

IlvMoveObjectInteractor is a local object interactor class that is used to let the user move a graphic object in a manager view.

Notice that the graphic objects can also be moved interactively using the selection view interactor IlvSelectInteractor. Therefore, the IlvMoveObjectInteractor is mainly useful for allowing to interactively move graphic objects without a selection interactor being installed.

Example

The following code example shows how to set IlvMoveObjectInteractor for a graphic object:

   IlvManager mgr = new IlvManager();
   // Create and add 2 graphic objects.
   IlvGraphic obj1 = new IlvRectangle(new IlvRect(60, 30, 50, 50));
   mgr.addObject(obj1, false);
   IlvGraphic obj2 = new IlvRectangle(new IlvRect(140, 50, 10, 10));
   mgr.addObject(obj2, false);
   
   // Set the move interactor on obj2 only. 
   obj2.setObjectInteractor(new IlvMoveObjectInteractor());
 

About Interactors and Accelerators

IlvMoveObjectInteractor is a custom local interactor, that is, a subclass of IlvObjectInteractor. A local interactor is a class that listens to a special event in a graphic object. All input events are handled by means of interactors or accelerators. For information about how to treat events in a manager, see Handling Events. The following code examples show how to handle user events:

See Also:
IlvGraphic.setObjectInteractor(IlvObjectInteractor), Serialized Form

Constructor Summary
IlvMoveObjectInteractor()
          Creates the interactor.
 
Method Summary
protected  void drawGhost(IlvGraphic obj, IlvObjectInteractorContext context)
          Draws a preview image of the user action (ghost image).
protected  void performMove(IlvGraphic object, IlvPoint position, IlvObjectInteractorContext context)
          This method is called to move the graphic object to it's new position.
protected  boolean processButtonDown(IlvGraphic obj, MouseEvent event, IlvObjectInteractorContext context)
          Processes the button down events.
protected  boolean processButtonDragged(IlvGraphic obj, MouseEvent event, IlvObjectInteractorContext context)
          Processes the button dragged events.
protected  boolean processButtonUp(IlvGraphic obj, MouseEvent event, IlvObjectInteractorContext context)
          Processes the button up events.
 boolean processEvent(IlvGraphic obj, AWTEvent event, IlvObjectInteractorContext context)
          Processes the events.
protected  void validate(IlvGraphic object, IlvPoint position, IlvObjectInteractorContext context)
          This method is called on each mouse movement.
 
Methods inherited from class ilog.views.IlvObjectInteractor
Get, handleExpose, onEnter, onExit, Put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvMoveObjectInteractor

public IlvMoveObjectInteractor()
Creates the interactor. You should not use the constructor to create an instance, you may share instances of this interactor by using the IlvObjectInteractor.Get method.

See Also:
IlvObjectInteractor.Get(java.lang.String)
Method Detail

performMove

protected void performMove(IlvGraphic object,
                           IlvPoint position,
                           IlvObjectInteractorContext context)
This method is called to move the graphic object to it's new position.

Parameters:
object - the moved graphic object.
position - the new desired position of the object in manager's coordinate system.
context - the context of execution of the interactor.

validate

protected void validate(IlvGraphic object,
                        IlvPoint position,
                        IlvObjectInteractorContext context)
This method is called on each mouse movement. This method can be overwritten in order to check if the position of the object is valid. A valid position can be returned in the position variable. Note that the current implementation does nothing.

Parameters:
object - the moved graphic object.
position - the current desired position of the object in the manager's coordinate system.
context - the context of execution of the interactor.

processButtonDown

protected boolean processButtonDown(IlvGraphic obj,
                                    MouseEvent event,
                                    IlvObjectInteractorContext context)
Processes the button down events.


processButtonDragged

protected boolean processButtonDragged(IlvGraphic obj,
                                       MouseEvent event,
                                       IlvObjectInteractorContext context)
Processes the button dragged events.


processButtonUp

protected boolean processButtonUp(IlvGraphic obj,
                                  MouseEvent event,
                                  IlvObjectInteractorContext context)
Processes the button up events.


processEvent

public boolean processEvent(IlvGraphic obj,
                            AWTEvent event,
                            IlvObjectInteractorContext context)
Processes the events.

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.

drawGhost

protected void drawGhost(IlvGraphic obj,
                         IlvObjectInteractorContext context)
Draws a preview image of the user action (ghost image). The moved object is drawn in Xor mode.



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