Statistics
| Revision:

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

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.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

    
50
import junit.framework.TestCase;
51

    
52
import org.gvsig.fmap.data.DataSet;
53
import org.gvsig.fmap.data.DataExplorer;
54
import org.gvsig.fmap.data.DataQuery;
55
import org.gvsig.fmap.data.DataStoreParameters;
56
import org.gvsig.fmap.data.exceptions.CloseException;
57
import org.gvsig.fmap.data.exceptions.DataException;
58
import org.gvsig.fmap.data.exceptions.InitializeException;
59
import org.gvsig.fmap.data.exceptions.OpenException;
60
import org.gvsig.fmap.data.exceptions.ReadException;
61
import org.gvsig.fmap.data.exceptions.WriteException;
62
import org.gvsig.fmap.data.feature.CommandsRecord;
63
import org.gvsig.fmap.data.feature.Feature;
64
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
65
import org.gvsig.fmap.data.feature.FeatureSet;
66
import org.gvsig.fmap.data.feature.FeatureReference;
67
import org.gvsig.fmap.data.feature.FeatureQuery;
68
import org.gvsig.fmap.data.feature.FeatureStore;
69
import org.gvsig.fmap.data.feature.FeatureType;
70
import org.gvsig.fmap.data.feature.expressionevaluator.AttributeValueEvaluator;
71
import org.gvsig.fmap.data.index.IndexException;
72
import org.gvsig.fmap.data.operation.DataStoreOperationContext;
73
import org.gvsig.fmap.data.operation.DataStoreOperationException;
74
import org.gvsig.fmap.data.operation.DataStoreOperationNotSupportedException;
75
import org.gvsig.fmap.geom.Geometry;
76
import org.gvsig.fmap.geom.GeometryFactory;
77
import org.gvsig.fmap.geom.GeometryManager;
78
import org.gvsig.fmap.geom.primitive.GeneralPathX;
79
import org.gvsig.fmap.mapcontext.rendering.legend.AbstractIntervalLegend;
80
import org.gvsig.fmap.mapcontext.rendering.legend.FInterval;
81
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend;
82
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
83
import org.gvsig.fmap.mapcontext.rendering.symbol.TestISymbol;
84
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
85
import org.gvsig.metadata.Metadata;
86
import org.gvsig.tools.exception.BaseException;
87
import org.gvsig.tools.observer.Observer;
88

    
89
import com.iver.utiles.XMLEntity;
90
import com.iver.utiles.XMLException;
91

    
92
/**
93
 * Integration test to ensure that the legends which implements the
94
 * IVectorialIntervalLegend interface follow the rules that follow the managing
95
 * of them by the application.
96
 *
97
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
98
 */
99
public class TestAbstractIntervalLegend extends TestCase {
100

    
101
        private static final Integer v0 = new Integer(0);
102
        private static final Integer v1 = new Integer(1);
103
        private static final Integer v2 = new Integer(2);
104
        private static final Integer v3 = new Integer(3);
105

    
106
        private static final String FIELD3 = "field3";
107
        private static final String FIELD2 = "field2";
108
        private static final String FIELD1 = "field1";
109
        private static final String FIELD0 = "field0";
110
        private static final int FIELDID = 0;
111

    
112
        private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, };
113
        private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, };
114
        private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, };
115
        private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, };
116

    
117
        private static final Integer[][] featureValues = new Integer[][] {
118
                feature0Values,
119
                feature1Values,
120
                feature2Values,
121
                feature3Values,};
122

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

    
125

    
126
        // private static final Value v4 = (Value)ValueFactory.createValue(4);
127
        // private static final Value v5 = (Value)ValueFactory.createValue(5);
128
        // private static final Value v6 = (Value)ValueFactory.createValue(6);
129
        // private static final Value v7 = (Value)ValueFactory.createValue(7);
130
        // private static final Value v8 = (Value)ValueFactory.createValue(8);
131
        // private static final Value v9 = (Value)ValueFactory.createValue(9);
132

    
133
        private AbstractIntervalLegend[] intervalLegends;
134
        private MockDataSource mockDataSource = new MockDataSource();
135

    
136
        /**
137
         * To avoid duplicated validation logic in the test a mock object is created
138
         * to use a DataSource for this test.
139
         *
140
         */
141
        private class MockDataSource implements FeatureStore {
142

    
143
                public DataSet getDataCollection(FeatureType type, String filter, String order) throws ReadException {
144
                        // TODO Auto-generated method stub
145
                        return null;
146
                }
147

    
148
                public DataSet getDataCollection(String[] fields, String filter, String order) throws ReadException {
149
                        // TODO Auto-generated method stub
150
                        return null;
151
                }
152

    
153
                public void getDataCollection(FeatureType type, String filter, String order, Observer observer) throws DataException {
154
                        // TODO Auto-generated method stub
155

    
156
                }
157

    
158
                public void getDataCollection(String[] fields, String filter, String order, Observer observer) throws DataException {
159
                        // TODO Auto-generated method stub
160

    
161
                }
162

    
163
                public void getDataSet(Observer observer) {
164
                        // TODO Auto-generated method stub
165

    
166
                }
167

    
168
                public Feature getFeatureByReference(FeatureReference reference) throws ReadException {
169
                        // TODO Auto-generated method stub
170
                        return null;
171
                }
172

    
173
                public Feature getFeatureByReference(FeatureReference reference, FeatureType featureType) throws ReadException {
174
                        // TODO Auto-generated method stub
175
                        return null;
176
                }
177

    
178
                public FeatureType getDefaultFeatureType() {
179
                        // TODO Auto-generated method stub
180
                        return null;
181
                }
182

    
183
                public List getFeatureTypes() {
184
                        // TODO Auto-generated method stub
185
                        return null;
186
                }
187

    
188
                public Feature createNewFeature(FeatureType type, boolean defaultValues) throws InitializeException {
189
                        // TODO Auto-generated method stub
190
                        return null;
191
                }
192

    
193
                public Feature createNewFeature(boolean defaultValues) throws InitializeException {
194
                        // TODO Auto-generated method stub
195
                        return null;
196
                }
197

    
198
                public void update(Feature feature) throws DataException {
199
                        // TODO Auto-generated method stub
200

    
201
                }
202

    
203
                public void delete(Feature feature) throws DataException {
204
                        // TODO Auto-generated method stub
205

    
206
                }
207

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

    
211
                }
212

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

    
216
                }
217

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

    
221
                }
222

    
223
                public void insert(FeatureAttributeDescriptor attributeDescriptor) throws DataException {
224
                        // TODO Auto-generated method stub
225

    
226
                }
227

    
228
                public void disableNotifications() {
229
                        // TODO Auto-generated method stub
230

    
231
                }
232

    
233
                public void enableNotifications() {
234
                        // TODO Auto-generated method stub
235

    
236
                }
237

    
238
                public boolean isLocked(FeatureReference id) {
239
                        // TODO Auto-generated method stub
240
                        return false;
241
                }
242

    
243
                public boolean lock(FeatureReference id) {
244
                        // TODO Auto-generated method stub
245
                        return false;
246
                }
247

    
248
                public boolean isWithDefaultLegend() {
249
                        // TODO Auto-generated method stub
250
                        return false;
251
                }
252

    
253
                public Object getDefaultLegend() throws ReadException {
254
                        // TODO Auto-generated method stub
255
                        return null;
256
                }
257

    
258
                public Object getDefaultLabelingStrategy() {
259
                        // TODO Auto-generated method stub
260
                        return null;
261
                }
262

    
263
                public boolean canAlterFeatureType() {
264
                        // TODO Auto-generated method stub
265
                        return false;
266
                }
267

    
268
                public DataStoreParameters getParameters() {
269
                        // TODO Auto-generated method stub
270
                        return null;
271
                }
272

    
273
                public String getName() {
274
                        // TODO Auto-generated method stub
275
                        return null;
276
                }
277

    
278
                public void init(DataStoreParameters parameters) throws InitializeException {
279
                        // TODO Auto-generated method stub
280

    
281
                }
282

    
283
                public void open() throws OpenException {
284
                        // TODO Auto-generated method stub
285

    
286
                }
287

    
288
                public void refresh() throws OpenException, InitializeException {
289
                        // TODO Auto-generated method stub
290

    
291
                }
292

    
293
                public void close() throws CloseException {
294
                        // TODO Auto-generated method stub
295

    
296
                }
297

    
298
                public void dispose() throws CloseException {
299
                        // TODO Auto-generated method stub
300

    
301
                }
302

    
303
                public DataSet getDataSet() throws ReadException {
304
                        // TODO Auto-generated method stub
305
                        return null;
306
                }
307

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

    
313
                public void setSelection(DataSet selection) {
314
                        // TODO Auto-generated method stub
315

    
316
                }
317

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

    
323
                public Iterator getChilds() {
324
                        // TODO Auto-generated method stub
325
                        return null;
326
                }
327

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

    
333
                public void edit() throws ReadException {
334
                        // TODO Auto-generated method stub
335

    
336
                }
337

    
338
                public void cancelEditing() {
339
                        // TODO Auto-generated method stub
340

    
341
                }
342

    
343
                public void finishEditing() throws WriteException, ReadException {
344
                        // TODO Auto-generated method stub
345

    
346
                }
347

    
348
                public boolean isEditing() {
349
                        // TODO Auto-generated method stub
350
                        return false;
351
                }
352

    
353
                public void undo() {
354
                        // TODO Auto-generated method stub
355

    
356
                }
357

    
358
                public void redo() {
359
                        // TODO Auto-generated method stub
360

    
361
                }
362

    
363
                public CommandsRecord getCommandsRecord() {
364
                        // TODO Auto-generated method stub
365
                        return null;
366
                }
367

    
368
                public void beginComplexNotification() {
369
                        // TODO Auto-generated method stub
370

    
371
                }
372

    
373
                public void endComplexNotification() {
374
                        // TODO Auto-generated method stub
375

    
376
                }
377

    
378
                public DataSet getLocked() {
379
                        // TODO Auto-generated method stub
380
                        return null;
381
                }
382

    
383
                public void setLocked(DataSet locked) {
384
                        // TODO Auto-generated method stub
385

    
386
                }
387

    
388
                public DataSet createLocked() {
389
                        // TODO Auto-generated method stub
390
                        return null;
391
                }
392

    
393
                public DataExplorer getExplorer() throws ReadException {
394
                        // TODO Auto-generated method stub
395
                        return null;
396
                }
397

    
398
                public void addObserver(Observer o) {
399
                        // TODO Auto-generated method stub
400

    
401
                }
402

    
403
                public void deleteObserver(Observer o) {
404
                        // TODO Auto-generated method stub
405

    
406
                }
407

    
408
                public void deleteObservers() {
409
                        // TODO Auto-generated method stub
410

    
411
                }
412

    
413
                public Metadata getMetadata() throws BaseException {
414
                        // TODO Auto-generated method stub
415
                        return null;
416
                }
417
//                public void start() throws ReadDriverException                                                                 { }
418
//                public void stop() throws ReadDriverException                                                                 { }
419
//                public long[] getWhereFilter() throws IOException                                                         {return null;}
420
//                public DataSourceFactory getDataSourceFactory()                                                         {return null;}
421
//                public Memento getMemento() throws MementoException                                                 {return null;}
422
//                public void setDataSourceFactory(DataSourceFactory dsf)                                         { }
423
//                public void setSourceInfo(SourceInfo sourceInfo)                                                          { }
424
//                public SourceInfo getSourceInfo()                                                                                         {return null;}
425
//                public String getAsString() throws ReadDriverException                                                 {return null;}
426
//                public void remove() throws WriteDriverException                                                         { }
427
//                public int[] getPrimaryKeys() throws ReadDriverException                                         {return null;}
428
//                public ValueCollection getPKValue(long rowIndex)throws ReadDriverException         {return null;}
429
//                public String getPKName(int fieldId) throws ReadDriverException                         {return null;}
430
//                public String[] getPKNames() throws ReadDriverException                                         {return null;}
431
//                public int getPKType(int i) throws ReadDriverException                                                 {return 0;}
432
//                public int getPKCardinality() throws ReadDriverException                                         {return 0;}
433
//                public Value[] getRow(long rowIndex) throws ReadDriverException                         {return null;}
434
//                public DataWare getDataWare(int mode) throws ReadDriverException                         {return null;}
435
//                public boolean isVirtualField(int fieldId) throws ReadDriverException                 {return false;}
436
//                public Driver getDriver()                                                                                                         {return null;}
437
//                public void reload() throws ReloadDriverException                                                         { }
438
//                public void addDataSourceListener(IDataSourceListener listener)                         { }
439
//                public void removeDataSourceListener(IDataSourceListener listener)                         { }
440
//                public Value getFieldValue(long rowIndex, int fieldId)throws ReadDriverException {return null;}
441
//                public int getFieldCount() throws ReadDriverException                                                 {return 0;}
442
//                public long getRowCount() throws ReadDriverException                                                 {return 0;}
443
//                public int getFieldWidth(int i) throws ReadDriverException                                         {return 0;}
444
//
445
//                public String getFieldName(int fieldId) throws ReadDriverException {
446
//                        return fieldNames[fieldId];
447
//                }
448
//
449
//                public String getName(){
450
//                        return "Mock datasource used for testing only";
451
//                }
452
//
453
//                public String[] getFieldNames() throws ReadDriverException {
454
//                        return fieldNames;
455
//                }
456
//
457
//                public int getFieldIndexByName(String fieldName)throws ReadDriverException {
458
//                        for (int i = 0; i < fieldNames.length; i++) {
459
//                                if (fieldNames[i].equals(fieldName))
460
//                                        return i;
461
//                        }
462
//                        return -1;
463
//                }
464
//
465
//                public int getFieldType(int i) throws ReadDriverException {
466
//                        return Types.INTEGER;
467
//                }
468

    
469
                public boolean implementsOperation(int code) {
470
                        // TODO Auto-generated method stub
471
                        return false;
472
                }
473

    
474
                public boolean implementsOperation(String name) {
475
                        // TODO Auto-generated method stub
476
                        return false;
477
                }
478

    
479
                public Object invokeOperation(int code,
480
                                DataStoreOperationContext context)
481
                                throws DataStoreOperationException,
482
                                DataStoreOperationNotSupportedException {
483
                        // TODO Auto-generated method stub
484
                        return null;
485
                }
486

    
487
                public Object invokeOperation(String name,
488
                                DataStoreOperationContext context)
489
                                throws DataStoreOperationException,
490
                                DataStoreOperationNotSupportedException {
491
                        // TODO Auto-generated method stub
492
                        return null;
493
                }
494

    
495
                public boolean canWriteGeometry(int gvSIGgeometryType) {
496
                        // TODO Auto-generated method stub
497
                        return false;
498
                }
499

    
500
                public Feature getByIndex(long index) throws ReadException {
501
                        // TODO Auto-generated method stub
502
                        return null;
503
                }
504

    
505

    
506
                public boolean hasIndex(FeatureType fType, String colName) {
507
                        // TODO Auto-generated method stub
508
                        return false;
509
                }
510

    
511
                public XMLEntity getXMLEntity() {
512
                        // TODO Auto-generated method stub
513
                        return null;
514
                }
515

    
516
                public void setXMLEntity(XMLEntity xmlEntity) throws XMLException {
517
                        // TODO Auto-generated method stub
518

    
519
                }
520

    
521
                public String getClassName() {
522
                        // TODO Auto-generated method stub
523
                        return null;
524
                }
525

    
526
                public FeatureAttributeDescriptor addEvaluatedAttribute(
527
                                FeatureType featureType, String attributeName,
528
                                String attributeType, String expression,
529
                                AttributeValueEvaluator evaluator) throws ReadException {
530
                        // TODO Auto-generated method stub
531
                        return null;
532
                }
533

    
534
                public void removeEvaluatedAttribute(FeatureAttributeDescriptor attibute)
535
                                throws DataException {
536
                        // TODO Auto-generated method stub
537

    
538
                }
539

    
540
                public DataSet getDataCollection(FeatureQuery featureQuery)
541
                                throws ReadException {
542
                        // TODO Auto-generated method stub
543
                        return null;
544
                }
545

    
546
                public void getDataCollection(FeatureQuery featureQuery,
547
                                Observer observer) throws DataException {
548
                        // TODO Auto-generated method stub
549

    
550
                }
551

    
552
                public FeatureSet getFeatureSet() throws ReadException {
553
                        // TODO Auto-generated method stub
554
                        return null;
555
                }
556

    
557
                public FeatureSet getFeatureSet(FeatureQuery featureQuery)
558
                                throws ReadException {
559
                        // TODO Auto-generated method stub
560
                        return null;
561
                }
562

    
563
                public void getFeatureSet(FeatureQuery featureQuery,
564
                                Observer observer) throws DataException {
565
                        // TODO Auto-generated method stub
566

    
567
                }
568

    
569
                public void getFeatureSet(Observer observer)
570
                                throws DataException {
571
                        // TODO Auto-generated method stub
572

    
573
                }
574

    
575
                public DataSet getDataSet(DataQuery dataQuery)
576
                                throws ReadException {
577
                        // TODO Auto-generated method stub
578
                        return null;
579
                }
580

    
581
                public void getDataSet(DataQuery dataQuery, Observer observer)
582
                                throws DataException {
583
                        // TODO Auto-generated method stub
584

    
585
                }
586

    
587
                public final DefaultFeatureSelection getFeatureSelection() {
588
                        return null;
589
                }
590

    
591
                public DefaultFeatureSelection createFeatureSelection() {
592
                        return null;
593
                }
594

    
595
                public final void setSelection(DefaultFeatureSelection selection) throws DataException {
596
                }
597

    
598
        }
599

    
600
         private static final FInterval interval0=new FInterval(0,2);
601
         private static final FInterval interval1=new FInterval(3,5);
602
         private static final FInterval interval2=new FInterval(6,8);
603
         private static final FInterval interval3=new FInterval(9,11);
604
        // private static final Value interval4;
605
        // private static final Value interval5;
606
        // private static final Value interval6;
607
        // private static final Value interval7;
608
        // private static final Value interval8;
609
        // private static final Value interval9;
610

    
611
        Hashtable symTable;
612

    
613
        private ISymbol[] symbols;
614
        private FInterval[] sampleIntervals = new FInterval[] { interval0, interval1, interval2, interval3, };
615
        private Feature[] features;
616

    
617
        // private FInterval[] intervals = new FInterval[] {
618
        // interval0,
619
        // interval1,
620
        // interval2,
621
        // interval3,
622
        // interval4,
623
        // interval5,
624
        // interval6,
625
        // interval7,
626
        // interval8,
627
        // interval9,
628
        // };
629

    
630
        protected void setUp() throws Exception {
631
                super.setUp();
632
                features = new Feature[4];
633

    
634
                // initialize test values
635
                for (int i = 0; i < features.length; i++) {
636

    
637
                        // create the geometry associated to the feature
638
                        int size = 200;
639
                        Dimension d = new Dimension(size, size);
640
                        Rectangle aShape = new Rectangle(i * size, i * size, d.width,
641
                                        d.height);
642
                        GeometryFactory geomFactory=GeometryManager.getInstance().getGeometryFactory();
643
                        Geometry geom = geomFactory.createPolyline2D(new GeneralPathX(
644
                                        aShape));
645

    
646
                        /*
647
                         * create a full-featured Feature with randomed values at its fields
648
                         * to avoid testing over the same values each time
649
                         */
650
                        //TODO
651
//                        features[i] = new MemoryFeature(geom, featureValues[i], "[" + i
652
//                                        + "]");
653
                }
654

    
655
                // initialize the symbol subset for this test
656
                symbols = TestISymbol.getNewSymbolInstances();
657

    
658
                // initialize the legends for this test
659
                ILegend[] allLegends = TestILegend.getNewLegendInstances();
660
                ArrayList intervalLegends = new ArrayList();
661
                for (int i = 0; i < allLegends.length; i++) {
662

    
663
                        if (allLegends[i] instanceof AbstractIntervalLegend) {
664
                                intervalLegends.add(allLegends[i]);
665
                        }
666

    
667
                        if (allLegends[i] instanceof IClassifiedVectorLegend) {
668
                                IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i];
669
                                cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] });
670
                                cvl.setFeatureStore(mockDataSource);
671

    
672
                        }
673
                }
674

    
675
                this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends
676
                                .toArray(new AbstractIntervalLegend[intervalLegends.size()]);
677
        }
678

    
679
        /**
680
         * This method is used to add symbols to a legend.That is, it takes an array
681
         * of AbstractIntervalLegend which is empty and, using a second array
682
         * of FIntervals(values), the first one is filled.Also, a hash table is filled
683
         * using the array of FIntervals (it will be useful in some tests to check
684
         * that a symbol can be taken using a feature) .
685
         *
686
         * @param legend
687
         * @return
688
         */
689
        private void fillClassifiedLegend(AbstractIntervalLegend legend,
690
                        FInterval[] values) {
691
                // initialize the hash table
692
                symTable = new Hashtable();
693

    
694
                // to add symbols to the legend and the hash table
695
                for (int j = 0; j < values.length; j++) {
696

    
697
                        ISymbol sym = symbols[j % symbols.length];
698
                        legend.addSymbol(values[j], sym);
699
                        symTable.put(values[j], sym);
700
                }
701
        }
702

    
703
        /**
704
         * This test ensures that when a legend is filled, the number of symbols
705
         * added is correct. To do it, is checked that the number of symbols of a
706
         * legend is the same as the length of the array of example values that we
707
         * have.
708
         *
709
         * @throws ReadDriverException
710
         */
711
        public void testICLAdittion() throws ReadException {
712

    
713
                // Fills the legend
714
                for (int i = 0; i < intervalLegends.length; i++) {
715
                        fillClassifiedLegend(intervalLegends[i], sampleIntervals);
716
                }
717

    
718
                for (int i = 0; i < intervalLegends.length; i++) {
719
                        assertEquals(intervalLegends[i].getClassName()
720
                                        + " fails with the comparation of the number of symbols",
721
                                        intervalLegends[i].getSymbols().length,
722
                                        sampleIntervals.length);
723
                }
724

    
725
        }
726

    
727
        /**
728
         * This test ensures that the symbols that we have previously added to a
729
         * legend are accessible using its features.To do it, this test compares the
730
         * symbol taken from the legend with the symbol taken from the hashTable
731
         * (using the same feature).
732
         *
733
         * @throws ReadDriverException
734
         */
735

    
736
        public void testICLCheckValueSymbols() throws ReadException {
737

    
738
                ISymbol tableSym =null;
739

    
740
                // fills the legends
741
                for (int i = 0; i < intervalLegends.length; i++) {
742
                        fillClassifiedLegend(intervalLegends[i], sampleIntervals);
743
                }
744

    
745
                for (int i = 0; i < intervalLegends.length; i++) {
746
                        // For each feature
747
                        for (int j = 0; j < features.length; j++) {
748
                                Feature myFeature = features[i];
749
                                // takes the value of the field that identifies the feature
750
                                Object val = myFeature.get(FIELDID);
751
                                // the last value is used to access to the hash table to obtain
752
                                // a symbol
753

    
754
                                if(interval0.isInInterval(val)) {
755
                                        tableSym = (ISymbol) symTable.get(interval0);
756
                                } else if(interval1.isInInterval(val)) {
757
                                        tableSym = (ISymbol) symTable.get(interval1);
758
                                } else if(interval2.isInInterval(val)) {
759
                                        tableSym = (ISymbol) symTable.get(interval2);
760
                                } else if(interval3.isInInterval(val)) {
761
                                        tableSym = (ISymbol) symTable.get(interval3);
762
                                }
763

    
764
                                AbstractIntervalLegend leg = intervalLegends[i];
765
                                // takes the symbol from a legend using the feature
766
                                ISymbol legendSym = leg.getSymbolByFeature(myFeature);
767
                                // compares that both symbols are the same
768
                                assertEquals(legendSym.getClassName()
769
                                                + " fails with the comparation of the class symbols",
770
                                                legendSym, tableSym);
771
                        }
772
                }
773
        }
774

    
775
}
776

    
777