root / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src-test / org / gvsig / fmap / mapcontext / rendering / TestIClassifiedLegend.java @ 24494
History | View | Annotate | Download (23.1 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.fmap.mapcontext.rendering; |
42 |
|
43 |
import java.awt.Dimension; |
44 |
import java.awt.Rectangle; |
45 |
import java.util.ArrayList; |
46 |
import java.util.Hashtable; |
47 |
import java.util.Iterator; |
48 |
import java.util.List; |
49 |
|
50 |
import junit.framework.TestCase; |
51 |
|
52 |
import org.gvsig.fmap.dal.DataExplorer; |
53 |
import org.gvsig.fmap.dal.DataQuery; |
54 |
import org.gvsig.fmap.dal.DataSet; |
55 |
import org.gvsig.fmap.dal.DataStoreParameters; |
56 |
import org.gvsig.fmap.dal.exceptions.CloseException; |
57 |
import org.gvsig.fmap.dal.exceptions.DataException; |
58 |
import org.gvsig.fmap.dal.exceptions.InitializeException; |
59 |
import org.gvsig.fmap.dal.exceptions.OpenException; |
60 |
import org.gvsig.fmap.dal.exceptions.ReadException; |
61 |
import org.gvsig.fmap.dal.exceptions.WriteException; |
62 |
import org.gvsig.fmap.dal.feature.CommandsRecord; |
63 |
import org.gvsig.fmap.dal.feature.Feature; |
64 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
65 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
66 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
67 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
68 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
69 |
import org.gvsig.fmap.dal.feature.FeatureType; |
70 |
import org.gvsig.fmap.dal.feature.expressionevaluator.AttributeValueEvaluator; |
71 |
import org.gvsig.fmap.dal.index.IndexException; |
72 |
import org.gvsig.fmap.dal.operation.DataStoreOperationContext; |
73 |
import org.gvsig.fmap.dal.operation.DataStoreOperationException; |
74 |
import org.gvsig.fmap.dal.operation.DataStoreOperationNotSupportedException; |
75 |
import org.gvsig.fmap.geom.Geometry; |
76 |
import org.gvsig.fmap.geom.GeometryFactory; |
77 |
import org.gvsig.fmap.geom.GeometryManager; |
78 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
79 |
import org.gvsig.fmap.mapcontext.rendering.legend.AbstractIntervalLegend; |
80 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend; |
81 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend; |
82 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
83 |
import org.gvsig.fmap.mapcontext.rendering.symbol.TestISymbol; |
84 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
85 |
import org.gvsig.metadata.Metadata; |
86 |
import org.gvsig.tools.exception.BaseException; |
87 |
import org.gvsig.tools.observer.Observer; |
88 |
|
89 |
import com.iver.utiles.XMLEntity; |
90 |
import com.iver.utiles.XMLException; |
91 |
|
92 |
|
93 |
/**
|
94 |
* Integration test to ensure that the legends which implements the
|
95 |
* IClassifiedLegend interface follow the rules that follow the managing of them
|
96 |
* by the application.
|
97 |
*
|
98 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
99 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
100 |
*/
|
101 |
public class TestIClassifiedLegend extends TestCase { |
102 |
|
103 |
private static final Integer v0 = new Integer(0); |
104 |
private static final Integer v1 = new Integer(1); |
105 |
private static final Integer v2 = new Integer(2); |
106 |
private static final Integer v3 = new Integer(3); |
107 |
|
108 |
private static final String FIELD3 = "field3"; |
109 |
private static final String FIELD2 = "field2"; |
110 |
private static final String FIELD1 = "field1"; |
111 |
private static final String FIELD0 = "field0"; |
112 |
private static final int FIELDID = 0; |
113 |
|
114 |
private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, }; |
115 |
private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, }; |
116 |
private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, }; |
117 |
private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, }; |
118 |
|
119 |
private static final Integer[][] featureValues = new Integer[][] { |
120 |
feature0Values, |
121 |
feature1Values, |
122 |
feature2Values, |
123 |
feature3Values,}; |
124 |
|
125 |
private static String[] fieldNames = new String[] {FIELD0,FIELD1,FIELD2,FIELD3,}; |
126 |
|
127 |
|
128 |
// private static final Value v4 = (Value)ValueFactory.createValue(4);
|
129 |
// private static final Value v5 = (Value)ValueFactory.createValue(5);
|
130 |
// private static final Value v6 = (Value)ValueFactory.createValue(6);
|
131 |
// private static final Value v7 = (Value)ValueFactory.createValue(7);
|
132 |
// private static final Value v8 = (Value)ValueFactory.createValue(8);
|
133 |
// private static final Value v9 = (Value)ValueFactory.createValue(9);
|
134 |
|
135 |
private AbstractIntervalLegend[] intervalLegends; |
136 |
private MockDataSource mockDataSource = new MockDataSource(); |
137 |
|
138 |
/**
|
139 |
* To avoid duplicated validation logic in the test a mock object is created
|
140 |
* to use a DataSource for this test.
|
141 |
*
|
142 |
*/
|
143 |
private class MockDataSource implements FeatureStore { |
144 |
|
145 |
public DataSet getDataCollection(FeatureType type, String filter, String order) throws ReadException { |
146 |
// TODO Auto-generated method stub
|
147 |
return null; |
148 |
} |
149 |
|
150 |
public DataSet getDataCollection(String[] fields, String filter, String order) throws ReadException { |
151 |
// TODO Auto-generated method stub
|
152 |
return null; |
153 |
} |
154 |
|
155 |
public void getDataCollection(FeatureType type, String filter, String order, Observer observer) throws DataException { |
156 |
// TODO Auto-generated method stub
|
157 |
|
158 |
} |
159 |
|
160 |
public void getDataCollection(String[] fields, String filter, String order, Observer observer) throws DataException { |
161 |
// TODO Auto-generated method stub
|
162 |
|
163 |
} |
164 |
|
165 |
public void getDataSet(Observer observer) { |
166 |
// TODO Auto-generated method stub
|
167 |
|
168 |
} |
169 |
|
170 |
public Feature getFeatureByReference(FeatureReference reference) throws ReadException { |
171 |
// TODO Auto-generated method stub
|
172 |
return null; |
173 |
} |
174 |
|
175 |
public Feature getFeatureByReference(FeatureReference reference, FeatureType featureType) throws ReadException { |
176 |
// TODO Auto-generated method stub
|
177 |
return null; |
178 |
} |
179 |
|
180 |
public FeatureType getDefaultFeatureType() {
|
181 |
// TODO Auto-generated method stub
|
182 |
return null; |
183 |
} |
184 |
|
185 |
public List getFeatureTypes() { |
186 |
// TODO Auto-generated method stub
|
187 |
return null; |
188 |
} |
189 |
|
190 |
public Feature createNewFeature(FeatureType type, boolean defaultValues) throws InitializeException { |
191 |
// TODO Auto-generated method stub
|
192 |
return null; |
193 |
} |
194 |
|
195 |
public Feature createNewFeature(boolean defaultValues) throws InitializeException { |
196 |
// TODO Auto-generated method stub
|
197 |
return null; |
198 |
} |
199 |
|
200 |
public void update(Feature feature) throws DataException { |
201 |
// TODO Auto-generated method stub
|
202 |
|
203 |
} |
204 |
|
205 |
public void delete(Feature feature) throws DataException { |
206 |
// TODO Auto-generated method stub
|
207 |
|
208 |
} |
209 |
|
210 |
public void insert(Feature feature) throws DataException { |
211 |
// TODO Auto-generated method stub
|
212 |
|
213 |
} |
214 |
|
215 |
public void update(FeatureAttributeDescriptor attributeDescriptor) throws DataException { |
216 |
// TODO Auto-generated method stub
|
217 |
|
218 |
} |
219 |
|
220 |
public void delete(FeatureAttributeDescriptor attributeDescriptor) throws DataException { |
221 |
// TODO Auto-generated method stub
|
222 |
|
223 |
} |
224 |
|
225 |
public void insert(FeatureAttributeDescriptor attributeDescriptor) throws DataException { |
226 |
// TODO Auto-generated method stub
|
227 |
|
228 |
} |
229 |
|
230 |
public void disableNotifications() { |
231 |
// TODO Auto-generated method stub
|
232 |
|
233 |
} |
234 |
|
235 |
public void enableNotifications() { |
236 |
// TODO Auto-generated method stub
|
237 |
|
238 |
} |
239 |
|
240 |
public boolean isLocked(FeatureReference id) { |
241 |
// TODO Auto-generated method stub
|
242 |
return false; |
243 |
} |
244 |
|
245 |
public boolean lock(FeatureReference id) { |
246 |
// TODO Auto-generated method stub
|
247 |
return false; |
248 |
} |
249 |
|
250 |
public boolean isWithDefaultLegend() { |
251 |
// TODO Auto-generated method stub
|
252 |
return false; |
253 |
} |
254 |
|
255 |
public Object getDefaultLegend() throws ReadException { |
256 |
// TODO Auto-generated method stub
|
257 |
return null; |
258 |
} |
259 |
|
260 |
public Object getDefaultLabelingStrategy() { |
261 |
// TODO Auto-generated method stub
|
262 |
return null; |
263 |
} |
264 |
|
265 |
public boolean canAlterFeatureType() { |
266 |
// TODO Auto-generated method stub
|
267 |
return false; |
268 |
} |
269 |
|
270 |
public DataStoreParameters getParameters() {
|
271 |
// TODO Auto-generated method stub
|
272 |
return null; |
273 |
} |
274 |
|
275 |
public String getName() { |
276 |
// TODO Auto-generated method stub
|
277 |
return null; |
278 |
} |
279 |
|
280 |
public void init(DataStoreParameters parameters) throws InitializeException { |
281 |
// TODO Auto-generated method stub
|
282 |
|
283 |
} |
284 |
|
285 |
public void open() throws OpenException { |
286 |
// TODO Auto-generated method stub
|
287 |
|
288 |
} |
289 |
|
290 |
public void refresh() throws OpenException, InitializeException { |
291 |
// TODO Auto-generated method stub
|
292 |
|
293 |
} |
294 |
|
295 |
public void close() throws CloseException { |
296 |
// TODO Auto-generated method stub
|
297 |
|
298 |
} |
299 |
|
300 |
public void dispose() throws CloseException { |
301 |
// TODO Auto-generated method stub
|
302 |
|
303 |
} |
304 |
|
305 |
public DataSet getDataSet() throws ReadException { |
306 |
// TODO Auto-generated method stub
|
307 |
return null; |
308 |
} |
309 |
|
310 |
public DataSet getSelection() {
|
311 |
// TODO Auto-generated method stub
|
312 |
return null; |
313 |
} |
314 |
|
315 |
public void setSelection(DataSet selection) { |
316 |
// TODO Auto-generated method stub
|
317 |
|
318 |
} |
319 |
|
320 |
public DataSet createSelection() {
|
321 |
// TODO Auto-generated method stub
|
322 |
return null; |
323 |
} |
324 |
|
325 |
public Iterator getChilds() { |
326 |
// TODO Auto-generated method stub
|
327 |
return null; |
328 |
} |
329 |
|
330 |
public boolean isEditable() { |
331 |
// TODO Auto-generated method stub
|
332 |
return false; |
333 |
} |
334 |
|
335 |
public void edit() throws ReadException { |
336 |
// TODO Auto-generated method stub
|
337 |
|
338 |
} |
339 |
|
340 |
public void cancelEditing() { |
341 |
// TODO Auto-generated method stub
|
342 |
|
343 |
} |
344 |
|
345 |
public void finishEditing() throws WriteException, ReadException { |
346 |
// TODO Auto-generated method stub
|
347 |
|
348 |
} |
349 |
|
350 |
public boolean isEditing() { |
351 |
// TODO Auto-generated method stub
|
352 |
return false; |
353 |
} |
354 |
|
355 |
public void undo() { |
356 |
// TODO Auto-generated method stub
|
357 |
|
358 |
} |
359 |
|
360 |
public void redo() { |
361 |
// TODO Auto-generated method stub
|
362 |
|
363 |
} |
364 |
|
365 |
public CommandsRecord getCommandsRecord() {
|
366 |
// TODO Auto-generated method stub
|
367 |
return null; |
368 |
} |
369 |
|
370 |
public void beginComplexNotification() { |
371 |
// TODO Auto-generated method stub
|
372 |
|
373 |
} |
374 |
|
375 |
public void endComplexNotification() { |
376 |
// TODO Auto-generated method stub
|
377 |
|
378 |
} |
379 |
|
380 |
public DataSet getLocked() {
|
381 |
// TODO Auto-generated method stub
|
382 |
return null; |
383 |
} |
384 |
|
385 |
public void setLocked(DataSet locked) { |
386 |
// TODO Auto-generated method stub
|
387 |
|
388 |
} |
389 |
|
390 |
public DataSet createLocked() {
|
391 |
// TODO Auto-generated method stub
|
392 |
return null; |
393 |
} |
394 |
|
395 |
public DataExplorer getExplorer() throws ReadException { |
396 |
// TODO Auto-generated method stub
|
397 |
return null; |
398 |
} |
399 |
|
400 |
public void addObserver(Observer o) { |
401 |
// TODO Auto-generated method stub
|
402 |
|
403 |
} |
404 |
|
405 |
public void deleteObserver(Observer o) { |
406 |
// TODO Auto-generated method stub
|
407 |
|
408 |
} |
409 |
|
410 |
public void deleteObservers() { |
411 |
// TODO Auto-generated method stub
|
412 |
|
413 |
} |
414 |
|
415 |
public Metadata getMetadata() throws BaseException { |
416 |
// TODO Auto-generated method stub
|
417 |
return null; |
418 |
} |
419 |
// public void start() throws ReadDriverException { }
|
420 |
// public void stop() throws ReadDriverException { }
|
421 |
// public long[] getWhereFilter() throws IOException {return null;}
|
422 |
// public DataSourceFactory getDataSourceFactory() {return null;}
|
423 |
// public Memento getMemento() throws MementoException {return null;}
|
424 |
// public void setDataSourceFactory(DataSourceFactory dsf) { }
|
425 |
// public void setSourceInfo(SourceInfo sourceInfo) { }
|
426 |
// public SourceInfo getSourceInfo() {return null;}
|
427 |
// public String getAsString() throws ReadDriverException {return null;}
|
428 |
// public void remove() throws WriteDriverException { }
|
429 |
// public int[] getPrimaryKeys() throws ReadDriverException {return null;}
|
430 |
// public ValueCollection getPKValue(long rowIndex)throws ReadDriverException {return null;}
|
431 |
// public String getPKName(int fieldId) throws ReadDriverException {return null;}
|
432 |
// public String[] getPKNames() throws ReadDriverException {return null;}
|
433 |
// public int getPKType(int i) throws ReadDriverException {return 0;}
|
434 |
// public int getPKCardinality() throws ReadDriverException {return 0;}
|
435 |
// public Value[] getRow(long rowIndex) throws ReadDriverException {return null;}
|
436 |
// public DataWare getDataWare(int mode) throws ReadDriverException {return null;}
|
437 |
// public boolean isVirtualField(int fieldId) throws ReadDriverException {return false;}
|
438 |
// public Driver getDriver() {return null;}
|
439 |
// public void reload() throws ReloadDriverException { }
|
440 |
// public void addDataSourceListener(IDataSourceListener listener) { }
|
441 |
// public void removeDataSourceListener(IDataSourceListener listener) { }
|
442 |
// public Value getFieldValue(long rowIndex, int fieldId)throws ReadDriverException {return null;}
|
443 |
// public int getFieldCount() throws ReadDriverException {return 0;}
|
444 |
// public long getRowCount() throws ReadDriverException {return 0;}
|
445 |
// public int getFieldWidth(int i) throws ReadDriverException {return 0;}
|
446 |
//
|
447 |
// public String getFieldName(int fieldId) throws ReadDriverException {
|
448 |
// return fieldNames[fieldId];
|
449 |
// }
|
450 |
//
|
451 |
// public String getName(){
|
452 |
// return "Mock datasource used for testing only";
|
453 |
// }
|
454 |
//
|
455 |
// public String[] getFieldNames() throws ReadDriverException {
|
456 |
// return fieldNames;
|
457 |
// }
|
458 |
//
|
459 |
// public int getFieldIndexByName(String fieldName)throws ReadDriverException {
|
460 |
// for (int i = 0; i < fieldNames.length; i++) {
|
461 |
// if (fieldNames[i].equals(fieldName))
|
462 |
// return i;
|
463 |
// }
|
464 |
// return -1;
|
465 |
// }
|
466 |
//
|
467 |
// public int getFieldType(int i) throws ReadDriverException {
|
468 |
// return Types.INTEGER;
|
469 |
// }
|
470 |
|
471 |
public boolean implementsOperation(int code) { |
472 |
// TODO Auto-generated method stub
|
473 |
return false; |
474 |
} |
475 |
|
476 |
public boolean implementsOperation(String name) { |
477 |
// TODO Auto-generated method stub
|
478 |
return false; |
479 |
} |
480 |
|
481 |
public Object invokeOperation(int code, |
482 |
DataStoreOperationContext context) |
483 |
throws DataStoreOperationException,
|
484 |
DataStoreOperationNotSupportedException { |
485 |
// TODO Auto-generated method stub
|
486 |
return null; |
487 |
} |
488 |
|
489 |
public Object invokeOperation(String name, |
490 |
DataStoreOperationContext context) |
491 |
throws DataStoreOperationException,
|
492 |
DataStoreOperationNotSupportedException { |
493 |
// TODO Auto-generated method stub
|
494 |
return null; |
495 |
} |
496 |
|
497 |
public boolean canWriteGeometry(int gvSIGgeometryType) { |
498 |
// TODO Auto-generated method stub
|
499 |
return false; |
500 |
} |
501 |
|
502 |
public Feature getByIndex(long index) throws ReadException { |
503 |
// TODO Auto-generated method stub
|
504 |
return null; |
505 |
} |
506 |
|
507 |
public void createIndex(FeatureType fType, String colName) throws IndexException { |
508 |
// TODO Auto-generated method stub
|
509 |
|
510 |
} |
511 |
|
512 |
public boolean hasIndex(FeatureType fType, String colName) { |
513 |
// TODO Auto-generated method stub
|
514 |
return false; |
515 |
} |
516 |
|
517 |
public XMLEntity getXMLEntity() {
|
518 |
// TODO Auto-generated method stub
|
519 |
return null; |
520 |
} |
521 |
|
522 |
public void setXMLEntity(XMLEntity xmlEntity) throws XMLException { |
523 |
// TODO Auto-generated method stub
|
524 |
|
525 |
} |
526 |
|
527 |
public String getClassName() { |
528 |
// TODO Auto-generated method stub
|
529 |
return null; |
530 |
} |
531 |
|
532 |
public FeatureAttributeDescriptor addEvaluatedAttribute(
|
533 |
FeatureType featureType, String attributeName,
|
534 |
String attributeType, String expression, |
535 |
AttributeValueEvaluator evaluator) throws ReadException {
|
536 |
// TODO Auto-generated method stub
|
537 |
return null; |
538 |
} |
539 |
|
540 |
public void removeEvaluatedAttribute(FeatureAttributeDescriptor attibute) |
541 |
throws DataException {
|
542 |
// TODO Auto-generated method stub
|
543 |
|
544 |
} |
545 |
|
546 |
public DataSet getDataCollection(FeatureQuery featureQuery)
|
547 |
throws ReadException {
|
548 |
// TODO Auto-generated method stub
|
549 |
return null; |
550 |
} |
551 |
|
552 |
public void getDataCollection(FeatureQuery featureQuery, |
553 |
Observer observer) throws DataException { |
554 |
// TODO Auto-generated method stub
|
555 |
|
556 |
} |
557 |
|
558 |
public FeatureSet getFeatureSet() throws ReadException { |
559 |
// TODO Auto-generated method stub
|
560 |
return null; |
561 |
} |
562 |
|
563 |
public FeatureSet getFeatureSet(FeatureQuery featureQuery)
|
564 |
throws ReadException {
|
565 |
// TODO Auto-generated method stub
|
566 |
return null; |
567 |
} |
568 |
|
569 |
public void getFeatureSet(FeatureQuery featureQuery, |
570 |
Observer observer) throws DataException { |
571 |
// TODO Auto-generated method stub
|
572 |
|
573 |
} |
574 |
|
575 |
public void getFeatureSet(Observer observer) |
576 |
throws DataException {
|
577 |
// TODO Auto-generated method stub
|
578 |
|
579 |
} |
580 |
|
581 |
public DataSet getDataSet(DataQuery dataQuery)
|
582 |
throws ReadException {
|
583 |
// TODO Auto-generated method stub
|
584 |
return null; |
585 |
} |
586 |
|
587 |
public void getDataSet(DataQuery dataQuery, Observer observer) |
588 |
throws DataException {
|
589 |
// TODO Auto-generated method stub
|
590 |
|
591 |
} |
592 |
|
593 |
public final DefaultFeatureSelection getFeatureSelection() { |
594 |
return null; |
595 |
} |
596 |
|
597 |
public DefaultFeatureSelection createFeatureSelection() {
|
598 |
return null; |
599 |
} |
600 |
|
601 |
public final void setSelection(DefaultFeatureSelection selection) throws DataException { |
602 |
} |
603 |
|
604 |
} |
605 |
|
606 |
//private static final FInterval interval0=new FInterval(0,2);
|
607 |
//private static final FInterval interval1=new FInterval(3,5);
|
608 |
//private static final FInterval interval2=new FInterval(6,2);
|
609 |
//private static final FInterval interval3=new FInterval(9,2);
|
610 |
// private static final Value interval4;
|
611 |
// private static final Value interval5;
|
612 |
// private static final Value interval6;
|
613 |
// private static final Value interval7;
|
614 |
// private static final Value interval8;
|
615 |
// private static final Value interval9;
|
616 |
|
617 |
Hashtable symTable;
|
618 |
|
619 |
private IClassifiedVectorLegend[] classifiedLegends; |
620 |
private ISymbol[] symbols; |
621 |
private Object[] sampleValues = new Object[] { v0, v1, v2, v3, }; |
622 |
private Feature[] features; |
623 |
|
624 |
// private FInterval[] intervals = new FInterval[] {
|
625 |
// interval0,
|
626 |
// interval1,
|
627 |
// interval2,
|
628 |
// interval3,
|
629 |
// interval4,
|
630 |
// interval5,
|
631 |
// interval6,
|
632 |
// interval7,
|
633 |
// interval8,
|
634 |
// interval9,
|
635 |
// };
|
636 |
|
637 |
protected void setUp() throws Exception { |
638 |
super.setUp();
|
639 |
features = new Feature[4]; |
640 |
|
641 |
// initialize test values
|
642 |
for (int i = 0; i < features.length; i++) { |
643 |
GeometryFactory geomFactory=GeometryManager.getInstance().getGeometryFactory(); |
644 |
// create the geometry associated to the feature
|
645 |
int size = 200; |
646 |
Dimension d = new Dimension(size, size); |
647 |
Rectangle aShape = new Rectangle(i * size, i * size, d.width, |
648 |
d.height); |
649 |
Geometry geom = geomFactory.createPolyline2D(new GeneralPathX(
|
650 |
aShape)); |
651 |
|
652 |
/*
|
653 |
* create a full-featured Feature with randomed values at its fields
|
654 |
* to avoid testing over the same values each time
|
655 |
*/
|
656 |
// features[i] = new DefaultFeature(geom, featureValues[i], "[" + i
|
657 |
// + "]");
|
658 |
} |
659 |
|
660 |
// initialize the symbol subset for this test
|
661 |
symbols = TestISymbol.getNewSymbolInstances(); |
662 |
|
663 |
// initialize the legends for this test
|
664 |
ILegend[] allLegends = TestILegend.getNewLegendInstances();
|
665 |
ArrayList clegends = new ArrayList(); |
666 |
ArrayList intervalLegends = new ArrayList(); |
667 |
for (int i = 0; i < allLegends.length; i++) { |
668 |
if (allLegends[i] instanceof AbstractIntervalLegend) { |
669 |
intervalLegends.add(allLegends[i]); |
670 |
} else if (allLegends[i] instanceof IClassifiedLegend) { |
671 |
clegends.add(allLegends[i]); |
672 |
} |
673 |
|
674 |
if (allLegends[i] instanceof IClassifiedVectorLegend) { |
675 |
IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i]; |
676 |
cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] }); |
677 |
cvl.setFeatureStore(mockDataSource); |
678 |
|
679 |
} |
680 |
} |
681 |
|
682 |
this.classifiedLegends = (IClassifiedVectorLegend[]) clegends |
683 |
.toArray(new IClassifiedVectorLegend[clegends.size()]);
|
684 |
this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends |
685 |
.toArray(new AbstractIntervalLegend[intervalLegends.size()]);
|
686 |
} |
687 |
|
688 |
/**
|
689 |
* This method is used to add symbols to a legend.That is, it takes an array
|
690 |
* of IClassifiedVectorialLegend which is empty andm, using a second array
|
691 |
* of objects (values), the first one is filled.Also, a hash table is filled
|
692 |
* too using the array of objects (it will be useful in some tests to check
|
693 |
* that a symbol can be taken using a feature) .
|
694 |
*
|
695 |
* @param legend
|
696 |
* @return
|
697 |
*/
|
698 |
private void fillClassifiedLegend(IClassifiedVectorLegend legend, |
699 |
Object[] values) { |
700 |
// initialize the hash table
|
701 |
symTable = new Hashtable(); |
702 |
|
703 |
// to add symbols to the legend and the hash table
|
704 |
for (int j = 0; j < values.length; j++) { |
705 |
|
706 |
ISymbol sym = symbols[j % symbols.length]; |
707 |
legend.addSymbol(values[j], sym); |
708 |
symTable.put(values[j], sym); |
709 |
} |
710 |
} |
711 |
|
712 |
/**
|
713 |
* This test ensures that when a legend is filled, the number of symbols
|
714 |
* added is correct. To do it, is checked that the number of symbols of a
|
715 |
* legend is the same as the length of the array of example values that we
|
716 |
* have.
|
717 |
*
|
718 |
* @throws ReadDriverException
|
719 |
*/
|
720 |
public void testICLAdittion() throws ReadException { |
721 |
|
722 |
// Fills the legend
|
723 |
for (int i = 0; i < classifiedLegends.length; i++) { |
724 |
fillClassifiedLegend(classifiedLegends[i], sampleValues); |
725 |
} |
726 |
|
727 |
for (int i = 0; i < classifiedLegends.length; i++) { |
728 |
assertEquals(classifiedLegends[i].getClassName() |
729 |
+ " fails with the comparation of the number of symbols",
|
730 |
classifiedLegends[i].getSymbols().length, |
731 |
sampleValues.length); |
732 |
} |
733 |
|
734 |
} |
735 |
|
736 |
/**
|
737 |
* This test ensures that the symbols that we have previously added to a
|
738 |
* legend are accessible using its features.To do it, this test compares the
|
739 |
* symbol taken from the legend with the symbol taken from the hashTable
|
740 |
* (using the same feature).
|
741 |
*
|
742 |
* @throws ReadDriverException
|
743 |
*/
|
744 |
|
745 |
public void testICLCheckValueSymbols() throws ReadException { |
746 |
// fills the legends
|
747 |
for (int i = 0; i < classifiedLegends.length; i++) { |
748 |
fillClassifiedLegend(classifiedLegends[i], sampleValues); |
749 |
} |
750 |
|
751 |
for (int i = 0; i < classifiedLegends.length; i++) { |
752 |
// For each feature
|
753 |
for (int j = 0; j < features.length; j++) { |
754 |
Feature myFeature = features[i]; |
755 |
// takes the value of the field that identifies the feature
|
756 |
Object val = myFeature.get(FIELDID);
|
757 |
// the last value is used to access to the hash table to obtain
|
758 |
// a symbol
|
759 |
ISymbol tableSym = (ISymbol) symTable.get(val); |
760 |
|
761 |
IClassifiedVectorLegend leg = classifiedLegends[i]; |
762 |
// takes the symbol from a legend using the feature
|
763 |
ISymbol legendSym = leg.getSymbolByFeature(myFeature); |
764 |
// compares that both symbols are the same
|
765 |
assertEquals(legendSym.getClassName() |
766 |
+ " fails with the comparation of the class symbols",
|
767 |
legendSym, tableSym); |
768 |
} |
769 |
} |
770 |
} |
771 |
|
772 |
} |