Statistics
| Revision:

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

History | View | Annotate | Download (23 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.CloseException;
53
import org.gvsig.fmap.data.DataCollection;
54
import org.gvsig.fmap.data.DataException;
55
import org.gvsig.fmap.data.DataExplorer;
56
import org.gvsig.fmap.data.DataQuery;
57
import org.gvsig.fmap.data.DataStoreParameters;
58
import org.gvsig.fmap.data.InitializeException;
59
import org.gvsig.fmap.data.OpenException;
60
import org.gvsig.fmap.data.ReadException;
61
import org.gvsig.fmap.data.WriteException;
62
import org.gvsig.fmap.data.commands.CommandsRecord;
63
import org.gvsig.fmap.data.feature.Feature;
64
import org.gvsig.fmap.data.feature.FeatureAttributeDescriptor;
65
import org.gvsig.fmap.data.feature.FeatureCollection;
66
import org.gvsig.fmap.data.feature.FeatureID;
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.IMetadata;
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 DataCollection getDataCollection(FeatureType type, String filter, String order) throws ReadException {
144
                        // TODO Auto-generated method stub
145
                        return null;
146
                }
147

    
148
                public DataCollection 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 getDataCollection(Observer observer) {
164
                        // TODO Auto-generated method stub
165

    
166
                }
167

    
168
                public Feature getFeatureByID(FeatureID id) throws ReadException {
169
                        // TODO Auto-generated method stub
170
                        return null;
171
                }
172

    
173
                public Feature getFeatureByID(FeatureID id, 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 createFeature(FeatureType type, boolean defaultValues) throws InitializeException {
189
                        // TODO Auto-generated method stub
190
                        return null;
191
                }
192

    
193
                public Feature createDefaultFeature(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(FeatureID id) {
239
                        // TODO Auto-generated method stub
240
                        return false;
241
                }
242

    
243
                public boolean lock(FeatureID 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 DataCollection getDataCollection() throws ReadException {
304
                        // TODO Auto-generated method stub
305
                        return null;
306
                }
307

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

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

    
316
                }
317

    
318
                public DataCollection 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 startEditing() 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 DataCollection getLocked() {
379
                        // TODO Auto-generated method stub
380
                        return null;
381
                }
382

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

    
386
                }
387

    
388
                public DataCollection 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 IMetadata 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
                public void createIndex(FeatureType fType, String colName) throws IndexException {
506
                        // TODO Auto-generated method stub
507

    
508
                }
509

    
510
                public boolean hasIndex(FeatureType fType, String colName) {
511
                        // TODO Auto-generated method stub
512
                        return false;
513
                }
514

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

    
520
                public void setXMLEntity(XMLEntity xmlEntity) throws XMLException {
521
                        // TODO Auto-generated method stub
522

    
523
                }
524

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

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

    
538
                public void removeEvaluatedAttribute(FeatureAttributeDescriptor attibute)
539
                                throws DataException {
540
                        // TODO Auto-generated method stub
541

    
542
                }
543

    
544
                public DataCollection getDataCollection(FeatureQuery featureQuery)
545
                                throws ReadException {
546
                        // TODO Auto-generated method stub
547
                        return null;
548
                }
549

    
550
                public void getDataCollection(FeatureQuery featureQuery,
551
                                Observer observer) throws DataException {
552
                        // TODO Auto-generated method stub
553

    
554
                }
555

    
556
                public FeatureCollection getFeatureCollection() throws ReadException {
557
                        // TODO Auto-generated method stub
558
                        return null;
559
                }
560

    
561
                public FeatureCollection getFeatureCollection(FeatureQuery featureQuery)
562
                                throws ReadException {
563
                        // TODO Auto-generated method stub
564
                        return null;
565
                }
566

    
567
                public void getFeatureCollection(FeatureQuery featureQuery,
568
                                Observer observer) throws DataException {
569
                        // TODO Auto-generated method stub
570

    
571
                }
572

    
573
                public void getFeatureCollection(Observer observer)
574
                                throws DataException {
575
                        // TODO Auto-generated method stub
576

    
577
                }
578

    
579
                public DataCollection getDataCollection(DataQuery dataQuery)
580
                                throws ReadException {
581
                        // TODO Auto-generated method stub
582
                        return null;
583
                }
584

    
585
                public void getDataCollection(DataQuery dataQuery, Observer observer)
586
                                throws DataException {
587
                        // TODO Auto-generated method stub
588

    
589
                }
590

    
591
        }
592

    
593
         private static final FInterval interval0=new FInterval(0,2);
594
         private static final FInterval interval1=new FInterval(3,5);
595
         private static final FInterval interval2=new FInterval(6,8);
596
         private static final FInterval interval3=new FInterval(9,11);
597
        // private static final Value interval4;
598
        // private static final Value interval5;
599
        // private static final Value interval6;
600
        // private static final Value interval7;
601
        // private static final Value interval8;
602
        // private static final Value interval9;
603

    
604
        Hashtable symTable;
605

    
606
        private ISymbol[] symbols;
607
        private FInterval[] sampleIntervals = new FInterval[] { interval0, interval1, interval2, interval3, };
608
        private Feature[] features;
609

    
610
        // private FInterval[] intervals = new FInterval[] {
611
        // interval0,
612
        // interval1,
613
        // interval2,
614
        // interval3,
615
        // interval4,
616
        // interval5,
617
        // interval6,
618
        // interval7,
619
        // interval8,
620
        // interval9,
621
        // };
622

    
623
        protected void setUp() throws Exception {
624
                super.setUp();
625
                features = new Feature[4];
626

    
627
                // initialize test values
628
                for (int i = 0; i < features.length; i++) {
629

    
630
                        // create the geometry associated to the feature
631
                        int size = 200;
632
                        Dimension d = new Dimension(size, size);
633
                        Rectangle aShape = new Rectangle(i * size, i * size, d.width,
634
                                        d.height);
635
                        GeometryFactory geomFactory=GeometryManager.getInstance().getGeometryFactory();
636
                        Geometry geom = geomFactory.createPolyline2D(new GeneralPathX(
637
                                        aShape));
638

    
639
                        /*
640
                         * create a full-featured Feature with randomed values at its fields
641
                         * to avoid testing over the same values each time
642
                         */
643
                        //TODO
644
//                        features[i] = new MemoryFeature(geom, featureValues[i], "[" + i
645
//                                        + "]");
646
                }
647

    
648
                // initialize the symbol subset for this test
649
                symbols = TestISymbol.getNewSymbolInstances();
650

    
651
                // initialize the legends for this test
652
                ILegend[] allLegends = TestILegend.getNewLegendInstances();
653
                ArrayList intervalLegends = new ArrayList();
654
                for (int i = 0; i < allLegends.length; i++) {
655

    
656
                        if (allLegends[i] instanceof AbstractIntervalLegend) {
657
                                intervalLegends.add(allLegends[i]);
658
                        }
659

    
660
                        if (allLegends[i] instanceof IClassifiedVectorLegend) {
661
                                IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i];
662
                                cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] });
663
                                cvl.setFeatureStore(mockDataSource);
664

    
665
                        }
666
                }
667

    
668
                this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends
669
                                .toArray(new AbstractIntervalLegend[intervalLegends.size()]);
670
        }
671

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

    
687
                // to add symbols to the legend and the hash table
688
                for (int j = 0; j < values.length; j++) {
689

    
690
                        ISymbol sym = symbols[j % symbols.length];
691
                        legend.addSymbol(values[j], sym);
692
                        symTable.put(values[j], sym);
693
                }
694
        }
695

    
696
        /**
697
         * This test ensures that when a legend is filled, the number of symbols
698
         * added is correct. To do it, is checked that the number of symbols of a
699
         * legend is the same as the length of the array of example values that we
700
         * have.
701
         *
702
         * @throws ReadDriverException
703
         */
704
        public void testICLAdittion() throws ReadException {
705

    
706
                // Fills the legend
707
                for (int i = 0; i < intervalLegends.length; i++) {
708
                        fillClassifiedLegend(intervalLegends[i], sampleIntervals);
709
                }
710

    
711
                for (int i = 0; i < intervalLegends.length; i++) {
712
                        assertEquals(intervalLegends[i].getClassName()
713
                                        + " fails with the comparation of the number of symbols",
714
                                        intervalLegends[i].getSymbols().length,
715
                                        sampleIntervals.length);
716
                }
717

    
718
        }
719

    
720
        /**
721
         * This test ensures that the symbols that we have previously added to a
722
         * legend are accessible using its features.To do it, this test compares the
723
         * symbol taken from the legend with the symbol taken from the hashTable
724
         * (using the same feature).
725
         *
726
         * @throws ReadDriverException
727
         */
728

    
729
        public void testICLCheckValueSymbols() throws ReadException {
730

    
731
                ISymbol tableSym =null;
732

    
733
                // fills the legends
734
                for (int i = 0; i < intervalLegends.length; i++) {
735
                        fillClassifiedLegend(intervalLegends[i], sampleIntervals);
736
                }
737

    
738
                for (int i = 0; i < intervalLegends.length; i++) {
739
                        // For each feature
740
                        for (int j = 0; j < features.length; j++) {
741
                                Feature myFeature = features[i];
742
                                // takes the value of the field that identifies the feature
743
                                Object val = myFeature.get(FIELDID);
744
                                // the last value is used to access to the hash table to obtain
745
                                // a symbol
746

    
747
                                if(interval0.isInInterval(val)) {
748
                                        tableSym = (ISymbol) symTable.get(interval0);
749
                                } else if(interval1.isInInterval(val)) {
750
                                        tableSym = (ISymbol) symTable.get(interval1);
751
                                } else if(interval2.isInInterval(val)) {
752
                                        tableSym = (ISymbol) symTable.get(interval2);
753
                                } else if(interval3.isInInterval(val)) {
754
                                        tableSym = (ISymbol) symTable.get(interval3);
755
                                }
756

    
757
                                AbstractIntervalLegend leg = intervalLegends[i];
758
                                // takes the symbol from a legend using the feature
759
                                ISymbol legendSym = leg.getSymbolByFeature(myFeature);
760
                                // compares that both symbols are the same
761
                                assertEquals(legendSym.getClassName()
762
                                                + " fails with the comparation of the class symbols",
763
                                                legendSym, tableSym);
764
                        }
765
                }
766
        }
767

    
768
}
769

    
770