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