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 @ 42488
History | View | Annotate | Download (21.7 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 |
public Feature getFeature(DynObject dynobject) {
|
687 |
// TODO Auto-generated method stub
|
688 |
return null; |
689 |
} |
690 |
|
691 |
@Override
|
692 |
public EditableFeature createNewFeature(Feature defaultValues) throws DataException { |
693 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
694 |
} |
695 |
|
696 |
@Override
|
697 |
public Iterator iterator() { |
698 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
699 |
} |
700 |
} |
701 |
|
702 |
private static final FInterval interval0=new FInterval(0,2); |
703 |
private static final FInterval interval1=new FInterval(3,5); |
704 |
private static final FInterval interval2=new FInterval(6,8); |
705 |
private static final FInterval interval3=new FInterval(9,11); |
706 |
// private static final Value interval4;
|
707 |
// private static final Value interval5;
|
708 |
// private static final Value interval6;
|
709 |
// private static final Value interval7;
|
710 |
// private static final Value interval8;
|
711 |
// private static final Value interval9;
|
712 |
|
713 |
Hashtable symTable;
|
714 |
|
715 |
private ISymbol[] symbols; |
716 |
private FInterval[] sampleIntervals = new FInterval[] { interval0, interval1, interval2, interval3, }; |
717 |
private Feature[] features; |
718 |
|
719 |
// private FInterval[] intervals = new FInterval[] {
|
720 |
// interval0,
|
721 |
// interval1,
|
722 |
// interval2,
|
723 |
// interval3,
|
724 |
// interval4,
|
725 |
// interval5,
|
726 |
// interval6,
|
727 |
// interval7,
|
728 |
// interval8,
|
729 |
// interval9,
|
730 |
// };
|
731 |
|
732 |
protected void doSetUp() throws Exception { |
733 |
features = new Feature[4]; |
734 |
|
735 |
// initialize test values
|
736 |
for (int i = 0; i < features.length; i++) { |
737 |
|
738 |
// create the geometry associated to the feature
|
739 |
int size = 200; |
740 |
Dimension d = new Dimension(size, size); |
741 |
Rectangle aShape = new Rectangle(i * size, i * size, d.width, |
742 |
d.height); |
743 |
GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
744 |
Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D); |
745 |
curve.setGeneralPath(new GeneralPathX(aShape.getPathIterator(null))); |
746 |
|
747 |
/*
|
748 |
* create a full-featured Feature with randomed values at its fields
|
749 |
* to avoid testing over the same values each time
|
750 |
*/
|
751 |
//TODO
|
752 |
// features[i] = new MemoryFeature(geom, featureValues[i], "[" + i
|
753 |
// + "]");
|
754 |
} |
755 |
|
756 |
// initialize the symbol subset for this test
|
757 |
TestISymbol.addSymbols(); |
758 |
symbols = TestISymbol.getNewSymbolInstances(); |
759 |
|
760 |
// initialize the legends for this test
|
761 |
ILegend[] allLegends = TestILegend.getNewLegendInstances();
|
762 |
ArrayList intervalLegends = new ArrayList(); |
763 |
for (int i = 0; i < allLegends.length; i++) { |
764 |
|
765 |
if (allLegends[i] instanceof AbstractIntervalLegend) { |
766 |
intervalLegends.add(allLegends[i]); |
767 |
} |
768 |
|
769 |
if (allLegends[i] instanceof IClassifiedVectorLegend) { |
770 |
IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i]; |
771 |
cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] }); |
772 |
// cvl.setFeatureStore(mockDataSource);
|
773 |
|
774 |
} |
775 |
} |
776 |
|
777 |
this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends |
778 |
.toArray(new AbstractIntervalLegend[intervalLegends.size()]);
|
779 |
} |
780 |
|
781 |
/**
|
782 |
* This method is used to add symbols to a legend.That is, it takes an array
|
783 |
* of AbstractIntervalLegend which is empty and, using a second array
|
784 |
* of FIntervals(values), the first one is filled.Also, a hash table is filled
|
785 |
* using the array of FIntervals (it will be useful in some tests to check
|
786 |
* that a symbol can be taken using a feature) .
|
787 |
*
|
788 |
* @param legend
|
789 |
* @return
|
790 |
*/
|
791 |
private void fillClassifiedLegend(AbstractIntervalLegend legend, |
792 |
FInterval[] values) {
|
793 |
// initialize the hash table
|
794 |
symTable = new Hashtable(); |
795 |
|
796 |
// to add symbols to the legend and the hash table
|
797 |
for (int j = 0; j < values.length; j++) { |
798 |
|
799 |
ISymbol sym = symbols[j % symbols.length]; |
800 |
legend.addSymbol(values[j], sym); |
801 |
symTable.put(values[j], sym); |
802 |
} |
803 |
} |
804 |
|
805 |
/**
|
806 |
* This test ensures that when a legend is filled, the number of symbols
|
807 |
* added is correct. To do it, is checked that the number of symbols of a
|
808 |
* legend is the same as the length of the array of example values that we
|
809 |
* have.
|
810 |
*
|
811 |
* @throws ReadDriverException
|
812 |
*/
|
813 |
public void testICLAdittion() throws ReadException { |
814 |
|
815 |
// Fills the legend
|
816 |
for (int i = 0; i < intervalLegends.length; i++) { |
817 |
fillClassifiedLegend(intervalLegends[i], sampleIntervals); |
818 |
} |
819 |
|
820 |
for (int i = 0; i < intervalLegends.length; i++) { |
821 |
assertEquals(intervalLegends[i].getClass().getName() |
822 |
+ " fails with the comparation of the number of symbols",
|
823 |
intervalLegends[i].getSymbols().length, |
824 |
sampleIntervals.length); |
825 |
} |
826 |
|
827 |
} |
828 |
|
829 |
/**
|
830 |
* This test ensures that the symbols that we have previously added to a
|
831 |
* legend are accessible using its features.To do it, this test compares the
|
832 |
* symbol taken from the legend with the symbol taken from the hashTable
|
833 |
* (using the same feature).
|
834 |
* @throws Exception
|
835 |
*/
|
836 |
public void testICLCheckValueSymbols() throws Exception { |
837 |
|
838 |
ISymbol tableSym =null;
|
839 |
|
840 |
// fills the legends
|
841 |
for (int i = 0; i < intervalLegends.length; i++) { |
842 |
fillClassifiedLegend(intervalLegends[i], sampleIntervals); |
843 |
} |
844 |
|
845 |
for (int i = 0; i < intervalLegends.length; i++) { |
846 |
// For each feature
|
847 |
for (int j = 0; j < features.length; j++) { |
848 |
Feature myFeature = features[i]; |
849 |
// takes the value of the field that identifies the feature
|
850 |
Object val = myFeature.get(FIELDID);
|
851 |
// the last value is used to access to the hash table to obtain
|
852 |
// a symbol
|
853 |
|
854 |
if(interval0.isInInterval(val)) {
|
855 |
tableSym = (ISymbol) symTable.get(interval0); |
856 |
} else if(interval1.isInInterval(val)) { |
857 |
tableSym = (ISymbol) symTable.get(interval1); |
858 |
} else if(interval2.isInInterval(val)) { |
859 |
tableSym = (ISymbol) symTable.get(interval2); |
860 |
} else if(interval3.isInInterval(val)) { |
861 |
tableSym = (ISymbol) symTable.get(interval3); |
862 |
} |
863 |
|
864 |
AbstractIntervalLegend leg = intervalLegends[i]; |
865 |
// takes the symbol from a legend using the feature
|
866 |
ISymbol legendSym = leg.getSymbolByFeature(myFeature); |
867 |
// compares that both symbols are the same
|
868 |
assertEquals(legendSym.getClass().getName() |
869 |
+ " fails with the comparation of the class symbols",
|
870 |
legendSym, tableSym); |
871 |
} |
872 |
} |
873 |
} |
874 |
|
875 |
} |
876 |
|
877 |
|