public class TLcdGXYSelectControllerModel2 extends Object
Controller model for selection of objects in a view, used by the TLcdGXYSelectController2
.
The class javadoc of the TLcdGXYSelectController2
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
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
method.
By overriding this method, you can use custom logic. 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.
When using the SELECT_HOW_CHOOSE
mode, the users will be presented with a pop-up where they can choose which domain objects to select.
The domain objects in the pop-up menu are by default represented by their toString
implementation.
This can be changed by overriding the formatObject
method.
Modifier and Type | Field and Description |
---|---|
static int |
INPUT_MODE_POINT
Mode defining that the selection was originated by a single interaction.
|
static int |
INPUT_MODE_RECTANGLE
Mode defining that the selection was originated by dragging a rectangle.
|
static int |
MOUSE_MODE_CLICK
Deprecated.
replaced by
INPUT_MODE_POINT |
static int |
MOUSE_MODE_DRAG
Deprecated.
replaced by
INPUT_MODE_RECTANGLE |
static int |
SELECT_BY_WHAT_BODIES_ON_CLICK
Mode defining that clicking on the body of an object can change the
selection.
|
static int |
SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINS
Mode defining that dragging over the body of an object can change the
selection, if the body lies within the selection rectangle.
|
static int |
SELECT_BY_WHAT_BODIES_ON_DRAG_OVERLAPS
Mode defining that dragging over the body of an object can change the
selection, if the body overlaps with the selection rectangle.
|
static int |
SELECT_BY_WHAT_LABELS_ON_CLICK
Mode defining that clicking on the label of an object can change the
selection.
|
static int |
SELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINS
Mode defining that dragging over the label of an object can change the
selection, if the label lies within the selection rectangle.
|
static int |
SELECT_BY_WHAT_LABELS_ON_DRAG_OVERLAPS
Mode defining that dragging over the label of an object can change the
selection, if the label overlaps with the selection rectangle.
Note: the implementation is based on
labelBoundsSFCT and therefore this
mode might not behave intuitive if the bounds of the label are different
from the actual representation of the label. |
static int |
SELECT_HOW_ADD
Mode defining that the candidates for the selection should be added to the
current selection.
|
static int |
SELECT_HOW_CHOOSE
Mode defining that, in the event multiple objects are candidates for
selection (e.g., several objects overlap), the user should choose which
object(s) to select, for example with a popup up menu.
This mode is typically combined (bit-wise or) with another mode,
such as
SELECT_HOW_ADD . |
static int |
SELECT_HOW_FIRST_TOUCHED
Mode defining that the first (topmost) object should be selected, and that
the possible existing selection should be cleared.
|
static int |
SELECT_HOW_INVERT
Mode defining that the current selection state of the candidates for the
selection should be toggled: those that were selected are deselected, those
that were deselected are selected.
|
static int |
SELECT_HOW_NO_CHANGE
Mode defining that no changes must be made to the selection.
|
static int |
SELECT_HOW_REMOVE
Mode defining that the candidates for the selection should be removed from
the current selection.
|
Constructor and Description |
---|
TLcdGXYSelectControllerModel2() |
Modifier and Type | Method and Description |
---|---|
void |
applySelection(ILcdGXYView aGXYView,
Rectangle aSelectionBounds,
int aInputMode,
int aX,
int aY,
int aSelectByWhatMode,
int aSelectHowMode,
ILcdGXYLayerSubsetList aSelectionCandidates)
Modifies the current selection, according to the given selection candidates
and by respecting the given modes.
If the aSelectHowMode contains
SELECT_HOW_FIRST_TOUCHED , the
current selection is cleared and the selection candidates are the only
selected objects afterward.
If the aSelectHowMode contains SELECT_HOW_CHOOSE , a popup
dialog is displayed allowing the user to choose from the selection
candidates. |
void |
applySelection(ILcdGXYView aGXYView,
Rectangle aSelectionBounds,
int aMouseMode,
MouseEvent aMouseEvent,
int aSelectByWhatMode,
int aSelectHowMode,
ILcdGXYLayerSubsetList aSelectionCandidates)
Deprecated.
use
applySelection
without the mouseEvent parameter instead. |
protected String |
formatObject(Object aObject,
ILcdGXYLayer aGXYLayer)
This method returns a String representation of the given domain
Object contained in the given ILcdGXYLayer . |
int |
getClickSensitivity()
Returns the click sensitivity.
|
int |
getPopupDeltaX()
Returns popup delta x.
|
int |
getPopupDeltaY()
Returns the popup delta y.
|
int |
getSensitivity()
This method returns the sensitivity that will be used when selecting objects or labels.
|
static String |
inputModeAsString(int aInputMode)
Utility method that converts the given input mode to a human readable
string.
|
static String |
mouseModeAsString(int aMouseMode)
Deprecated.
Replaced by
inputModeAsString(int) . |
static String |
selectByWhatAsString(int aSelectByWhat)
Utility method that converts the given select-by-what mode to a human
readable string.
|
int |
selectByWhatMode(ILcdGXYView aGXYView,
Rectangle aSelectionBounds,
int aMouseMode,
MouseEvent aMouseEvent)
Deprecated.
The controller model should not depend on the kind of input. If this behaviour
is to be changed override the method in the
TLcdGXYSelectController2 instead. |
static String |
selectHowAsString(int aSelectHow)
Utility method that converts the given select-how mode to a human readable
string.
|
int |
selectHowMode(ILcdGXYView aGXYView,
Rectangle aSelectionBounds,
int aMouseMode,
MouseEvent aMouseEvent,
int aSelectByWhatMode)
Deprecated.
The controllers themselves should be responsible for specifying the select how mode,
mainly because it often depends on the kind of input device. An equivalent method has been added
to
TLcdGXYSelectController2 , to allow the same kind of customization. |
ILcdGXYLayerSubsetList |
selectionCandidates(ILcdGXYView aGXYView,
Rectangle aSelectionBounds,
int aMouseMode,
MouseEvent aMouseEvent,
int aSelectByWhatMode,
int aSelectHowMode)
Returns the selection candidates for the given selection bounds and modes.
If the aSelectHowMode contains
SELECT_HOW_CHOOSE , or if the
aMouseMode is INPUT_MODE_RECTANGLE , multiple objects can be
returned, otherwise only one object is returned.
If the aSelectHowMode contains SELECT_HOW_NO_CHANGE , no selection
candidates are returned.
The aSelectByWhatMode can be composed (bit-wise or) of these values:
SELECT_BY_WHAT_BODIES_ON_CLICK : depends on the behavior
of isTouched . |
void |
setClickSensitivity(int aClickSensitivity)
Sets the click sensitivity.
|
void |
setPopupDeltaX(int aPopupDeltaX)
Sets the horizontal gap between the location of the mouse pointer and the popup menu.
|
void |
setPopupDeltaY(int aPopupDeltaY)
Sets the horizontal gap between the location of the mouse pointer and the popup menu.
|
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 static final int SELECT_BY_WHAT_BODIES_ON_CLICK
ILcdGXYPainter.BODY
.public static final int SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINS
ILcdGXYPainter.BODY
.public static final int SELECT_BY_WHAT_BODIES_ON_DRAG_OVERLAPS
ILcdGXYPainter.BODY
.
Note: the implementation is based on boundsSFCT
and therefore this mode might not
behave intuitive if the bounds of the object are different from the actual
representation of the object. For example for an L-shaped polyline the
dragged rectangle might not touch the L, but still overlap with the outer
bounds of the L.public static final int SELECT_BY_WHAT_LABELS_ON_CLICK
ILcdGXYEditableLabelsLayer
.public static final int SELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINS
ILcdGXYEditableLabelsLayer
.public static final int SELECT_BY_WHAT_LABELS_ON_DRAG_OVERLAPS
labelBoundsSFCT
and therefore this
mode might not behave intuitive if the bounds of the label are different
from the actual representation of the label.
ILcdGXYEditableLabelsLayer
.public static final int SELECT_HOW_CHOOSE
SELECT_HOW_ADD
.public static final int SELECT_HOW_FIRST_TOUCHED
public static final int SELECT_HOW_ADD
public static final int SELECT_HOW_REMOVE
public static final int SELECT_HOW_INVERT
public static final int SELECT_HOW_NO_CHANGE
@Deprecated public static final int MOUSE_MODE_DRAG
INPUT_MODE_RECTANGLE
@Deprecated public static final int MOUSE_MODE_CLICK
INPUT_MODE_POINT
public static final int INPUT_MODE_RECTANGLE
public static final int INPUT_MODE_POINT
public int getSensitivity()
TLcdGXYContext
passed to the painters.setSensitivity(int)
,
TLcdGXYContext.getSensitivity()
public void setSensitivity(int aSensitivity)
aSensitivity
- the sensitivity that will be used for selecting objects.getSensitivity()
,
TLcdGXYContext.setSensitivity(int)
public int getPopupDeltaX()
setPopupDeltaX(int)
public void setPopupDeltaX(int aPopupDeltaX)
applySelection(com.luciad.view.gxy.ILcdGXYView, java.awt.Rectangle, int, int, int, int, int, com.luciad.view.gxy.ILcdGXYLayerSubsetList)
applySelection} to know when the
popup is displayed.aPopupDeltaX
- the delta in the x-direction.getPopupDeltaX()
public int getPopupDeltaY()
setPopupDeltaY(int)
public void setPopupDeltaY(int aPopupDeltaY)
applySelection(com.luciad.view.gxy.ILcdGXYView, java.awt.Rectangle, int, int, int, int, int, com.luciad.view.gxy.ILcdGXYLayerSubsetList)
applySelection} to know when the
popup is displayed.aPopupDeltaY
- the delta in the y-direction.getPopupDeltaY()
protected String formatObject(Object aObject, ILcdGXYLayer aGXYLayer)
Object
contained in the given ILcdGXYLayer
.
The name is used to display in the popup menu.
This method can be redefined.
Please refer to applySelection(com.luciad.view.gxy.ILcdGXYView, java.awt.Rectangle, int, int, int, int, int, com.luciad.view.gxy.ILcdGXYLayerSubsetList)
applySelection} to know when the
popup is displayed.aObject
- the object we want a string representation from.aGXYLayer
- the layer containing the object.public int getClickSensitivity()
setClickSensitivity(int)
public void setClickSensitivity(int aClickSensitivity)
aClickSensitivity
- The click sensitivity, in pixels.@Deprecated public int selectByWhatMode(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aMouseMode, MouseEvent aMouseEvent)
TLcdGXYSelectController2
instead.SELECT_BY_WHAT_BODIES_ON_CLICK
,
SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINS
, SELECT_BY_WHAT_LABELS_ON_CLICK
and SELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINS
.
This method can be overridden to alter its behavior.aGXYView
- The ILcdGXYView
, provided as contextual
information.aSelectionBounds
- The selection rectangle, in view coordinates
(pixels). This could for example be the rectangle the user dragged on the
map, or a one pixel wide rectangle for a mouse click.aMouseMode
- Either INPUT_MODE_POINT
or INPUT_MODE_RECTANGLE
, indicating if this selection change originated from a
mouse click or from a mouse drag.aMouseEvent
- The last mouse event that was involved in the
selection change.SELECT_BY
.@Deprecated public int selectHowMode(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aMouseMode, MouseEvent aMouseEvent, int aSelectByWhatMode)
TLcdGXYSelectController2
, to allow the same kind of customization.first touched
. Shift inverts
the selection, alt allows the user to
choose
, alt-shift combines these two
(bit-wise or). Other modifier combinations won't change
the selection. A right click that touches the current
selection does not alter the selection either, as the user probably
intended to invoke a popup menu.
This method can be overridden to alter its behavior.aGXYView
- The ILcdGXYView
, provided as contextual
information.aSelectionBounds
- The selection rectangle, in view coordinates
(pixels). This could for example be the rectangle the user dragged on the
map, or a one pixel wide rectangle for a mouse click.aMouseMode
- Either INPUT_MODE_POINT
or INPUT_MODE_RECTANGLE
, indicating if this selection change originated from a
mouse click or from a mouse drag.aMouseEvent
- The last mouse event that was involved in the
selection change.aSelectByWhatMode
- The select-by-what mode, for example the result
of the method selectByWhatMode
. It is a bit-wise
or of the constants in this class that start with SELECT_BY
.SELECT_HOW
.public ILcdGXYLayerSubsetList selectionCandidates(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aMouseMode, MouseEvent aMouseEvent, int aSelectByWhatMode, int aSelectHowMode)
SELECT_HOW_CHOOSE
, or if the
aMouseMode is INPUT_MODE_RECTANGLE
, multiple objects can be
returned, otherwise only one object is returned.
If the aSelectHowMode contains SELECT_HOW_NO_CHANGE
, no selection
candidates are returned.
The aSelectByWhatMode can be composed (bit-wise or) of these values:
SELECT_BY_WHAT_BODIES_ON_CLICK
: depends on the behavior
of isTouched
.
SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINS
: means the boundsSFCT
must be completely inside the
aSelectionBounds.
SELECT_BY_WHAT_BODIES_ON_DRAG_OVERLAPS
: means the
boundsSFCT
must overlap with the
aSelectionBounds.
SELECT_BY_WHAT_LABELS_ON_CLICK
: depends on the behavior
of isLabelTouched
, or labelBoundsSFCT
if no
ILcdGXYLabelPainter2
is available.
SELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINS
: means the labelBoundsSFCT
must be completely
inside the aSelectionBounds.
SELECT_BY_WHAT_LABELS_ON_DRAG_OVERLAPS
: means the
labelBoundsSFCT
must overlap
with the aSelectionBounds.
aGXYView
- The ILcdGXYView
, provided as contextual
information.aSelectionBounds
- The selection rectangle, in view coordinates
(pixels). This could for example be the rectangle the user dragged on the
map, or a one pixel wide rectangle for a mouse click.aMouseMode
- Either INPUT_MODE_POINT
or INPUT_MODE_RECTANGLE
, indicating if this selection change originated from a
mouse click or from a mouse drag.aMouseEvent
- The last mouse event that was involved in the
selection change.aSelectByWhatMode
- The select-by-what mode, for example the result
of the method selectByWhatMode
. It is a bit-wise
or of the constants in this class that start with SELECT_BY
.aSelectHowMode
- The select-how-mode, for example the result of the
method selectHowMode
. It is a bit-wise or of the
constants in this class that start with SELECT_HOW
.ILcdGXYLayerSubsetList
containing the selection
candidates. This list can be empty, but must never be null
.@Deprecated public void applySelection(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aMouseMode, MouseEvent aMouseEvent, int aSelectByWhatMode, int aSelectHowMode, ILcdGXYLayerSubsetList aSelectionCandidates)
applySelection
without the mouseEvent parameter instead.SELECT_HOW_FIRST_TOUCHED
, the
current selection is cleared and the selection candidates are the only
selected objects afterward.
If the aSelectHowMode contains SELECT_HOW_CHOOSE
, a popup
dialog is displayed allowing the user to choose from the selection
candidates. The dialog is either an AWT or a Swing dialog, depending on the
ILcdGXYView
being an AWT or a Swing component. If the user
selects an item from the popup, the selection change depends on the other
information (bit-wise or) that is available in the mode: SELECT_HOW_ADD
, SELECT_HOW_REMOVE
, ...
All other modes simply select (SELECT_HOW_ADD
), deselect
(SELECT_HOW_REMOVE
), or toggle (SELECT_HOW_INVERT
) the selection state of the selection
candidates.
If the aSelectHowMode contains SELECT_HOW_NO_CHANGE
, the selection
remains unchanged.
This method can be overridden to alter its behavior.aGXYView
- The ILcdGXYView
, provided as contextual
information.aSelectionBounds
- The selection rectangle, in view coordinates
(pixels). This could for example be the rectangle the user dragged on the
map, or a one pixel wide rectangle for a mouse click.aMouseMode
- Either INPUT_MODE_POINT
or INPUT_MODE_RECTANGLE
, indicating if this selection change originated from a
mouse click or from a mouse drag.aMouseEvent
- The last mouse event that was involved in the
selection change.aSelectByWhatMode
- The select-by-what mode, for example the result
of the method selectByWhatMode
. It is a bit-wise
or of the constants in this class that start with SELECT_BY
.aSelectHowMode
- The select-how-mode, for example the result of the
method selectHowMode
. It is a bit-wise or of the
constants in this class that start with SELECT_HOW
.aSelectionCandidates
- The objects (and their layers) that are
involved in this selection change. For example the result of the method
selectionCandidates
.public void applySelection(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aInputMode, int aX, int aY, int aSelectByWhatMode, int aSelectHowMode, ILcdGXYLayerSubsetList aSelectionCandidates)
SELECT_HOW_FIRST_TOUCHED
, the
current selection is cleared and the selection candidates are the only
selected objects afterward.
If the aSelectHowMode contains SELECT_HOW_CHOOSE
, a popup
dialog is displayed allowing the user to choose from the selection
candidates. The dialog is either an AWT or a Swing dialog, depending on the
ILcdGXYView
being an AWT or a Swing component. If the user
selects an item from the popup, the selection change depends on the other
information (bit-wise or) that is available in the mode: SELECT_HOW_ADD
, SELECT_HOW_REMOVE
, ...
All other modes simply select (SELECT_HOW_ADD
), deselect
(SELECT_HOW_REMOVE
), or toggle (SELECT_HOW_INVERT
) the selection state of the selection
candidates.
If the aSelectHowMode contains SELECT_HOW_NO_CHANGE
, the selection
remains unchanged.
This method can be overridden to alter its behavior.aGXYView
- The ILcdGXYView
, provided as contextual
information.aSelectionBounds
- The selection rectangle, in view coordinates
(pixels). This could for example be the rectangle the user dragged on the
map, or a one pixel wide rectangle for a mouse click.aInputMode
- Either INPUT_MODE_POINT
or INPUT_MODE_RECTANGLE
, indicating if this selection change originated from a
mouse click or from a mouse drag.aX
- the x-coordinate of the location used for selection.aY
- the y-coordinate of the location used for selection.aSelectByWhatMode
- The select-by-what mode, for example the result
of the method selectByWhatMode
. It is a bit-wise
or of the constants in this class that start with SELECT_BY
.aSelectHowMode
- The select-how-mode, for example the result of the
method selectHowMode
. It is a bit-wise or of the
constants in this class that start with SELECT_HOW
.aSelectionCandidates
- The objects (and their layers) that are
involved in this selection change. For example the result of the method
selectionCandidates
.@Deprecated public static String mouseModeAsString(int aMouseMode)
inputModeAsString(int)
.aMouseMode
- The mouse mode, a bit-wise or of the constants in this
class that start with MOUSE_MODE
.public static String inputModeAsString(int aInputMode)
aInputMode
- The input mode, a bit-wise or of the constants in this
class that start with INPUT_MODE
.public static String selectByWhatAsString(int aSelectByWhat)
aSelectByWhat
- The select by mode, a bit-wise or of the constants in
this class that start with SELECT_BY_WHAT
.public static String selectHowAsString(int aSelectHow)
aSelectHow
- The select how mode, a bit-wise or of the constants in
this class that start with SELECT_HOW
.