Class SelectionEvent

  • All Implemented Interfaces:
    java.io.Serializable

    public class SelectionEvent
    extends TimeStampedEvent
    An event issued when the user activates a different object or selects a number of objects. This might occur for example when the user clicks on a region on the map.
    See Also:
    SelectionListener, EventDispatcher, Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ST_DEFAULT
      Default selection type.
      static int ST_REGIONS
      Indicates, that some regions on the map have been selected or shall be selected.
      • Fields inherited from class java.util.EventObject

        source
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected SelectionEvent​(java.lang.Object source, java.util.List<java.util.List<java.lang.Object>> contexts, int selectionType)  
    • Field Detail

      • ST_REGIONS

        public static final int ST_REGIONS
        Indicates, that some regions on the map have been selected or shall be selected.

        Used by the SelectionActions classes and in the Mapper class. These selections have to be ignored by some components (like EMapOverviewPanel) as the selectionstate of the map is not mirrored in the tree in EMapOverviewPanel. On the other hand the Mapper class should ignore all SelectionEvents with a type different to ST_REGIONS (This makes it possible for the user to treat selections of regions on the map and other selections in different ways.)

        See Also:
        Constant Field Values
    • Constructor Detail

      • SelectionEvent

        protected SelectionEvent​(java.lang.Object source,
                                 java.util.List<java.util.List<java.lang.Object>> contexts,
                                 int selectionType)
        Parameters:
        source - should not be null
        contexts - may only be null if selectedObjects is empty or null.
        selectionType -
    • Method Detail

      • getSelectedObjects

        public java.util.List<java.lang.Object> getSelectedObjects()
        Returns the possibly multiple objects selected by the user. They do not necessarily include the active object. A value of null indicates that previously selected objects are not affected by this event.
      • getContexts

        public java.util.List<java.util.List<java.lang.Object>> getContexts()
        Returns the possibly multiple objects selected by the user. They do not necessarily include the active object. A value of null indicates that previously selected objects are not affected by this event.
      • getActiveObject

        public java.lang.Object getActiveObject()
        Returns the one single object activated by the user. A ST_REGIONS selection never has an active object.
      • getSelectionType

        public int getSelectionType()
        Returns the type of the SelectionEvent. This has to be one of final int-values defined above (like ST_REGIONS, ST_DEFAULT).
      • create

        public static SelectionEvent create​(java.lang.Object source,
                                            SelectionEvent event)
        Copies an event to an event with a new source.
      • create

        public static SelectionEvent create​(java.lang.Object source,
                                            HasRegion hasRegion)
        Select a single HasRegion.
        Parameters:
        source -
        hasRegion -
      • create

        public static SelectionEvent create​(java.lang.Object source,
                                            Region region)
        Select a single region.
        Parameters:
        source -
        region -
      • create

        public static SelectionEvent create​(java.lang.Object source,
                                            Region activeRegion,
                                            java.util.Collection<Region> regions)
        Select a number of Regions with one active Region
        Parameters:
        source -
        activeRegion - null allowed
        regions -
      • create

        public static SelectionEvent create​(java.lang.Object source,
                                            HasRegion activeUnit,
                                            java.util.Collection<? extends HasRegion> selectedObjects)
        Select a number of HasRegions with one active object
        Parameters:
        source -
        activeUnit - null allowed
        selectedObjects -
      • create

        public static SelectionEvent create​(java.lang.Object source,
                                            java.util.Collection<Region> regions)
        Make a ST_REGIONS selection.
        Parameters:
        source -
        regions -
      • create

        public static SelectionEvent create​(java.lang.Object source,
                                            java.util.List<? extends java.util.List<?>> contexts)
        Creates a ST_DEFAULT SelectionEvent with all the details.
        Parameters:
        source -
        contexts -
      • create

        public static SelectionEvent create​(java.lang.Object source,
                                            java.lang.Object selection,
                                            int mode)
        Select one arbitrary object
        Parameters:
        source -
        selection -
        mode -
      • isSingleSelection

        public boolean isSingleSelection()
        Returns true if only a single object has been selected and it is not a ST_REGIONS selection.
      • create

        public static SelectionEvent create​(java.lang.Object source)
        Creates an empty selection event.
        Parameters:
        source -
        Returns:
        A new event.
      • equals

        public boolean equals​(java.lang.Object obj)
        Ignores the source.
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object