1 |
alfonx |
244 |
/******************************************************************************* |
2 |
|
|
* Copyright (c) 2009 Martin O. J. Schmitz. |
3 |
|
|
* |
4 |
|
|
* This file is part of the SCHMITZM library - a collection of utility |
5 |
|
|
* classes based on Java 1.6, focussing (not only) on Java Swing |
6 |
|
|
* and the Geotools library. |
7 |
|
|
* |
8 |
|
|
* The SCHMITZM project is hosted at: |
9 |
|
|
* http://wald.intevation.org/projects/schmitzm/ |
10 |
|
|
* |
11 |
|
|
* This program is free software; you can redistribute it and/or |
12 |
|
|
* modify it under the terms of the GNU Lesser General Public License |
13 |
|
|
* as published by the Free Software Foundation; either version 3 |
14 |
|
|
* of the License, or (at your option) any later version. |
15 |
|
|
* |
16 |
|
|
* This program is distributed in the hope that it will be useful, |
17 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 |
|
|
* GNU General Public License for more details. |
20 |
|
|
* |
21 |
|
|
* You should have received a copy of the GNU Lesser General Public License (license.txt) |
22 |
|
|
* along with this program; if not, write to the Free Software |
23 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 |
|
|
* or try this link: http://www.gnu.org/licenses/lgpl.html |
25 |
|
|
* |
26 |
|
|
* Contributors: |
27 |
|
|
* Martin O. J. Schmitz - initial API and implementation |
28 |
|
|
* Stefan A. Krüger - additional utility classes |
29 |
|
|
******************************************************************************/ |
30 |
alfonx |
96 |
/** |
31 |
|
|
Copyright 2008 Stefan Alfons Krüger |
32 |
|
|
|
33 |
|
|
atlas-framework - This file is part of the Atlas Framework |
34 |
|
|
|
35 |
|
|
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. |
36 |
|
|
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
37 |
|
|
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA |
38 |
|
|
|
39 |
|
|
Diese Bibliothek ist freie Software; Sie dürfen sie unter den Bedingungen der GNU Lesser General Public License, wie von der Free Software Foundation veröffentlicht, weiterverteilen und/oder modifizieren; entweder gemäß Version 2.1 der Lizenz oder (nach Ihrer Option) jeder späteren Version. |
40 |
|
|
Diese Bibliothek wird in der Hoffnung weiterverbreitet, daß sie nützlich sein wird, jedoch OHNE IRGENDEINE GARANTIE, auch ohne die implizierte Garantie der MARKTREIFE oder der VERWENDBARKEIT FÜR EINEN BESTIMMTEN ZWECK. Mehr Details finden Sie in der GNU Lesser General Public License. |
41 |
|
|
Sie sollten eine Kopie der GNU Lesser General Public License zusammen mit dieser Bibliothek erhalten haben; falls nicht, schreiben Sie an die Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA. |
42 |
|
|
**/ |
43 |
|
|
|
44 |
|
|
package skrueger.geotools.selection; |
45 |
|
|
|
46 |
|
|
import org.geotools.feature.Feature; |
47 |
|
|
|
48 |
mojays |
103 |
import skrueger.geotools.StyledFeatureCollectionInterface; |
49 |
|
|
import skrueger.geotools.StyledFeatureSourceInterface; |
50 |
alfonx |
226 |
import skrueger.geotools.StyledFeaturesInterface; |
51 |
alfonx |
224 |
import skrueger.geotools.StyledLayerInterface; |
52 |
alfonx |
96 |
|
53 |
|
|
/** |
54 |
mojays |
103 |
* This manager holds a set of {@link Feature Features} which are <i>selected</i> |
55 |
alfonx |
224 |
* in a {@link StyledLayerInterface} ({@link StyledFeatureCollectionInterface} or |
56 |
mojays |
103 |
* {@link StyledFeatureSourceInterface}). |
57 |
alfonx |
96 |
* @author <a href="mailto:[email protected]">Martin Schmitz</a> (University of Bonn/Germany) |
58 |
|
|
*/ |
59 |
alfonx |
111 |
public class StyledFeatureLayerSelectionModel extends StyledLayerSelectionModel<String> { |
60 |
mojays |
103 |
/** |
61 |
|
|
* Creates a new selection model. |
62 |
alfonx |
224 |
* @param styledLayer styled map the selection is controlled of |
63 |
mojays |
103 |
*/ |
64 |
alfonx |
226 |
public StyledFeatureLayerSelectionModel(StyledFeaturesInterface styledLayer) { |
65 |
alfonx |
224 |
super(styledLayer); |
66 |
mojays |
103 |
} |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
//*********** UNUSED STUFF ************** |
71 |
|
|
|
72 |
|
|
// /** A static logger for this class */ |
73 |
|
|
// private static final Logger LOGGER = Logger.getLogger(StyledFeatureLayerSelectionModel.class); |
74 |
|
|
// /** Holds the current selection as {@link Style}. */ |
75 |
|
|
// protected Style selectionMapStyle = null; |
76 |
|
|
// /** Holds the current selection as {@link Filter}. */ |
77 |
|
|
// protected Filter selectionFilter = null; |
78 |
|
|
// /** Holds the current selection as {@code ChartStyle}. |
79 |
|
|
// * TODO: determine an appropriate type for the chart styling. */ |
80 |
|
|
// protected Object selectionChartStyle = null; |
81 |
alfonx |
96 |
// |
82 |
|
|
// /** |
83 |
|
|
// * Creates a new selection model. |
84 |
|
|
// * @param layer layer to control the selection of |
85 |
|
|
// */ |
86 |
|
|
// public StyledFeatureLayerSelectionModel() { |
87 |
|
|
// } |
88 |
|
|
// |
89 |
|
|
// /** |
90 |
|
|
// * Not yet implemented! |
91 |
|
|
// * Extends the current selection by all features contained by |
92 |
|
|
// * the specified {@link Envelope}. |
93 |
|
|
// * @param env defines a bounding box |
94 |
|
|
// */ |
95 |
|
|
// public void addSelection(Envelope env) { |
96 |
|
|
// // TODO: implement me! |
97 |
|
|
// refreshSelection(); |
98 |
|
|
// } |
99 |
|
|
// |
100 |
|
|
// /** |
101 |
|
|
// * Not yet implemented! |
102 |
|
|
// * Reduces the current selection by all features contained by |
103 |
|
|
// * the specified {@link Envelope}. |
104 |
|
|
// * @param env defines a bounding box |
105 |
|
|
// */ |
106 |
|
|
// public void removeSelection(Envelope env) { |
107 |
|
|
// // TODO: implement me! |
108 |
|
|
// refreshSelection(); |
109 |
|
|
// } |
110 |
|
|
// |
111 |
|
|
// /** |
112 |
|
|
// * Not yet implemented! |
113 |
|
|
// * Extends the current selection by all features accepted by |
114 |
|
|
// * the specified {@link Filter}. |
115 |
|
|
// * @param filter defines some features of the layer |
116 |
|
|
// * @return {@code true} if selection has changed by calling this method |
117 |
|
|
// */ |
118 |
|
|
// public boolean addSelection(Filter filter) { |
119 |
|
|
// // TODO: implement me! |
120 |
|
|
// refreshSelection(); |
121 |
|
|
// return false; |
122 |
|
|
// } |
123 |
|
|
// |
124 |
|
|
// /** |
125 |
|
|
// * Not yet implemented! |
126 |
|
|
// * Removes all features accepted by the specified {@link Filter} from the |
127 |
|
|
// * selection. |
128 |
|
|
// * @param filter defines some features of the layer |
129 |
|
|
// * @return {@code true} if selection has changed by calling this method |
130 |
|
|
// */ |
131 |
|
|
// public boolean removeSelection(Filter filter) { |
132 |
|
|
// // TODO: implement me! |
133 |
|
|
// refreshSelection(); |
134 |
|
|
// return false; |
135 |
|
|
// } |
136 |
|
|
// |
137 |
|
|
// /** |
138 |
|
|
// * Returns a {@link Filter}, which defines the current selection. |
139 |
|
|
// */ |
140 |
|
|
// public Filter getSelectionAsFilter() { |
141 |
|
|
// return selectionFilter; |
142 |
|
|
// } |
143 |
|
|
// |
144 |
|
|
// /** |
145 |
|
|
// * Returns a {@link Style}, which highlights the current selection. |
146 |
|
|
// */ |
147 |
|
|
// public Style getSelectionAsStyle() { |
148 |
|
|
// return selectionMapStyle; |
149 |
|
|
// } |
150 |
|
|
// |
151 |
|
|
// /** |
152 |
|
|
// * Resets all selection objects with the new selection. |
153 |
|
|
// */ |
154 |
|
|
// protected void resetSelectionObjects() { |
155 |
|
|
//// resetMapStyle(); // TODO go to mapLayerSync |
156 |
|
|
// resetFilter(); |
157 |
|
|
// resetChartStyle(); |
158 |
|
|
// } |
159 |
|
|
// |
160 |
|
|
// |
161 |
|
|
//// |
162 |
|
|
//// /** |
163 |
|
|
//// * Creates a {@link Style} to highlight the current selection. |
164 |
|
|
//// */ |
165 |
|
|
//// protected void resetMapStyle() { |
166 |
|
|
//// selectionMapStyle = null; |
167 |
|
|
//// try { |
168 |
|
|
//// if ( selectionFeatures.isEmpty() ) |
169 |
|
|
//// selectionMapStyle = getLayer().getStyle(); |
170 |
|
|
//// else |
171 |
|
|
//// selectionMapStyle = StylingUtil.createDefaultStyle(getLayer().getGeoObject()); |
172 |
|
|
//// |
173 |
|
|
////// getLayer().setStyle(selectionMapStyle); |
174 |
|
|
//// } catch (Exception e) { |
175 |
|
|
//// LOGGER.error("Error while trying to create a selection style",e); |
176 |
|
|
//// } |
177 |
|
|
//// } |
178 |
|
|
// |
179 |
|
|
// /** |
180 |
|
|
// * Creates a {@link Filter} for the current selection. |
181 |
|
|
// */ |
182 |
|
|
// protected void resetFilter() { |
183 |
|
|
// // create a filter which accepts all Features contained |
184 |
|
|
// // in the selection list |
185 |
|
|
// selectionFilter = new AbstractFilterImpl( FeatureUtil.FILTER_FACTORY ) { |
186 |
|
|
// public boolean evaluate(Object feature) { |
187 |
|
|
// if ( feature instanceof Feature ) |
188 |
|
|
// return evaluate((Filter)feature); |
189 |
|
|
// return false; |
190 |
|
|
// } |
191 |
|
|
// public boolean evaluate(Feature feature) { |
192 |
|
|
// return selectionFeatures.contains(feature); |
193 |
|
|
// } |
194 |
|
|
// }; |
195 |
|
|
// } |
196 |
|
|
// |
197 |
|
|
// /** |
198 |
|
|
// * Not yet implemented! |
199 |
|
|
// * Creates a {@code ChartStyle} to highlight the current selection. |
200 |
|
|
// */ |
201 |
|
|
// protected void resetChartStyle() { |
202 |
|
|
// selectionChartStyle = null; |
203 |
|
|
// // TODO: define the selectionChartStyle |
204 |
|
|
// } |
205 |
|
|
} |