Revision 43215
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.join/src/test/java/org/gvsig/app/join/dal/feature/JoinTransformTest.java | ||
---|---|---|
100 | 100 |
names.add(((FeatureAttributeDescriptor) iter.next()).getName()); |
101 | 101 |
} |
102 | 102 |
|
103 |
transform.initialize(store, store2,
|
|
103 |
transform.setValues(store, store2,
|
|
104 | 104 |
"NOMBRE", "NOMBRE", |
105 | 105 |
null, null, |
106 | 106 |
(String[]) names.toArray(new String[0])); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.join/src/main/java/org/gvsig/app/join/dal/feature/JoinTransform.java | ||
---|---|---|
56 | 56 |
import org.slf4j.Logger; |
57 | 57 |
import org.slf4j.LoggerFactory; |
58 | 58 |
|
59 |
public class JoinTransform extends AbstractFeatureStoreTransform { |
|
59 |
public class JoinTransform |
|
60 |
extends AbstractFeatureStoreTransform { |
|
60 | 61 |
|
61 |
private static Logger logger = LoggerFactory.getLogger(JoinTransform.class);
|
|
62 |
|
|
62 |
private static final Logger logger = LoggerFactory.getLogger(JoinTransform.class);
|
|
63 |
|
|
63 | 64 |
public static final String PERSISTENCE_DEFINITION_NAME = "JoinTransform"; |
64 |
|
|
65 |
|
|
65 | 66 |
/** |
66 | 67 |
* Store from which the join transform will get the additional attributes |
67 | 68 |
*/ |
... | ... | |
85 | 86 |
private String[] attrs; |
86 | 87 |
|
87 | 88 |
/** |
88 |
* Attribute names may change after transformation a prefix is applied. |
|
89 |
* This map keeps correspondence between store1 original names
|
|
90 |
* and their transformed counterparts.
|
|
89 |
* Attribute names may change after transformation a prefix is applied. This
|
|
90 |
* map keeps correspondence between store1 original names and their
|
|
91 |
* transformed counterparts. |
|
91 | 92 |
*/ |
92 |
private Map<String,String> store1NamesMap;
|
|
93 |
private final Map<String, String> store1NamesMap;
|
|
93 | 94 |
|
94 | 95 |
/** |
95 | 96 |
* Attribute names may change after transformation if they are repeated in |
96 | 97 |
* both stores or if a prefix is applied. This map keeps correspondence |
97 | 98 |
* between store2 original names and their transformed counterparts. |
98 | 99 |
*/ |
99 |
private Map<String,String> store2NamesMap;
|
|
100 |
private final Map<String, String> store2NamesMap;
|
|
100 | 101 |
|
101 | 102 |
private JoinTransformEvaluator evaluator = null; |
102 | 103 |
|
... | ... | |
112 | 113 |
* A default constructor |
113 | 114 |
*/ |
114 | 115 |
public JoinTransform() { |
115 |
store1NamesMap = new HashMap<String,String>();
|
|
116 |
store2NamesMap = new HashMap<String,String>();
|
|
116 |
store1NamesMap = new HashMap<>(); |
|
117 |
store2NamesMap = new HashMap<>(); |
|
117 | 118 |
} |
118 | 119 |
|
119 | 120 |
/** |
120 | 121 |
* Initializes all the necessary data for this transform |
121 | 122 |
* |
122 |
* @param store1 |
|
123 |
* store whose default feature type is the target of this |
|
124 |
* transform |
|
123 |
* @param store1 store whose default feature type is the target of this |
|
124 |
* transform |
|
125 | 125 |
* |
126 |
* @param store2 |
|
127 |
* store whose default feature type will provide the new |
|
128 |
* attributes to join |
|
126 |
* @param store2 store whose default feature type will provide the new |
|
127 |
* attributes to join |
|
129 | 128 |
* |
130 |
* @param keyAttr1 |
|
131 |
* key attribute in store1 that matches keyAttr2 in store2 |
|
132 |
* (foreign key), used for joining both stores. |
|
129 |
* @param keyAttr1 key attribute in store1 that matches keyAttr2 in store2 |
|
130 |
* (foreign key), used for joining both stores. |
|
133 | 131 |
* |
134 |
* @param keyAttr2 |
|
135 |
* key attribute in store2 that matches keyAttr1 in store2 |
|
136 |
* (foreign key), used for joining both stores. |
|
132 |
* @param keyAttr2 key attribute in store2 that matches keyAttr1 in store2 |
|
133 |
* (foreign key), used for joining both stores. |
|
134 |
* @param prefix1 |
|
135 |
* @param prefix2 |
|
137 | 136 |
* |
138 |
* @param attrs |
|
139 |
* names of the attributes in store2 that will be joined to |
|
140 |
* store1. |
|
137 |
* @param attrs names of the attributes in store2 that will be joined to |
|
138 |
* store1. |
|
141 | 139 |
*/ |
142 |
public void initialize(FeatureStore store1, FeatureStore store2,
|
|
140 |
public void setValues(FeatureStore store1, FeatureStore store2,
|
|
143 | 141 |
String keyAttr1, String keyAttr2, String prefix1, String prefix2, |
144 |
String[] attrs) |
|
145 |
throws DataException { |
|
142 |
String[] attrs) { |
|
146 | 143 |
|
147 |
if (store1 == store2) {
|
|
144 |
if( store1 == store2 ) {
|
|
148 | 145 |
throw new IllegalArgumentException("store1 == store2"); |
149 | 146 |
} |
150 | 147 |
|
151 |
// Initialize needed data |
|
152 | 148 |
this.setFeatureStore(store1); |
153 | 149 |
this.store2 = store2; |
154 | 150 |
this.keyAttr1 = keyAttr1; |
... | ... | |
157 | 153 |
this.prefix2 = prefix2; // TODO |
158 | 154 |
this.attrs = attrs; |
159 | 155 |
|
156 |
} |
|
157 |
|
|
158 |
@Override |
|
159 |
public void setUp() throws Exception { |
|
160 |
|
|
160 | 161 |
// calculate this transform resulting feature type |
161 | 162 |
// by adding all specified attrs from store2 to store1's default |
162 | 163 |
// feature type |
163 | 164 |
// FIXME for more than one FTypes ?? |
164 |
this.originalFeatureType = this.getFeatureStore() |
|
165 |
.getDefaultFeatureType(); |
|
165 |
this.originalFeatureType = this.getFeatureStore().getDefaultFeatureType(); |
|
166 | 166 |
|
167 | 167 |
// keep index of geometry and att desc ============== |
168 |
int orig_geom_field_index =
|
|
169 |
this.originalFeatureType.getDefaultGeometryAttributeIndex(); |
|
170 |
FeatureAttributeDescriptor orig_geom_field_att =
|
|
171 |
this.originalFeatureType.getDefaultGeometryAttribute(); |
|
172 |
|
|
168 |
int orig_geom_field_index |
|
169 |
= this.originalFeatureType.getDefaultGeometryAttributeIndex();
|
|
170 |
FeatureAttributeDescriptor orig_geom_field_att |
|
171 |
= this.originalFeatureType.getDefaultGeometryAttribute();
|
|
172 |
|
|
173 | 173 |
// Create the feature type and copy the store 1 type |
174 | 174 |
EditableFeatureType editableFeatureType = this.getFeatureStore().getDefaultFeatureType().getEditable(); |
175 | 175 |
FeatureAttributeDescriptor[] featureAttributeDescriptors = editableFeatureType.getAttributeDescriptors(); |
176 |
for (int i=0 ; i<featureAttributeDescriptors.length ; i++){
|
|
177 |
editableFeatureType.remove(featureAttributeDescriptors[i].getName());
|
|
178 |
}
|
|
176 |
for( int i = 0; i < featureAttributeDescriptors.length; i++ ) {
|
|
177 |
editableFeatureType.remove(featureAttributeDescriptors[i].getName()); |
|
178 |
} |
|
179 | 179 |
addFeatureType(editableFeatureType, featureAttributeDescriptors, prefix1, store1NamesMap); |
180 | 180 |
|
181 | 181 |
// =========== set the new geom field name and restore geometry values |
182 |
if (orig_geom_field_index >= 0) {
|
|
182 |
if( orig_geom_field_index >= 0 ) {
|
|
183 | 183 |
EditableFeatureAttributeDescriptor ed_att = null; |
184 |
ed_att = (EditableFeatureAttributeDescriptor) |
|
185 |
editableFeatureType.getAttributeDescriptor(orig_geom_field_index); |
|
184 |
ed_att = (EditableFeatureAttributeDescriptor) editableFeatureType.getAttributeDescriptor(orig_geom_field_index); |
|
186 | 185 |
ed_att.setSRS(orig_geom_field_att.getSRS()); |
187 | 186 |
ed_att.setObjectClass(orig_geom_field_att.getObjectClass()); |
188 | 187 |
ed_att.setGeometryType(orig_geom_field_att.getGeomType()); |
... | ... | |
197 | 196 |
FeatureType featureType2 = store2.getDefaultFeatureType(); |
198 | 197 |
|
199 | 198 |
// Add the fields |
200 |
for (int i = 0; i < attrs.length; i++) {
|
|
201 |
addFeatureType(editableFeatureType, featureType2.getAttributeDescriptor(attrs[i]), prefix2, store2NamesMap);
|
|
199 |
for( int i = 0; i < attrs.length; i++ ) {
|
|
200 |
addFeatureType(editableFeatureType, featureType2.getAttributeDescriptor(attrs[i]), prefix2, store2NamesMap); |
|
202 | 201 |
} |
203 | 202 |
|
204 |
if (this.store2NamesMap.containsKey(keyAttr2)) {
|
|
203 |
if( this.store2NamesMap.containsKey(keyAttr2) ) {
|
|
205 | 204 |
this.attrsForQuery = this.attrs; |
206 | 205 |
} else { |
207 | 206 |
List<String> list = new ArrayList<String>(this.attrs.length + 1); |
208 | 207 |
list.addAll(Arrays.asList(this.attrs)); |
209 | 208 |
list.add(keyAttr2); |
210 |
this.attrsForQuery = (String[]) list.toArray(new String[] {});
|
|
209 |
this.attrsForQuery = (String[]) list.toArray(new String[]{}); |
|
211 | 210 |
} |
212 | 211 |
|
213 | 212 |
// assign calculated feature type as this transform's feature type |
214 |
FeatureType[] types = new FeatureType[] { editableFeatureType.getNotEditableCopy() }; |
|
213 |
FeatureType[] types = new FeatureType[]{ |
|
214 |
editableFeatureType.getNotEditableCopy()}; |
|
215 | 215 |
setFeatureTypes(Arrays.asList(types), types[0]); |
216 | 216 |
} |
217 | 217 |
|
218 | 218 |
private void addFeatureType(EditableFeatureType targetFeatureType, FeatureAttributeDescriptor[] featureAttributeDescriptors, |
219 |
String prefix, Map<String, String> storeMap) throws DataException{ |
|
219 |
String prefix, Map<String, String> storeMap) throws DataException {
|
|
220 | 220 |
|
221 |
for (int i=0 ; i<featureAttributeDescriptors.length ; i++){
|
|
221 |
for( int i = 0; i < featureAttributeDescriptors.length; i++ ) {
|
|
222 | 222 |
addFeatureType(targetFeatureType, featureAttributeDescriptors[i], prefix, storeMap); |
223 | 223 |
} |
224 | 224 |
} |
225 | 225 |
|
226 | 226 |
private void addFeatureType(EditableFeatureType targetFeatureType, FeatureAttributeDescriptor featureAttributeDescriptor, |
227 |
String prefix, Map<String, String> storeMap) throws DataException{ |
|
227 |
String prefix, Map<String, String> storeMap) throws DataException {
|
|
228 | 228 |
|
229 | 229 |
String attName = featureAttributeDescriptor.getName(); |
230 |
if ((prefix != null) && (!prefix.equals(""))){
|
|
230 |
if( (prefix != null) && (!prefix.equals("")) ) {
|
|
231 | 231 |
attName = prefix + "_" + attName; |
232 | 232 |
} |
233 | 233 |
|
234 | 234 |
// If an attribute already exists, calculate an alternate name and add it to our type |
235 | 235 |
int j = 0; |
236 |
while (targetFeatureType.getIndex(attName) >= 0) {
|
|
236 |
while( targetFeatureType.getIndex(attName) >= 0 ) {
|
|
237 | 237 |
attName = targetFeatureType.getAttributeDescriptor(attName).getName() + "_" + ++j; |
238 | 238 |
} |
239 | 239 |
|
240 |
EditableFeatureAttributeDescriptor editableFeatureAttributeDescriptor =
|
|
241 |
targetFeatureType.add(attName, featureAttributeDescriptor.getType(), |
|
240 |
EditableFeatureAttributeDescriptor editableFeatureAttributeDescriptor |
|
241 |
= targetFeatureType.add(attName, featureAttributeDescriptor.getType(),
|
|
242 | 242 |
featureAttributeDescriptor.getSize()); |
243 | 243 |
editableFeatureAttributeDescriptor.setPrecision(featureAttributeDescriptor.getPrecision()); |
244 | 244 |
|
245 | 245 |
// keep correspondence between original name and transformed name |
246 | 246 |
storeMap.put(featureAttributeDescriptor.getName(), attName); |
247 |
}
|
|
247 |
} |
|
248 | 248 |
|
249 | 249 |
/** |
250 | 250 |
* |
... | ... | |
255 | 255 |
* |
256 | 256 |
* @throws DataException |
257 | 257 |
*/ |
258 |
@Override |
|
258 | 259 |
public void applyTransform(Feature source, EditableFeature target) |
259 |
throws DataException { |
|
260 |
throws DataException {
|
|
260 | 261 |
|
261 | 262 |
// copy the data from store1 into the resulting feature |
262 | 263 |
this.copySourceToTarget(source, target); |
... | ... | |
281 | 282 |
|
282 | 283 |
Feature feat; |
283 | 284 |
|
284 |
|
|
285 | 285 |
itFeat = set.fastIterator(); |
286 |
if (itFeat.hasNext()) {
|
|
286 |
if( itFeat.hasNext() ) {
|
|
287 | 287 |
feat = (Feature) itFeat.next(); |
288 | 288 |
|
289 | 289 |
// copy all attributes from joined feature to target |
290 | 290 |
this.copyJoinToTarget(feat, target); |
291 | 291 |
} |
292 | 292 |
} finally { |
293 |
if (itFeat != null) {
|
|
293 |
if( itFeat != null ) {
|
|
294 | 294 |
itFeat.dispose(); |
295 | 295 |
} |
296 |
if (set != null) {
|
|
296 |
if( set != null ) {
|
|
297 | 297 |
set.dispose(); |
298 | 298 |
} |
299 | 299 |
} |
... | ... | |
305 | 305 |
*/ |
306 | 306 |
private void copyJoinToTarget(Feature join, EditableFeature target) { |
307 | 307 |
Iterator<Entry<String, String>> iter = store2NamesMap.entrySet() |
308 |
.iterator(); |
|
308 |
.iterator();
|
|
309 | 309 |
Entry<String, String> entry; |
310 | 310 |
FeatureType trgType = target.getType(); |
311 | 311 |
FeatureAttributeDescriptor attr; |
312 |
while (iter.hasNext()) {
|
|
312 |
while( iter.hasNext() ) {
|
|
313 | 313 |
entry = iter.next(); |
314 | 314 |
attr = trgType.getAttributeDescriptor((String) entry.getValue()); |
315 |
if (attr != null) {
|
|
315 |
if( attr != null ) {
|
|
316 | 316 |
target.set(attr.getIndex(), join.get((String) entry.getKey())); |
317 | 317 |
} |
318 | 318 |
} |
... | ... | |
327 | 327 |
FeatureType ftSrc = source.getType(); |
328 | 328 |
FeatureType ftTrg = target.getType(); |
329 | 329 |
|
330 |
|
|
331 |
for (int i = 0; i < source.getType().size(); i++) { |
|
330 |
for( int i = 0; i < source.getType().size(); i++ ) { |
|
332 | 331 |
attr = ftSrc.getAttributeDescriptor(i); |
333 | 332 |
attrTrg = ftTrg.getAttributeDescriptor(store1NamesMap.get(attr.getName())); |
334 |
if (attrTrg != null) {
|
|
333 |
if( attrTrg != null ) {
|
|
335 | 334 |
try { |
336 | 335 |
target.set(attrTrg.getIndex(), source.get(i)); |
337 |
} catch ( SetReadOnlyAttributeException e1) {
|
|
336 |
} catch (SetReadOnlyAttributeException e1) { |
|
338 | 337 |
// Ignore, do nothing |
339 |
|
|
338 |
|
|
340 | 339 |
} catch (IllegalArgumentException e) { |
341 | 340 |
attrTrg = ftTrg.getAttributeDescriptor(attr.getName()); |
342 | 341 |
target.set(attrTrg.getIndex(), attrTrg.getDefaultValue()); |
... | ... | |
348 | 347 |
} |
349 | 348 |
|
350 | 349 |
private JoinTransformEvaluator getEvaluator() { |
351 |
if (this.evaluator == null){ |
|
352 |
FeatureType ft2 = null; |
|
353 |
try { |
|
354 |
ft2 = this.store2.getDefaultFeatureType(); |
|
355 |
} catch (DataException e) { |
|
356 |
logger.error("While getting feat type.", e); |
|
357 |
} |
|
358 |
FeatureAttributeDescriptor att2 = ft2.getAttributeDescriptor(keyAttr2); |
|
359 |
boolean is_num = att2.getDataType().isNumeric(); |
|
350 |
if( this.evaluator == null ) { |
|
351 |
FeatureType ft2 = null; |
|
352 |
try { |
|
353 |
ft2 = this.store2.getDefaultFeatureType(); |
|
354 |
} catch (DataException e) { |
|
355 |
logger.warn("Can't access to the feature type to build the evaluator.", e); |
|
356 |
throw new RuntimeException("Can't access to the feature type to build the evaluator.", e); |
|
357 |
} |
|
358 |
FeatureAttributeDescriptor att2 = ft2.getAttributeDescriptor(keyAttr2); |
|
359 |
boolean is_num = att2.getDataType().isNumeric(); |
|
360 | 360 |
this.evaluator = new JoinTransformEvaluator(keyAttr2, is_num); |
361 | 361 |
} |
362 | 362 |
return evaluator; |
363 | 363 |
|
364 | 364 |
} |
365 | 365 |
|
366 |
private class JoinTransformEvaluator implements Evaluator { |
|
366 |
private class JoinTransformEvaluator |
|
367 |
implements Evaluator { |
|
367 | 368 |
|
368 | 369 |
private String attribute; |
369 | 370 |
private boolean isNumeric = false; |
... | ... | |
372 | 373 |
private EvaluatorFieldsInfo info = null; |
373 | 374 |
|
374 | 375 |
// private int attributeIndex; |
375 |
|
|
376 | 376 |
public JoinTransformEvaluator(String attribute, boolean is_numeric) { |
377 | 377 |
this.attribute = attribute; |
378 | 378 |
this.isNumeric = is_numeric; |
... | ... | |
390 | 390 |
this.info.addMatchFieldValue(this.attribute, value); |
391 | 391 |
} |
392 | 392 |
|
393 |
@Override |
|
393 | 394 |
public Object evaluate(EvaluatorData arg0) throws EvaluatorException { |
394 | 395 |
Object curValue = arg0.getDataValue(attribute); |
395 |
if (curValue == null) {
|
|
396 |
if( curValue == null ) {
|
|
396 | 397 |
return value == null; |
397 | 398 |
} |
398 | 399 |
return curValue.equals(value); |
399 | 400 |
} |
400 | 401 |
|
402 |
@Override |
|
401 | 403 |
public String getSQL() { |
402 | 404 |
return this.sql; |
403 | 405 |
} |
404 | 406 |
|
407 |
@Override |
|
405 | 408 |
public String getDescription() { |
406 | 409 |
return "Evaluates join transform match"; |
407 | 410 |
} |
408 | 411 |
|
412 |
@Override |
|
409 | 413 |
public String getName() { |
410 | 414 |
return "JoinTransformEvaluator"; |
411 | 415 |
} |
412 | 416 |
|
417 |
@Override |
|
413 | 418 |
public EvaluatorFieldsInfo getFieldsInfo() { |
414 | 419 |
return this.info; |
415 | 420 |
} |
416 | 421 |
|
417 |
}
|
|
422 |
} |
|
418 | 423 |
|
419 | 424 |
@SuppressWarnings("unchecked") |
425 |
@Override |
|
420 | 426 |
public FeatureType getSourceFeatureTypeFrom(FeatureType arg0) { |
421 | 427 |
return originalFeatureType; |
422 | 428 |
} |
423 | 429 |
|
424 |
public boolean isTransformsOriginalValues() { |
|
425 |
return false; |
|
426 |
} |
|
427 |
|
|
428 | 430 |
public static void registerPersistent() { |
429 | 431 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
430 | 432 |
|
... | ... | |
434 | 436 |
|
435 | 437 |
DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_DEFINITION_NAME); |
436 | 438 |
|
437 |
if (definition == null){
|
|
439 |
if( definition == null ) {
|
|
438 | 440 |
definition = persistenceManager.addDefinition( |
439 | 441 |
JoinTransform.class, |
440 | 442 |
PERSISTENCE_DEFINITION_NAME, |
441 | 443 |
"JoinTransform Persistence definition", |
442 |
null,
|
|
444 |
null, |
|
443 | 445 |
null |
444 | 446 |
); |
445 | 447 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, |
... | ... | |
454 | 456 |
} |
455 | 457 |
} |
456 | 458 |
|
459 |
@Override |
|
457 | 460 |
public void saveToState(PersistentState state) throws PersistenceException { |
458 | 461 |
super.saveToState(state); |
459 | 462 |
state.set("store2", this.store2); |
460 | 463 |
state.set("keyAttr1", this.keyAttr1); |
461 | 464 |
state.set("keyAttr2", this.keyAttr2); |
462 | 465 |
state.set("prefix1", this.prefix1); |
463 |
state.set("prefix2", this.prefix2);
|
|
466 |
state.set("prefix2", this.prefix2); |
|
464 | 467 |
state.set("attrs", this.attrs); |
465 | 468 |
} |
466 | 469 |
|
470 |
@Override |
|
467 | 471 |
public void loadFromState(PersistentState state) throws PersistenceException { |
468 | 472 |
super.loadFromState(state); |
469 |
FeatureStore store2 = (FeatureStore) state.get("store2"); |
|
470 |
String keyAttr1 = state.getString("keyAttr1"); |
|
471 |
String keyAttr2 = state.getString("keyAttr2"); |
|
472 |
String prefix1 = state.getString("prefix1"); |
|
473 |
String prefix2 = state.getString("prefix2"); |
|
474 |
String[] attrs = (String[]) state.getArray("attrs", String.class); |
|
475 |
try { |
|
476 |
initialize(getFeatureStore(), store2, keyAttr1, keyAttr2, prefix1, prefix2, attrs); |
|
477 |
} catch (DataException e) { |
|
478 |
throw new PersistenceException("Impossible to create the transform", e); |
|
479 |
} |
|
473 |
store2 = (FeatureStore) state.get("store2"); |
|
474 |
keyAttr1 = state.getString("keyAttr1"); |
|
475 |
keyAttr2 = state.getString("keyAttr2"); |
|
476 |
prefix1 = state.getString("prefix1"); |
|
477 |
prefix2 = state.getString("prefix2"); |
|
478 |
attrs = (String[]) state.getArray("attrs", String.class); |
|
480 | 479 |
} |
481 | 480 |
|
482 | 481 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.join/src/main/java/org/gvsig/app/join/daltransform/JoinTransformGui.java | ||
---|---|---|
72 | 72 |
public FeatureStoreTransform createFeatureStoreTransform( |
73 | 73 |
FeatureStore featureStore) throws DataException { |
74 | 74 |
JoinTransform transform = new JoinTransform(); |
75 |
transform.initialize(featureStore, |
|
76 |
secondDataStoreWizard.getSelectedFeatureStore(), |
|
77 |
parametersWizard.getKeyAttr1(), |
|
78 |
parametersWizard.getkeyAtrr2(), |
|
79 |
parametersWizard.getPrefix1(), |
|
80 |
parametersWizard.getPrefix2(), |
|
81 |
parametersWizard.getAttributes() |
|
75 |
transform.setValues( |
|
76 |
featureStore, |
|
77 |
secondDataStoreWizard.getSelectedFeatureStore(), |
|
78 |
parametersWizard.getKeyAttr1(), |
|
79 |
parametersWizard.getkeyAtrr2(), |
|
80 |
parametersWizard.getPrefix1(), |
|
81 |
parametersWizard.getPrefix2(), |
|
82 |
parametersWizard.getAttributes() |
|
82 | 83 |
); |
83 | 84 |
return transform; |
84 | 85 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.eventtheme/src/test/java/org/gvsig/app/eventlayer/dal/feature/EventThemeTransformTest.java | ||
---|---|---|
67 | 67 |
FeatureStore store = (FeatureStore) dataManager.openStore("DBF", |
68 | 68 |
this.getDefaultDataStoreParameters()); |
69 | 69 |
EventThemeTransform transform = new EventThemeTransform(); |
70 |
transform.initialize(store, geometryFieldName, xFieldName, yFieldName,
|
|
70 |
transform.setValues(store, geometryFieldName, xFieldName, yFieldName,
|
|
71 | 71 |
CRSFactory.getCRS(projection)); |
72 | 72 |
return transform; |
73 | 73 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.eventtheme/src/main/java/org/gvsig/app/eventtheme/daltransform/EventThemeTransformGui.java | ||
---|---|---|
83 | 83 |
public FeatureStoreTransform createFeatureStoreTransform( |
84 | 84 |
FeatureStore featureStore) throws DataException { |
85 | 85 |
EventThemeTransform transform = new EventThemeTransform(); |
86 |
transform.initialize(featureStore, |
|
87 |
panel.getGeometryName(), |
|
88 |
panel.getXName(), |
|
89 |
panel.getYName(), |
|
90 |
panel.getProjection()); |
|
86 |
transform.setValues( |
|
87 |
featureStore, |
|
88 |
panel.getGeometryName(), |
|
89 |
panel.getXName(), |
|
90 |
panel.getYName(), |
|
91 |
panel.getProjection() |
|
92 |
); |
|
91 | 93 |
return transform; |
92 | 94 |
} |
93 | 95 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.daltransform.app/org.gvsig.daltransform.app.eventtheme/src/main/java/org/gvsig/app/eventtheme/dal/feature/EventThemeTransform.java | ||
---|---|---|
25 | 25 |
* AUTHORS (In addition to CIT): |
26 | 26 |
* 2009 {Iver T.I.} {Task} |
27 | 27 |
*/ |
28 |
|
|
29 | 28 |
package org.gvsig.app.eventtheme.dal.feature; |
30 | 29 |
|
31 | 30 |
import java.util.Arrays; |
32 | 31 |
|
33 | 32 |
import javax.swing.JOptionPane; |
33 |
import org.apache.commons.lang3.StringUtils; |
|
34 | 34 |
|
35 | 35 |
import org.cresques.cts.IProjection; |
36 | 36 |
|
... | ... | |
74 | 74 |
import org.slf4j.LoggerFactory; |
75 | 75 |
|
76 | 76 |
/** |
77 |
* This class implements a transformation for a events theme. The original |
|
78 |
* {@link DataStore} have to have a couple of attributes, one with the X |
|
79 |
* coordinate and the second one with the Y coordinate. The result of |
|
80 |
* the transformation is a {@link DataStore} that has a new geometric |
|
81 |
* attribute and its value is a point with the coordinates specified in |
|
82 |
* the original {@link DataStore}. |
|
77 |
* This class implements a transformation for a events theme. The original |
|
78 |
* {@link DataStore} have to have a couple of attributes, one with the X |
|
79 |
* coordinate and the second one with the Y coordinate. The result of the |
|
80 |
* transformation is a {@link DataStore} that has a new geometric attribute and |
|
81 |
* its value is a point with the coordinates specified in the original |
|
82 |
* {@link DataStore}. |
|
83 |
* |
|
83 | 84 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
84 | 85 |
*/ |
85 |
public class EventThemeTransform extends AbstractFeatureStoreTransform { |
|
86 |
public class EventThemeTransform |
|
87 |
extends AbstractFeatureStoreTransform { |
|
86 | 88 |
|
87 |
private static Logger logger = LoggerFactory.getLogger(
|
|
88 |
EventThemeTransform.class);
|
|
89 |
|
|
89 |
private static Logger logger = LoggerFactory.getLogger(
|
|
90 |
EventThemeTransform.class);
|
|
91 |
|
|
90 | 92 |
public static final String PERSISTENCE_DEFINITION_NAME = "EventThemeTransform"; |
91 | 93 |
/** |
92 |
* Max number of features used for initial estimation |
|
93 |
* of extent. Many other features will be ignored |
|
94 |
* simply with "iter.next()" |
|
94 |
* Max number of features used for initial estimation of extent. Many other |
|
95 |
* features will be ignored simply with "iter.next()" |
|
95 | 96 |
*/ |
96 | 97 |
public static int MAX_INI_FEATURES = 200; |
97 | 98 |
|
... | ... | |
100 | 101 |
private String geometryFieldName = null; |
101 | 102 |
private IProjection projection = null; |
102 | 103 |
private FeatureType originalFeatureType; |
103 |
private GeometryManager geometryManager = GeometryLocator.getGeometryManager();
|
|
104 |
private GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
104 | 105 |
private Envelope envelope; |
105 | 106 |
|
106 | 107 |
public EventThemeTransform() { |
... | ... | |
109 | 110 |
} |
110 | 111 |
|
111 | 112 |
/** |
112 |
* This method initializes the transformation, sets the name of the parameters and |
|
113 |
* sets the value of the {@link FeatureType} returned by the transformation. |
|
114 |
* @param store |
|
115 |
* The original store. |
|
116 |
* @param geometryFieldName |
|
117 |
* The field that contains the geometric attribute. |
|
118 |
* @param xFieldName |
|
119 |
* The field that contains the X coordinate. |
|
120 |
* @param yFieldName |
|
121 |
* The field that contains the Y coordinate. |
|
113 |
* This method initializes the transformation, sets the name of the |
|
114 |
* parameters and sets the value of the {@link FeatureType} returned by the |
|
115 |
* transformation. |
|
116 |
* |
|
117 |
* @param store The original store. |
|
118 |
* @param geometryFieldName The field that contains the geometric attribute. |
|
119 |
* @param xFieldName The field that contains the X coordinate. |
|
120 |
* @param yFieldName The field that contains the Y coordinate. |
|
121 |
* @param projection |
|
122 | 122 |
* @throws DataException |
123 | 123 |
*/ |
124 |
public void initialize(
|
|
125 |
FeatureStore store,
|
|
126 |
String geometryFieldName,
|
|
127 |
String xFieldName,
|
|
128 |
String yFieldName,
|
|
129 |
IProjection projection) throws DataException{
|
|
130 |
|
|
124 |
public void setValues(
|
|
125 |
FeatureStore store,
|
|
126 |
String geometryFieldName,
|
|
127 |
String xFieldName,
|
|
128 |
String yFieldName,
|
|
129 |
IProjection projection) throws DataException {
|
|
130 |
|
|
131 | 131 |
setFeatureStore(store); |
132 | 132 |
this.xFieldName = xFieldName; |
133 | 133 |
this.yFieldName = yFieldName; |
134 | 134 |
this.projection = projection; |
135 |
if ((geometryFieldName == null) || (geometryFieldName.equals(""))){
|
|
135 |
if( StringUtils.isEmpty(geometryFieldName) ) {
|
|
136 | 136 |
this.geometryFieldName = "the_geom"; |
137 |
}else{
|
|
137 |
} else {
|
|
138 | 138 |
this.geometryFieldName = geometryFieldName; |
139 | 139 |
} |
140 |
} |
|
141 |
|
|
142 |
@Override |
|
143 |
public void setUp() throws Exception { |
|
144 |
|
|
140 | 145 |
this.originalFeatureType = this.getFeatureStore() |
141 |
.getDefaultFeatureType(); |
|
146 |
.getDefaultFeatureType();
|
|
142 | 147 |
|
143 | 148 |
EditableFeatureType type = originalFeatureType.getEditable(); |
144 |
if (type.get(this.geometryFieldName) == null){
|
|
145 |
EditableFeatureAttributeDescriptor attributeDescriptor = type.add(this.geometryFieldName, DataTypes.GEOMETRY);
|
|
149 |
if( type.get(this.geometryFieldName) == null ) {
|
|
150 |
EditableFeatureAttributeDescriptor attributeDescriptor = type.add(this.geometryFieldName, DataTypes.GEOMETRY); |
|
146 | 151 |
try { |
147 | 152 |
attributeDescriptor.setGeometryType(geometryManager.getGeometryType(TYPES.POINT, SUBTYPES.GEOM2D)); |
148 | 153 |
} catch (GeometryTypeNotSupportedException e) { |
149 | 154 |
throw new InitializeException(e); |
150 | 155 |
} catch (GeometryTypeNotValidException e) { |
151 | 156 |
throw new InitializeException(e); |
152 |
}
|
|
157 |
} |
|
153 | 158 |
attributeDescriptor.setSRS(projection); |
154 | 159 |
} |
155 | 160 |
|
... | ... | |
157 | 162 |
/* |
158 | 163 |
* creates and updates envelope with all features |
159 | 164 |
*/ |
160 |
initEnvelope(store, MAX_INI_FEATURES);
|
|
165 |
initEnvelope(this.getFeatureStore(), MAX_INI_FEATURES);
|
|
161 | 166 |
} catch (CreateEnvelopeException e) { |
162 | 167 |
throw new org.gvsig.fmap.dal.feature.exception.CreateGeometryException(e); |
163 | 168 |
} |
164 | 169 |
|
165 | 170 |
type.setDefaultGeometryAttributeName(this.geometryFieldName); |
166 |
FeatureType[] types = new FeatureType[] { type.getNotEditableCopy() };
|
|
171 |
FeatureType[] types = new FeatureType[]{type.getNotEditableCopy()};
|
|
167 | 172 |
setFeatureTypes(Arrays.asList(types), types[0]); |
168 | 173 |
} |
169 |
|
|
170 |
|
|
171 | 174 |
|
172 | 175 |
/** |
173 | 176 |
* creates and updates envelope with all features |
174 |
*
|
|
177 |
* |
|
175 | 178 |
*/ |
176 | 179 |
private void initEnvelope(FeatureStore fsto, int max_feats) throws CreateEnvelopeException { |
177 |
|
|
180 |
|
|
178 | 181 |
envelope = geometryManager.createEnvelope(SUBTYPES.GEOM2D); |
179 | 182 |
FeatureSet fset = null; |
180 | 183 |
DisposableIterator diter = null; |
... | ... | |
182 | 185 |
try { |
183 | 186 |
fset = fsto.getFeatureSet(); |
184 | 187 |
diter = fset.fastIterator(); |
185 |
|
|
188 |
|
|
186 | 189 |
// int count = 0; |
187 | 190 |
int countused = 0; |
188 | 191 |
int nextwait = 1; |
189 | 192 |
int index = 0; |
190 |
|
|
191 |
while (diter.hasNext() && (countused < max_feats)) {
|
|
192 |
|
|
193 |
|
|
194 |
while( diter.hasNext() && (countused < max_feats) ) {
|
|
195 |
|
|
193 | 196 |
feat = (Feature) diter.next(); |
194 | 197 |
/* |
195 | 198 |
* This loop will use about 70 features from the first |
... | ... | |
206 | 209 |
* so it's not very important. |
207 | 210 |
*/ |
208 | 211 |
index++; |
209 |
if (index == nextwait) {
|
|
210 |
index = 0;
|
|
211 |
/*
|
|
212 |
if( index == nextwait ) {
|
|
213 |
index = 0;
|
|
214 |
/*
|
|
212 | 215 |
* This causes that the first 5 features |
213 | 216 |
* will always be used. |
214 |
*/
|
|
215 |
if (countused > 5) {
|
|
216 |
nextwait++;
|
|
217 |
}
|
|
218 |
this.updateEnvelope(feat);
|
|
219 |
countused++;
|
|
217 |
*/
|
|
218 |
if( countused > 5 ) {
|
|
219 |
nextwait++;
|
|
220 |
}
|
|
221 |
this.updateEnvelope(feat);
|
|
222 |
countused++;
|
|
220 | 223 |
} |
221 | 224 |
// count++; |
222 | 225 |
} |
223 |
|
|
226 |
|
|
224 | 227 |
diter.dispose(); |
225 |
|
|
228 |
|
|
226 | 229 |
} catch (Exception dex) { |
227 | 230 |
throw new CreateEnvelopeException(SUBTYPES.GEOM2D, dex); |
228 | 231 |
} |
229 | 232 |
} |
230 |
|
|
233 |
|
|
231 | 234 |
public void setEnvelope(Envelope env) { |
232 |
this.envelope = env;
|
|
235 |
this.envelope = env;
|
|
233 | 236 |
} |
234 | 237 |
|
235 | 238 |
/* |
236 | 239 |
* Currently not used |
237 | 240 |
*/ |
238 | 241 |
private void launchFullExtentThread(DisposableIterator diter) { |
239 |
|
|
240 |
ComputeExtentTask task = new ComputeExtentTask(diter, this); |
|
241 |
task.start(); |
|
242 |
} |
|
243 | 242 |
|
244 |
/* (non-Javadoc) |
|
245 |
* @see org.gvsig.fmap.dal.feature.FeatureStoreTransform#applyTransform(org.gvsig.fmap.dal.feature.Feature, org.gvsig.fmap.dal.feature.EditableFeature) |
|
246 |
*/ |
|
243 |
ComputeExtentTask task = new ComputeExtentTask(diter, this); |
|
244 |
task.start(); |
|
245 |
} |
|
246 |
|
|
247 |
@Override |
|
247 | 248 |
public void applyTransform(Feature source, EditableFeature target) |
248 |
throws DataException { |
|
249 |
|
|
249 |
throws DataException {
|
|
250 |
|
|
250 | 251 |
this.copySourceToTarget(source, target); |
251 | 252 |
|
252 | 253 |
try { |
253 |
|
|
254 |
Geometry point = null;
|
|
254 |
|
|
255 |
Geometry point; |
|
255 | 256 |
Object xval = source.get(xFieldName); |
256 | 257 |
Object yval = source.get(yFieldName); |
257 |
if (xval == null || yval == null) {
|
|
258 |
if( xval == null || yval == null ) {
|
|
258 | 259 |
logger.info("Found row with null coordinates in event theme (created null geometry)"); |
259 | 260 |
target.set(geometryFieldName, null); |
260 |
target.setDefaultGeometry(null);
|
|
261 |
target.setDefaultGeometry(null); |
|
261 | 262 |
} else { |
262 | 263 |
point = geometryManager.createPoint( |
263 | 264 |
new Double(xval.toString()), |
264 | 265 |
new Double(yval.toString()), |
265 | 266 |
SUBTYPES.GEOM2D); |
266 | 267 |
target.set(geometryFieldName, point); |
267 |
target.setDefaultGeometry(point);
|
|
268 |
target.setDefaultGeometry(point); |
|
268 | 269 |
envelope.add(point.getEnvelope()); |
269 | 270 |
} |
270 |
} catch ( SetReadOnlyAttributeException e1) {
|
|
271 |
} catch (SetReadOnlyAttributeException e1) {
|
|
271 | 272 |
// Do nothing |
272 |
|
|
273 |
|
|
273 | 274 |
} catch (Exception e) { |
274 | 275 |
throw new org.gvsig.fmap.dal.feature.exception.CreateGeometryException( |
275 | 276 |
TYPES.POINT, SUBTYPES.GEOM2D, e); |
276 |
}
|
|
277 |
|
|
277 |
} |
|
278 |
|
|
278 | 279 |
} |
279 |
|
|
280 |
|
|
280 | 281 |
/** |
281 | 282 |
* Used internally to initialize envelope |
282 |
*
|
|
283 |
* |
|
283 | 284 |
*/ |
284 | 285 |
private void updateEnvelope(Feature feat) throws CreateGeometryException { |
285 | 286 |
|
... | ... | |
299 | 300 |
FeatureType ftSrc = source.getType(); |
300 | 301 |
FeatureType ftTrg = target.getType(); |
301 | 302 |
|
302 |
|
|
303 |
for (int i = 0; i < source.getType().size(); i++) { |
|
303 |
for( int i = 0; i < source.getType().size(); i++ ) { |
|
304 | 304 |
attr = ftSrc.getAttributeDescriptor(i); |
305 |
if (ftTrg.getIndex(attr.getName()) > -1) {
|
|
305 |
if( ftTrg.getIndex(attr.getName()) > -1 ) {
|
|
306 | 306 |
try { |
307 | 307 |
target.set(attr.getName(), source.get(i)); |
308 | 308 |
} catch (IllegalArgumentException e) { |
... | ... | |
315 | 315 |
|
316 | 316 |
} |
317 | 317 |
|
318 |
/* (non-Javadoc) |
|
319 |
* @see org.gvsig.fmap.dal.feature.FeatureStoreTransform#getSourceFeatureTypeFrom(org.gvsig.fmap.dal.feature.FeatureType) |
|
320 |
*/ |
|
318 |
@Override |
|
321 | 319 |
public FeatureType getSourceFeatureTypeFrom(FeatureType targetFeatureType) { |
322 | 320 |
return this.originalFeatureType; |
323 | 321 |
} |
324 | 322 |
|
325 |
/* (non-Javadoc) |
|
326 |
* @see org.gvsig.fmap.dal.feature.FeatureStoreTransform#isTransformsOriginalValues() |
|
327 |
*/ |
|
323 |
@Override |
|
328 | 324 |
public boolean isTransformsOriginalValues() { |
329 | 325 |
return true; |
330 | 326 |
} |
... | ... | |
338 | 334 |
|
339 | 335 |
DynStruct definition = persistenceManager.getDefinition(PERSISTENCE_DEFINITION_NAME); |
340 | 336 |
|
341 |
if (definition == null){
|
|
337 |
if( definition == null ) {
|
|
342 | 338 |
definition = persistenceManager.addDefinition( |
343 | 339 |
EventThemeTransform.class, |
344 | 340 |
PERSISTENCE_DEFINITION_NAME, |
345 | 341 |
"EventThemeTransform Persistence definition", |
346 |
null,
|
|
342 |
null, |
|
347 | 343 |
null |
348 | 344 |
); |
349 | 345 |
definition.extend(PersistenceManager.PERSISTENCE_NAMESPACE, |
... | ... | |
356 | 352 |
} |
357 | 353 |
} |
358 | 354 |
|
359 |
/* (non-Javadoc) |
|
360 |
* @see org.gvsig.tools.persistence.Persistent#saveToState(org.gvsig.tools.persistence.PersistentState) |
|
361 |
*/ |
|
355 |
@Override |
|
362 | 356 |
public void saveToState(PersistentState state) throws PersistenceException { |
363 | 357 |
super.saveToState(state); |
364 | 358 |
state.set("geometryFieldName", this.geometryFieldName); |
365 | 359 |
state.set("xFieldName", this.xFieldName); |
366 | 360 |
state.set("yFieldName", this.yFieldName); |
367 |
state.set("projection", this.projection);
|
|
361 |
state.set("projection", this.projection); |
|
368 | 362 |
} |
369 | 363 |
|
370 |
/* (non-Javadoc) |
|
371 |
* @see org.gvsig.tools.persistence.Persistent#loadFromState(org.gvsig.tools.persistence.PersistentState) |
|
372 |
*/ |
|
364 |
@Override |
|
373 | 365 |
public void loadFromState(PersistentState state) |
374 |
throws PersistenceException { |
|
375 |
super.loadFromState(state); |
|
376 |
String geometryFieldName = state.getString("geometryFieldName"); |
|
377 |
String xFieldName = state.getString("xFieldName"); |
|
378 |
String yFieldName = state.getString("yFieldName"); |
|
379 |
IProjection projection = (IProjection)state.get("projection"); |
|
380 |
try { |
|
381 |
initialize(getFeatureStore(), geometryFieldName, xFieldName, yFieldName, projection); |
|
382 |
} catch (DataException e) { |
|
383 |
throw new PersistenceException("Impossible to create the transform", e); |
|
384 |
} |
|
366 |
throws PersistenceException { |
|
367 |
super.loadFromState(state); |
|
368 |
geometryFieldName = state.getString("geometryFieldName"); |
|
369 |
xFieldName = state.getString("xFieldName"); |
|
370 |
yFieldName = state.getString("yFieldName"); |
|
371 |
projection = (IProjection) state.get("projection"); |
|
385 | 372 |
} |
386 | 373 |
|
374 |
@Override |
|
387 | 375 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
388 |
if (DataStore.METADATA_CRS.equals(name)){
|
|
376 |
if( DataStore.METADATA_CRS.equals(name) ) {
|
|
389 | 377 |
return projection; |
390 |
}else if(DataStore.METADATA_ENVELOPE.equals(name)){
|
|
378 |
} else if( DataStore.METADATA_ENVELOPE.equals(name) ) {
|
|
391 | 379 |
return envelope; |
392 | 380 |
} |
393 | 381 |
return null; |
394 | 382 |
} |
395 | 383 |
|
384 |
@Override |
|
396 | 385 |
public boolean hasDynValue(String name) { |
397 |
return ((DataStore.METADATA_CRS.equals(name)) || |
|
398 |
(DataStore.METADATA_ENVELOPE.equals(name))); |
|
399 |
} |
|
400 |
|
|
401 |
|
|
386 |
return ((DataStore.METADATA_CRS.equals(name)) |
|
387 |
|| (DataStore.METADATA_ENVELOPE.equals(name))); |
|
388 |
} |
|
389 |
|
|
402 | 390 |
/** |
403 |
*
|
|
391 |
* |
|
404 | 392 |
* A thread to compute the true extent (in case it has a lot of features) |
405 | 393 |
* Currently not used. |
406 |
*
|
|
394 |
* |
|
407 | 395 |
* @author jldominguez |
408 |
*
|
|
396 |
* |
|
409 | 397 |
* @deprecated This is not used because it causes issues with |
410 |
* ConsurrentModificationException because the store is notified of |
|
411 |
* a change (the transformation). Anyway, this is not very important I think.
|
|
398 |
* ConsurrentModificationException because the store is notified of a change
|
|
399 |
* (the transformation). Anyway, this is not very important I think. |
|
412 | 400 |
*/ |
413 |
private class ComputeExtentTask extends AbstractMonitorableTask { |
|
414 |
|
|
415 |
private DisposableIterator disp_iter = null; |
|
416 |
private EventThemeTransform tra_toupdate = null; |
|
417 |
|
|
418 |
public ComputeExtentTask(DisposableIterator diter, EventThemeTransform ettra) { |
|
419 |
/* |
|
401 |
private class ComputeExtentTask |
|
402 |
extends AbstractMonitorableTask { |
|
403 |
|
|
404 |
private DisposableIterator disp_iter = null; |
|
405 |
private EventThemeTransform tra_toupdate = null; |
|
406 |
|
|
407 |
public ComputeExtentTask(DisposableIterator diter, EventThemeTransform ettra) { |
|
408 |
/* |
|
420 | 409 |
* Auto-added by task manager |
421 |
*/ |
|
422 |
super(Messages.getText("_Extent_of_event_theme"), true); |
|
423 |
disp_iter = diter; |
|
424 |
tra_toupdate = ettra; |
|
425 |
} |
|
426 |
|
|
427 |
public void run() { |
|
410 |
*/ |
|
411 |
super(Messages.getText("_Extent_of_event_theme"), true); |
|
412 |
disp_iter = diter; |
|
413 |
tra_toupdate = ettra; |
|
414 |
} |
|
428 | 415 |
|
429 |
Envelope env = null; |
|
430 |
Feature feat = null; |
|
431 |
Point point = null; |
|
432 |
int count = 99; |
|
433 |
|
|
434 |
try { |
|
435 |
while (disp_iter.hasNext()) { |
|
416 |
public void run() { |
|
417 |
|
|
418 |
Envelope env = null; |
|
419 |
Feature feat = null; |
|
420 |
Point point = null; |
|
421 |
int count = 99; |
|
422 |
|
|
423 |
try { |
|
424 |
while( disp_iter.hasNext() ) { |
|
436 | 425 |
feat = (Feature) disp_iter.next(); |
437 | 426 |
point = geometryManager.createPoint( |
438 |
Double.parseDouble(feat.get(xFieldName).toString()),
|
|
439 |
Double.parseDouble(feat.get(yFieldName).toString()),
|
|
440 |
SUBTYPES.GEOM2D);
|
|
441 |
if (env == null) {
|
|
442 |
env = (Envelope) point.getEnvelope().clone();
|
|
427 |
Double.parseDouble(feat.get(xFieldName).toString()), |
|
428 |
Double.parseDouble(feat.get(yFieldName).toString()), |
|
429 |
SUBTYPES.GEOM2D); |
|
430 |
if( env == null ) {
|
|
431 |
env = (Envelope) point.getEnvelope().clone();
|
|
443 | 432 |
} else { |
444 |
env.add(point.getEnvelope());
|
|
433 |
env.add(point.getEnvelope());
|
|
445 | 434 |
} |
446 | 435 |
count++; |
447 | 436 |
Thread.sleep(10); |
448 |
if (count % 100 == 0) {
|
|
449 |
System.out.println("COUNT = " + count);
|
|
437 |
if( count % 100 == 0 ) {
|
|
438 |
System.out.println("COUNT = " + count);
|
|
450 | 439 |
} |
451 | 440 |
} |
452 |
} catch (Exception exc) {
|
|
453 |
|
|
454 |
ApplicationLocator.getManager().message(
|
|
455 |
Messages.getText("_Error_while_getting_extent"),
|
|
456 |
JOptionPane.ERROR_MESSAGE);
|
|
457 |
logger.info("Error while getting extent in thread.", exc);
|
|
458 |
|
|
459 |
}
|
|
460 |
|
|
461 |
disp_iter.dispose();
|
|
462 |
// =================
|
|
463 |
if (env != null) {
|
|
464 |
Envelope curr_env = (Envelope) tra_toupdate.getDynValue(
|
|
465 |
DataStore.METADATA_ENVELOPE);
|
|
466 |
curr_env.add(env);
|
|
467 |
}
|
|
468 |
// =========== End
|
|
469 |
TaskStatusManager man = this.getTaskStatus().getManager();
|
|
470 |
man.remove(this.getTaskStatus());
|
|
471 |
}
|
|
472 |
|
|
441 |
} catch (Exception exc) {
|
|
442 |
|
|
443 |
ApplicationLocator.getManager().message(
|
|
444 |
Messages.getText("_Error_while_getting_extent"),
|
|
445 |
JOptionPane.ERROR_MESSAGE);
|
|
446 |
logger.info("Error while getting extent in thread.", exc);
|
|
447 |
|
|
448 |
}
|
|
449 |
|
|
450 |
disp_iter.dispose();
|
|
451 |
// =================
|
|
452 |
if( env != null ) {
|
|
453 |
Envelope curr_env = (Envelope) tra_toupdate.getDynValue(
|
|
454 |
DataStore.METADATA_ENVELOPE);
|
|
455 |
curr_env.add(env);
|
|
456 |
}
|
|
457 |
// =========== End
|
|
458 |
TaskStatusManager man = this.getTaskStatus().getManager();
|
|
459 |
man.remove(this.getTaskStatus());
|
|
460 |
}
|
|
461 |
|
|
473 | 462 |
} |
474 | 463 |
} |
475 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/ViewManager.java | ||
---|---|---|
260 | 260 |
IconThemeHelper.registerIcon("layer", "layer-icon", ViewManager.class); |
261 | 261 |
IconThemeHelper.registerIcon("layer", "layer-icon-group", ViewManager.class); |
262 | 262 |
IconThemeHelper.registerIcon("layer", "layer-icon-vectorial", ViewManager.class); |
263 |
IconThemeHelper.registerIcon("layer", "layer-icon-csv", ViewManager.class); |
|
263 | 264 |
IconThemeHelper.registerIcon("layer", "layer-icon-dgn", ViewManager.class); |
264 | 265 |
IconThemeHelper.registerIcon("layer", "layer-icon-dxf", ViewManager.class); |
265 | 266 |
IconThemeHelper.registerIcon("layer", "layer-icon-postgresql", ViewManager.class); |
... | ... | |
274 | 275 |
IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-unique-value", ViewManager.class); |
275 | 276 |
|
276 | 277 |
MapContextManager mapContextMgr = MapContextLocator.getMapContextManager(); |
278 |
mapContextMgr.registerIconLayer("CSV", "layer-icon-csv"); |
|
277 | 279 |
mapContextMgr.registerIconLayer("DGN", "layer-icon-dgn"); |
278 | 280 |
mapContextMgr.registerIconLayer("DXF", "layer-icon-dxf"); |
279 | 281 |
mapContextMgr.registerIconLayer("jdbc", "layer-icon-jdbc"); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/toc/actions/LayerErrorsPanel.java | ||
---|---|---|
4 | 4 |
import java.awt.event.ActionEvent; |
5 | 5 |
import java.awt.event.ActionListener; |
6 | 6 |
import java.util.ArrayList; |
7 |
import java.util.HashSet; |
|
7 | 8 |
import java.util.List; |
9 |
import java.util.Set; |
|
8 | 10 |
|
9 | 11 |
import org.apache.commons.lang3.exception.ExceptionUtils; |
10 | 12 |
|
... | ... | |
13 | 15 |
import org.gvsig.fmap.mapcontrol.swing.dynobject.DynObjectEditor; |
14 | 16 |
import org.gvsig.tools.ToolsLocator; |
15 | 17 |
import org.gvsig.tools.i18n.I18nManager; |
18 |
import org.gvsig.tools.util.impl.CallableException; |
|
16 | 19 |
|
17 | 20 |
import org.slf4j.Logger; |
18 | 21 |
import org.slf4j.LoggerFactory; |
19 | 22 |
|
20 |
public class LayerErrorsPanel extends LayerErrorsView { |
|
23 |
public class LayerErrorsPanel |
|
24 |
extends LayerErrorsView { |
|
21 | 25 |
|
22 | 26 |
private static final Logger logger = LoggerFactory.getLogger(LayerErrorsPanel.class); |
23 | 27 |
private static final long serialVersionUID = -5972995402218954892L; |
... | ... | |
54 | 58 |
this.setPreferredSize(new Dimension(550, 400)); |
55 | 59 |
} |
56 | 60 |
|
57 |
public void setName(String name){ |
|
61 |
@Override |
|
62 |
public void setName(String name) { |
|
58 | 63 |
this.txtLayerName.setText(name); |
59 | 64 |
} |
60 | 65 |
|
61 |
public void setError(Exception e){
|
|
62 |
List<Exception> exs = new ArrayList<Exception>();
|
|
66 |
public void setError(Throwable e) {
|
|
67 |
List<Throwable> exs = new ArrayList<>();
|
|
63 | 68 |
exs.add(e); |
64 |
this.txtMessage.setText(this.getMessageAsHTML(exs));
|
|
69 |
this.txtMessage.setText(new MessageAsHTML(exs).toString());
|
|
65 | 70 |
this.btnViewParameters.setEnabled(false); |
66 | 71 |
} |
67 | 72 |
|
68 | 73 |
public void setLayer(FLayer layer) { |
69 | 74 |
this.layer = layer; |
70 | 75 |
setName(layer.getName()); |
71 |
this.txtMessage.setText(this.getMessageAsHTML(layer.getErrors()));
|
|
76 |
this.txtMessage.setText(new MessageAsHTML(layer.getErrors()).toString());
|
|
72 | 77 |
this.btnViewParameters.setEnabled(this.layer instanceof SingleLayer); |
73 | 78 |
} |
74 | 79 |
|
75 |
private String getMessageAsHTML(List<Exception> exs) { |
|
76 |
StringBuilder html = new StringBuilder(); |
|
77 |
//html.append("<html>\n"); |
|
78 |
for (Exception ex : exs) { |
|
79 |
String lastmsg = ""; |
|
80 |
html.append("<ul>\n"); |
|
81 |
for( Throwable cause : ExceptionUtils.getThrowableList(ex) ) { |
|
82 |
String message = cause.getMessage(); |
|
83 |
if (message != null) { |
|
84 |
if (!message.equalsIgnoreCase(lastmsg)) { |
|
85 |
lastmsg = message; |
|
86 |
html.append("<li>"); |
|
87 |
html.append(message.replace("\n", "<br>\n")); |
|
88 |
html.append("</li>\n"); |
|
80 |
private class MessageAsHTML { |
|
81 |
|
|
82 |
StringBuilder html; |
|
83 |
Set<String> usedMsgs; |
|
84 |
|
|
85 |
public MessageAsHTML(List<Throwable> exs) { |
|
86 |
this.clear(); |
|
87 |
this.build(exs); |
|
88 |
} |
|
89 |
|
|
90 |
public MessageAsHTML() { |
|
91 |
this.clear(); |
|
92 |
} |
|
93 |
|
|
94 |
public void clear() { |
|
95 |
this.html = new StringBuilder(); |
|
96 |
this.usedMsgs = new HashSet<>(); |
|
97 |
} |
|
98 |
|
|
99 |
public void build(List<Throwable> exs) { |
|
100 |
for( Throwable ex : exs ) { |
|
101 |
// html.append("<ul>\n"); |
|
102 |
List<Throwable> causes = new ArrayList<>(); |
|
103 |
causes.addAll(ExceptionUtils.getThrowableList(ex)); |
|
104 |
if( ex instanceof List ) { |
|
105 |
causes.addAll((List<Throwable>) ex); |
|
106 |
} |
|
107 |
for( Throwable cause : causes ) { |
|
108 |
if( cause instanceof List ) { |
|
109 |
continue; |
|
89 | 110 |
} |
111 |
if( cause instanceof CallableException ) { |
|
112 |
cause = ((CallableException) cause).getCause(); |
|
113 |
} |
|
114 |
if( cause == null ) { |
|
115 |
continue; |
|
116 |
} |
|
117 |
String message = cause.getMessage(); |
|
118 |
if( message != null ) { |
|
119 |
if( !this.usedMsgs.contains(message) ) { |
|
120 |
this.usedMsgs.add(message); |
|
121 |
html.append("<li>"); |
|
122 |
html.append(message.replace("\n", "<br>\n")); |
|
123 |
if( cause.getCause() != null ) { |
|
124 |
this.build(ExceptionUtils.getThrowableList( |
|
125 |
cause.getCause())); |
|
126 |
} |
|
127 |
html.append("</li>\n"); |
|
128 |
} |
|
129 |
} |
|
90 | 130 |
} |
131 |
|
|
132 |
// html.append("</ul>\n"); |
|
91 | 133 |
} |
92 |
html.append("</ul><br>\n"); |
|
93 | 134 |
} |
94 |
//html.append("</html>\n"); |
|
95 |
return html.toString(); |
|
135 |
|
|
136 |
@Override |
|
137 |
public String toString() { |
|
138 |
return "<ul>\n" + html.toString() + "</ul>\n"; |
|
139 |
} |
|
96 | 140 |
} |
97 | 141 |
|
98 | 142 |
private void translate() { |
... | ... | |
109 | 153 |
|
110 | 154 |
private void doViewParameters() { |
111 | 155 |
try { |
112 |
DynObjectEditor editor = new DynObjectEditor( ((SingleLayer)layer).getDataStore().getParameters() ); |
|
156 |
DynObjectEditor editor = new DynObjectEditor( |
|
157 |
((SingleLayer) layer).getDataStore().getParameters() |
|
158 |
); |
|
113 | 159 |
editor.editObject(true); |
114 | 160 |
} catch (Throwable th) { |
115 |
logger.warn("Can't show standard properties dialog for this parameters.",th); |
|
161 |
logger.warn( |
|
162 |
"Can't show standard properties dialog for this parameters.", |
|
163 |
th); |
|
116 | 164 |
} |
117 | 165 |
} |
118 | 166 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/view/legend/gui/LabelingManager.java | ||
---|---|---|
21 | 21 |
* For any additional information, do not hesitate to contact us |
22 | 22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
23 | 23 |
*/ |
24 |
|
|
25 | 24 |
package org.gvsig.app.project.documents.view.legend.gui; |
26 | 25 |
|
27 | 26 |
import java.awt.BorderLayout; |
... | ... | |
50 | 49 |
import org.gvsig.symbology.swing.SymbologySwingManager; |
51 | 50 |
import org.gvsig.utils.swing.JComboBox; |
52 | 51 |
|
53 |
|
|
54 | 52 |
/** |
55 | 53 |
* |
56 | 54 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
57 | 55 |
* |
58 | 56 |
*/ |
59 |
public class LabelingManager extends AbstractThemeManagerPage implements ActionListener { |
|
60 |
private static final long serialVersionUID = 856162295985695717L; |
|
57 |
public class LabelingManager |
|
58 |
extends AbstractThemeManagerPage |
|
59 |
implements ActionListener { |
|
60 |
|
|
61 |
private static final long serialVersionUID = 856162295985695717L; |
|
61 | 62 |
// private static ArrayList<Class<? extends ILabelingStrategyPanel>> installedPanels = new ArrayList<Class<? extends ILabelingStrategyPanel>>(); |
62 |
private Comparator<Class<?>> comparator=new Comparator<Class<?>>(){
|
|
63 |
private Comparator<Class<?>> comparator = new Comparator<Class<?>>() {
|
|
63 | 64 |
|
64 |
public int compare(Class<?> o1, Class<?> o2) {
|
|
65 |
return o1.getSimpleName().compareTo(o2.getSimpleName());
|
|
66 |
}
|
|
65 |
public int compare(Class<?> o1, Class<?> o2) {
|
|
66 |
return o1.getSimpleName().compareTo(o2.getSimpleName());
|
|
67 |
}
|
|
67 | 68 |
|
68 |
};
|
|
69 |
private TreeMap<Class<?>, ILabelingStrategyPanel> strategyPanels =
|
|
70 |
new TreeMap<Class<?>, ILabelingStrategyPanel>(comparator);
|
|
69 |
};
|
|
70 |
private TreeMap<Class<?>, ILabelingStrategyPanel> strategyPanels
|
|
71 |
= new TreeMap<Class<?>, ILabelingStrategyPanel>(comparator);
|
|
71 | 72 |
|
72 |
private JCheckBox chkApplyLabels;
|
|
73 |
private ILabelable layer;
|
|
74 |
private JPanel content;
|
|
75 |
private JPanel pnlNorth;
|
|
76 |
private JComboBox cmbStrategy;
|
|
73 |
private JCheckBox chkApplyLabels;
|
|
74 |
private ILabelable layer;
|
|
75 |
private JPanel content;
|
|
76 |
private JPanel pnlNorth;
|
|
77 |
private JComboBox cmbStrategy;
|
|
77 | 78 |
|
79 |
public LabelingManager() { |
|
80 |
super(); |
|
81 |
initialize(); |
|
82 |
} |
|
78 | 83 |
|
79 |
public LabelingManager() { |
|
80 |
super(); |
|
81 |
initialize(); |
|
82 |
} |
|
84 |
private class LabelingStrategyItem { |
|
83 | 85 |
|
84 |
private class LabelingStrategyItem { |
|
85 |
private ILabelingStrategyPanel strategyPanel; |
|
86 |
private ILabelingStrategyPanel strategyPanel; |
|
86 | 87 |
|
87 |
private LabelingStrategyItem(ILabelingStrategyPanel strategyPanel) {
|
|
88 |
this.strategyPanel = strategyPanel;
|
|
89 |
}
|
|
88 |
private LabelingStrategyItem(ILabelingStrategyPanel strategyPanel) {
|
|
89 |
this.strategyPanel = strategyPanel;
|
|
90 |
}
|
|
90 | 91 |
|
91 |
public String toString() {
|
|
92 |
return strategyPanel.getLabelingStrategyName();
|
|
93 |
}
|
|
92 |
public String toString() {
|
|
93 |
return strategyPanel.getLabelingStrategyName();
|
|
94 |
}
|
|
94 | 95 |
|
95 |
public boolean equals(Object obj) {
|
|
96 |
if (obj instanceof LabelingStrategyItem) {
|
|
97 |
LabelingStrategyItem item = (LabelingStrategyItem) obj;
|
|
98 |
return this.strategyPanel.getClass().equals(item.strategyPanel.getClass());
|
|
96 |
public boolean equals(Object obj) {
|
|
97 |
if( obj instanceof LabelingStrategyItem ) {
|
|
98 |
LabelingStrategyItem item = (LabelingStrategyItem) obj;
|
|
99 |
return this.strategyPanel.getClass().equals(item.strategyPanel.getClass());
|
|
99 | 100 |
|
100 |
}
|
|
101 |
return super.equals(obj);
|
|
102 |
}
|
|
101 |
}
|
|
102 |
return super.equals(obj);
|
|
103 |
}
|
|
103 | 104 |
|
104 |
}
|
|
105 |
}
|
|
105 | 106 |
|
106 |
@Override
|
|
107 |
public int getPriority() {
|
|
108 |
return 600;
|
|
109 |
}
|
|
107 |
@Override
|
|
108 |
public int getPriority() { |
|
109 |
return 600;
|
|
110 |
} |
|
110 | 111 |
|
111 |
private void initialize() {
|
|
112 |
setLayout(new BorderLayout());
|
|
113 |
SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager();
|
|
112 |
private void initialize() {
|
|
113 |
setLayout(new BorderLayout());
|
|
114 |
SymbologySwingManager symbologySwingManager = SymbologySwingLocator.getSwingManager(); |
|
114 | 115 |
|
115 |
Iterator<ILabelingStrategyPanel> it = symbologySwingManager.getLabelingEditors().iterator();
|
|
116 |
while( it.hasNext() ) {
|
|
117 |
ILabelingStrategyPanel pnl = it.next();
|
|
118 |
strategyPanels.put(pnl.getLabelingStrategyClass(), pnl);
|
|
119 |
}
|
|
120 |
content = new JPanel(new BorderLayout());
|
|
121 |
content.setBorder(BorderFactory.createEtchedBorder());
|
|
122 |
add(getPnlNorth(), BorderLayout.NORTH);
|
|
123 |
add(content, BorderLayout.SOUTH);
|
|
116 |
Iterator<ILabelingStrategyPanel> it = symbologySwingManager.getLabelingEditors().iterator(); |
|
117 |
while( it.hasNext() ) { |
|
118 |
ILabelingStrategyPanel pnl = it.next(); |
|
119 |
strategyPanels.put(pnl.getLabelingStrategyClass(), pnl); |
|
120 |
}
|
|
121 |
content = new JPanel(new BorderLayout());
|
|
122 |
content.setBorder(BorderFactory.createEtchedBorder());
|
|
123 |
add(getPnlNorth(), BorderLayout.NORTH);
|
|
124 |
add(content, BorderLayout.SOUTH);
|
|
124 | 125 |
|
125 |
}
|
|
126 |
}
|
|
126 | 127 |
|
127 |
private JPanel getPnlNorth() {
|
|
128 |
if (pnlNorth == null) {
|
|
129 |
pnlNorth = new JPanel(new BorderLayout(5,5));
|
|
130 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
128 |
private JPanel getPnlNorth() {
|
|
129 |
if( pnlNorth == null ) {
|
|
130 |
pnlNorth = new JPanel(new BorderLayout(5, 5));
|
|
131 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
131 | 132 |
|
132 |
aux.add(getChkApplyLabels());
|
|
133 |
pnlNorth.add(aux, BorderLayout.NORTH);
|
|
134 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
135 |
aux.add(new JLabel(PluginServices.getText(this, "general")+":"));
|
|
136 |
aux.add(getCmbStrategy());
|
|
137 |
pnlNorth.add(aux, BorderLayout.CENTER);
|
|
133 |
aux.add(getChkApplyLabels());
|
|
134 |
pnlNorth.add(aux, BorderLayout.NORTH);
|
|
135 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
|
136 |
aux.add(new JLabel(PluginServices.getText(this, "general") + ":"));
|
|
137 |
aux.add(getCmbStrategy());
|
|
138 |
pnlNorth.add(aux, BorderLayout.CENTER);
|
|
138 | 139 |
|
139 |
}
|
|
140 |
return pnlNorth;
|
|
141 |
}
|
|
140 |
}
|
|
141 |
return pnlNorth;
|
|
142 |
}
|
|
142 | 143 |
|
143 |
private JComboBox getCmbStrategy() {
|
|
144 |
if (cmbStrategy == null) {
|
|
145 |
Iterator<ILabelingStrategyPanel> it = strategyPanels.values().iterator();
|
|
146 |
final ArrayList<LabelingStrategyItem> aux = new ArrayList<LabelingStrategyItem>();
|
|
147 |
while (it.hasNext()) {
|
|
148 |
aux.add(new LabelingStrategyItem(it.next()));
|
|
149 |
}
|
|
150 |
final LabelingStrategyItem items[] = aux.toArray(new LabelingStrategyItem[aux.size()]);
|
|
144 |
private JComboBox getCmbStrategy() {
|
|
145 |
if( cmbStrategy == null ) {
|
|
146 |
Iterator<ILabelingStrategyPanel> it = strategyPanels.values().iterator();
|
|
147 |
final ArrayList<LabelingStrategyItem> aux = new ArrayList<LabelingStrategyItem>();
|
|
148 |
while( it.hasNext() ) {
|
|
149 |
aux.add(new LabelingStrategyItem(it.next()));
|
|
150 |
}
|
|
151 |
final LabelingStrategyItem items[] = aux.toArray(new LabelingStrategyItem[aux.size()]);
|
|
151 | 152 |
|
152 |
cmbStrategy = new JComboBox(items) {
|
|
153 |
private static final long serialVersionUID = 7506754097091500846L;
|
|
153 |
cmbStrategy = new JComboBox(items) {
|
|
154 |
private static final long serialVersionUID = 7506754097091500846L;
|
|
154 | 155 |
|
155 |
@Override |
|
156 |
public void setSelectedItem(Object anObject) { |
|
157 |
if (anObject == null) |
|
158 |
return; |
|
159 |
if (anObject instanceof ILabelingStrategy) { |
|
160 |
ILabelingStrategy st = (ILabelingStrategy) anObject; |
|
161 |
for (ILabelingStrategyPanel pnl : strategyPanels.values()) { |
|
162 |
if (pnl.getLabelingStrategyClass() != null && |
|
163 |
pnl.getLabelingStrategyClass().equals(st.getClass())) { |
|
164 |
super.setSelectedItem(new LabelingStrategyItem(pnl)); |
|
165 |
return; |
|
166 |
} |
|
167 |
} |
|
168 |
} else { |
|
169 |
super.setSelectedItem(anObject); |
|
170 |
} |
|
171 |
} |
|
172 |
}; |
|
156 |
@Override |
|
157 |
public void setSelectedItem(Object anObject) { |
|
158 |
if( anObject == null ) { |
|
159 |
return; |
|
160 |
} |
|
161 |
if( anObject instanceof ILabelingStrategy ) { |
|
162 |
ILabelingStrategy st = (ILabelingStrategy) anObject; |
|
163 |
for( ILabelingStrategyPanel pnl : strategyPanels.values() ) { |
|
164 |
if( pnl.getLabelingStrategyClass() != null |
|
165 |
&& pnl.getLabelingStrategyClass().equals(st.getClass()) ) { |
|
166 |
super.setSelectedItem(new LabelingStrategyItem(pnl)); |
|
167 |
return; |
|
168 |
} |
|
169 |
} |
|
170 |
} else { |
|
171 |
super.setSelectedItem(anObject); |
|
172 |
} |
|
173 |
} |
|
174 |
}; |
|
173 | 175 |
|
174 |
cmbStrategy.setName("CMBMODE");
|
|
175 |
cmbStrategy.addActionListener(this);
|
|
176 |
}
|
|
176 |
cmbStrategy.setName("CMBMODE");
|
|
177 |
cmbStrategy.addActionListener(this);
|
|
178 |
}
|
|
177 | 179 |
|
178 |
return cmbStrategy;
|
|
179 |
}
|
|
180 |
return cmbStrategy;
|
|
181 |
}
|
|
180 | 182 |
|
181 |
private JCheckBox getChkApplyLabels() {
|
|
182 |
if (chkApplyLabels == null) {
|
|
183 |
chkApplyLabels = new JCheckBox(PluginServices.getText(this, "enable_labeling"));
|
|
184 |
chkApplyLabels.setName("CHKAPPLYLABELS");
|
|
185 |
chkApplyLabels.addActionListener(this);
|
|
186 |
}
|
|
187 |
return chkApplyLabels;
|
|
188 |
}
|
|
183 |
private JCheckBox getChkApplyLabels() {
|
|
184 |
if( chkApplyLabels == null ) {
|
|
185 |
chkApplyLabels = new JCheckBox(PluginServices.getText(this, "enable_labeling"));
|
|
186 |
chkApplyLabels.setName("CHKAPPLYLABELS");
|
|
187 |
chkApplyLabels.addActionListener(this);
|
|
188 |
}
|
|
189 |
return chkApplyLabels;
|
|
190 |
}
|
|
189 | 191 |
|
190 |
/** |
|
191 |
* |
|
192 |
* @deprecated use {#SymbolSwingManger. |
Also available in: Unified diff