svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.lib / org.gvsig.symbology.lib.impl / src / test / java / org / gvsig / symbology / fmap / mapcontext / rendering / legend / TestAbstractIntervalLegend.java @ 40560
History | View | Annotate | Download (21.1 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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.
|
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.
|
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.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.symbology.fmap.mapcontext.rendering.legend; |
25 |
|
26 |
import java.awt.Dimension; |
27 |
import java.awt.Rectangle; |
28 |
import java.util.ArrayList; |
29 |
import java.util.Collection; |
30 |
import java.util.Hashtable; |
31 |
import java.util.Iterator; |
32 |
import java.util.List; |
33 |
import java.util.Set; |
34 |
|
35 |
import org.cresques.cts.IProjection; |
36 |
|
37 |
import org.gvsig.fmap.dal.DataQuery; |
38 |
import org.gvsig.fmap.dal.DataServerExplorer; |
39 |
import org.gvsig.fmap.dal.DataSet; |
40 |
import org.gvsig.fmap.dal.DataStoreParameters; |
41 |
import org.gvsig.fmap.dal.exception.DataException; |
42 |
import org.gvsig.fmap.dal.exception.ReadException; |
43 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
44 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
45 |
import org.gvsig.fmap.dal.feature.Feature; |
46 |
import org.gvsig.fmap.dal.feature.FeatureCache; |
47 |
import org.gvsig.fmap.dal.feature.FeatureIndex; |
48 |
import org.gvsig.fmap.dal.feature.FeatureIndexes; |
49 |
import org.gvsig.fmap.dal.feature.FeatureLocks; |
50 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
51 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
52 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
53 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
54 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
55 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms; |
56 |
import org.gvsig.fmap.dal.feature.FeatureType; |
57 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
58 |
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException; |
59 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
60 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
61 |
import org.gvsig.fmap.geom.GeometryLocator; |
62 |
import org.gvsig.fmap.geom.GeometryManager; |
63 |
import org.gvsig.fmap.geom.primitive.Curve; |
64 |
import org.gvsig.fmap.geom.primitive.Envelope; |
65 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
66 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend; |
67 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
68 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
69 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractIntervalLegend; |
70 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval; |
71 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestISymbol; |
72 |
import org.gvsig.timesupport.Interval; |
73 |
import org.gvsig.tools.dynobject.DynClass; |
74 |
import org.gvsig.tools.dynobject.DynObject; |
75 |
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException; |
76 |
import org.gvsig.tools.dynobject.exception.DynMethodException; |
77 |
import org.gvsig.tools.exception.BaseException; |
78 |
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase; |
79 |
import org.gvsig.tools.observer.Observer; |
80 |
import org.gvsig.tools.persistence.PersistentState; |
81 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
82 |
import org.gvsig.tools.undo.RedoException; |
83 |
import org.gvsig.tools.undo.UndoException; |
84 |
import org.gvsig.tools.visitor.Visitor; |
85 |
|
86 |
|
87 |
/**
|
88 |
* Integration test to ensure that the legends which implements the
|
89 |
* IVectorialIntervalLegend interface follow the rules that follow the managing
|
90 |
* of them by the application.
|
91 |
*
|
92 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
93 |
*/
|
94 |
public class TestAbstractIntervalLegend extends AbstractLibraryAutoInitTestCase { |
95 |
|
96 |
private static final Integer v0 = new Integer(0); |
97 |
private static final Integer v1 = new Integer(1); |
98 |
private static final Integer v2 = new Integer(2); |
99 |
private static final Integer v3 = new Integer(3); |
100 |
|
101 |
private static final String FIELD3 = "field3"; |
102 |
private static final String FIELD2 = "field2"; |
103 |
private static final String FIELD1 = "field1"; |
104 |
private static final String FIELD0 = "field0"; |
105 |
private static final int FIELDID = 0; |
106 |
|
107 |
private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, }; |
108 |
private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, }; |
109 |
private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, }; |
110 |
private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, }; |
111 |
|
112 |
private static final Integer[][] featureValues = new Integer[][] { |
113 |
feature0Values, |
114 |
feature1Values, |
115 |
feature2Values, |
116 |
feature3Values,}; |
117 |
|
118 |
private static String[] fieldNames = new String[] {FIELD0,FIELD1,FIELD2,FIELD3,}; |
119 |
|
120 |
|
121 |
// private static final Value v4 = (Value)ValueFactory.createValue(4);
|
122 |
// private static final Value v5 = (Value)ValueFactory.createValue(5);
|
123 |
// private static final Value v6 = (Value)ValueFactory.createValue(6);
|
124 |
// private static final Value v7 = (Value)ValueFactory.createValue(7);
|
125 |
// private static final Value v8 = (Value)ValueFactory.createValue(8);
|
126 |
// private static final Value v9 = (Value)ValueFactory.createValue(9);
|
127 |
|
128 |
private AbstractIntervalLegend[] intervalLegends; |
129 |
private MockDataSource mockDataSource = new MockDataSource(); |
130 |
|
131 |
/**
|
132 |
* To avoid duplicated validation logic in the test a mock object is created
|
133 |
* to use a DataSource for this test.
|
134 |
*
|
135 |
*/
|
136 |
private class MockDataSource implements FeatureStore { |
137 |
|
138 |
public boolean allowWrite() { |
139 |
|
140 |
return false; |
141 |
} |
142 |
|
143 |
public void beginEditingGroup(String description) |
144 |
throws NeedEditingModeException {
|
145 |
|
146 |
|
147 |
} |
148 |
|
149 |
public boolean canWriteGeometry(int gvSIGgeometryType) |
150 |
throws DataException {
|
151 |
|
152 |
return false; |
153 |
} |
154 |
|
155 |
public void cancelEditing() throws DataException { |
156 |
|
157 |
|
158 |
} |
159 |
|
160 |
public FeatureSelection createFeatureSelection() throws DataException { |
161 |
|
162 |
return null; |
163 |
} |
164 |
|
165 |
public FeatureIndex createIndex(FeatureType featureType,
|
166 |
String attributeName, String indexName) throws DataException { |
167 |
|
168 |
return null; |
169 |
} |
170 |
|
171 |
public EditableFeature createNewFeature() throws DataException { |
172 |
|
173 |
return null; |
174 |
} |
175 |
|
176 |
public EditableFeature createNewFeature(FeatureType type,
|
177 |
Feature defaultValues) throws DataException {
|
178 |
|
179 |
return null; |
180 |
} |
181 |
|
182 |
public EditableFeature createNewFeature(FeatureType type,
|
183 |
boolean defaultValues) throws DataException { |
184 |
|
185 |
return null; |
186 |
} |
187 |
|
188 |
public EditableFeature createNewFeature(boolean defaultValues) |
189 |
throws DataException {
|
190 |
|
191 |
return null; |
192 |
} |
193 |
|
194 |
public void delete(Feature feature) throws DataException { |
195 |
|
196 |
|
197 |
} |
198 |
|
199 |
public void edit() throws DataException { |
200 |
|
201 |
|
202 |
} |
203 |
|
204 |
public void edit(int mode) throws DataException { |
205 |
|
206 |
|
207 |
} |
208 |
|
209 |
public void endEditingGroup() throws NeedEditingModeException { |
210 |
|
211 |
|
212 |
} |
213 |
|
214 |
public void finishEditing() throws DataException { |
215 |
|
216 |
|
217 |
} |
218 |
|
219 |
public FeatureType getDefaultFeatureType() throws DataException { |
220 |
|
221 |
return null; |
222 |
} |
223 |
|
224 |
public Envelope getEnvelope() {
|
225 |
|
226 |
return null; |
227 |
} |
228 |
|
229 |
public Feature getFeatureByReference(FeatureReference reference)
|
230 |
throws DataException {
|
231 |
|
232 |
return null; |
233 |
} |
234 |
|
235 |
public Feature getFeatureByReference(FeatureReference reference,
|
236 |
FeatureType featureType) throws DataException {
|
237 |
|
238 |
return null; |
239 |
} |
240 |
|
241 |
public FeatureSelection getFeatureSelection() throws DataException { |
242 |
|
243 |
return null; |
244 |
} |
245 |
|
246 |
public FeatureSet getFeatureSet() throws DataException { |
247 |
|
248 |
return null; |
249 |
} |
250 |
|
251 |
public FeatureSet getFeatureSet(FeatureQuery featureQuery)
|
252 |
throws DataException {
|
253 |
|
254 |
return null; |
255 |
} |
256 |
|
257 |
public void getFeatureSet(FeatureQuery featureQuery, Observer observer) |
258 |
throws DataException {
|
259 |
|
260 |
|
261 |
} |
262 |
|
263 |
public void getFeatureSet(Observer observer) throws DataException { |
264 |
|
265 |
|
266 |
} |
267 |
|
268 |
public List getFeatureTypes() throws DataException { |
269 |
|
270 |
return null; |
271 |
} |
272 |
|
273 |
public FeatureIndexes getIndexes() {
|
274 |
|
275 |
return null; |
276 |
} |
277 |
|
278 |
public FeatureLocks getLocks() throws DataException { |
279 |
|
280 |
return null; |
281 |
} |
282 |
|
283 |
public DataStoreParameters getParameters() {
|
284 |
|
285 |
return null; |
286 |
} |
287 |
|
288 |
public IProjection getSRSDefaultGeometry() throws DataException { |
289 |
|
290 |
return null; |
291 |
} |
292 |
|
293 |
public FeatureStoreTransforms getTransforms() {
|
294 |
|
295 |
return null; |
296 |
} |
297 |
|
298 |
public void insert(EditableFeature feature) throws DataException { |
299 |
|
300 |
|
301 |
} |
302 |
|
303 |
public boolean isAppendModeSupported() { |
304 |
|
305 |
return false; |
306 |
} |
307 |
|
308 |
public boolean isAppending() { |
309 |
|
310 |
return false; |
311 |
} |
312 |
|
313 |
public boolean isEditing() { |
314 |
|
315 |
return false; |
316 |
} |
317 |
|
318 |
public boolean isLocksSupported() { |
319 |
|
320 |
return false; |
321 |
} |
322 |
|
323 |
|
324 |
public void setSelection(FeatureSet selection) throws DataException { |
325 |
|
326 |
|
327 |
} |
328 |
public void update(EditableFeatureType featureType) |
329 |
throws DataException {
|
330 |
|
331 |
|
332 |
} |
333 |
|
334 |
public void update(EditableFeature feature) throws DataException { |
335 |
|
336 |
|
337 |
} |
338 |
|
339 |
public void validateFeatures(int mode) throws DataException { |
340 |
|
341 |
|
342 |
} |
343 |
|
344 |
public DataSet createSelection() throws DataException { |
345 |
|
346 |
return null; |
347 |
} |
348 |
|
349 |
public void dispose() { |
350 |
|
351 |
|
352 |
} |
353 |
|
354 |
public Iterator getChildren() { |
355 |
|
356 |
return null; |
357 |
} |
358 |
|
359 |
public DataSet getDataSet() throws DataException { |
360 |
|
361 |
return null; |
362 |
} |
363 |
|
364 |
public DataSet getDataSet(DataQuery dataQuery) throws DataException { |
365 |
|
366 |
return null; |
367 |
} |
368 |
|
369 |
public void getDataSet(Observer observer) throws DataException { |
370 |
|
371 |
|
372 |
} |
373 |
|
374 |
public void getDataSet(DataQuery dataQuery, Observer observer) |
375 |
throws DataException {
|
376 |
|
377 |
|
378 |
} |
379 |
|
380 |
public DataServerExplorer getExplorer() throws DataException { |
381 |
|
382 |
return null; |
383 |
} |
384 |
|
385 |
public String getName() { |
386 |
|
387 |
return null; |
388 |
} |
389 |
|
390 |
public DataSet getSelection() throws DataException { |
391 |
|
392 |
return null; |
393 |
} |
394 |
|
395 |
public void refresh() throws DataException { |
396 |
|
397 |
|
398 |
} |
399 |
|
400 |
public void setSelection(DataSet selection) throws DataException { |
401 |
|
402 |
|
403 |
} |
404 |
|
405 |
public void beginComplexNotification() { |
406 |
|
407 |
|
408 |
} |
409 |
|
410 |
public void disableNotifications() { |
411 |
|
412 |
|
413 |
} |
414 |
|
415 |
public void enableNotifications() { |
416 |
|
417 |
|
418 |
} |
419 |
|
420 |
public void endComplexNotification() { |
421 |
|
422 |
|
423 |
} |
424 |
|
425 |
public void addObserver(Observer o) { |
426 |
|
427 |
|
428 |
} |
429 |
|
430 |
public void deleteObserver(Observer o) { |
431 |
|
432 |
|
433 |
} |
434 |
|
435 |
public void deleteObservers() { |
436 |
|
437 |
|
438 |
} |
439 |
|
440 |
public void saveToState(PersistentState state) |
441 |
throws PersistenceException {
|
442 |
|
443 |
|
444 |
} |
445 |
|
446 |
public void loadFromState(PersistentState state) throws PersistenceException { |
447 |
|
448 |
|
449 |
} |
450 |
|
451 |
public FeatureQuery createFeatureQuery() {
|
452 |
|
453 |
return null; |
454 |
} |
455 |
|
456 |
public boolean canRedo() { |
457 |
|
458 |
return false; |
459 |
} |
460 |
|
461 |
public boolean canUndo() { |
462 |
|
463 |
return false; |
464 |
} |
465 |
|
466 |
public List getRedoInfos() { |
467 |
|
468 |
return null; |
469 |
} |
470 |
|
471 |
public List getUndoInfos() { |
472 |
|
473 |
return null; |
474 |
} |
475 |
|
476 |
public void redo() throws RedoException { |
477 |
|
478 |
|
479 |
} |
480 |
|
481 |
public void redo(int num) throws RedoException { |
482 |
|
483 |
|
484 |
} |
485 |
|
486 |
public void undo() throws UndoException { |
487 |
|
488 |
|
489 |
} |
490 |
|
491 |
public void undo(int num) throws UndoException { |
492 |
|
493 |
|
494 |
} |
495 |
|
496 |
public FeatureIndex createIndex(FeatureType featureType,
|
497 |
String attributeName, String indexName, Observer observer) |
498 |
throws DataException {
|
499 |
|
500 |
return null; |
501 |
} |
502 |
|
503 |
public Object getMetadataID() { |
504 |
|
505 |
return null; |
506 |
} |
507 |
|
508 |
public void delegate(DynObject dynObject) { |
509 |
|
510 |
|
511 |
} |
512 |
|
513 |
public DynClass getDynClass() {
|
514 |
|
515 |
return null; |
516 |
} |
517 |
|
518 |
public Object getDynValue(String name) throws DynFieldNotFoundException { |
519 |
|
520 |
return null; |
521 |
} |
522 |
|
523 |
public boolean hasDynValue(String name) { |
524 |
|
525 |
return false; |
526 |
} |
527 |
|
528 |
public void implement(DynClass dynClass) { |
529 |
|
530 |
|
531 |
} |
532 |
|
533 |
public Object invokeDynMethod(String name, DynObject context) |
534 |
throws DynMethodException {
|
535 |
|
536 |
return null; |
537 |
} |
538 |
|
539 |
public Object invokeDynMethod(int code, DynObject context) |
540 |
throws DynMethodException {
|
541 |
|
542 |
return null; |
543 |
} |
544 |
|
545 |
public void setDynValue(String name, Object value) |
546 |
throws DynFieldNotFoundException {
|
547 |
|
548 |
|
549 |
} |
550 |
|
551 |
/*
|
552 |
* (non-Javadoc)
|
553 |
*
|
554 |
* @see org.gvsig.metadata.Metadata#getMetadataChildren()
|
555 |
*/
|
556 |
public Set getMetadataChildren() { |
557 |
|
558 |
return null; |
559 |
} |
560 |
|
561 |
/*
|
562 |
* (non-Javadoc)
|
563 |
*
|
564 |
* @see org.gvsig.metadata.Metadata#getMetadataName()
|
565 |
*/
|
566 |
public String getMetadataName() { |
567 |
|
568 |
return null; |
569 |
} |
570 |
|
571 |
public FeatureType getFeatureType(String featureTypeId) |
572 |
throws DataException {
|
573 |
|
574 |
return null; |
575 |
} |
576 |
|
577 |
public DataQuery createQuery() {
|
578 |
|
579 |
return null; |
580 |
} |
581 |
|
582 |
public long getFeatureCount() throws DataException { |
583 |
|
584 |
return 0; |
585 |
} |
586 |
|
587 |
public void accept(Visitor visitor, DataQuery dataQuery) |
588 |
throws BaseException {
|
589 |
} |
590 |
|
591 |
public void accept(Visitor visitor) throws BaseException { |
592 |
} |
593 |
|
594 |
public void createCache(String name, |
595 |
DynObject parameters) throws DataException {
|
596 |
// Do nothing
|
597 |
} |
598 |
|
599 |
public FeatureCache getCache() {
|
600 |
return null; |
601 |
} |
602 |
|
603 |
public void clear() { |
604 |
// Nothing to do
|
605 |
} |
606 |
|
607 |
public void export(DataServerExplorer explorer, String provider, |
608 |
NewFeatureStoreParameters params) throws DataException {
|
609 |
// Nothing to do
|
610 |
} |
611 |
|
612 |
public String getProviderName() { |
613 |
return null; |
614 |
} |
615 |
|
616 |
public String getFullName() { |
617 |
// TODO Auto-generated method stub
|
618 |
return null; |
619 |
} |
620 |
|
621 |
public boolean isKnownEnvelope() { |
622 |
// TODO Auto-generated method stub
|
623 |
return false; |
624 |
} |
625 |
|
626 |
public boolean hasRetrievedFeaturesLimit() { |
627 |
// TODO Auto-generated method stub
|
628 |
return false; |
629 |
} |
630 |
|
631 |
public int getRetrievedFeaturesLimit() { |
632 |
// TODO Auto-generated method stub
|
633 |
return 0; |
634 |
} |
635 |
|
636 |
public FeatureIndex createIndex(String indexTypeName, |
637 |
FeatureType featureType, String attributeName, String indexName) |
638 |
throws DataException {
|
639 |
// TODO Auto-generated method stub
|
640 |
return null; |
641 |
} |
642 |
|
643 |
public FeatureIndex createIndex(String indexTypeName, |
644 |
FeatureType featureType, String attributeName, String indexName, |
645 |
Observer observer) throws DataException { |
646 |
// TODO Auto-generated method stub
|
647 |
return null; |
648 |
} |
649 |
|
650 |
public Interval getInterval() {
|
651 |
// TODO Auto-generated method stub
|
652 |
return null; |
653 |
} |
654 |
|
655 |
public Collection getTimes() { |
656 |
// TODO Auto-generated method stub
|
657 |
return null; |
658 |
} |
659 |
|
660 |
public Collection getTimes(Interval interval) { |
661 |
// TODO Auto-generated method stub
|
662 |
return null; |
663 |
} |
664 |
|
665 |
public Object clone() throws CloneNotSupportedException { |
666 |
// TODO Auto-generated method stub
|
667 |
return super.clone(); |
668 |
} |
669 |
|
670 |
/* (non-Javadoc)
|
671 |
* @see org.gvsig.fmap.dal.feature.FeatureStore#commitChanges()
|
672 |
*/
|
673 |
public void commitChanges() throws DataException { |
674 |
// TODO Auto-generated method stub
|
675 |
|
676 |
} |
677 |
|
678 |
/* (non-Javadoc)
|
679 |
* @see org.gvsig.fmap.dal.feature.FeatureStore#canCommitChanges()
|
680 |
*/
|
681 |
public boolean canCommitChanges() throws DataException { |
682 |
// TODO Auto-generated method stub
|
683 |
return false; |
684 |
} |
685 |
} |
686 |
|
687 |
private static final FInterval interval0=new FInterval(0,2); |
688 |
private static final FInterval interval1=new FInterval(3,5); |
689 |
private static final FInterval interval2=new FInterval(6,8); |
690 |
private static final FInterval interval3=new FInterval(9,11); |
691 |
// private static final Value interval4;
|
692 |
// private static final Value interval5;
|
693 |
// private static final Value interval6;
|
694 |
// private static final Value interval7;
|
695 |
// private static final Value interval8;
|
696 |
// private static final Value interval9;
|
697 |
|
698 |
Hashtable symTable;
|
699 |
|
700 |
private ISymbol[] symbols; |
701 |
private FInterval[] sampleIntervals = new FInterval[] { interval0, interval1, interval2, interval3, }; |
702 |
private Feature[] features; |
703 |
|
704 |
// private FInterval[] intervals = new FInterval[] {
|
705 |
// interval0,
|
706 |
// interval1,
|
707 |
// interval2,
|
708 |
// interval3,
|
709 |
// interval4,
|
710 |
// interval5,
|
711 |
// interval6,
|
712 |
// interval7,
|
713 |
// interval8,
|
714 |
// interval9,
|
715 |
// };
|
716 |
|
717 |
protected void doSetUp() throws Exception { |
718 |
features = new Feature[4]; |
719 |
|
720 |
// initialize test values
|
721 |
for (int i = 0; i < features.length; i++) { |
722 |
|
723 |
// create the geometry associated to the feature
|
724 |
int size = 200; |
725 |
Dimension d = new Dimension(size, size); |
726 |
Rectangle aShape = new Rectangle(i * size, i * size, d.width, |
727 |
d.height); |
728 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
729 |
Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
730 |
curve.setGeneralPath(new GeneralPathX(aShape.getPathIterator(null))); |
731 |
|
732 |
/*
|
733 |
* create a full-featured Feature with randomed values at its fields
|
734 |
* to avoid testing over the same values each time
|
735 |
*/
|
736 |
//TODO
|
737 |
// features[i] = new MemoryFeature(geom, featureValues[i], "[" + i
|
738 |
// + "]");
|
739 |
} |
740 |
|
741 |
// initialize the symbol subset for this test
|
742 |
TestISymbol.addSymbols(); |
743 |
symbols = TestISymbol.getNewSymbolInstances(); |
744 |
|
745 |
// initialize the legends for this test
|
746 |
ILegend[] allLegends = TestILegend.getNewLegendInstances();
|
747 |
ArrayList intervalLegends = new ArrayList(); |
748 |
for (int i = 0; i < allLegends.length; i++) { |
749 |
|
750 |
if (allLegends[i] instanceof AbstractIntervalLegend) { |
751 |
intervalLegends.add(allLegends[i]); |
752 |
} |
753 |
|
754 |
if (allLegends[i] instanceof IClassifiedVectorLegend) { |
755 |
IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i]; |
756 |
cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] }); |
757 |
// cvl.setFeatureStore(mockDataSource);
|
758 |
|
759 |
} |
760 |
} |
761 |
|
762 |
this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends |
763 |
.toArray(new AbstractIntervalLegend[intervalLegends.size()]);
|
764 |
} |
765 |
|
766 |
/**
|
767 |
* This method is used to add symbols to a legend.That is, it takes an array
|
768 |
* of AbstractIntervalLegend which is empty and, using a second array
|
769 |
* of FIntervals(values), the first one is filled.Also, a hash table is filled
|
770 |
* using the array of FIntervals (it will be useful in some tests to check
|
771 |
* that a symbol can be taken using a feature) .
|
772 |
*
|
773 |
* @param legend
|
774 |
* @return
|
775 |
*/
|
776 |
private void fillClassifiedLegend(AbstractIntervalLegend legend, |
777 |
FInterval[] values) {
|
778 |
// initialize the hash table
|
779 |
symTable = new Hashtable(); |
780 |
|
781 |
// to add symbols to the legend and the hash table
|
782 |
for (int j = 0; j < values.length; j++) { |
783 |
|
784 |
ISymbol sym = symbols[j % symbols.length]; |
785 |
legend.addSymbol(values[j], sym); |
786 |
symTable.put(values[j], sym); |
787 |
} |
788 |
} |
789 |
|
790 |
/**
|
791 |
* This test ensures that when a legend is filled, the number of symbols
|
792 |
* added is correct. To do it, is checked that the number of symbols of a
|
793 |
* legend is the same as the length of the array of example values that we
|
794 |
* have.
|
795 |
*
|
796 |
* @throws ReadDriverException
|
797 |
*/
|
798 |
public void testICLAdittion() throws ReadException { |
799 |
|
800 |
// Fills the legend
|
801 |
for (int i = 0; i < intervalLegends.length; i++) { |
802 |
fillClassifiedLegend(intervalLegends[i], sampleIntervals); |
803 |
} |
804 |
|
805 |
for (int i = 0; i < intervalLegends.length; i++) { |
806 |
assertEquals(intervalLegends[i].getClass().getName() |
807 |
+ " fails with the comparation of the number of symbols",
|
808 |
intervalLegends[i].getSymbols().length, |
809 |
sampleIntervals.length); |
810 |
} |
811 |
|
812 |
} |
813 |
|
814 |
/**
|
815 |
* This test ensures that the symbols that we have previously added to a
|
816 |
* legend are accessible using its features.To do it, this test compares the
|
817 |
* symbol taken from the legend with the symbol taken from the hashTable
|
818 |
* (using the same feature).
|
819 |
* @throws Exception
|
820 |
*/
|
821 |
public void testICLCheckValueSymbols() throws Exception { |
822 |
|
823 |
ISymbol tableSym =null;
|
824 |
|
825 |
// fills the legends
|
826 |
for (int i = 0; i < intervalLegends.length; i++) { |
827 |
fillClassifiedLegend(intervalLegends[i], sampleIntervals); |
828 |
} |
829 |
|
830 |
for (int i = 0; i < intervalLegends.length; i++) { |
831 |
// For each feature
|
832 |
for (int j = 0; j < features.length; j++) { |
833 |
Feature myFeature = features[i]; |
834 |
// takes the value of the field that identifies the feature
|
835 |
Object val = myFeature.get(FIELDID);
|
836 |
// the last value is used to access to the hash table to obtain
|
837 |
// a symbol
|
838 |
|
839 |
if(interval0.isInInterval(val)) {
|
840 |
tableSym = (ISymbol) symTable.get(interval0); |
841 |
} else if(interval1.isInInterval(val)) { |
842 |
tableSym = (ISymbol) symTable.get(interval1); |
843 |
} else if(interval2.isInInterval(val)) { |
844 |
tableSym = (ISymbol) symTable.get(interval2); |
845 |
} else if(interval3.isInInterval(val)) { |
846 |
tableSym = (ISymbol) symTable.get(interval3); |
847 |
} |
848 |
|
849 |
AbstractIntervalLegend leg = intervalLegends[i]; |
850 |
// takes the symbol from a legend using the feature
|
851 |
ISymbol legendSym = leg.getSymbolByFeature(myFeature); |
852 |
// compares that both symbols are the same
|
853 |
assertEquals(legendSym.getClass().getName() |
854 |
+ " fails with the comparation of the class symbols",
|
855 |
legendSym, tableSym); |
856 |
} |
857 |
} |
858 |
} |
859 |
|
860 |
} |
861 |
|
862 |
|