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