Class TLcdGXYSelectController2

All Implemented Interfaces:
ILcdUndoableSource, ILcdAWTEventListener, ILcdStatusSource, ILcdGXYChainableController, ILcdGXYController, KeyListener, MouseListener, MouseMotionListener, Serializable, EventListener
Direct Known Subclasses:
TLcdGXYEditController2

public class TLcdGXYSelectController2 extends TLcdGXYDragRectangleController implements MouseListener, ILcdGXYChainableController

Controller that allows the user to select domain objects in the view using the mouse. The controller supports selection changes by clicking on the view or by dragging a rectangle.

If case you want to programmatically (de)select objects, query the selection or get informed about selection changes, you should use:

How selection works

The selection controller works in multiple steps:
  1. The controller interprets the user input: first, this controller gathers information about the selection intent of the user. For example whether the user wants to add or remove the object to/from the selection, whether the user wants to drag a rectangle to select multiple objects in one go, ... .
  2. The controller model performs the actual update of the selection: once all this information is gathered, it is passed to the controller model:
    1. The selectionCandidates method is used to query the view and the layers for objects that match the mouse click (or the selection rectangle).
    2. The selection of those selection candidates is updated by calling the applySelection method.

Customizing the controller

(De)Activate rectangle selection mode

This controller uses the multi-select modifier key to determine whether or not a MouseEvent should be interpreted as a "select by dragging a rectangle". Call the setter if you want to replace the default key.

Selecting objects by their labels or only by their bodies

This controller calls the selectByWhatMode(ILcdGXYView, Rectangle, int, MouseEvent) method to determine whether the bodies only or also the labels should be considered when determining which objects are selection candidates. This information is passed to the TLcdGXYSelectControllerModel2, and it is the responsibility of the controller model to respect this choice.

Overlapping objects: selecting the topmost element only or not

This controller calls the selectHowMode(ILcdGXYView, Rectangle, int, MouseEvent, int) method to determine how selection candidates are selected when there are multiple candidates.

The resulting integer is passed to the controller model, and it is the controller model who decides how to handle this choice.

Selecting or deselecting the selection candidates

This controller calls the selectHowMode(ILcdGXYView, Rectangle, int, MouseEvent, int) to determine what to do with the selection candidates. For example should the objects be added to the current selection, replace the current selection, ... .

The resulting integer is passed to the controller model, and it is the controller model who decides how to handle this choice.

Replacing the controller model

The actual adjusting of the selection is done by the TLcdGXYSelectControllerModel2. You can customize the selection behavior by installing a custom controller model instance on this model, or by specifying a custom controller model in the constructor.

Double click and right click pop-up menu

This controller has methods to:
  • Specify an ActionListener which should be triggered when a double click is performed (setDoubleClickAction(ActionListener)). A typical use-case of this is setting an action listener which shows the properties of an object when double-clicking on it.
  • Specify an ActionListener which should be triggered when the user performs a right click (setRightClickAction(ActionListener))}). A typical use-case of this is setting an action which shows a pop-up menu for the selected object when right-clicking.
Since:
7.0
See Also: