Interacting with the graphic components

The controller manages interactors. Interactors translate user gestures—a series of one or more mouse events that are executed by the user to perform a single task—and keystrokes into actions to be performed, and more specifically into Swing action invocations. JViews TGO provides two types of interactor:
  • View interactors that operate on the view as a whole and
  • Object interactors that apply to each object contained in the view individually.
Events associated with interactors can be customized, except for some gestures, such as selection management, tooltips, and display of pop-up menus, which have standard behavior in most user interfaces. All interactors recognize a number of basic user gestures, such as pressing a mouse button, while only certain component-specific interactors handle more complex gestures, such as moving a node or a table column or creating a link. In addition, all interactors include support for displaying a pop-up menu. For information about component-specific interactions, see the information on each graphic component.
You can define global object interactors (that apply to the entire application) using the IlpInteractorManager interface. A default implementation of this interface, IlpDefaultInteractorManager, is provided, which you can use globally and access through the default context. For information about the default context, see The application context.
By default, the controller is associated with a default interactor manager. If interactors specific to given representation objects have been defined, these will hide the global interactors. In this case, when an interactor is requested, it is first searched for among the local interactors and then, if none is found, in the default manager interactor.
The figure below shows the basic classes and interfaces that implement interactor support.
tgo_interactor.png
Interactor classes and interfaces
  • The class IlpGesture is an enumeration defining the basic user gestures that are recognized by all the interactors, whatever the component they are attached to.
  • The interface IlpInteractor contains methods to attach keystrokes or user gestures to actions and to set a pop-up menu factory to the interactor.
  • The class IlpInteractionContext contains information about the view to which the user events apply, the recognized gestures that are incomplete, the complete gestures, if any, and the position where this gesture takes place.
  • The class IlpAbstractPopupMenuFactory provides pop-up menus for an interactor given the specified interaction context.
  • The class IlpAbstractInteractor is an abstract implementation of IlpInteractor. This class provides an implementation for the method processEvent that recognizes the basic gestures defined in IlpGesture. The only method that subclasses should implement is createEventAction . This method must provide an ActionEvent instance that is passed to the action associated with the recognized gesture.

View interactors

View interactors are defined by the interface IlpViewInteractor. They handle interactions with a graphic view and are attached to the controller associated with that view. When a view interactor is attached to the controller, the controller registers all the user events happening on that view. It retrieves the view interaction context or creates one, if none has been defined, and calls the IlpViewInteractor.processEvent method to process the events. If an event applies to a graphic object, the view interactor will first check whether this object is associated with an object interactor and, if so, will delegate processing to that interactor. See Object interactors. The view interaction context, defined by the class IlpViewInteractionContext, extends IlpInteractionContext to add the appropriate graphic objects and an IlpObjectInteractionContext that is passed to object interactors.
The diagram below shows the interfaces and classes related to view interactors.
tgo_view_interactor.png
View interactors interfaces and classes
A default implementation is provided for the view interactor, which is defined by the class IlpDefaultViewInteractor. This class defines standard behavior for all its associated graphic views. The default view interactor provides an IlpViewActionEvent that gives access to information contained in the view interactor context to the action that is called when a user gesture is recognized.

Selection handling in pop-up menus

The selection behavior attached to pop-up menus is defined by the method manageSelection and is as follows:
  • When the mouse is over an object and this object is not selected, this object is selected and other objects are deselected. If the object is selected, the selection remains unchanged.
  • When the mouse is not over an object, all the objects in the view are deselected.
To modify this behavior, you must redefine the method manageSelection.

Tooltip support

In JViews TGO, tooltip support is based on the Swing tooltip support and is handled by the graphic view. It allows you to create tooltips for graphic objects that represent entire objects or attributes and can be customized by means of cascading style sheets. You can define tooltips as simple text or as complex graphic objects.
The following properties are available to configure tooltips:
  • tooltipText defines a string value to be used as the object tooltip.
  • tooltipGraphic defines a graphic object that is used to create a tooltip. This property has priority over tooltipText .
The following code shows how to add tooltip support to a given graphic view.

How to add tooltip support to the view

IlpNetwork network = new IlpNetwork();
IlpGraphicView view = network.getView();
IlpToolTipManager.AddToolTipSupport (view);
Once you have added tooltip support to a graphic view, you can configure its behavior with the IlpToolTipManager API.

How to configure tooltip support

IlpToolTipManager tmgr = IlpToolTipManager.GetToolTipManager(view);

How to remove tooltip support from the view

Tooltip support can be removed from a graphic view with the following method.
IlpToolTipManager.RemoveToolTipSupport (view);

Object interactors

Object interactors are defined by the interface IlpObjectInteractor. They handle interactions with simple or composite IlpGraphic objects or representation objects. If a user event applies to a simple graphic object that is part of a composite graphic object and that object has no associated interactor, then the event will be passed to and processed by the interactor of the parent object, if any.
The diagram below shows the interfaces and classes related to object interactors.
tgo_object_interactor.png
Object interactors interfaces and classes
IlpObjectInteractionContext extends IlpInteractionContext to add the concerned graphic object or representation object.
A default implementation is provided for the object interactor, which is defined by the class IlpDefaultObjectInteractor. The default object interactor provides an IlpObjectActionEvent that gives access to information contained in the object interactor context to the action that is called when a user gesture is recognized.