public class TLspSelectControllerModel extends Object
Controller model for selection of objects in a view, used by the TLspSelectController
.
The class javadoc of the TLspSelectController
explains how the select controller and this controller model work together to update the selection.
The object of which the selection is potentially updated are collected by the selectionCandidates(ALspSelectInput, Set, boolean, ILspView)
method.
When using the TLspSelectController
, the controller calls the select(ALspSelectInput, Set, TLspSelectChoice, TLspSelectMode, ILspView)
method
which in turn calls the selectionCandidates(ALspSelectInput, Set, boolean, ILspView)
method.
By overriding this method, you can use custom logic. An example is to only consider objects of which the bounds are completely contained in the selection rectangle instead of all objects with overlapping bounds.
The update of the selection happens in the applySelection(ALspSelectInput, TLspSelectChoice, TLspSelectMode, List, ILspView)
method.
This method delegates the actual updating of the selection to a ILspSelectionCandidateHandler
.
You can replace the existing ones (or register your own instance when you have a custom TLspSelectChoice
)
by calling the setSelectionCandidateHandlerFor(TLspSelectChoice, ILspSelectionCandidateHandler)
method.
If that is not sufficient, you can always override the method to implement your own behavior.
An example customization is to show a dialog to the user when multiple selection candidates are available, and let the user decide which ones to select.
TLspSelectController
Constructor and Description |
---|
TLspSelectControllerModel()
Creates a new
TLspSelectControllerModel with default settings. |
Modifier and Type | Method and Description |
---|---|
protected void |
applySelection(ALspSelectInput aInput,
TLspSelectChoice aChoice,
TLspSelectMode aMode,
List<TLspDomainObjectContext> aSelectionCandidates,
ILspView aView)
Uses the passed arguments to change the selection of some or all of the objects
in
aSelectionCandidates |
int |
getSensitivity()
This method returns the sensitivity that will be used when selecting
objects or labels.
|
void |
select(ALspSelectInput aInput,
Set<TLspPaintRepresentation> aRepresentations,
TLspSelectChoice aChoice,
TLspSelectMode aMode,
ILspView aView)
Selects (an) object(s) interacting with a rectangle in a view according to the
TLspSelectChoice
and TLspSelectMode . |
List<TLspDomainObjectContext> |
selectionCandidates(ALspSelectInput aInput,
Set<TLspPaintRepresentation> aRepresentations,
boolean aMultiple,
ILspView aView)
Returns the set of selection candidates that should be considered for selection based on the passed
arguments.
|
void |
setSelectionCandidateHandlerFor(TLspSelectChoice aChoice,
ILspSelectionCandidateHandler aHandler)
Registers
aHandler as the selection candidate handler to use for aChoice . |
void |
setSensitivity(int aSensitivity)
This method sets the sensitivity that should be used by painters to determine which
object is selected by the input device (usually the mouse).
|
public TLspSelectControllerModel()
TLspSelectControllerModel
with default settings.public void setSelectionCandidateHandlerFor(TLspSelectChoice aChoice, ILspSelectionCandidateHandler aHandler)
aHandler
as the selection candidate handler to use for aChoice
.
By default TLspSelectChoice.DEFAULT
is mapped on a standard
TLspDefaultSelectionCandidateHandler
and TLspSelectChoice.CHOOSE
is mapped on
a default TLspPopupMenuSelectionCandidateHandler
.aChoice
- The TLspSelectChoice
to map the passed handler to.aHandler
- The handler to be used for the passed choice.public int getSensitivity()
This method returns the sensitivity that will be used when selecting objects or labels.
The sensitivity is the maximum distance at which the representation of an object can be removed from a selection point, such as the position of the mouse cursor, and still be considered a valid selection candidate. The distance is expressed in pixels.
setSensitivity(int)
public void setSensitivity(int aSensitivity)
This method sets the sensitivity that should be used by painters to determine which object is selected by the input device (usually the mouse).
The sensitivity is the maximum distance at which the representation of an object can be removed from a selection point, such as the position of the mouse cursor, and still be considered a valid selection candidate. The distance is expressed in pixels. Tweaking the selection sensitivity is especially useful when you are using less exact input methods like a touch screen.
aSensitivity
- the sensitivity that will be used for selecting objects, expressed in pixels.getSensitivity()
public void select(ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, TLspSelectChoice aChoice, TLspSelectMode aMode, ILspView aView)
Selects (an) object(s) interacting with a rectangle in a view according to the TLspSelectChoice
and TLspSelectMode
.
The default implementation of this method:
selectionCandidates(ALspSelectInput, Set, boolean, ILspView)
.applySelection(ALspSelectInput, TLspSelectChoice, TLspSelectMode, List, ILspView)
aInput
- the selection input.aRepresentations
- the paint representations to be taken into account when selecting objects.aChoice
- the choice, this controls which of the possible selection candidates are taken into account.
The default implementation only supports TLspSelectChoice.DEFAULT
and TLspSelectChoice.CHOOSE
.aMode
- the mode, this controls how the selection is adapted for the remaining selection candidates.aView
- the view to select in.public List<TLspDomainObjectContext> selectionCandidates(ALspSelectInput aInput, Set<TLspPaintRepresentation> aRepresentations, boolean aMultiple, ILspView aView)
Returns the set of selection candidates that should be considered for selection based on the passed arguments.
The default implementation:aInput
- the selection input.aRepresentations
- the paint representations to be taken into account when selecting objects.aMultiple
- flag that indicates whether or not multiple selection candidates are needed, this allows
optimizations if only one is necessary.aView
- the view to select in.protected void applySelection(ALspSelectInput aInput, TLspSelectChoice aChoice, TLspSelectMode aMode, List<TLspDomainObjectContext> aSelectionCandidates, ILspView aView)
Uses the passed arguments to change the selection of some or all of the objects
in aSelectionCandidates
TLspSelectMode.NO_CHANGE
TLspSelectMode.REPLACE
ILspSelectionCandidateHandler
for aChoice
.
By default this controller supports 2 choices:
TLspSelectChoice.DEFAULT
: the controller uses a TLspDefaultSelectionCandidateHandler
to update the selection.TLspSelectChoice.CHOOSE
: the controller uses a TLspPopupMenuSelectionCandidateHandler
to update the selection.aInput
- the selection input.aChoice
- the choice, this controls which of the possible selection candidates are taken into accountaMode
- the mode, this controls how the selection is adapted for the remaining selection candidates.aSelectionCandidates
- a list of objects for which a new selection state should be determined.aView
- the view to select in.