Revision 42219
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/impl/DefaultGraphicLayer.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License
|
|
8 |
* as published by the Free Software Foundation; either version 3
|
|
9 |
* of the License, or (at your option) any later version.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 10 |
* |
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
* GNU General Public License for more details.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
package org.gvsig.fmap.mapcontext.layers.vectorial.impl; |
25 | 24 |
|
... | ... | |
59 | 58 |
import org.slf4j.LoggerFactory; |
60 | 59 |
|
61 | 60 |
/** |
62 |
* Default {@link GraphicLayer} implementation. |
|
61 |
* Default {@link GraphicLayer} implementation. |
|
62 |
* |
|
63 | 63 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
64 | 64 |
*/ |
65 |
public class DefaultGraphicLayer extends FLyrVect implements GraphicLayer{ |
|
66 |
private static final String DEFAULT = "default"; |
|
67 |
protected static final Logger logger = LoggerFactory.getLogger(DefaultGraphicLayer.class); |
|
68 |
private static DataManager dataManager = DALLocator.getDataManager(); |
|
69 |
private IVectorialUniqueValueLegend legend = null; |
|
70 |
|
|
71 |
private FeatureStore store = null; |
|
72 |
private long ids = 0; |
|
65 |
public class DefaultGraphicLayer extends FLyrVect implements GraphicLayer { |
|
73 | 66 |
|
74 |
private int symbolId = -1; |
|
75 |
|
|
76 |
private int featureIdIndex; |
|
77 |
private int groupIdIndex; |
|
78 |
private int geomIndex; |
|
79 |
private int idsymIndex; |
|
80 |
private int labelIndex; |
|
81 |
private int tagIndex; |
|
82 |
private int priorityIndex; |
|
83 |
|
|
84 |
public void initialize(IProjection projection) throws ValidateDataParametersException, DataException, LoadLayerException { |
|
85 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
86 |
store = dataManager.createMemoryStore(FEATURE_ATTR_PRIORITY); |
|
87 |
store.edit(); |
|
67 |
private static final String DEFAULT = "default"; |
|
68 |
protected static final Logger logger = LoggerFactory.getLogger(DefaultGraphicLayer.class); |
|
69 |
private static DataManager dataManager = DALLocator.getDataManager(); |
|
70 |
private IVectorialUniqueValueLegend legend = null; |
|
88 | 71 |
|
89 |
EditableFeatureType editableFeatureType = store.getDefaultFeatureType().getEditable(); |
|
72 |
private FeatureStore store = null; |
|
73 |
private long ids = 0; |
|
90 | 74 |
|
91 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_GROUPID, DataTypes.STRING);
|
|
75 |
private int symbolId = -1;
|
|
92 | 76 |
|
93 |
EditableFeatureAttributeDescriptor geometryDescriptor = editableFeatureType.add(GraphicLayer.FEATURE_ATTR_GEOMETRY, DataTypes.GEOMETRY); |
|
94 |
try { |
|
95 |
geometryDescriptor.setGeometryType(geomManager.getGeometryType(TYPES.GEOMETRY, SUBTYPES.GEOM2D)); |
|
96 |
} catch (Exception e) { |
|
97 |
logger.info("Can't create/assign geomery type to feature type of GraphicLayer.", e); |
|
98 |
} |
|
99 |
geometryDescriptor.setSRS(projection); |
|
100 |
editableFeatureType.setDefaultGeometryAttributeName(GraphicLayer.FEATURE_ATTR_GEOMETRY); |
|
77 |
private int featureIdIndex; |
|
78 |
private int groupIdIndex; |
|
79 |
private int geomIndex; |
|
80 |
private int idsymIndex; |
|
81 |
private int labelIndex; |
|
82 |
private int tagIndex; |
|
83 |
private int priorityIndex; |
|
101 | 84 |
|
102 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_IDSYMBOL, DataTypes.INT); |
|
85 |
public void initialize(IProjection projection) throws ValidateDataParametersException, DataException, LoadLayerException { |
|
86 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
87 |
store = dataManager.createMemoryStore(FEATURE_ATTR_PRIORITY); |
|
88 |
store.edit(); |
|
103 | 89 |
|
104 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_LABEL, DataTypes.STRING);
|
|
90 |
EditableFeatureType editableFeatureType = store.getDefaultFeatureType().getEditable();
|
|
105 | 91 |
|
106 |
EditableFeatureAttributeDescriptor featureIdDescriptor = |
|
107 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_FEATUREID, DataTypes.LONG); |
|
92 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_GROUPID, DataTypes.STRING); |
|
108 | 93 |
|
109 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_TAG, DataTypes.OBJECT); |
|
110 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_PRIORITY, DataTypes.INT); |
|
111 |
|
|
112 |
featureIdDescriptor.setIsPrimaryKey(true); |
|
113 |
editableFeatureType.setHasOID(true); |
|
94 |
EditableFeatureAttributeDescriptor geometryDescriptor = editableFeatureType.add(GraphicLayer.FEATURE_ATTR_GEOMETRY, DataTypes.GEOMETRY); |
|
95 |
try { |
|
96 |
geometryDescriptor.setGeometryType(geomManager.getGeometryType(TYPES.GEOMETRY, SUBTYPES.GEOM2D)); |
|
97 |
} catch (Exception e) { |
|
98 |
logger.info("Can't create/assign geomery type to feature type of GraphicLayer.", e); |
|
99 |
} |
|
100 |
geometryDescriptor.setSRS(projection); |
|
101 |
editableFeatureType.setDefaultGeometryAttributeName(GraphicLayer.FEATURE_ATTR_GEOMETRY); |
|
114 | 102 |
|
115 |
store.update(editableFeatureType);
|
|
103 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_IDSYMBOL, DataTypes.INT);
|
|
116 | 104 |
|
117 |
store.finishEditing(); |
|
118 |
|
|
119 |
FeatureType ftype = store.getDefaultFeatureType(); |
|
120 |
featureIdIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_FEATUREID); |
|
121 |
groupIdIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_GROUPID); |
|
122 |
geomIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_GEOMETRY); |
|
123 |
idsymIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_IDSYMBOL); |
|
124 |
labelIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_LABEL); |
|
125 |
tagIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_TAG); |
|
126 |
priorityIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_PRIORITY); |
|
105 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_LABEL, DataTypes.STRING); |
|
127 | 106 |
|
128 |
this.bindToDataStore(store); |
|
129 |
|
|
130 |
setName("Graphic Layer"); |
|
131 |
} |
|
132 |
|
|
133 |
public void addGraphic(String groupId, Geometry geom, int idsym) { |
|
134 |
addGraphic(groupId, geom, idsym, null, null, DEFAULT_PRIORITY); |
|
135 |
} |
|
107 |
EditableFeatureAttributeDescriptor featureIdDescriptor |
|
108 |
= editableFeatureType.add(GraphicLayer.FEATURE_ATTR_FEATUREID, DataTypes.LONG); |
|
136 | 109 |
|
137 |
public void addGraphic(Geometry geom, int idsym) { |
|
138 |
addGraphic(DEFAULT, geom, idsym, null, null, DEFAULT_PRIORITY); |
|
139 |
} |
|
110 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_TAG, DataTypes.OBJECT); |
|
111 |
editableFeatureType.add(GraphicLayer.FEATURE_ATTR_PRIORITY, DataTypes.INT); |
|
140 | 112 |
|
141 |
public void addGraphic(Geometry geom, int idsym, String label) { |
|
142 |
addGraphic(DEFAULT, geom, idsym, label, null, DEFAULT_PRIORITY); |
|
143 |
} |
|
113 |
featureIdDescriptor.setIsPrimaryKey(true); |
|
114 |
editableFeatureType.setHasOID(true); |
|
144 | 115 |
|
145 |
public void addGraphic(String groupId, Geometry geom, int idsym, String label) { |
|
146 |
addGraphic(groupId, geom, idsym, label, null, DEFAULT_PRIORITY); |
|
147 |
} |
|
148 |
|
|
149 |
public void addGraphic(String groupId, Geometry geom, int idsym, String label, |
|
150 |
Object tag, int priority) { |
|
116 |
store.update(editableFeatureType); |
|
151 | 117 |
|
152 |
try{ |
|
153 |
store.beginComplexNotification(); |
|
154 |
// Just in case another thread is going to read from the store |
|
155 |
synchronized (store) { |
|
156 |
if (!store.isEditing()){ |
|
157 |
store.edit(FeatureStore.MODE_APPEND); |
|
158 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
159 |
store.finishEditing(); |
|
160 |
} else { |
|
161 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
162 |
} |
|
163 |
} |
|
164 |
store.endComplexNotification(); |
|
165 |
} catch (DataException e) { |
|
166 |
logger.error("Error adding a geometry to the graphic layer", e); |
|
167 |
} |
|
168 |
} |
|
118 |
store.finishEditing(); |
|
169 | 119 |
|
120 |
FeatureType ftype = store.getDefaultFeatureType(); |
|
121 |
featureIdIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_FEATUREID); |
|
122 |
groupIdIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_GROUPID); |
|
123 |
geomIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_GEOMETRY); |
|
124 |
idsymIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_IDSYMBOL); |
|
125 |
labelIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_LABEL); |
|
126 |
tagIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_TAG); |
|
127 |
priorityIndex = ftype.getIndex(GraphicLayer.FEATURE_ATTR_PRIORITY); |
|
128 |
|
|
129 |
this.bindToDataStore(store); |
|
130 |
|
|
131 |
setName("Graphic Layer"); |
|
132 |
} |
|
133 |
|
|
134 |
public void addGraphic(String groupId, Geometry geom, int idsym) { |
|
135 |
addGraphic(groupId, geom, idsym, null, null, DEFAULT_PRIORITY); |
|
136 |
} |
|
137 |
|
|
138 |
public void addGraphic(Geometry geom, int idsym) { |
|
139 |
addGraphic(DEFAULT, geom, idsym, null, null, DEFAULT_PRIORITY); |
|
140 |
} |
|
141 |
|
|
142 |
public void addGraphic(Geometry geom, int idsym, String label) { |
|
143 |
addGraphic(DEFAULT, geom, idsym, label, null, DEFAULT_PRIORITY); |
|
144 |
} |
|
145 |
|
|
146 |
public void addGraphic(String groupId, Geometry geom, int idsym, String label) { |
|
147 |
addGraphic(groupId, geom, idsym, label, null, DEFAULT_PRIORITY); |
|
148 |
} |
|
149 |
|
|
150 |
public void addGraphic(String groupId, Geometry geom, int idsym, String label, |
|
151 |
Object tag, int priority) { |
|
152 |
|
|
153 |
try { |
|
154 |
store.beginComplexNotification(); |
|
155 |
// Just in case another thread is going to read from the store |
|
156 |
synchronized (store) { |
|
157 |
if (store.isEditing() || store.isAppending() ) { |
|
158 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
159 |
} else { |
|
160 |
store.edit(FeatureStore.MODE_APPEND); |
|
161 |
try { |
|
162 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
163 |
store.finishEditing(); |
|
164 |
} catch(Throwable th) { |
|
165 |
try { |
|
166 |
store.cancelEditing(); |
|
167 |
} catch(Throwable th2) { |
|
168 |
// Do nothing |
|
169 |
} |
|
170 |
throw th; |
|
171 |
} |
|
172 |
} |
|
173 |
} |
|
174 |
} catch (Throwable th) { |
|
175 |
logger.warn("Error adding a geometry to the graphic layer", th); |
|
176 |
} finally { |
|
177 |
try { |
|
178 |
store.endComplexNotification(); |
|
179 |
} catch(Exception ex) { |
|
180 |
// Do nothing |
|
181 |
} |
|
182 |
} |
|
183 |
} |
|
184 |
|
|
170 | 185 |
private void insertGeometry(String groupId, Geometry geom, int idsym, |
171 |
String label, Object tag, int priority) throws DataException { |
|
186 |
String label, Object tag, int priority) throws DataException {
|
|
172 | 187 |
EditableFeature feature = store.createNewFeature().getEditable(); |
173 | 188 |
feature.setString(groupIdIndex, groupId); |
174 | 189 |
feature.setGeometry(geomIndex, geom); |
175 |
feature.setInt(idsymIndex, idsym);
|
|
176 |
feature.setString(labelIndex, label);
|
|
190 |
feature.setInt(idsymIndex, idsym); |
|
191 |
feature.setString(labelIndex, label); |
|
177 | 192 |
feature.setLong(featureIdIndex, ids); |
178 | 193 |
feature.set(tagIndex, tag); |
179 | 194 |
feature.setInt(priorityIndex, priority); |
... | ... | |
181 | 196 |
ids++; |
182 | 197 |
|
183 | 198 |
store.insert(feature); |
184 |
}
|
|
199 |
} |
|
185 | 200 |
|
186 | 201 |
public void addGraphics(String groupId, Iterator geoms, int idsym) { |
187 | 202 |
addGraphics(groupId, geoms, idsym, null, null, DEFAULT_PRIORITY); |
188 | 203 |
} |
189 | 204 |
|
190 | 205 |
public void addGraphics(String groupId, Iterator geoms, int idsym, |
191 |
String label) { |
|
206 |
String label) {
|
|
192 | 207 |
addGraphics(groupId, geoms, idsym, label, null, DEFAULT_PRIORITY); |
193 | 208 |
} |
194 | 209 |
|
195 | 210 |
public void addGraphics(String groupId, Iterator geoms, int idsym, |
196 |
String label, Object tag, int priority) { |
|
211 |
String label, Object tag, int priority) {
|
|
197 | 212 |
try { |
198 |
// Just in case another thread is going to read from the store |
|
199 |
synchronized (store) { |
|
200 |
if (!store.isEditing()) { |
|
201 |
store.edit(FeatureStore.MODE_APPEND); |
|
202 |
store.disableNotifications(); |
|
203 |
for (; geoms.hasNext();) { |
|
204 |
Geometry geom = (Geometry) geoms.next(); |
|
205 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
206 |
} |
|
207 |
store.enableNotifications(); |
|
208 |
store.finishEditing(); |
|
209 |
} else { |
|
210 |
store.disableNotifications(); |
|
211 |
for (; geoms.hasNext();) { |
|
212 |
Geometry geom = (Geometry) geoms.next(); |
|
213 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
214 |
} |
|
215 |
store.enableNotifications(); |
|
216 |
} |
|
217 |
} |
|
218 |
} catch (DataException e) { |
|
219 |
logger.error("Error adding a geometry to the graphic layer", e); |
|
213 |
// Just in case another thread is going to read from the store |
|
214 |
synchronized (store) { |
|
215 |
if (store.isEditing() || store.isAppending() ) { |
|
216 |
store.disableNotifications(); |
|
217 |
for (; geoms.hasNext();) { |
|
218 |
Geometry geom = (Geometry) geoms.next(); |
|
219 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
220 |
} |
|
221 |
store.enableNotifications(); |
|
222 |
} else { |
|
223 |
store.edit(FeatureStore.MODE_APPEND); |
|
224 |
try { |
|
225 |
store.disableNotifications(); |
|
226 |
for (; geoms.hasNext();) { |
|
227 |
Geometry geom = (Geometry) geoms.next(); |
|
228 |
insertGeometry(groupId, geom, idsym, label, tag, priority); |
|
229 |
} |
|
230 |
store.enableNotifications(); |
|
231 |
store.finishEditing(); |
|
232 |
} catch(Throwable th) { |
|
233 |
try { |
|
234 |
store.cancelEditing(); |
|
235 |
} catch(Throwable th2) { |
|
236 |
// Do nothing |
|
237 |
} |
|
238 |
throw th; |
|
239 |
|
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
243 |
} catch (Throwable th) { |
|
244 |
logger.warn("Error adding a geometry to the graphic layer", th); |
|
220 | 245 |
} |
221 | 246 |
} |
222 | 247 |
|
223 |
public int addSymbol(ISymbol newSymbol) {
|
|
224 |
symbolId++;
|
|
225 |
legend.addSymbol(new Integer(symbolId), newSymbol);
|
|
226 |
return symbolId;
|
|
227 |
}
|
|
248 |
public int addSymbol(ISymbol newSymbol) {
|
|
249 |
symbolId++;
|
|
250 |
legend.addSymbol(new Integer(symbolId), newSymbol);
|
|
251 |
return symbolId;
|
|
252 |
}
|
|
228 | 253 |
|
229 |
public ISymbol getSymbol(int symbolPos) {
|
|
230 |
return legend.getSymbolByValue(new Integer(symbolPos));
|
|
231 |
}
|
|
254 |
public ISymbol getSymbol(int symbolPos) {
|
|
255 |
return legend.getSymbolByValue(new Integer(symbolPos));
|
|
256 |
}
|
|
232 | 257 |
|
233 |
public int getSymbolId(ISymbol symbol) {
|
|
234 |
Object key = legend.getSymbolKey(symbol);
|
|
235 |
return key == null ? -1 : ((Number) key).intValue();
|
|
236 |
}
|
|
258 |
public int getSymbolId(ISymbol symbol) {
|
|
259 |
Object key = legend.getSymbolKey(symbol);
|
|
260 |
return key == null ? -1 : ((Number) key).intValue();
|
|
261 |
}
|
|
237 | 262 |
|
238 |
public void clearAllGraphics() {
|
|
239 |
DisposableIterator iterator = null;
|
|
240 |
FeatureSet featureSet = null;
|
|
241 |
try{
|
|
242 |
if (!store.isEditing()){
|
|
243 |
store.edit();
|
|
244 |
featureSet = store.getFeatureSet();
|
|
245 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) {
|
|
246 |
Feature feature = (Feature) iterator.next();
|
|
247 |
featureSet.delete(feature);
|
|
248 |
}
|
|
249 |
store.finishEditing();
|
|
250 |
} else {
|
|
251 |
featureSet = store.getFeatureSet();
|
|
252 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) {
|
|
253 |
Feature feature = (Feature) iterator.next();
|
|
254 |
featureSet.delete(feature);
|
|
255 |
}
|
|
256 |
}
|
|
257 |
} catch (DataException e) {
|
|
258 |
logger.error("Error clearing all the geometry of the graphic layer", e);
|
|
259 |
} finally {
|
|
260 |
if (featureSet != null) {
|
|
261 |
featureSet.dispose();
|
|
262 |
}
|
|
263 |
if (iterator != null) {
|
|
264 |
iterator.dispose();
|
|
265 |
}
|
|
266 |
}
|
|
267 |
}
|
|
263 |
public void clearAllGraphics() {
|
|
264 |
DisposableIterator iterator = null;
|
|
265 |
FeatureSet featureSet = null;
|
|
266 |
try {
|
|
267 |
if (!store.isEditing()) {
|
|
268 |
store.edit();
|
|
269 |
featureSet = store.getFeatureSet();
|
|
270 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) {
|
|
271 |
Feature feature = (Feature) iterator.next();
|
|
272 |
featureSet.delete(feature);
|
|
273 |
}
|
|
274 |
store.finishEditing();
|
|
275 |
} else {
|
|
276 |
featureSet = store.getFeatureSet();
|
|
277 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) {
|
|
278 |
Feature feature = (Feature) iterator.next();
|
|
279 |
featureSet.delete(feature);
|
|
280 |
}
|
|
281 |
}
|
|
282 |
} catch (DataException e) {
|
|
283 |
logger.warn("Error clearing all the geometry of the graphic layer", e);
|
|
284 |
} finally {
|
|
285 |
if (featureSet != null) {
|
|
286 |
featureSet.dispose();
|
|
287 |
}
|
|
288 |
if (iterator != null) {
|
|
289 |
iterator.dispose();
|
|
290 |
}
|
|
291 |
}
|
|
292 |
}
|
|
268 | 293 |
|
269 |
public int clearAllSymbols() {
|
|
270 |
legend.clear();
|
|
271 |
symbolId = -1;
|
|
272 |
return symbolId;
|
|
273 |
}
|
|
294 |
public int clearAllSymbols() {
|
|
295 |
legend.clear();
|
|
296 |
symbolId = -1;
|
|
297 |
return symbolId;
|
|
298 |
}
|
|
274 | 299 |
|
275 |
public void removeGraphics(String groupId) {
|
|
276 |
DisposableIterator iterator = null;
|
|
277 |
FeatureSet featureSet = null;
|
|
278 |
try{
|
|
279 |
store.beginComplexNotification();
|
|
280 |
if (!store.isEditing()){
|
|
281 |
store.edit();
|
|
282 |
featureSet = store.getFeatureSet();
|
|
283 |
store.beginEditingGroup(groupId);
|
|
284 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) {
|
|
285 |
Feature feature = (Feature) iterator.next();
|
|
286 |
if (feature.get(FEATURE_ATTR_GROUPID).equals(groupId)) {
|
|
287 |
featureSet.delete(feature);
|
|
288 |
}
|
|
289 |
}
|
|
290 |
store.endEditingGroup();
|
|
291 |
store.finishEditing();
|
|
292 |
} else {
|
|
293 |
featureSet = store.getFeatureSet();
|
|
294 |
store.beginEditingGroup(groupId);
|
|
295 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) {
|
|
296 |
Feature feature = (Feature) iterator.next();
|
|
297 |
if (feature.get(FEATURE_ATTR_GROUPID).equals(groupId)) {
|
|
298 |
featureSet.delete(feature);
|
|
299 |
}
|
|
300 |
}
|
|
301 |
store.endEditingGroup();
|
|
302 |
}
|
|
303 |
store.endComplexNotification();
|
|
304 |
} catch (DataException e) {
|
|
305 |
logger.error("Error clearing all the geometry of the graphic layer", e);
|
|
306 |
} finally {
|
|
307 |
if (featureSet != null) {
|
|
308 |
featureSet.dispose();
|
|
309 |
}
|
|
310 |
if (iterator != null) {
|
|
311 |
iterator.dispose();
|
|
312 |
}
|
|
313 |
}
|
|
314 |
}
|
|
300 |
public void removeGraphics(String groupId) {
|
|
301 |
DisposableIterator iterator = null;
|
|
302 |
FeatureSet featureSet = null;
|
|
303 |
try {
|
|
304 |
store.beginComplexNotification();
|
|
305 |
if (!store.isEditing()) {
|
|
306 |
store.edit();
|
|
307 |
featureSet = store.getFeatureSet();
|
|
308 |
store.beginEditingGroup(groupId);
|
|
309 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) {
|
|
310 |
Feature feature = (Feature) iterator.next();
|
|
311 |
if (feature.get(FEATURE_ATTR_GROUPID).equals(groupId)) {
|
|
312 |
featureSet.delete(feature);
|
|
313 |
}
|
|
314 |
}
|
|
315 |
store.endEditingGroup();
|
|
316 |
store.finishEditing();
|
|
317 |
} else {
|
|
318 |
featureSet = store.getFeatureSet();
|
|
319 |
store.beginEditingGroup(groupId);
|
|
320 |
for (iterator = featureSet.fastIterator(); iterator.hasNext();) {
|
|
321 |
Feature feature = (Feature) iterator.next();
|
|
322 |
if (feature.get(FEATURE_ATTR_GROUPID).equals(groupId)) {
|
|
323 |
featureSet.delete(feature);
|
|
324 |
}
|
|
325 |
}
|
|
326 |
store.endEditingGroup();
|
|
327 |
}
|
|
328 |
store.endComplexNotification();
|
|
329 |
} catch (DataException e) {
|
|
330 |
logger.warn("Error clearing all the geometry of the graphic layer", e);
|
|
331 |
} finally {
|
|
332 |
if (featureSet != null) {
|
|
333 |
featureSet.dispose();
|
|
334 |
}
|
|
335 |
if (iterator != null) {
|
|
336 |
iterator.dispose();
|
|
337 |
}
|
|
338 |
}
|
|
339 |
}
|
|
315 | 340 |
|
316 |
protected void doDispose() throws BaseException {
|
|
317 |
super.doDispose();
|
|
318 |
if (store != null) {
|
|
319 |
store.dispose();
|
|
320 |
store = null;
|
|
321 |
}
|
|
322 |
}
|
|
341 |
protected void doDispose() throws BaseException {
|
|
342 |
super.doDispose();
|
|
343 |
if (store != null) {
|
|
344 |
store.dispose();
|
|
345 |
store = null;
|
|
346 |
}
|
|
347 |
}
|
|
323 | 348 |
|
324 |
public void setLegend(IVectorLegend legend) throws LegendLayerException {
|
|
325 |
if (legend instanceof IVectorialUniqueValueLegend){
|
|
326 |
super.setLegend(legend);
|
|
327 |
this.legend = (IVectorialUniqueValueLegend)legend;
|
|
328 |
this.legend.setClassifyingFieldNames(new String[]{FEATURE_ATTR_IDSYMBOL});
|
|
329 |
}else{
|
|
330 |
if( this.legend != null ) { // Skip the first assignment, is always bad.
|
|
331 |
logger.warn("The allocation of legend type '"+legend.getClass().getName()+"' is ignored. Required a legend of type IVectorialUniqueValueLegend.");
|
|
332 |
}
|
|
333 |
}
|
|
334 |
}
|
|
335 |
|
|
349 |
public void setLegend(IVectorLegend legend) throws LegendLayerException {
|
|
350 |
if (legend instanceof IVectorialUniqueValueLegend) {
|
|
351 |
super.setLegend(legend);
|
|
352 |
this.legend = (IVectorialUniqueValueLegend) legend;
|
|
353 |
this.legend.setClassifyingFieldNames(new String[]{FEATURE_ATTR_IDSYMBOL});
|
|
354 |
} else {
|
|
355 |
if (this.legend != null) { // Skip the first assignment, is always bad.
|
|
356 |
logger.warn("The allocation of legend type '" + legend.getClass().getName() + "' is ignored. Required a legend of type IVectorialUniqueValueLegend.");
|
|
357 |
}
|
|
358 |
}
|
|
359 |
}
|
|
360 |
|
|
336 | 361 |
public Envelope getFullEnvelope() throws ReadException { |
337 | 362 |
Envelope rAux; |
338 | 363 |
try { |
... | ... | |
342 | 367 |
} |
343 | 368 |
|
344 | 369 |
if (rAux == null) { |
345 |
return null;
|
|
370 |
return null;
|
|
346 | 371 |
} |
347 |
|
|
372 |
|
|
348 | 373 |
ICoordTrans ct = getCoordTrans(); |
349 | 374 |
if (ct != null) { |
350 |
rAux = rAux.convert(ct);
|
|
375 |
rAux = rAux.convert(ct);
|
|
351 | 376 |
} |
352 | 377 |
return rAux; |
353 | 378 |
} |
Also available in: Unified diff