Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src-test / org / gvsig / fmap / mapcontext / rendering / TestIClassifiedLegend.java @ 28076

History | View | Annotate | Download (23.2 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.IClassifiedLegend;
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
/**
106
 * Integration test to ensure that the legends which implements the
107
 * IClassifiedLegend interface follow the rules that follow the managing of them
108
 * by the application.
109
 *
110
 * @author jaume dominguez faus - jaume.dominguez@iver.es
111
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
112
 */
113
public class TestIClassifiedLegend extends TestCase {
114

    
115
        private static final Integer v0 = new Integer(0);
116
        private static final Integer v1 = new Integer(1);
117
        private static final Integer v2 = new Integer(2);
118
        private static final Integer v3 = new Integer(3);
119

    
120
        private static final String FIELD3 = "field3";
121
        private static final String FIELD2 = "field2";
122
        private static final String FIELD1 = "field1";
123
        private static final String FIELD0 = "field0";
124
        private static final int FIELDID = 0;
125

    
126
        private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, };
127
        private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, };
128
        private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, };
129
        private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, };
130

    
131
        private static final Integer[][] featureValues = new Integer[][] {
132
                feature0Values,
133
                feature1Values,
134
                feature2Values,
135
                feature3Values,};
136

    
137
        private static String[] fieldNames = new String[] {FIELD0,FIELD1,FIELD2,FIELD3,};
138

    
139

    
140
        // private static final Value v4 = (Value)ValueFactory.createValue(4);
141
        // private static final Value v5 = (Value)ValueFactory.createValue(5);
142
        // private static final Value v6 = (Value)ValueFactory.createValue(6);
143
        // private static final Value v7 = (Value)ValueFactory.createValue(7);
144
        // private static final Value v8 = (Value)ValueFactory.createValue(8);
145
        // private static final Value v9 = (Value)ValueFactory.createValue(9);
146

    
147
        private AbstractIntervalLegend[] intervalLegends;
148
        private MockDataSource mockDataSource = new MockDataSource();
149

    
150
        /**
151
         * To avoid duplicated validation logic in the test a mock object is created
152
         * to use a DataSource for this test.
153
         *
154
         */
155
        private class MockDataSource implements FeatureStore {
156

    
157
                public boolean allowWrite() {
158
                        // TODO Auto-generated method stub
159
                        return false;
160
                }
161

    
162
                public void beginEditingGroup(String description)
163
                                throws NeedEditingModeException {
164
                        // TODO Auto-generated method stub
165

    
166
                }
167

    
168
                public boolean canWriteGeometry(int gvSIGgeometryType)
169
                                throws DataException {
170
                        // TODO Auto-generated method stub
171
                        return false;
172
                }
173

    
174
                public void cancelEditing() throws DataException {
175
                        // TODO Auto-generated method stub
176

    
177
                }
178

    
179
                public FeatureSelection createFeatureSelection() throws DataException {
180
                        // TODO Auto-generated method stub
181
                        return null;
182
                }
183

    
184
                public FeatureIndex createIndex(FeatureType featureType,
185
                                String attributeName, String indexName) throws DataException {
186
                        // TODO Auto-generated method stub
187
                        return null;
188
                }
189

    
190
                public EditableFeature createNewFeature() throws DataException {
191
                        // TODO Auto-generated method stub
192
                        return null;
193
                }
194

    
195
                public EditableFeature createNewFeature(FeatureType type,
196
                                Feature defaultValues) throws DataException {
197
                        // TODO Auto-generated method stub
198
                        return null;
199
                }
200

    
201
                public EditableFeature createNewFeature(FeatureType type,
202
                                boolean defaultValues) throws DataException {
203
                        // TODO Auto-generated method stub
204
                        return null;
205
                }
206

    
207
                public EditableFeature createNewFeature(boolean defaultValues)
208
                                throws DataException {
209
                        // TODO Auto-generated method stub
210
                        return null;
211
                }
212

    
213
                public void delete(Feature feature) throws DataException {
214
                        // TODO Auto-generated method stub
215

    
216
                }
217

    
218
                public void edit() throws DataException {
219
                        // TODO Auto-generated method stub
220

    
221
                }
222

    
223
                public void edit(int mode) throws DataException {
224
                        // TODO Auto-generated method stub
225

    
226
                }
227

    
228
                public void endEditingGroup() throws NeedEditingModeException {
229
                        // TODO Auto-generated method stub
230

    
231
                }
232

    
233
                public void export(DataServerExplorer explorer,
234
                                NewFeatureStoreParameters params) throws DataException {
235
                        // TODO Auto-generated method stub
236

    
237
                }
238

    
239
                public void finishEditing() throws DataException {
240
                        // TODO Auto-generated method stub
241

    
242
                }
243

    
244
                public FeatureType getDefaultFeatureType() throws DataException {
245
                        // TODO Auto-generated method stub
246
                        return null;
247
                }
248

    
249
                public Envelope getEnvelope() {
250
                        // TODO Auto-generated method stub
251
                        return null;
252
                }
253

    
254
                public Feature getFeatureByReference(FeatureReference reference)
255
                                throws DataException {
256
                        // TODO Auto-generated method stub
257
                        return null;
258
                }
259

    
260
                public Feature getFeatureByReference(FeatureReference reference,
261
                                FeatureType featureType) throws DataException {
262
                        // TODO Auto-generated method stub
263
                        return null;
264
                }
265

    
266
                public FeatureSelection getFeatureSelection() throws DataException {
267
                        // TODO Auto-generated method stub
268
                        return null;
269
                }
270

    
271
                public FeatureSet getFeatureSet() throws DataException {
272
                        // TODO Auto-generated method stub
273
                        return null;
274
                }
275

    
276
                public FeatureSet getFeatureSet(FeatureQuery featureQuery)
277
                                throws DataException {
278
                        // TODO Auto-generated method stub
279
                        return null;
280
                }
281

    
282
                public void getFeatureSet(FeatureQuery featureQuery, Observer observer)
283
                                throws DataException {
284
                        // TODO Auto-generated method stub
285

    
286
                }
287

    
288
                public void getFeatureSet(Observer observer) throws DataException {
289
                        // TODO Auto-generated method stub
290

    
291
                }
292

    
293
                public List getFeatureTypes() throws DataException {
294
                        // TODO Auto-generated method stub
295
                        return null;
296
                }
297

    
298
                public FeatureIndexes getIndexes() {
299
                        // TODO Auto-generated method stub
300
                        return null;
301
                }
302

    
303
                public FeatureLocks getLocks() throws DataException {
304
                        // TODO Auto-generated method stub
305
                        return null;
306
                }
307

    
308
                public DataStoreParameters getParameters() {
309
                        // TODO Auto-generated method stub
310
                        return null;
311
                }
312

    
313
                public IProjection getSRSDefaultGeometry() throws DataException {
314
                        // TODO Auto-generated method stub
315
                        return null;
316
                }
317

    
318
                public FeatureStoreTransforms getTransforms() {
319
                        // TODO Auto-generated method stub
320
                        return null;
321
                }
322

    
323
                public void insert(EditableFeature feature) throws DataException {
324
                        // TODO Auto-generated method stub
325

    
326
                }
327

    
328
                public boolean isAppendModeSupported() {
329
                        // TODO Auto-generated method stub
330
                        return false;
331
                }
332

    
333
                public boolean isAppending() {
334
                        // TODO Auto-generated method stub
335
                        return false;
336
                }
337

    
338
                public boolean isEditing() {
339
                        // TODO Auto-generated method stub
340
                        return false;
341
                }
342

    
343
                public boolean isLocksSupported() {
344
                        // TODO Auto-generated method stub
345
                        return false;
346
                }
347

    
348
                public void setSelection(FeatureSet selection) throws DataException {
349
                        // TODO Auto-generated method stub
350

    
351
                }
352

    
353
                public void update(EditableFeatureType featureType)
354
                                throws DataException {
355
                        // TODO Auto-generated method stub
356

    
357
                }
358

    
359
                public void update(EditableFeature feature) throws DataException {
360
                        // TODO Auto-generated method stub
361

    
362
                }
363

    
364
                public void validateFeatures(int mode) throws DataException {
365
                        // TODO Auto-generated method stub
366

    
367
                }
368

    
369
                public DataSet createSelection() throws DataException {
370
                        // TODO Auto-generated method stub
371
                        return null;
372
                }
373

    
374
                public void dispose() throws DataException {
375
                        // TODO Auto-generated method stub
376

    
377
                }
378

    
379
                public Iterator getChildren() {
380
                        // TODO Auto-generated method stub
381
                        return null;
382
                }
383

    
384
                public DataSet getDataSet() throws DataException {
385
                        // TODO Auto-generated method stub
386
                        return null;
387
                }
388

    
389
                public DataSet getDataSet(DataQuery dataQuery) throws DataException {
390
                        // TODO Auto-generated method stub
391
                        return null;
392
                }
393

    
394
                public void getDataSet(Observer observer) throws DataException {
395
                        // TODO Auto-generated method stub
396

    
397
                }
398

    
399
                public void getDataSet(DataQuery dataQuery, Observer observer)
400
                                throws DataException {
401
                        // TODO Auto-generated method stub
402

    
403
                }
404

    
405
                public DataServerExplorer getExplorer() throws DataException {
406
                        // TODO Auto-generated method stub
407
                        return null;
408
                }
409

    
410
                public String getName() {
411
                        // TODO Auto-generated method stub
412
                        return null;
413
                }
414

    
415
                public DataSet getSelection() throws DataException {
416
                        // TODO Auto-generated method stub
417
                        return null;
418
                }
419

    
420
                public void refresh() throws DataException {
421
                        // TODO Auto-generated method stub
422

    
423
                }
424

    
425
                public void setSelection(DataSet selection) throws DataException {
426
                        // TODO Auto-generated method stub
427

    
428
                }
429

    
430
                public void beginComplexNotification() {
431
                        // TODO Auto-generated method stub
432

    
433
                }
434

    
435
                public void disableNotifications() {
436
                        // TODO Auto-generated method stub
437

    
438
                }
439

    
440
                public void enableNotifications() {
441
                        // TODO Auto-generated method stub
442

    
443
                }
444

    
445
                public void endComplexNotification() {
446
                        // TODO Auto-generated method stub
447

    
448
                }
449

    
450
                public void addObserver(Observer o) {
451
                        // TODO Auto-generated method stub
452

    
453
                }
454

    
455
                public void deleteObserver(Observer o) {
456
                        // TODO Auto-generated method stub
457

    
458
                }
459

    
460
                public void deleteObservers() {
461
                        // TODO Auto-generated method stub
462

    
463
                }
464

    
465
                public PersistentState getState() throws PersistenceException {
466
                        // TODO Auto-generated method stub
467
                        return null;
468
                }
469

    
470
                public void saveToState(PersistentState state)
471
                                throws PersistenceException {
472
                        // TODO Auto-generated method stub
473

    
474
                }
475

    
476
                public void setState(PersistentState state) throws PersistenceException {
477
                        // TODO Auto-generated method stub
478

    
479
                }
480

    
481
                public Object getOperation(int code) throws OperationException,
482
                                OperationNotSupportedException {
483
                        // TODO Auto-generated method stub
484
                        return null;
485
                }
486

    
487
                public Object getOperation(String name) throws OperationException,
488
                                OperationNotSupportedException {
489
                        // TODO Auto-generated method stub
490
                        return null;
491
                }
492

    
493
                public boolean hasOperation(int code) {
494
                        // TODO Auto-generated method stub
495
                        return false;
496
                }
497

    
498
                public boolean hasOperation(String name) {
499
                        // TODO Auto-generated method stub
500
                        return false;
501
                }
502

    
503
                public Object invokeOperation(int code, OperationContext context)
504
                                throws OperationException, OperationNotSupportedException {
505
                        // TODO Auto-generated method stub
506
                        return null;
507
                }
508

    
509
                public Object invokeOperation(String name, OperationContext context)
510
                                throws OperationException, OperationNotSupportedException {
511
                        // TODO Auto-generated method stub
512
                        return null;
513
                }
514

    
515
                public FeatureQuery createFeatureQuery() {
516
                        // TODO Auto-generated method stub
517
                        return null;
518
                }
519

    
520
                public boolean canRedo() {
521
                        // TODO Auto-generated method stub
522
                        return false;
523
                }
524

    
525
                public boolean canUndo() {
526
                        // TODO Auto-generated method stub
527
                        return false;
528
                }
529

    
530
                public List getRedoInfos() {
531
                        // TODO Auto-generated method stub
532
                        return null;
533
                }
534

    
535
                public List getUndoInfos() {
536
                        // TODO Auto-generated method stub
537
                        return null;
538
                }
539

    
540
                public void redo() throws RedoException {
541
                        // TODO Auto-generated method stub
542

    
543
                }
544

    
545
                public void redo(int num) throws RedoException {
546
                        // TODO Auto-generated method stub
547

    
548
                }
549

    
550
                public void undo() throws UndoException {
551
                        // TODO Auto-generated method stub
552

    
553
                }
554

    
555
                public void undo(int num) throws UndoException {
556
                        // TODO Auto-generated method stub
557

    
558
                }
559

    
560
                public FeatureIndex createIndex(FeatureType featureType,
561
                                String attributeName, String indexName, Observer observer)
562
                                throws DataException {
563
                        // TODO Auto-generated method stub
564
                        return null;
565
                }
566

    
567
                public Metadata getMetadata() throws MetadataNotFoundException {
568
                        // TODO Auto-generated method stub
569
                        return null;
570
                }
571

    
572
                public Object getMetadataID() {
573
                        // TODO Auto-generated method stub
574
                        return null;
575
                }
576

    
577
                public void delegate(DynObject dynObject) {
578
                        // TODO Auto-generated method stub
579

    
580
                }
581

    
582
                public DynClass getDynClass() {
583
                        // TODO Auto-generated method stub
584
                        return null;
585
                }
586

    
587
                public Object getDynValue(String name) throws DynFieldNotFoundException {
588
                        // TODO Auto-generated method stub
589
                        return null;
590
                }
591

    
592
                public boolean hasDynValue(String name) {
593
                        // TODO Auto-generated method stub
594
                        return false;
595
                }
596

    
597
                public void implement(DynClass dynClass) {
598
                        // TODO Auto-generated method stub
599

    
600
                }
601

    
602
                public Object invokeDynMethod(String name, DynObject context)
603
                                throws DynMethodException {
604
                        // TODO Auto-generated method stub
605
                        return null;
606
                }
607

    
608
                public Object invokeDynMethod(int code, DynObject context)
609
                                throws DynMethodException {
610
                        // TODO Auto-generated method stub
611
                        return null;
612
                }
613

    
614
                public void setDynValue(String name, Object value)
615
                                throws DynFieldNotFoundException {
616
                        // TODO Auto-generated method stub
617

    
618
                }
619

    
620
                /*
621
                 * (non-Javadoc)
622
                 *
623
                 * @see org.gvsig.metadata.Metadata#getMetadataChildren()
624
                 */
625
                public Set getMetadataChildren() {
626
                        // TODO Auto-generated method stub
627
                        return null;
628
                }
629

    
630
                /*
631
                 * (non-Javadoc)
632
                 *
633
                 * @see org.gvsig.metadata.Metadata#getMetadataName()
634
                 */
635
                public String getMetadataName() {
636
                        // TODO Auto-generated method stub
637
                        return null;
638
                }
639

    
640
                public FeatureType getFeatureType(String featureTypeId)
641
                                throws DataException {
642
                        // TODO Auto-generated method stub
643
                        return null;
644
                }
645

    
646
                public DataQuery createQuery() {
647
                        // TODO Auto-generated method stub
648
                        return null;
649
                }
650

    
651
                public long getFeatureCount() throws DataException {
652
                        // TODO Auto-generated method stub
653
                        return 0;
654
                }
655

    
656
        }
657

    
658
        //private static final FInterval interval0=new FInterval(0,2);
659
        //private static final FInterval interval1=new FInterval(3,5);
660
        //private static final FInterval interval2=new FInterval(6,2);
661
        //private static final FInterval interval3=new FInterval(9,2);
662
        // private static final Value interval4;
663
        // private static final Value interval5;
664
        // private static final Value interval6;
665
        // private static final Value interval7;
666
        // private static final Value interval8;
667
        // private static final Value interval9;
668

    
669
        Hashtable symTable;
670

    
671
        private IClassifiedVectorLegend[] classifiedLegends;
672
        private ISymbol[] symbols;
673
        private Object[] sampleValues = new Object[] { v0, v1, v2, v3, };
674
        private Feature[] features;
675

    
676
        // private FInterval[] intervals = new FInterval[] {
677
        // interval0,
678
        // interval1,
679
        // interval2,
680
        // interval3,
681
        // interval4,
682
        // interval5,
683
        // interval6,
684
        // interval7,
685
        // interval8,
686
        // interval9,
687
        // };
688

    
689
        protected void setUp() throws Exception {
690
                super.setUp();
691
                features = new Feature[4];
692

    
693
                //Initializes the geometries library
694
                DefaultGeometryLibrary lib = new DefaultGeometryLibrary();
695
                lib.initialize();
696
                lib.postInitialize();
697

    
698
                // initialize test values
699
                for (int i = 0; i < features.length; i++) {
700
                        // create the geometry associated to the feature
701
                        int size = 200;
702
                        Dimension d = new Dimension(size, size);
703
                        Rectangle aShape = new Rectangle(i * size, i * size, d.width,
704
                                        d.height);
705
                        GeometryManager geomManager = GeometryLocator.getGeometryManager();
706
                        Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
707
                        curve.setGeneralPath(new GeneralPathX(aShape));
708

    
709
                        /*
710
                         * create a full-featured Feature with randomed values at its fields
711
                         * to avoid testing over the same values each time
712
                         */
713
//                        features[i] = new DefaultFeature(geom, featureValues[i], "[" + i
714
//                                        + "]");
715
                }
716

    
717
                // initialize the symbol subset for this test
718
                symbols = TestISymbol.getNewSymbolInstances();
719

    
720
                // initialize the legends for this test
721
                ILegend[] allLegends = TestILegend.getNewLegendInstances();
722
                ArrayList clegends = new ArrayList();
723
                ArrayList intervalLegends = new ArrayList();
724
                for (int i = 0; i < allLegends.length; i++) {
725
                        if (allLegends[i] instanceof AbstractIntervalLegend) {
726
                                intervalLegends.add(allLegends[i]);
727
                        } else if (allLegends[i] instanceof IClassifiedLegend) {
728
                                clegends.add(allLegends[i]);
729
                        }
730

    
731
                        if (allLegends[i] instanceof IClassifiedVectorLegend) {
732
                                IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i];
733
                                cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] });
734
                                cvl.setFeatureStore(mockDataSource);
735

    
736
                        }
737
                }
738

    
739
                this.classifiedLegends = (IClassifiedVectorLegend[]) clegends
740
                                .toArray(new IClassifiedVectorLegend[clegends.size()]);
741
                this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends
742
                                .toArray(new AbstractIntervalLegend[intervalLegends.size()]);
743
        }
744

    
745
        /**
746
         * This method is used to add symbols to a legend.That is, it takes an array
747
         * of IClassifiedVectorialLegend which is empty andm, using a second array
748
         * of objects (values), the first one is filled.Also, a hash table is filled
749
         * too using the array of objects (it will be useful in some tests to check
750
         * that a symbol can be taken using a feature) .
751
         *
752
         * @param legend
753
         * @return
754
         */
755
        private void fillClassifiedLegend(IClassifiedVectorLegend legend,
756
                        Object[] values) {
757
                // initialize the hash table
758
                symTable = new Hashtable();
759

    
760
                // to add symbols to the legend and the hash table
761
                for (int j = 0; j < values.length; j++) {
762

    
763
                        ISymbol sym = symbols[j % symbols.length];
764
                        legend.addSymbol(values[j], sym);
765
                        symTable.put(values[j], sym);
766
                }
767
        }
768

    
769
        /**
770
         * This test ensures that when a legend is filled, the number of symbols
771
         * added is correct. To do it, is checked that the number of symbols of a
772
         * legend is the same as the length of the array of example values that we
773
         * have.
774
         *
775
         * @throws ReadDriverException
776
         */
777
        public void testICLAdittion() throws ReadException {
778

    
779
                // Fills the legend
780
                for (int i = 0; i < classifiedLegends.length; i++) {
781
                        fillClassifiedLegend(classifiedLegends[i], sampleValues);
782
                }
783

    
784
                for (int i = 0; i < classifiedLegends.length; i++) {
785
                        assertEquals(classifiedLegends[i].getClassName()
786
                                        + " fails with the comparation of the number of symbols",
787
                                        classifiedLegends[i].getSymbols().length,
788
                                        sampleValues.length);
789
                }
790

    
791
        }
792

    
793
        /**
794
         * This test ensures that the symbols that we have previously added to a
795
         * legend are accessible using its features.To do it, this test compares the
796
         * symbol taken from the legend with the symbol taken from the hashTable
797
         * (using the same feature).
798
         *
799
         * @throws ReadDriverException
800
         */
801

    
802
        public void testICLCheckValueSymbols() throws ReadException {
803
                // fills the legends
804
                for (int i = 0; i < classifiedLegends.length; i++) {
805
                        fillClassifiedLegend(classifiedLegends[i], sampleValues);
806
                }
807

    
808
                for (int i = 0; i < classifiedLegends.length; i++) {
809
                        // For each feature
810
                        for (int j = 0; j < features.length; j++) {
811
                                Feature myFeature = features[i];
812
                                // takes the value of the field that identifies the feature
813
                                Object val = myFeature.get(FIELDID);
814
                                // the last value is used to access to the hash table to obtain
815
                                // a symbol
816
                                ISymbol tableSym = (ISymbol) symTable.get(val);
817

    
818
                                IClassifiedVectorLegend leg = classifiedLegends[i];
819
                                // takes the symbol from a legend using the feature
820
                                ISymbol legendSym = leg.getSymbolByFeature(myFeature);
821
                                // compares that both symbols are the same
822
                                assertEquals(legendSym.getClassName()
823
                                                + " fails with the comparation of the class symbols",
824
                                                legendSym, tableSym);
825
                        }
826
                }
827
        }
828

    
829
}