Class TLcdGXYSelectControllerModel2

java.lang.Object
com.luciad.view.gxy.controller.TLcdGXYSelectControllerModel2

public class TLcdGXYSelectControllerModel2 extends Object

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

    Fields
    Modifier and Type
    Field
    Description
    static 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.
    replaced by INPUT_MODE_POINT
    static final int
    Deprecated.
    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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    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.
    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
    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.
    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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SELECT_BY_WHAT_BODIES_ON_CLICK

      public static final int SELECT_BY_WHAT_BODIES_ON_CLICK
      Mode defining that clicking on the body of an object can change the selection. The body is defined as in ILcdGXYPainter.BODY.
    • SELECT_BY_WHAT_BODIES_ON_DRAG_CONTAINS

      public static final 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. The body is defined as in ILcdGXYPainter.BODY.
    • SELECT_BY_WHAT_BODIES_ON_DRAG_OVERLAPS

      public static final 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. The body is defined as in 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.

    • SELECT_BY_WHAT_LABELS_ON_CLICK

      public static final int SELECT_BY_WHAT_LABELS_ON_CLICK
      Mode defining that clicking on the label of an object can change the selection.
      Selecting objects using their label requires the use of an ILcdGXYEditableLabelsLayer.
    • SELECT_BY_WHAT_LABELS_ON_DRAG_CONTAINS

      public static final 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.
      Selecting objects using their label requires the use of an ILcdGXYEditableLabelsLayer.
    • SELECT_BY_WHAT_LABELS_ON_DRAG_OVERLAPS

      public static final 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.
      Selecting objects using their label requires the use of an ILcdGXYEditableLabelsLayer.

    • SELECT_HOW_CHOOSE

      public static final 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.

    • SELECT_HOW_FIRST_TOUCHED

      public static final int SELECT_HOW_FIRST_TOUCHED
      Mode 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_ADD
      Mode defining that the candidates for the selection should be added to the current selection.
    • SELECT_HOW_REMOVE

      public static final int SELECT_HOW_REMOVE
      Mode defining that the candidates for the selection should be removed from the current selection.
    • SELECT_HOW_INVERT

      public static final 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.
    • SELECT_HOW_NO_CHANGE

      public static final int SELECT_HOW_NO_CHANGE
      Mode defining that no changes must be made to the selection.
    • MOUSE_MODE_DRAG

      @Deprecated public static final int MOUSE_MODE_DRAG
      Deprecated.
      Mode defining that the selection was originated by a mouse drag.
    • MOUSE_MODE_CLICK

      @Deprecated public static final int MOUSE_MODE_CLICK
      Deprecated.
      replaced by INPUT_MODE_POINT
      Mode defining that the selection was originated by a mouse click.
    • INPUT_MODE_RECTANGLE

      public static final int INPUT_MODE_RECTANGLE
      Mode defining that the selection was originated by dragging a rectangle.
    • INPUT_MODE_POINT

      public static final int INPUT_MODE_POINT
      Mode 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 of TLcdGXYContext 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 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.
      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 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.
      Parameters:
      aPopupDeltaY - the delta in the y-direction.
      See Also:
    • formatObject

      protected String formatObject(Object aObject, ILcdGXYLayer aGXYLayer)
      This method returns a String representation of the given domain 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.

      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 the TLcdGXYSelectController2 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 of 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.

      Parameters:
      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.
      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 to TLcdGXYSelectController2, 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 is 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.

      Parameters:
      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.
      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 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:

      This method can be overridden to alter its behavior.
      Parameters:
      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.
      Returns:
      A ILcdGXYLayerSubsetList containing the selection candidates. This list can be empty, but must never be null.
    • applySelection

      @Deprecated public void applySelection(ILcdGXYView aGXYView, Rectangle aSelectionBounds, int aMouseMode, MouseEvent aMouseEvent, int aSelectByWhatMode, int aSelectHowMode, ILcdGXYLayerSubsetList aSelectionCandidates)
      Deprecated.
      use applySelection without the mouseEvent parameter instead.
      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. 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.

      Parameters:
      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.
    • 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 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. 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.

      Parameters:
      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.
    • mouseModeAsString

      @Deprecated public static String mouseModeAsString(int aMouseMode)
      Deprecated.
      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 with MOUSE_MODE.
      Returns:
      A human readable string representation for the given mouse mode.
    • inputModeAsString

      public static String inputModeAsString(int aInputMode)
      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 with INPUT_MODE.
      Returns:
      A human readable string representation for the given input mode.
    • selectByWhatAsString

      public static String selectByWhatAsString(int aSelectByWhat)
      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 with SELECT_BY_WHAT.
      Returns:
      A human readable string representation for the given select-by-what mode.
    • selectHowAsString

      public static String selectHowAsString(int aSelectHow)
      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 with SELECT_HOW.
      Returns:
      A human readable string representation for the given select-how mode.