Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.lib / org.gvsig.symbology.lib.impl / src / test / java / org / gvsig / symbology / fmap / mapcontext / rendering / legend / TestIClassifiedLegend.java @ 40560

History | View | Annotate | Download (21.2 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.symbology.fmap.mapcontext.rendering.legend;
25

    
26
import java.awt.Dimension;
27
import java.awt.Rectangle;
28
import java.util.ArrayList;
29
import java.util.Collection;
30
import java.util.Hashtable;
31
import java.util.Iterator;
32
import java.util.List;
33
import java.util.Set;
34

    
35
import org.cresques.cts.IProjection;
36

    
37
import org.gvsig.fmap.dal.DataQuery;
38
import org.gvsig.fmap.dal.DataServerExplorer;
39
import org.gvsig.fmap.dal.DataSet;
40
import org.gvsig.fmap.dal.DataStoreParameters;
41
import org.gvsig.fmap.dal.exception.DataException;
42
import org.gvsig.fmap.dal.exception.ReadException;
43
import org.gvsig.fmap.dal.feature.EditableFeature;
44
import org.gvsig.fmap.dal.feature.EditableFeatureType;
45
import org.gvsig.fmap.dal.feature.Feature;
46
import org.gvsig.fmap.dal.feature.FeatureCache;
47
import org.gvsig.fmap.dal.feature.FeatureIndex;
48
import org.gvsig.fmap.dal.feature.FeatureIndexes;
49
import org.gvsig.fmap.dal.feature.FeatureLocks;
50
import org.gvsig.fmap.dal.feature.FeatureQuery;
51
import org.gvsig.fmap.dal.feature.FeatureReference;
52
import org.gvsig.fmap.dal.feature.FeatureSelection;
53
import org.gvsig.fmap.dal.feature.FeatureSet;
54
import org.gvsig.fmap.dal.feature.FeatureStore;
55
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms;
56
import org.gvsig.fmap.dal.feature.FeatureType;
57
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
58
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
59
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
60
import org.gvsig.fmap.geom.Geometry.TYPES;
61
import org.gvsig.fmap.geom.GeometryLocator;
62
import org.gvsig.fmap.geom.GeometryManager;
63
import org.gvsig.fmap.geom.primitive.Curve;
64
import org.gvsig.fmap.geom.primitive.Envelope;
65
import org.gvsig.fmap.geom.primitive.GeneralPathX;
66
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend;
67
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend;
68
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
69
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
70
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractIntervalLegend;
71
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.TestISymbol;
72
import org.gvsig.timesupport.Interval;
73
import org.gvsig.tools.dynobject.DynClass;
74
import org.gvsig.tools.dynobject.DynObject;
75
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
76
import org.gvsig.tools.dynobject.exception.DynMethodException;
77
import org.gvsig.tools.exception.BaseException;
78
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
79
import org.gvsig.tools.observer.Observer;
80
import org.gvsig.tools.persistence.PersistentState;
81
import org.gvsig.tools.persistence.exception.PersistenceException;
82
import org.gvsig.tools.undo.RedoException;
83
import org.gvsig.tools.undo.UndoException;
84
import org.gvsig.tools.visitor.Visitor;
85

    
86

    
87
/**
88
 * Integration test to ensure that the legends which implements the
89
 * IClassifiedLegend interface follow the rules that follow the managing of them
90
 * by the application.
91
 *
92
 * @author jaume dominguez faus - jaume.dominguez@iver.es
93
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
94
 */
95
public class TestIClassifiedLegend extends AbstractLibraryAutoInitTestCase {
96

    
97
        private static final Integer v0 = new Integer(0);
98
        private static final Integer v1 = new Integer(1);
99
        private static final Integer v2 = new Integer(2);
100
        private static final Integer v3 = new Integer(3);
101

    
102
        private static final String FIELD3 = "field3";
103
        private static final String FIELD2 = "field2";
104
        private static final String FIELD1 = "field1";
105
        private static final String FIELD0 = "field0";
106
        private static final int FIELDID = 0;
107

    
108
//        private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, };
109
//        private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, };
110
//        private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, };
111
//        private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, };
112
//
113
//        private static final Integer[][] featureValues = new Integer[][] {
114
//                feature0Values,
115
//                feature1Values,
116
//                feature2Values,
117
//                feature3Values,};
118

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

    
121

    
122
        // private static final Value v4 = (Value)ValueFactory.createValue(4);
123
        // private static final Value v5 = (Value)ValueFactory.createValue(5);
124
        // private static final Value v6 = (Value)ValueFactory.createValue(6);
125
        // private static final Value v7 = (Value)ValueFactory.createValue(7);
126
        // private static final Value v8 = (Value)ValueFactory.createValue(8);
127
        // private static final Value v9 = (Value)ValueFactory.createValue(9);
128

    
129
        private AbstractIntervalLegend[] intervalLegends;
130
//        private MockDataSource mockDataSource = new MockDataSource();
131

    
132
        /**
133
         * To avoid duplicated validation logic in the test a mock object is created
134
         * to use a DataSource for this test.
135
         *
136
         */
137
        private class MockDataSource implements FeatureStore {
138

    
139
                public boolean allowWrite() {
140

    
141
                        return false;
142
                }
143

    
144
                public void beginEditingGroup(String description)
145
                                throws NeedEditingModeException {
146

    
147

    
148
                }
149

    
150
                public boolean canWriteGeometry(int gvSIGgeometryType)
151
                                throws DataException {
152

    
153
                        return false;
154
                }
155

    
156
                public void cancelEditing() throws DataException {
157

    
158

    
159
                }
160

    
161
                public FeatureSelection createFeatureSelection() throws DataException {
162

    
163
                        return null;
164
                }
165

    
166
                public FeatureIndex createIndex(FeatureType featureType,
167
                                String attributeName, String indexName) throws DataException {
168

    
169
                        return null;
170
                }
171

    
172
                public EditableFeature createNewFeature() throws DataException {
173

    
174
                        return null;
175
                }
176

    
177
                public EditableFeature createNewFeature(FeatureType type,
178
                                Feature defaultValues) throws DataException {
179

    
180
                        return null;
181
                }
182

    
183
                public EditableFeature createNewFeature(FeatureType type,
184
                                boolean defaultValues) throws DataException {
185

    
186
                        return null;
187
                }
188

    
189
                public EditableFeature createNewFeature(boolean defaultValues)
190
                                throws DataException {
191

    
192
                        return null;
193
                }
194

    
195
                public void delete(Feature feature) throws DataException {
196

    
197

    
198
                }
199

    
200
                public void edit() throws DataException {
201

    
202

    
203
                }
204

    
205
                public void edit(int mode) throws DataException {
206

    
207

    
208
                }
209

    
210
                public void endEditingGroup() throws NeedEditingModeException {
211

    
212

    
213
                }
214

    
215
                public void finishEditing() throws DataException {
216

    
217

    
218
                }
219

    
220
                public FeatureType getDefaultFeatureType() throws DataException {
221

    
222
                        return null;
223
                }
224

    
225
                public Envelope getEnvelope() {
226

    
227
                        return null;
228
                }
229

    
230
                public Feature getFeatureByReference(FeatureReference reference)
231
                                throws DataException {
232

    
233
                        return null;
234
                }
235

    
236
                public Feature getFeatureByReference(FeatureReference reference,
237
                                FeatureType featureType) throws DataException {
238

    
239
                        return null;
240
                }
241

    
242
                public FeatureSelection getFeatureSelection() throws DataException {
243

    
244
                        return null;
245
                }
246

    
247
                public FeatureSet getFeatureSet() throws DataException {
248

    
249
                        return null;
250
                }
251

    
252
                public FeatureSet getFeatureSet(FeatureQuery featureQuery)
253
                                throws DataException {
254

    
255
                        return null;
256
                }
257

    
258
                public void getFeatureSet(FeatureQuery featureQuery, Observer observer)
259
                                throws DataException {
260

    
261

    
262
                }
263

    
264
                public void getFeatureSet(Observer observer) throws DataException {
265

    
266

    
267
                }
268

    
269
                public List getFeatureTypes() throws DataException {
270

    
271
                        return null;
272
                }
273

    
274
                public FeatureIndexes getIndexes() {
275

    
276
                        return null;
277
                }
278

    
279
                public FeatureLocks getLocks() throws DataException {
280

    
281
                        return null;
282
                }
283

    
284
                public DataStoreParameters getParameters() {
285

    
286
                        return null;
287
                }
288

    
289
                public IProjection getSRSDefaultGeometry() throws DataException {
290

    
291
                        return null;
292
                }
293

    
294
                public FeatureStoreTransforms getTransforms() {
295

    
296
                        return null;
297
                }
298

    
299
                public void insert(EditableFeature feature) throws DataException {
300

    
301

    
302
                }
303

    
304
                public boolean isAppendModeSupported() {
305

    
306
                        return false;
307
                }
308

    
309
                public boolean isAppending() {
310

    
311
                        return false;
312
                }
313

    
314
                public boolean isEditing() {
315

    
316
                        return false;
317
                }
318

    
319
                public boolean isLocksSupported() {
320

    
321
                        return false;
322
                }
323

    
324
                public void setSelection(FeatureSet selection) throws DataException {
325

    
326

    
327
                }
328

    
329
                public void update(EditableFeatureType featureType)
330
                                throws DataException {
331

    
332

    
333
                }
334

    
335
                public void update(EditableFeature feature) throws DataException {
336

    
337

    
338
                }
339

    
340
                public void validateFeatures(int mode) throws DataException {
341

    
342

    
343
                }
344

    
345
                public DataSet createSelection() throws DataException {
346

    
347
                        return null;
348
                }
349

    
350
                public void dispose() {
351

    
352

    
353
                }
354

    
355
                public Iterator getChildren() {
356

    
357
                        return null;
358
                }
359

    
360
                public DataSet getDataSet() throws DataException {
361

    
362
                        return null;
363
                }
364

    
365
                public DataSet getDataSet(DataQuery dataQuery) throws DataException {
366

    
367
                        return null;
368
                }
369

    
370
                public void getDataSet(Observer observer) throws DataException {
371

    
372

    
373
                }
374

    
375
                public void getDataSet(DataQuery dataQuery, Observer observer)
376
                                throws DataException {
377

    
378

    
379
                }
380

    
381
                public DataServerExplorer getExplorer() throws DataException {
382

    
383
                        return null;
384
                }
385

    
386
                public String getName() {
387

    
388
                        return null;
389
                }
390

    
391
                public DataSet getSelection() throws DataException {
392

    
393
                        return null;
394
                }
395

    
396
                public void refresh() throws DataException {
397

    
398

    
399
                }
400

    
401
                public void setSelection(DataSet selection) throws DataException {
402

    
403

    
404
                }
405

    
406
                public void beginComplexNotification() {
407

    
408

    
409
                }
410

    
411
                public void disableNotifications() {
412

    
413

    
414
                }
415

    
416
                public void enableNotifications() {
417

    
418

    
419
                }
420

    
421
                public void endComplexNotification() {
422

    
423

    
424
                }
425

    
426
                public void addObserver(Observer o) {
427

    
428

    
429
                }
430

    
431
                public void deleteObserver(Observer o) {
432

    
433

    
434
                }
435

    
436
                public void deleteObservers() {
437

    
438

    
439
                }
440

    
441
                public void saveToState(PersistentState state)
442
                                throws PersistenceException {
443

    
444

    
445
                }
446

    
447
                public void loadFromState(PersistentState state) throws PersistenceException {
448

    
449

    
450
                }
451

    
452
                public FeatureQuery createFeatureQuery() {
453

    
454
                        return null;
455
                }
456

    
457
                public boolean canRedo() {
458

    
459
                        return false;
460
                }
461

    
462
                public boolean canUndo() {
463

    
464
                        return false;
465
                }
466

    
467
                public List getRedoInfos() {
468

    
469
                        return null;
470
                }
471

    
472
                public List getUndoInfos() {
473

    
474
                        return null;
475
                }
476

    
477
                public void redo() throws RedoException {
478

    
479

    
480
                }
481

    
482
                public void redo(int num) throws RedoException {
483

    
484

    
485
                }
486

    
487
                public void undo() throws UndoException {
488

    
489

    
490
                }
491

    
492
                public void undo(int num) throws UndoException {
493

    
494

    
495
                }
496

    
497
                public FeatureIndex createIndex(FeatureType featureType,
498
                                String attributeName, String indexName, Observer observer)
499
                                throws DataException {
500

    
501
                        return null;
502
                }
503

    
504
                public Object getMetadataID() {
505

    
506
                        return null;
507
                }
508

    
509
                public void delegate(DynObject dynObject) {
510

    
511

    
512
                }
513

    
514
                public DynClass getDynClass() {
515

    
516
                        return null;
517
                }
518

    
519
                public Object getDynValue(String name) throws DynFieldNotFoundException {
520

    
521
                        return null;
522
                }
523

    
524
                public boolean hasDynValue(String name) {
525

    
526
                        return false;
527
                }
528

    
529
                public void implement(DynClass dynClass) {
530

    
531

    
532
                }
533

    
534
                public Object invokeDynMethod(String name, DynObject context)
535
                                throws DynMethodException {
536

    
537
                        return null;
538
                }
539

    
540
                public Object invokeDynMethod(int code, DynObject context)
541
                                throws DynMethodException {
542

    
543
                        return null;
544
                }
545

    
546
                public void setDynValue(String name, Object value)
547
                                throws DynFieldNotFoundException {
548

    
549

    
550
                }
551

    
552
                /*
553
                 * (non-Javadoc)
554
                 *
555
                 * @see org.gvsig.metadata.Metadata#getMetadataChildren()
556
                 */
557
                public Set getMetadataChildren() {
558

    
559
                        return null;
560
                }
561

    
562
                /*
563
                 * (non-Javadoc)
564
                 *
565
                 * @see org.gvsig.metadata.Metadata#getMetadataName()
566
                 */
567
                public String getMetadataName() {
568

    
569
                        return null;
570
                }
571

    
572
                public FeatureType getFeatureType(String featureTypeId)
573
                                throws DataException {
574

    
575
                        return null;
576
                }
577

    
578
                public DataQuery createQuery() {
579

    
580
                        return null;
581
                }
582

    
583
                public long getFeatureCount() throws DataException {
584

    
585
                        return 0;
586
                }
587

    
588
                public void accept(Visitor visitor, DataQuery dataQuery)
589
                                throws BaseException {
590
                }
591

    
592
                public void accept(Visitor visitor) throws BaseException {
593
                }
594

    
595
                public void createCache(String name,
596
                                DynObject parameters) throws DataException {
597
                        // Do nothing
598
                }
599

    
600
                public FeatureCache getCache() {
601
                        return null;
602
                }
603

    
604
                public void clear() {
605
                        // Nothing to do
606
                }
607

    
608
                public void export(DataServerExplorer explorer, String provider,
609
                                NewFeatureStoreParameters params) throws DataException {
610
                        
611
                }
612

    
613
                public String getProviderName() {
614
                        return null;
615
                }
616

    
617
                public String getFullName() {
618
                        // TODO Auto-generated method stub
619
                        return null;
620
                }
621

    
622
        public boolean isKnownEnvelope() {
623
            // TODO Auto-generated method stub
624
            return false;
625
        }
626

    
627
        public boolean hasRetrievedFeaturesLimit() {
628
            // TODO Auto-generated method stub
629
            return false;
630
        }
631

    
632
        public int getRetrievedFeaturesLimit() {
633
            // TODO Auto-generated method stub
634
            return 0;
635
        }
636

    
637
        public FeatureIndex createIndex(String indexTypeName,
638
            FeatureType featureType, String attributeName, String indexName)
639
            throws DataException {
640
            // TODO Auto-generated method stub
641
            return null;
642
        }
643

    
644
        public FeatureIndex createIndex(String indexTypeName,
645
            FeatureType featureType, String attributeName, String indexName,
646
            Observer observer) throws DataException {
647
            // TODO Auto-generated method stub
648
            return null;
649
        }
650

    
651
        public Interval getInterval() {
652
            // TODO Auto-generated method stub
653
            return null;
654
        }
655

    
656
        public Collection getTimes() {
657
            // TODO Auto-generated method stub
658
            return null;
659
        }
660

    
661
        public Collection getTimes(Interval interval) {
662
            // TODO Auto-generated method stub
663
            return null;
664
        }
665
        
666
        public Object clone() throws CloneNotSupportedException {
667
            // TODO Auto-generated method stub
668
            return super.clone();
669
        }
670

    
671
        /* (non-Javadoc)
672
         * @see org.gvsig.fmap.dal.feature.FeatureStore#commitChanges()
673
         */
674
        public void commitChanges() throws DataException {
675
            // TODO Auto-generated method stub
676
            
677
        }
678

    
679
        /* (non-Javadoc)
680
         * @see org.gvsig.fmap.dal.feature.FeatureStore#canCommitChanges()
681
         */
682
        public boolean canCommitChanges() throws DataException {
683
            // TODO Auto-generated method stub
684
            return false;
685
        }
686

    
687
        }
688

    
689
        //private static final FInterval interval0=new FInterval(0,2);
690
        //private static final FInterval interval1=new FInterval(3,5);
691
        //private static final FInterval interval2=new FInterval(6,2);
692
        //private static final FInterval interval3=new FInterval(9,2);
693
        // private static final Value interval4;
694
        // private static final Value interval5;
695
        // private static final Value interval6;
696
        // private static final Value interval7;
697
        // private static final Value interval8;
698
        // private static final Value interval9;
699

    
700
        Hashtable symTable;
701

    
702
        private IClassifiedVectorLegend[] classifiedLegends;
703
        private ISymbol[] symbols;
704
        private Object[] sampleValues = new Object[] { v0, v1, v2, v3, };
705
        private Feature[] features;
706

    
707
        // private FInterval[] intervals = new FInterval[] {
708
        // interval0,
709
        // interval1,
710
        // interval2,
711
        // interval3,
712
        // interval4,
713
        // interval5,
714
        // interval6,
715
        // interval7,
716
        // interval8,
717
        // interval9,
718
        // };
719

    
720
        protected void doSetUp() throws Exception {
721
                
722
                features = new Feature[4];
723

    
724
//                //Initializes the geometries library
725
//                DefaultGeometryLibrary lib = new DefaultGeometryLibrary();
726
//                lib.initialize();
727
//                lib.postInitialize();
728

    
729
                // initialize test values
730
                for (int i = 0; i < features.length; i++) {
731
                        // create the geometry associated to the feature
732
                        int size = 200;
733
                        Dimension d = new Dimension(size, size);
734
                        Rectangle aShape = new Rectangle(i * size, i * size, d.width,
735
                                        d.height);
736
                        GeometryManager geomManager = GeometryLocator.getGeometryManager();
737
                        Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
738
                        curve.setGeneralPath(new GeneralPathX(aShape.getPathIterator(null)));
739

    
740
                        /*
741
                         * create a full-featured Feature with randomed values at its fields
742
                         * to avoid testing over the same values each time
743
                         */
744
//                        features[i] = new DefaultFeature(geom, featureValues[i], "[" + i
745
//                                        + "]");
746
                }
747

    
748
                // initialize the symbol subset for this test
749
                symbols = TestISymbol.getNewSymbolInstances();
750

    
751
                // initialize the legends for this test
752
                ILegend[] allLegends = TestILegend.getNewLegendInstances();
753
                ArrayList clegends = new ArrayList();
754
                ArrayList intervalLegends = new ArrayList();
755
                for (int i = 0; i < allLegends.length; i++) {
756
                        if (allLegends[i] instanceof AbstractIntervalLegend) {
757
                                intervalLegends.add(allLegends[i]);
758
                        } else if (allLegends[i] instanceof IClassifiedLegend) {
759
                                clegends.add(allLegends[i]);
760
                        }
761

    
762
                        if (allLegends[i] instanceof IClassifiedVectorLegend) {
763
                                IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i];
764
                                cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] });
765
//                                cvl.setFeatureStore(mockDataSource);
766

    
767
                        }
768
                }
769

    
770
                this.classifiedLegends = (IClassifiedVectorLegend[]) clegends
771
                                .toArray(new IClassifiedVectorLegend[clegends.size()]);
772
                this.intervalLegends =
773
                                (AbstractIntervalLegend[]) intervalLegends
774
                                .toArray(new AbstractIntervalLegend[intervalLegends.size()]);
775
        }
776

    
777
        /**
778
         * This method is used to add symbols to a legend.That is, it takes an array
779
         * of IClassifiedVectorialLegend which is empty andm, using a second array
780
         * of objects (values), the first one is filled.Also, a hash table is filled
781
         * too using the array of objects (it will be useful in some tests to check
782
         * that a symbol can be taken using a feature) .
783
         *
784
         * @param legend
785
         * @return
786
         */
787
        private void fillClassifiedLegend(IClassifiedVectorLegend legend,
788
                        Object[] values) {
789
                // initialize the hash table
790
                symTable = new Hashtable();
791

    
792
                // to add symbols to the legend and the hash table
793
                for (int j = 0; j < values.length; j++) {
794

    
795
                        ISymbol sym = symbols[j % symbols.length];
796
                        legend.addSymbol(values[j], sym);
797
                        symTable.put(values[j], sym);
798
                }
799
        }
800

    
801
        /**
802
         * This test ensures that when a legend is filled, the number of symbols
803
         * added is correct. To do it, is checked that the number of symbols of a
804
         * legend is the same as the length of the array of example values that we
805
         * have.
806
         *
807
         * @throws ReadDriverException
808
         */
809
        public void testICLAdittion() throws ReadException {
810

    
811
                // Fills the legend
812
                for (int i = 0; i < classifiedLegends.length; i++) {
813
                        fillClassifiedLegend(classifiedLegends[i], sampleValues);
814
                }
815

    
816
                for (int i = 0; i < classifiedLegends.length; i++) {
817
                        assertEquals(classifiedLegends[i].getClass().getName()
818
                                        + " fails with the comparation of the number of symbols",
819
                                        classifiedLegends[i].getSymbols().length,
820
                                        sampleValues.length);
821
                }
822

    
823
        }
824

    
825
        /**
826
         * This test ensures that the symbols that we have previously added to a
827
         * legend are accessible using its features.To do it, this test compares the
828
         * symbol taken from the legend with the symbol taken from the hashTable
829
         * (using the same feature).
830
         * @throws Exception 
831
         */
832
        public void testICLCheckValueSymbols() throws Exception {
833
                // fills the legends
834
                for (int i = 0; i < classifiedLegends.length; i++) {
835
                        fillClassifiedLegend(classifiedLegends[i], sampleValues);
836
                }
837

    
838
                for (int i = 0; i < classifiedLegends.length; i++) {
839
                        // For each feature
840
                        for (int j = 0; j < features.length; j++) {
841
                                Feature myFeature = features[i];
842
                                // takes the value of the field that identifies the feature
843
                                Object val = myFeature.get(FIELDID);
844
                                // the last value is used to access to the hash table to obtain
845
                                // a symbol
846
                                ISymbol tableSym = (ISymbol) symTable.get(val);
847

    
848
                                IClassifiedVectorLegend leg = classifiedLegends[i];
849
                                // takes the symbol from a legend using the feature
850
                                ISymbol legendSym = leg.getSymbolByFeature(myFeature);
851
                                // compares that both symbols are the same
852
                                assertEquals(legendSym.getClass().getName()
853
                                                + " fails with the comparation of the class symbols",
854
                                                legendSym, tableSym);
855
                        }
856
                }
857
        }
858

    
859
}