Class TLcdGXYSelectControllerModel2
Controller model for selection of objects in a view, used by the TLcdGXYSelectController2
.
How selection works
The class javadoc of the TLcdGXYSelectController2
explains how the select controller and this controller model work together to update the selection.
Customizing the selection behavior
Which domain objects are used as selection candidates
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.
Supporting custom selection update behavior
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.
Customizing the string representation of the domain objects in the pop-up when using the CHOOSE mode
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.
- Since:
- 7.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Mode defining that the selection was originated by a single interaction.static final int
Mode defining that the selection was originated by dragging a rectangle.static final int
Deprecated.static final int
Deprecated.replaced byINPUT_MODE_RECTANGLE
static final int
Mode defining that clicking on the body of an object can change the selection.static final int
Mode defining that dragging over the body of an object can change the selection, if the body lies within the selection rectangle.static final int
Mode defining that dragging over the body of an object can change the selection, if the body overlaps with the selection rectangle.static final int
Mode defining that clicking on the label of an object can change the selection.static final int
Mode defining that dragging over the label of an object can change the selection, if the label lies within the selection rectangle.static final int
Mode defining that dragging over the label of an object can change the selection, if the label overlaps with the selection rectangle.static final int
Mode defining that the candidates for the selection should be added to the current selection.static final int
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.static final int
Mode defining that the first (topmost) object should be selected, and that the possible existing selection should be cleared.static final int
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 final int
Mode defining that no changes must be made to the selection.static final int
Mode defining that the candidates for the selection should be removed from the current selection. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.void
applySelection
(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aMouseMode, MouseEvent aMouseEvent, int aSelectByWhatMode, int aSelectHowMode, ILcdGXYLayerSubsetList aSelectionCandidates) Deprecated.useapplySelection
without the mouseEvent parameter instead.protected String
formatObject
(Object aObject, ILcdGXYLayer aGXYLayer) This method returns a String representation of the given domainObject
contained in the givenILcdGXYLayer
.int
Returns the click sensitivity.int
Returns popup delta x.int
Returns the popup delta y.int
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 byinputModeAsString(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.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.selectionCandidates
(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aMouseMode, MouseEvent aMouseEvent, int aSelectByWhatMode, int aSelectHowMode) Returns the selection candidates for the given selection bounds and modes.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).
-
Field Details
-
SELECT_BY_WHAT_BODIES_ON_CLICK
public static final int SELECT_BY_WHAT_BODIES_ON_CLICKMode defining that clicking on the body of an object can change the selection. The body is defined as inILcdGXYPainter.BODY
. -
SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINS
public static final int SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINSMode defining that dragging over the body of an object can change the selection, if the body lies within the selection rectangle. The body is defined as inILcdGXYPainter.BODY
. -
SELECT_BY_WHAT_BODIES_ON_DRAG_OVERLAPS
public static final int SELECT_BY_WHAT_BODIES_ON_DRAG_OVERLAPSMode defining that dragging over the body of an object can change the selection, if the body overlaps with the selection rectangle. The body is defined as inILcdGXYPainter.BODY
. Note: the implementation is based onboundsSFCT
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. -
SELECT_BY_WHAT_LABELS_ON_CLICK
public static final int SELECT_BY_WHAT_LABELS_ON_CLICKMode defining that clicking on the label of an object can change the selection.
Selecting objects using their label requires the use of anILcdGXYEditableLabelsLayer
. -
SELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINS
public static final int SELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINSMode defining that dragging over the label of an object can change the selection, if the label lies within the selection rectangle.
Selecting objects using their label requires the use of anILcdGXYEditableLabelsLayer
. -
SELECT_BY_WHAT_LABELS_ON_DRAG_OVERLAPS
public static final int SELECT_BY_WHAT_LABELS_ON_DRAG_OVERLAPSMode 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 onlabelBoundsSFCT
and therefore this mode might not behave intuitive if the bounds of the label are different from the actual representation of the label.
Selecting objects using their label requires the use of anILcdGXYEditableLabelsLayer
. -
SELECT_HOW_CHOOSE
public static final int SELECT_HOW_CHOOSEMode 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 asSELECT_HOW_ADD
. -
SELECT_HOW_FIRST_TOUCHED
public static final int SELECT_HOW_FIRST_TOUCHEDMode defining that the first (topmost) object should be selected, and that the possible existing selection should be cleared. -
SELECT_HOW_ADD
public static final int SELECT_HOW_ADDMode defining that the candidates for the selection should be added to the current selection. -
SELECT_HOW_REMOVE
public static final int SELECT_HOW_REMOVEMode defining that the candidates for the selection should be removed from the current selection. -
SELECT_HOW_INVERT
public static final int SELECT_HOW_INVERTMode 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. -
SELECT_HOW_NO_CHANGE
public static final int SELECT_HOW_NO_CHANGEMode defining that no changes must be made to the selection. -
MOUSE_MODE_DRAG
Deprecated.replaced byINPUT_MODE_RECTANGLE
Mode defining that the selection was originated by a mouse drag. -
MOUSE_MODE_CLICK
Deprecated.replaced byINPUT_MODE_POINT
Mode defining that the selection was originated by a mouse click. -
INPUT_MODE_RECTANGLE
public static final int INPUT_MODE_RECTANGLEMode defining that the selection was originated by dragging a rectangle. -
INPUT_MODE_POINT
public static final int INPUT_MODE_POINTMode defining that the selection was originated by a single interaction.
-
-
Constructor Details
-
TLcdGXYSelectControllerModel2
public TLcdGXYSelectControllerModel2()
-
-
Method Details
-
getSensitivity
public int getSensitivity()This method returns the sensitivity that will be used when selecting objects or labels. It indicates how far (in screen coordinates) the input location (mouse cursor, etc...) can be from the visual representation of an object on the screen and still interact with it. This value will be passed to all created instances ofTLcdGXYContext
passed to the painters.- Returns:
- the sensitivity to be used for selecting objects.
- See Also:
-
setSensitivity
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).- Parameters:
aSensitivity
- the sensitivity that will be used for selecting objects.- See Also:
-
getPopupDeltaX
public int getPopupDeltaX()Returns popup delta x.- Returns:
- popup delta x.
- See Also:
-
setPopupDeltaX
public void setPopupDeltaX(int aPopupDeltaX) Sets the horizontal gap between the location of the mouse pointer and the popup menu. Please refer toapplySelection(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.- Parameters:
aPopupDeltaX
- the delta in the x-direction.- See Also:
-
getPopupDeltaY
public int getPopupDeltaY()Returns the popup delta y.- Returns:
- the popup delta y.
- See Also:
-
setPopupDeltaY
public void setPopupDeltaY(int aPopupDeltaY) Sets the horizontal gap between the location of the mouse pointer and the popup menu. Please refer toapplySelection(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.- Parameters:
aPopupDeltaY
- the delta in the y-direction.- See Also:
-
formatObject
This method returns a String representation of the given domainObject
contained in the givenILcdGXYLayer
. The name is used to display in the popup menu. This method can be redefined. Please refer toapplySelection(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.- Parameters:
aObject
- the object we want a string representation from.aGXYLayer
- the layer containing the object.- Returns:
- aObject.toString()
-
getClickSensitivity
public int getClickSensitivity()Returns the click sensitivity.- Returns:
- the click sensitivity.
- See Also:
-
setClickSensitivity
public void setClickSensitivity(int aClickSensitivity) Sets the click sensitivity. This value represents the largest possible difference (in pixels) between the representation of an object, and the actual object. If for example icons are used to represent points on the map, the icon could be 16 by 16 pixels, whereas the object itself is a point, having a zero size. So the required sensitivity for this example is 16 pixels. The drawback of setting a too large value is a performance loss, the drawback of setting a too small value is that objects (e.g., icons) could be difficult to select if they are clicked on near the edge of the icon.- Parameters:
aClickSensitivity
- The click sensitivity, in pixels.
-
selectByWhatMode
@Deprecated public 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 theTLcdGXYSelectController2
instead.Returns the mode that defines by what objects can be selected: by their bodies, their labels, ... The default value is a bit-wise or ofSELECT_BY_WHAT_BODIES_ON_CLICK
,SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINS
,SELECT_BY_WHAT_LABELS_ON_CLICK
andSELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINS
. This method can be overridden to alter its behavior.- Parameters:
aGXYView
- TheILcdGXYView
, 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
- EitherINPUT_MODE_POINT
orINPUT_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.- Returns:
- The select-by-what mode, a bit-wise or of the constants defined in
this class that start with
SELECT_BY
.
-
selectHowMode
@Deprecated public 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 toTLcdGXYSelectController2
, to allow the same kind of customization.Returns the mode that defines how the objects involved in the selection should interact with the existing selection, for example add them, remove them, toggle their selection state, etc. By default, if no modifiers are pressed the mode isfirst touched
. Shiftinverts
the selection, alt allows the user tochoose
, alt-shift combines these two (bit-wise or). Other modifier combinationswon'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.- Parameters:
aGXYView
- TheILcdGXYView
, 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
- EitherINPUT_MODE_POINT
orINPUT_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 methodselectByWhatMode
. It is a bit-wise or of the constants in this class that start withSELECT_BY
.- Returns:
- The select-how mode, a bit-wise or of the constants in this class
that start with
SELECT_HOW
.
-
selectionCandidates
public 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 containsSELECT_HOW_CHOOSE
, or if the aMouseMode isINPUT_MODE_RECTANGLE
, multiple objects can be returned, otherwise only one object is returned. If the aSelectHowMode containsSELECT_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 ofisTouched
.SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINS
: means theboundsSFCT
must be completely inside the aSelectionBounds.SELECT_BY_WHAT_BODIES_ON_DRAG_OVERLAPS
: means theboundsSFCT
must overlap with the aSelectionBounds.SELECT_BY_WHAT_LABELS_ON_CLICK
: depends on the behavior ofisLabelTouched
, orlabelBoundsSFCT
if noILcdGXYLabelPainter2
is available.SELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINS
: means thelabelBoundsSFCT
must be completely inside the aSelectionBounds.SELECT_BY_WHAT_LABELS_ON_DRAG_OVERLAPS
: means thelabelBoundsSFCT
must overlap with the aSelectionBounds.
- Parameters:
aGXYView
- TheILcdGXYView
, 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
- EitherINPUT_MODE_POINT
orINPUT_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 methodselectByWhatMode
. It is a bit-wise or of the constants in this class that start withSELECT_BY
.aSelectHowMode
- The select-how-mode, for example the result of the methodselectHowMode
. It is a bit-wise or of the constants in this class that start withSELECT_HOW
.- Returns:
- A
ILcdGXYLayerSubsetList
containing the selection candidates. This list can be empty, but must never benull
.
-
applySelection
@Deprecated public void applySelection(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aMouseMode, MouseEvent aMouseEvent, int aSelectByWhatMode, int aSelectHowMode, ILcdGXYLayerSubsetList aSelectionCandidates) Deprecated.useapplySelection
without the mouseEvent parameter instead.Modifies the current selection, according to the given selection candidates and by respecting the given modes. If the aSelectHowMode containsSELECT_HOW_FIRST_TOUCHED
, the current selection is cleared and the selection candidates are the only selected objects afterward. If the aSelectHowMode containsSELECT_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 theILcdGXYView
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 containsSELECT_HOW_NO_CHANGE
, the selection remains unchanged. This method can be overridden to alter its behavior.- Parameters:
aGXYView
- TheILcdGXYView
, 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
- EitherINPUT_MODE_POINT
orINPUT_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 methodselectByWhatMode
. It is a bit-wise or of the constants in this class that start withSELECT_BY
.aSelectHowMode
- The select-how-mode, for example the result of the methodselectHowMode
. It is a bit-wise or of the constants in this class that start withSELECT_HOW
.aSelectionCandidates
- The objects (and their layers) that are involved in this selection change. For example the result of the methodselectionCandidates
.
-
applySelection
public 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 containsSELECT_HOW_FIRST_TOUCHED
, the current selection is cleared and the selection candidates are the only selected objects afterward. If the aSelectHowMode containsSELECT_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 theILcdGXYView
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 containsSELECT_HOW_NO_CHANGE
, the selection remains unchanged. This method can be overridden to alter its behavior.- Parameters:
aGXYView
- TheILcdGXYView
, 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
- EitherINPUT_MODE_POINT
orINPUT_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 methodselectByWhatMode
. It is a bit-wise or of the constants in this class that start withSELECT_BY
.aSelectHowMode
- The select-how-mode, for example the result of the methodselectHowMode
. It is a bit-wise or of the constants in this class that start withSELECT_HOW
.aSelectionCandidates
- The objects (and their layers) that are involved in this selection change. For example the result of the methodselectionCandidates
.
-
mouseModeAsString
Deprecated.Replaced byinputModeAsString(int)
.Utility method that converts the given mouse mode to a human readable string. This method is intended for debugging or logging purposes.- Parameters:
aMouseMode
- The mouse mode, a bit-wise or of the constants in this class that start withMOUSE_MODE
.- Returns:
- A human readable string representation for the given mouse mode.
-
inputModeAsString
Utility method that converts the given input mode to a human readable string. This method is intended for debugging or logging purposes.- Parameters:
aInputMode
- The input mode, a bit-wise or of the constants in this class that start withINPUT_MODE
.- Returns:
- A human readable string representation for the given input mode.
-
selectByWhatAsString
Utility method that converts the given select-by-what mode to a human readable string. This method is intended for debugging or logging purposes.- Parameters:
aSelectByWhat
- The select by mode, a bit-wise or of the constants in this class that start withSELECT_BY_WHAT
.- Returns:
- A human readable string representation for the given select-by-what mode.
-
selectHowAsString
Utility method that converts the given select-how mode to a human readable string. This method is intended for debugging or logging purposes.- Parameters:
aSelectHow
- The select how mode, a bit-wise or of the constants in this class that start withSELECT_HOW
.- Returns:
- A human readable string representation for the given select-how mode.
-
INPUT_MODE_POINT