View Javadoc
1   package fr.ifremer.dali.ui.swing.util.map;
2   
3   /*-
4    * #%L
5    * Dali :: UI
6    * %%
7    * Copyright (C) 2014 - 2017 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Affero General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Affero General Public License
20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  
24  import fr.ifremer.dali.ui.swing.util.map.layer.DataFeatureLayer;
25  import org.geotools.geometry.DirectPosition2D;
26  
27  import java.awt.Point;
28  import java.util.EventObject;
29  import java.util.Set;
30  
31  /**
32   * @author peck7 on 14/09/2017.
33   */
34  public class DataSelectionEvent extends EventObject {
35  
36      public enum Type {
37  
38          /**
39           * The selectedDataLayers layer selection
40           * The selectedDataLayers object is a Set of <{@link DataFeatureLayer}/>
41           */
42          DATA_LAYER_SELECTED,
43  
44          /**
45           * Empty selection
46           */
47          EMPTY_SELECTION
48      }
49  
50      private Type type;
51  
52      private Set<DataFeatureLayer> selectedDataLayers;
53  
54      private Point screenPoint;
55  
56      private DirectPosition2D worldPos;
57  
58      public DataSelectionEvent(DataMapPane source, Type type) {
59          this(source, type, null, null, null);
60      }
61  
62      /**
63       * Constructs the Event.
64       *
65       * @param source      The object on which the Event initially occurred.
66       * @param type        the type of event
67       * @param dataLayers  the selected data layers
68       * @param screenPoint the selection point in screen coordinates
69       * @param worldPos    the selection point in world coordinates
70       * @throws IllegalArgumentException if source is null.
71       */
72      public DataSelectionEvent(DataMapPane source, Type type, Set<DataFeatureLayer> dataLayers, Point screenPoint, DirectPosition2D worldPos) {
73          super(source);
74          this.type = type;
75          this.selectedDataLayers = dataLayers;
76          this.screenPoint = screenPoint;
77          this.worldPos = worldPos;
78      }
79  
80      @Override
81      public DataMapPane getSource() {
82          return (DataMapPane) super.getSource();
83      }
84  
85      public Type getType() {
86          return type;
87      }
88  
89      public Set<DataFeatureLayer> getSelectedDataLayers() {
90          return selectedDataLayers;
91      }
92  
93      public Point getScreenPoint() {
94          return screenPoint;
95      }
96  
97      public DirectPosition2D getWorldPos() {
98          return worldPos;
99      }
100 }