ilog.views
Class IlvObjectInteractor

java.lang.Object
  extended by ilog.views.IlvObjectInteractor
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
IltExpandCollapseInteractor, IltObjectInteractor, IlvButtonInteractor, IlvCompositeInteractor, IlvExpandCollapseRenderer.ExpandCollapseInteractor, IlvGraphicGroupInteractor, IlvGraphicHandleInteractor, IlvGraphicSet.DelegateObjectInteractor, IlvGroupInteractor, IlvHoverHighlightingImageOperation, IlvHyperEdgeEdition, IlvHyperEdgePinConnectorEdition, IlvLaneRenderer.ResizeLaneInteractor, IlvMoveObjectInteractor, IlvPolyPointsEdition, IlvReshapeSelection, IlvSubGraphRenderer.ExpandCollapseInteractor, SVGHREFObjectInteractor

public abstract class IlvObjectInteractor
extends Object
implements Serializable

Object interactors are used to handle local events for graphic objects. Extend this class to make a custom object interactor for your graphic objects.

Overview

Interactors are objects that define user actions. For example, how a graphic object will move when it is dragged by a user, or how panning a manager view is performed. The interactive behavior is controlled either by using view interactors (IlvManagerViewInteractor and subclasses) associated to the entire manager view or by object interactors (IlvObjectInteractor and subclasses) associated to each individual graphic object.

When an event is received by a manager view that has no associated view interactor, the event is dispatched to the manager (see IlvManagerView.processEvent(AWTEvent) and IlvManager.processEvent(AWTEvent, IlvManagerView)). The manager attempts to send it to the object interactor of the graphic object located at the mouse position.

To associate a specific behavior to a graphic object, you use an object interactor, that is, an subclass of IlvObjectInteractor. The event dispatched by the manager is processed by the method processEvent(IlvGraphic, AWTEvent, IlvObjectInteractorContext).

An object interactor can be associated to every object in a manager, and several objects can share the same object interactor. To attach an interactor to a graphic object, create an IlvObjectInteractor instance, then bind it to one or more graphic objects using the method IlvGraphic.setObjectInteractor(IlvObjectInteractor). It is the interactor, and not the graphic object, that manages user events and deals with them.

Example

The following code example shows how to set a custom object interactor 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);
   
   // Create your custom object interactor (a subclass of IlvObjectInteractor).
   IlvObjectInteractor myInter = new MyObjectInteractor();
   
   // Set this interactor on obj2 only. 
   obj2.setObjectInteractor(myInter);
 

About Interactors and 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:
IlvManager, IlvManagerView, IlvGraphic.setObjectInteractor(ilog.views.IlvObjectInteractor), IlvGraphic.getObjectInteractor(), IlvManagerViewInteractor, IlvSelectInteractor, Serialized Form

Constructor Summary
protected IlvObjectInteractor()
          Creates a new IlvObjectInteractor.
 
Method Summary
static IlvObjectInteractor Get(String name)
          Returns an object interactor.
 void handleExpose(IlvGraphic obj, Graphics g, IlvObjectInteractorContext context)
          Called by the view when the view is drawn.
 void onEnter(IlvGraphic sel, IlvObjectInteractorContext context)
          Called when the selection is entered.
 void onExit(IlvGraphic sel, IlvObjectInteractorContext context)
          Called when the selection is exited.
abstract  boolean processEvent(IlvGraphic obj, AWTEvent event, IlvObjectInteractorContext context)
          Processes the events.
static void Put(String name, IlvObjectInteractor inter)
          Registers an object interactor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlvObjectInteractor

protected IlvObjectInteractor()
Creates a new IlvObjectInteractor.

Method Detail

processEvent

public abstract boolean processEvent(IlvGraphic obj,
                                     AWTEvent event,
                                     IlvObjectInteractorContext context)
Processes the events. You should not call this method directly.

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.

handleExpose

public void handleExpose(IlvGraphic obj,
                         Graphics g,
                         IlvObjectInteractorContext context)
Called by the view when the view is drawn. You normally do not need to call it directly.

The default implementation does nothing.

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

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.

Subclasses can override this method to perform specific tasks when the selection is entered. The default implementation does nothing.

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.

Subclasses can override this method to perform specific tasks when the selection is entered. The default implementation does nothing.

Parameters:
sel - The selection object.
context - The context for the object interactor.
Since:
JViews 8.0

Get

public static IlvObjectInteractor Get(String name)
Returns an object interactor. Object interactors may be shared so that successive calls to this method will return the same instance of interactor.

Parameters:
name - The fully qualified class name of the interactor (for instance, "mypackage.MyObjectInteractor").
Returns:
The interactor, or null if no such interactor can be created.

Put

public static void Put(String name,
                       IlvObjectInteractor inter)
Registers an object interactor. This can be used for object interactors that can be shared among objects. When the object interactor with the same class name is requested via Get(java.lang.String), the stored object interactor is returned.

Parameters:
name - The fully qualified class name of the interactor (for instance, "mypackage.MyObjectInteractor").
inter - The interactor instance.
Since:
JViews 8.1


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