|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectilog.views.IlvObjectInteractor
public abstract class IlvObjectInteractor
Object interactors are used to handle local events for graphic objects. Extend this class to make a custom object interactor for your graphic objects.
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.
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);
For information about how to treat events in a manager, see Handling Events. The following code examples show how to handle user events:
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 |
|---|
protected IlvObjectInteractor()
IlvObjectInteractor.
| Method Detail |
|---|
public abstract boolean processEvent(IlvGraphic obj,
AWTEvent event,
IlvObjectInteractorContext context)
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.
public void handleExpose(IlvGraphic obj,
Graphics g,
IlvObjectInteractorContext context)
The default implementation does nothing.
obj - The graphic object to which the object interactor is associated.g - The Graphics where obj is drawn.context - The interactor context.
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.
Subclasses can override this method to perform specific tasks when the selection is entered. The default implementation does nothing.
sel - The selection object.context - The context for the object interactor.
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.
Subclasses can override this method to perform specific tasks when the selection is entered. The default implementation does nothing.
sel - The selection object.context - The context for the object interactor.public static IlvObjectInteractor Get(String name)
name - The fully qualified class name of the interactor
(for instance, "mypackage.MyObjectInteractor").
null if no such interactor
can be created.
public static void Put(String name,
IlvObjectInteractor inter)
Get(java.lang.String), the stored object interactor is returned.
name - The fully qualified class name of the interactor
(for instance, "mypackage.MyObjectInteractor").inter - The interactor instance.
|
||||||||||
| PREV CLASS Documentation homepage NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||