Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.symbology / src / test / java / org / gvsig / symbology / fmap / mapcontext / rendering / legend / TestAbstractIntervalLegend.java @ 30754

History | View | Annotate | Download (23.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.Hashtable;
47
import java.util.Iterator;
48
import java.util.List;
49
import java.util.Set;
50

    
51
import org.cresques.cts.IProjection;
52
import org.gvsig.fmap.dal.DataQuery;
53
import org.gvsig.fmap.dal.DataServerExplorer;
54
import org.gvsig.fmap.dal.DataSet;
55
import org.gvsig.fmap.dal.DataStoreParameters;
56
import org.gvsig.fmap.dal.exception.DataException;
57
import org.gvsig.fmap.dal.exception.ReadException;
58
import org.gvsig.fmap.dal.feature.EditableFeature;
59
import org.gvsig.fmap.dal.feature.EditableFeatureType;
60
import org.gvsig.fmap.dal.feature.Feature;
61
import org.gvsig.fmap.dal.feature.FeatureIndex;
62
import org.gvsig.fmap.dal.feature.FeatureIndexes;
63
import org.gvsig.fmap.dal.feature.FeatureLocks;
64
import org.gvsig.fmap.dal.feature.FeatureQuery;
65
import org.gvsig.fmap.dal.feature.FeatureReference;
66
import org.gvsig.fmap.dal.feature.FeatureSelection;
67
import org.gvsig.fmap.dal.feature.FeatureSet;
68
import org.gvsig.fmap.dal.feature.FeatureStore;
69
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms;
70
import org.gvsig.fmap.dal.feature.FeatureType;
71
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
72
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
73
import org.gvsig.fmap.geom.GeometryLocator;
74
import org.gvsig.fmap.geom.GeometryManager;
75
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
76
import org.gvsig.fmap.geom.Geometry.TYPES;
77
import org.gvsig.fmap.geom.primitive.Curve;
78
import org.gvsig.fmap.geom.primitive.Envelope;
79
import org.gvsig.fmap.geom.primitive.GeneralPathX;
80
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
81
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
82
import org.gvsig.metadata.Metadata;
83
import org.gvsig.metadata.exceptions.MetadataNotFoundException;
84
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractIntervalLegend;
85
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.FInterval;
86
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestISymbol;
87
import org.gvsig.tools.dynobject.DynClass;
88
import org.gvsig.tools.dynobject.DynObject;
89
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
90
import org.gvsig.tools.dynobject.exception.DynMethodException;
91
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
92
import org.gvsig.tools.observer.Observer;
93
import org.gvsig.tools.operations.OperationContext;
94
import org.gvsig.tools.operations.OperationException;
95
import org.gvsig.tools.operations.OperationNotSupportedException;
96
import org.gvsig.tools.persistence.PersistenceException;
97
import org.gvsig.tools.persistence.PersistentState;
98
import org.gvsig.tools.undo.RedoException;
99
import org.gvsig.tools.undo.UndoException;
100

    
101
/**
102
 * Integration test to ensure that the legends which implements the
103
 * IVectorialIntervalLegend interface follow the rules that follow the managing
104
 * of them by the application.
105
 *
106
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
107
 */
108
public class TestAbstractIntervalLegend extends AbstractLibraryAutoInitTestCase {
109

    
110
        private static final Integer v0 = new Integer(0);
111
        private static final Integer v1 = new Integer(1);
112
        private static final Integer v2 = new Integer(2);
113
        private static final Integer v3 = new Integer(3);
114

    
115
        private static final String FIELD3 = "field3";
116
        private static final String FIELD2 = "field2";
117
        private static final String FIELD1 = "field1";
118
        private static final String FIELD0 = "field0";
119
        private static final int FIELDID = 0;
120

    
121
        private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, };
122
        private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, };
123
        private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, };
124
        private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, };
125

    
126
        private static final Integer[][] featureValues = new Integer[][] {
127
                feature0Values,
128
                feature1Values,
129
                feature2Values,
130
                feature3Values,};
131

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

    
134

    
135
        // private static final Value v4 = (Value)ValueFactory.createValue(4);
136
        // private static final Value v5 = (Value)ValueFactory.createValue(5);
137
        // private static final Value v6 = (Value)ValueFactory.createValue(6);
138
        // private static final Value v7 = (Value)ValueFactory.createValue(7);
139
        // private static final Value v8 = (Value)ValueFactory.createValue(8);
140
        // private static final Value v9 = (Value)ValueFactory.createValue(9);
141

    
142
        private AbstractIntervalLegend[] intervalLegends;
143
        private MockDataSource mockDataSource = new MockDataSource();
144

    
145
        /**
146
         * To avoid duplicated validation logic in the test a mock object is created
147
         * to use a DataSource for this test.
148
         *
149
         */
150
        private class MockDataSource implements FeatureStore {
151

    
152
                public boolean allowWrite() {
153
                        // TODO Auto-generated method stub
154
                        return false;
155
                }
156

    
157
                public void beginEditingGroup(String description)
158
                                throws NeedEditingModeException {
159
                        // TODO Auto-generated method stub
160

    
161
                }
162

    
163
                public boolean canWriteGeometry(int gvSIGgeometryType)
164
                                throws DataException {
165
                        // TODO Auto-generated method stub
166
                        return false;
167
                }
168

    
169
                public void cancelEditing() throws DataException {
170
                        // TODO Auto-generated method stub
171

    
172
                }
173

    
174
                public FeatureSelection createFeatureSelection() throws DataException {
175
                        // TODO Auto-generated method stub
176
                        return null;
177
                }
178

    
179
                public FeatureIndex createIndex(FeatureType featureType,
180
                                String attributeName, String indexName) throws DataException {
181
                        // TODO Auto-generated method stub
182
                        return null;
183
                }
184

    
185
                public EditableFeature createNewFeature() throws DataException {
186
                        // TODO Auto-generated method stub
187
                        return null;
188
                }
189

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

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

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

    
208
                public void delete(Feature feature) throws DataException {
209
                        // TODO Auto-generated method stub
210

    
211
                }
212

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

    
216
                }
217

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

    
221
                }
222

    
223
                public void endEditingGroup() throws NeedEditingModeException {
224
                        // TODO Auto-generated method stub
225

    
226
                }
227

    
228
                public void export(DataServerExplorer explorer,
229
                                NewFeatureStoreParameters params) throws DataException {
230
                        // TODO Auto-generated method stub
231

    
232
                }
233

    
234
                public void finishEditing() throws DataException {
235
                        // TODO Auto-generated method stub
236

    
237
                }
238

    
239
                public FeatureType getDefaultFeatureType() throws DataException {
240
                        // TODO Auto-generated method stub
241
                        return null;
242
                }
243

    
244
                public Envelope getEnvelope() {
245
                        // TODO Auto-generated method stub
246
                        return null;
247
                }
248

    
249
                public Feature getFeatureByReference(FeatureReference reference)
250
                                throws DataException {
251
                        // TODO Auto-generated method stub
252
                        return null;
253
                }
254

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

    
261
                public FeatureSelection getFeatureSelection() throws DataException {
262
                        // TODO Auto-generated method stub
263
                        return null;
264
                }
265

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

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

    
277
                public void getFeatureSet(FeatureQuery featureQuery, Observer observer)
278
                                throws DataException {
279
                        // TODO Auto-generated method stub
280

    
281
                }
282

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

    
286
                }
287

    
288
                public List getFeatureTypes() throws DataException {
289
                        // TODO Auto-generated method stub
290
                        return null;
291
                }
292

    
293
                public FeatureIndexes getIndexes() {
294
                        // TODO Auto-generated method stub
295
                        return null;
296
                }
297

    
298
                public FeatureLocks getLocks() throws DataException {
299
                        // TODO Auto-generated method stub
300
                        return null;
301
                }
302

    
303
                public DataStoreParameters getParameters() {
304
                        // TODO Auto-generated method stub
305
                        return null;
306
                }
307

    
308
                public IProjection getSRSDefaultGeometry() throws DataException {
309
                        // TODO Auto-generated method stub
310
                        return null;
311
                }
312

    
313
                public FeatureStoreTransforms getTransforms() {
314
                        // TODO Auto-generated method stub
315
                        return null;
316
                }
317

    
318
                public void insert(EditableFeature feature) throws DataException {
319
                        // TODO Auto-generated method stub
320

    
321
                }
322

    
323
                public boolean isAppendModeSupported() {
324
                        // TODO Auto-generated method stub
325
                        return false;
326
                }
327

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

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

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

    
343

    
344
                public void setSelection(FeatureSet selection) throws DataException {
345
                        // TODO Auto-generated method stub
346

    
347
                }
348
                public void update(EditableFeatureType featureType)
349
                                throws DataException {
350
                        // TODO Auto-generated method stub
351

    
352
                }
353

    
354
                public void update(EditableFeature feature) throws DataException {
355
                        // TODO Auto-generated method stub
356

    
357
                }
358

    
359
                public void validateFeatures(int mode) throws DataException {
360
                        // TODO Auto-generated method stub
361

    
362
                }
363

    
364
                public DataSet createSelection() throws DataException {
365
                        // TODO Auto-generated method stub
366
                        return null;
367
                }
368

    
369
                public void dispose() throws DataException {
370
                        // TODO Auto-generated method stub
371

    
372
                }
373

    
374
                public Iterator getChildren() {
375
                        // TODO Auto-generated method stub
376
                        return null;
377
                }
378

    
379
                public DataSet getDataSet() throws DataException {
380
                        // TODO Auto-generated method stub
381
                        return null;
382
                }
383

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

    
389
                public void getDataSet(Observer observer) throws DataException {
390
                        // TODO Auto-generated method stub
391

    
392
                }
393

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

    
398
                }
399

    
400
                public DataServerExplorer getExplorer() throws DataException {
401
                        // TODO Auto-generated method stub
402
                        return null;
403
                }
404

    
405
                public String getName() {
406
                        // TODO Auto-generated method stub
407
                        return null;
408
                }
409

    
410
                public DataSet getSelection() throws DataException {
411
                        // TODO Auto-generated method stub
412
                        return null;
413
                }
414

    
415
                public void refresh() throws DataException {
416
                        // TODO Auto-generated method stub
417

    
418
                }
419

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

    
423
                }
424

    
425
                public void beginComplexNotification() {
426
                        // TODO Auto-generated method stub
427

    
428
                }
429

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

    
433
                }
434

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

    
438
                }
439

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

    
443
                }
444

    
445
                public void addObserver(Observer o) {
446
                        // TODO Auto-generated method stub
447

    
448
                }
449

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

    
453
                }
454

    
455
                public void deleteObservers() {
456
                        // TODO Auto-generated method stub
457

    
458
                }
459

    
460
                public PersistentState getState() throws PersistenceException {
461
                        // TODO Auto-generated method stub
462
                        return null;
463
                }
464

    
465
                public void saveToState(PersistentState state)
466
                                throws PersistenceException {
467
                        // TODO Auto-generated method stub
468

    
469
                }
470

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

    
474
                }
475

    
476
                public Object getOperation(int code) throws OperationException,
477
                                OperationNotSupportedException {
478
                        // TODO Auto-generated method stub
479
                        return null;
480
                }
481

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

    
488
                public boolean hasOperation(int code) {
489
                        // TODO Auto-generated method stub
490
                        return false;
491
                }
492

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

    
498
                public Object invokeOperation(int code, OperationContext context)
499
                                throws OperationException, OperationNotSupportedException {
500
                        // TODO Auto-generated method stub
501
                        return null;
502
                }
503

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

    
510
                public FeatureQuery createFeatureQuery() {
511
                        // TODO Auto-generated method stub
512
                        return null;
513
                }
514

    
515
                public boolean canRedo() {
516
                        // TODO Auto-generated method stub
517
                        return false;
518
                }
519

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

    
525
                public List getRedoInfos() {
526
                        // TODO Auto-generated method stub
527
                        return null;
528
                }
529

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

    
535
                public void redo() throws RedoException {
536
                        // TODO Auto-generated method stub
537

    
538
                }
539

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

    
543
                }
544

    
545
                public void undo() throws UndoException {
546
                        // TODO Auto-generated method stub
547

    
548
                }
549

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

    
553
                }
554

    
555
                public FeatureIndex createIndex(FeatureType featureType,
556
                                String attributeName, String indexName, Observer observer)
557
                                throws DataException {
558
                        // TODO Auto-generated method stub
559
                        return null;
560
                }
561

    
562
                public Metadata getMetadata() throws MetadataNotFoundException {
563
                        // TODO Auto-generated method stub
564
                        return null;
565
                }
566

    
567
                public Object getMetadataID() {
568
                        // TODO Auto-generated method stub
569
                        return null;
570
                }
571

    
572
                public void delegate(DynObject dynObject) {
573
                        // TODO Auto-generated method stub
574

    
575
                }
576

    
577
                public DynClass getDynClass() {
578
                        // TODO Auto-generated method stub
579
                        return null;
580
                }
581

    
582
                public Object getDynValue(String name) throws DynFieldNotFoundException {
583
                        // TODO Auto-generated method stub
584
                        return null;
585
                }
586

    
587
                public boolean hasDynValue(String name) {
588
                        // TODO Auto-generated method stub
589
                        return false;
590
                }
591

    
592
                public void implement(DynClass dynClass) {
593
                        // TODO Auto-generated method stub
594

    
595
                }
596

    
597
                public Object invokeDynMethod(String name, DynObject context)
598
                                throws DynMethodException {
599
                        // TODO Auto-generated method stub
600
                        return null;
601
                }
602

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

    
609
                public void setDynValue(String name, Object value)
610
                                throws DynFieldNotFoundException {
611
                        // TODO Auto-generated method stub
612

    
613
                }
614

    
615
                /*
616
                 * (non-Javadoc)
617
                 *
618
                 * @see org.gvsig.metadata.Metadata#getMetadataChildren()
619
                 */
620
                public Set getMetadataChildren() {
621
                        // TODO Auto-generated method stub
622
                        return null;
623
                }
624

    
625
                /*
626
                 * (non-Javadoc)
627
                 *
628
                 * @see org.gvsig.metadata.Metadata#getMetadataName()
629
                 */
630
                public String getMetadataName() {
631
                        // TODO Auto-generated method stub
632
                        return null;
633
                }
634

    
635
                public FeatureType getFeatureType(String featureTypeId)
636
                                throws DataException {
637
                        // TODO Auto-generated method stub
638
                        return null;
639
                }
640

    
641
                public DataQuery createQuery() {
642
                        // TODO Auto-generated method stub
643
                        return null;
644
                }
645

    
646
                public long getFeatureCount() throws DataException {
647
                        // TODO Auto-generated method stub
648
                        return 0;
649
                }
650

    
651

    
652
        }
653

    
654
         private static final FInterval interval0=new FInterval(0,2);
655
         private static final FInterval interval1=new FInterval(3,5);
656
         private static final FInterval interval2=new FInterval(6,8);
657
         private static final FInterval interval3=new FInterval(9,11);
658
        // private static final Value interval4;
659
        // private static final Value interval5;
660
        // private static final Value interval6;
661
        // private static final Value interval7;
662
        // private static final Value interval8;
663
        // private static final Value interval9;
664

    
665
        Hashtable symTable;
666

    
667
        private ISymbol[] symbols;
668
        private FInterval[] sampleIntervals = new FInterval[] { interval0, interval1, interval2, interval3, };
669
        private Feature[] features;
670

    
671
        // private FInterval[] intervals = new FInterval[] {
672
        // interval0,
673
        // interval1,
674
        // interval2,
675
        // interval3,
676
        // interval4,
677
        // interval5,
678
        // interval6,
679
        // interval7,
680
        // interval8,
681
        // interval9,
682
        // };
683

    
684
        protected void doSetUp() throws Exception {
685
                features = new Feature[4];
686

    
687
                // initialize test values
688
                for (int i = 0; i < features.length; i++) {
689

    
690
                        // create the geometry associated to the feature
691
                        int size = 200;
692
                        Dimension d = new Dimension(size, size);
693
                        Rectangle aShape = new Rectangle(i * size, i * size, d.width,
694
                                        d.height);
695
                        GeometryManager geomManager = GeometryLocator.getGeometryManager();
696
                        Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
697
                        curve.setGeneralPath(new GeneralPathX(aShape.getPathIterator(null)));
698

    
699
                        /*
700
                         * create a full-featured Feature with randomed values at its fields
701
                         * to avoid testing over the same values each time
702
                         */
703
                        //TODO
704
//                        features[i] = new MemoryFeature(geom, featureValues[i], "[" + i
705
//                                        + "]");
706
                }
707

    
708
                // initialize the symbol subset for this test
709
                TestISymbol.addSymbols();
710
                symbols = TestISymbol.getNewSymbolInstances();
711

    
712
                // initialize the legends for this test
713
                ILegend[] allLegends = TestILegend.getNewLegendInstances();
714
                ArrayList intervalLegends = new ArrayList();
715
                for (int i = 0; i < allLegends.length; i++) {
716

    
717
                        if (allLegends[i] instanceof AbstractIntervalLegend) {
718
                                intervalLegends.add(allLegends[i]);
719
                        }
720

    
721
                        if (allLegends[i] instanceof IClassifiedVectorLegend) {
722
                                IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i];
723
                                cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] });
724
//                                cvl.setFeatureStore(mockDataSource);
725

    
726
                        }
727
                }
728

    
729
                this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends
730
                                .toArray(new AbstractIntervalLegend[intervalLegends.size()]);
731
        }
732

    
733
        /**
734
         * This method is used to add symbols to a legend.That is, it takes an array
735
         * of AbstractIntervalLegend which is empty and, using a second array
736
         * of FIntervals(values), the first one is filled.Also, a hash table is filled
737
         * using the array of FIntervals (it will be useful in some tests to check
738
         * that a symbol can be taken using a feature) .
739
         *
740
         * @param legend
741
         * @return
742
         */
743
        private void fillClassifiedLegend(AbstractIntervalLegend legend,
744
                        FInterval[] values) {
745
                // initialize the hash table
746
                symTable = new Hashtable();
747

    
748
                // to add symbols to the legend and the hash table
749
                for (int j = 0; j < values.length; j++) {
750

    
751
                        ISymbol sym = symbols[j % symbols.length];
752
                        legend.addSymbol(values[j], sym);
753
                        symTable.put(values[j], sym);
754
                }
755
        }
756

    
757
        /**
758
         * This test ensures that when a legend is filled, the number of symbols
759
         * added is correct. To do it, is checked that the number of symbols of a
760
         * legend is the same as the length of the array of example values that we
761
         * have.
762
         *
763
         * @throws ReadDriverException
764
         */
765
        public void testICLAdittion() throws ReadException {
766

    
767
                // Fills the legend
768
                for (int i = 0; i < intervalLegends.length; i++) {
769
                        fillClassifiedLegend(intervalLegends[i], sampleIntervals);
770
                }
771

    
772
                for (int i = 0; i < intervalLegends.length; i++) {
773
                        assertEquals(intervalLegends[i].getClass().getName()
774
                                        + " fails with the comparation of the number of symbols",
775
                                        intervalLegends[i].getSymbols().length,
776
                                        sampleIntervals.length);
777
                }
778

    
779
        }
780

    
781
        /**
782
         * This test ensures that the symbols that we have previously added to a
783
         * legend are accessible using its features.To do it, this test compares the
784
         * symbol taken from the legend with the symbol taken from the hashTable
785
         * (using the same feature).
786
         * @throws Exception 
787
         */
788
        public void testICLCheckValueSymbols() throws Exception {
789

    
790
                ISymbol tableSym =null;
791

    
792
                // fills the legends
793
                for (int i = 0; i < intervalLegends.length; i++) {
794
                        fillClassifiedLegend(intervalLegends[i], sampleIntervals);
795
                }
796

    
797
                for (int i = 0; i < intervalLegends.length; i++) {
798
                        // For each feature
799
                        for (int j = 0; j < features.length; j++) {
800
                                Feature myFeature = features[i];
801
                                // takes the value of the field that identifies the feature
802
                                Object val = myFeature.get(FIELDID);
803
                                // the last value is used to access to the hash table to obtain
804
                                // a symbol
805

    
806
                                if(interval0.isInInterval(val)) {
807
                                        tableSym = (ISymbol) symTable.get(interval0);
808
                                } else if(interval1.isInInterval(val)) {
809
                                        tableSym = (ISymbol) symTable.get(interval1);
810
                                } else if(interval2.isInInterval(val)) {
811
                                        tableSym = (ISymbol) symTable.get(interval2);
812
                                } else if(interval3.isInInterval(val)) {
813
                                        tableSym = (ISymbol) symTable.get(interval3);
814
                                }
815

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

    
827
}
828

    
829