Revision 33017

View differences:

tags/v2_0_0_Build_2008/extensions/org.gvsig.symbology/distribution/distribution.xml
1
<assembly>
2
	<id>distribution</id>
3
	<formats>
4
		<format>dir</format>
5
	</formats>
6
	<fileSets>
7
		<!-- Extructure for the extension -->
8
		<fileSet>
9
			<directory>src/main/resources/config</directory>
10
			<outputDirectory>${extension.install.dir.name}
11
			</outputDirectory>
12
		</fileSet>
13
		<fileSet>
14
			<directory>src/main/resources/images</directory>
15
			<outputDirectory>${extension.install.dir.name}/images
16
			</outputDirectory>
17
		</fileSet>
18
		<fileSet>
19
			<directory>src/main/resources/about</directory>
20
			<outputDirectory>${extension.install.dir.name}
21
			</outputDirectory>
22
		</fileSet>
23
		<fileSet>
24
			<directory>src/main/resources/locale</directory>
25
			<outputDirectory>${extension.install.dir.name}
26
			</outputDirectory>
27
		</fileSet>
28
	</fileSets>
29
	<files>
30
		<file>
31
			<source>src/main/resources/build.number</source>
32
			<outputDirectory>${extension.install.dir.name}
33
			</outputDirectory>
34
		</file>
35
	</files>
36

  
37
	<dependencySets>
38
		<dependencySet>
39
			<outputDirectory>${extension.install.dir.name}/${library-dir}
40
			</outputDirectory>
41
			<includes>
42
				<include>org.gvsig:org.gvsig.symbology</include>
43
			</includes>
44
		</dependencySet>
45
	</dependencySets>
46
</assembly>
tags/v2_0_0_Build_2008/extensions/org.gvsig.symbology/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/TestIClassifiedLegend.java
1
 /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.symbology.fmap.mapcontext.rendering.legend;
42

  
43
import java.awt.Dimension;
44
import java.awt.Rectangle;
45
import java.util.ArrayList;
46
import java.util.Hashtable;
47
import java.util.Iterator;
48
import java.util.List;
49
import java.util.Set;
50

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

  
101

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

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

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

  
123
//	private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, };
124
//	private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, };
125
//	private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, };
126
//	private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, };
127
//
128
//	private static final Integer[][] featureValues = new Integer[][] {
129
//		feature0Values,
130
//		feature1Values,
131
//		feature2Values,
132
//		feature3Values,};
133

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

  
136

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

  
144
	private AbstractIntervalLegend[] intervalLegends;
145
//	private MockDataSource mockDataSource = new MockDataSource();
146

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

  
154
		public boolean allowWrite() {
155

  
156
			return false;
157
		}
158

  
159
		public void beginEditingGroup(String description)
160
				throws NeedEditingModeException {
161

  
162

  
163
		}
164

  
165
		public boolean canWriteGeometry(int gvSIGgeometryType)
166
				throws DataException {
167

  
168
			return false;
169
		}
170

  
171
		public void cancelEditing() throws DataException {
172

  
173

  
174
		}
175

  
176
		public FeatureSelection createFeatureSelection() throws DataException {
177

  
178
			return null;
179
		}
180

  
181
		public FeatureIndex createIndex(FeatureType featureType,
182
				String attributeName, String indexName) throws DataException {
183

  
184
			return null;
185
		}
186

  
187
		public EditableFeature createNewFeature() throws DataException {
188

  
189
			return null;
190
		}
191

  
192
		public EditableFeature createNewFeature(FeatureType type,
193
				Feature defaultValues) throws DataException {
194

  
195
			return null;
196
		}
197

  
198
		public EditableFeature createNewFeature(FeatureType type,
199
				boolean defaultValues) throws DataException {
200

  
201
			return null;
202
		}
203

  
204
		public EditableFeature createNewFeature(boolean defaultValues)
205
				throws DataException {
206

  
207
			return null;
208
		}
209

  
210
		public void delete(Feature feature) throws DataException {
211

  
212

  
213
		}
214

  
215
		public void edit() throws DataException {
216

  
217

  
218
		}
219

  
220
		public void edit(int mode) throws DataException {
221

  
222

  
223
		}
224

  
225
		public void endEditingGroup() throws NeedEditingModeException {
226

  
227

  
228
		}
229

  
230
		public void finishEditing() throws DataException {
231

  
232

  
233
		}
234

  
235
		public FeatureType getDefaultFeatureType() throws DataException {
236

  
237
			return null;
238
		}
239

  
240
		public Envelope getEnvelope() {
241

  
242
			return null;
243
		}
244

  
245
		public Feature getFeatureByReference(FeatureReference reference)
246
				throws DataException {
247

  
248
			return null;
249
		}
250

  
251
		public Feature getFeatureByReference(FeatureReference reference,
252
				FeatureType featureType) throws DataException {
253

  
254
			return null;
255
		}
256

  
257
		public FeatureSelection getFeatureSelection() throws DataException {
258

  
259
			return null;
260
		}
261

  
262
		public FeatureSet getFeatureSet() throws DataException {
263

  
264
			return null;
265
		}
266

  
267
		public FeatureSet getFeatureSet(FeatureQuery featureQuery)
268
				throws DataException {
269

  
270
			return null;
271
		}
272

  
273
		public void getFeatureSet(FeatureQuery featureQuery, Observer observer)
274
				throws DataException {
275

  
276

  
277
		}
278

  
279
		public void getFeatureSet(Observer observer) throws DataException {
280

  
281

  
282
		}
283

  
284
		public List getFeatureTypes() throws DataException {
285

  
286
			return null;
287
		}
288

  
289
		public FeatureIndexes getIndexes() {
290

  
291
			return null;
292
		}
293

  
294
		public FeatureLocks getLocks() throws DataException {
295

  
296
			return null;
297
		}
298

  
299
		public DataStoreParameters getParameters() {
300

  
301
			return null;
302
		}
303

  
304
		public IProjection getSRSDefaultGeometry() throws DataException {
305

  
306
			return null;
307
		}
308

  
309
		public FeatureStoreTransforms getTransforms() {
310

  
311
			return null;
312
		}
313

  
314
		public void insert(EditableFeature feature) throws DataException {
315

  
316

  
317
		}
318

  
319
		public boolean isAppendModeSupported() {
320

  
321
			return false;
322
		}
323

  
324
		public boolean isAppending() {
325

  
326
			return false;
327
		}
328

  
329
		public boolean isEditing() {
330

  
331
			return false;
332
		}
333

  
334
		public boolean isLocksSupported() {
335

  
336
			return false;
337
		}
338

  
339
		public void setSelection(FeatureSet selection) throws DataException {
340

  
341

  
342
		}
343

  
344
		public void update(EditableFeatureType featureType)
345
				throws DataException {
346

  
347

  
348
		}
349

  
350
		public void update(EditableFeature feature) throws DataException {
351

  
352

  
353
		}
354

  
355
		public void validateFeatures(int mode) throws DataException {
356

  
357

  
358
		}
359

  
360
		public DataSet createSelection() throws DataException {
361

  
362
			return null;
363
		}
364

  
365
		public void dispose() {
366

  
367

  
368
		}
369

  
370
		public Iterator getChildren() {
371

  
372
			return null;
373
		}
374

  
375
		public DataSet getDataSet() throws DataException {
376

  
377
			return null;
378
		}
379

  
380
		public DataSet getDataSet(DataQuery dataQuery) throws DataException {
381

  
382
			return null;
383
		}
384

  
385
		public void getDataSet(Observer observer) throws DataException {
386

  
387

  
388
		}
389

  
390
		public void getDataSet(DataQuery dataQuery, Observer observer)
391
				throws DataException {
392

  
393

  
394
		}
395

  
396
		public DataServerExplorer getExplorer() throws DataException {
397

  
398
			return null;
399
		}
400

  
401
		public String getName() {
402

  
403
			return null;
404
		}
405

  
406
		public DataSet getSelection() throws DataException {
407

  
408
			return null;
409
		}
410

  
411
		public void refresh() throws DataException {
412

  
413

  
414
		}
415

  
416
		public void setSelection(DataSet selection) throws DataException {
417

  
418

  
419
		}
420

  
421
		public void beginComplexNotification() {
422

  
423

  
424
		}
425

  
426
		public void disableNotifications() {
427

  
428

  
429
		}
430

  
431
		public void enableNotifications() {
432

  
433

  
434
		}
435

  
436
		public void endComplexNotification() {
437

  
438

  
439
		}
440

  
441
		public void addObserver(Observer o) {
442

  
443

  
444
		}
445

  
446
		public void deleteObserver(Observer o) {
447

  
448

  
449
		}
450

  
451
		public void deleteObservers() {
452

  
453

  
454
		}
455

  
456
		public void saveToState(PersistentState state)
457
				throws PersistenceException {
458

  
459

  
460
		}
461

  
462
		public void loadFromState(PersistentState state) throws PersistenceException {
463

  
464

  
465
		}
466

  
467
		public FeatureQuery createFeatureQuery() {
468

  
469
			return null;
470
		}
471

  
472
		public boolean canRedo() {
473

  
474
			return false;
475
		}
476

  
477
		public boolean canUndo() {
478

  
479
			return false;
480
		}
481

  
482
		public List getRedoInfos() {
483

  
484
			return null;
485
		}
486

  
487
		public List getUndoInfos() {
488

  
489
			return null;
490
		}
491

  
492
		public void redo() throws RedoException {
493

  
494

  
495
		}
496

  
497
		public void redo(int num) throws RedoException {
498

  
499

  
500
		}
501

  
502
		public void undo() throws UndoException {
503

  
504

  
505
		}
506

  
507
		public void undo(int num) throws UndoException {
508

  
509

  
510
		}
511

  
512
		public FeatureIndex createIndex(FeatureType featureType,
513
				String attributeName, String indexName, Observer observer)
514
				throws DataException {
515

  
516
			return null;
517
		}
518

  
519
		public Object getMetadataID() {
520

  
521
			return null;
522
		}
523

  
524
		public void delegate(DynObject dynObject) {
525

  
526

  
527
		}
528

  
529
		public DynClass getDynClass() {
530

  
531
			return null;
532
		}
533

  
534
		public Object getDynValue(String name) throws DynFieldNotFoundException {
535

  
536
			return null;
537
		}
538

  
539
		public boolean hasDynValue(String name) {
540

  
541
			return false;
542
		}
543

  
544
		public void implement(DynClass dynClass) {
545

  
546

  
547
		}
548

  
549
		public Object invokeDynMethod(String name, DynObject context)
550
				throws DynMethodException {
551

  
552
			return null;
553
		}
554

  
555
		public Object invokeDynMethod(int code, DynObject context)
556
				throws DynMethodException {
557

  
558
			return null;
559
		}
560

  
561
		public void setDynValue(String name, Object value)
562
				throws DynFieldNotFoundException {
563

  
564

  
565
		}
566

  
567
		/*
568
		 * (non-Javadoc)
569
		 *
570
		 * @see org.gvsig.metadata.Metadata#getMetadataChildren()
571
		 */
572
		public Set getMetadataChildren() {
573

  
574
			return null;
575
		}
576

  
577
		/*
578
		 * (non-Javadoc)
579
		 *
580
		 * @see org.gvsig.metadata.Metadata#getMetadataName()
581
		 */
582
		public String getMetadataName() {
583

  
584
			return null;
585
		}
586

  
587
		public FeatureType getFeatureType(String featureTypeId)
588
				throws DataException {
589

  
590
			return null;
591
		}
592

  
593
		public DataQuery createQuery() {
594

  
595
			return null;
596
		}
597

  
598
		public long getFeatureCount() throws DataException {
599

  
600
			return 0;
601
		}
602

  
603
		public void accept(Visitor visitor, DataQuery dataQuery)
604
				throws BaseException {
605
		}
606

  
607
		public void accept(Visitor visitor) throws BaseException {
608
		}
609

  
610
		public void createCache(String name,
611
				DynObject parameters) throws DataException {
612
			// Do nothing
613
		}
614

  
615
		public FeatureCache getCache() {
616
			return null;
617
		}
618

  
619
		public void clear() {
620
			// Nothing to do
621
		}
622

  
623
		public void export(DataServerExplorer explorer, String provider,
624
				NewFeatureStoreParameters params) throws DataException {
625
			
626
		}
627

  
628
		public String getProviderName() {
629
			return null;
630
		}
631

  
632
	}
633

  
634
	//private static final FInterval interval0=new FInterval(0,2);
635
	//private static final FInterval interval1=new FInterval(3,5);
636
	//private static final FInterval interval2=new FInterval(6,2);
637
	//private static final FInterval interval3=new FInterval(9,2);
638
	// private static final Value interval4;
639
	// private static final Value interval5;
640
	// private static final Value interval6;
641
	// private static final Value interval7;
642
	// private static final Value interval8;
643
	// private static final Value interval9;
644

  
645
	Hashtable symTable;
646

  
647
	private IClassifiedVectorLegend[] classifiedLegends;
648
	private ISymbol[] symbols;
649
	private Object[] sampleValues = new Object[] { v0, v1, v2, v3, };
650
	private Feature[] features;
651

  
652
	// private FInterval[] intervals = new FInterval[] {
653
	// interval0,
654
	// interval1,
655
	// interval2,
656
	// interval3,
657
	// interval4,
658
	// interval5,
659
	// interval6,
660
	// interval7,
661
	// interval8,
662
	// interval9,
663
	// };
664

  
665
	protected void doSetUp() throws Exception {
666
		
667
		features = new Feature[4];
668

  
669
//		//Initializes the geometries library
670
//		DefaultGeometryLibrary lib = new DefaultGeometryLibrary();
671
//		lib.initialize();
672
//		lib.postInitialize();
673

  
674
		// initialize test values
675
		for (int i = 0; i < features.length; i++) {
676
			// create the geometry associated to the feature
677
			int size = 200;
678
			Dimension d = new Dimension(size, size);
679
			Rectangle aShape = new Rectangle(i * size, i * size, d.width,
680
					d.height);
681
			GeometryManager geomManager = GeometryLocator.getGeometryManager();
682
			Curve curve = (Curve)geomManager.create(TYPES.CURVE, SUBTYPES.GEOM2D);
683
			curve.setGeneralPath(new GeneralPathX(aShape.getPathIterator(null)));
684

  
685
			/*
686
			 * create a full-featured Feature with randomed values at its fields
687
			 * to avoid testing over the same values each time
688
			 */
689
//			features[i] = new DefaultFeature(geom, featureValues[i], "[" + i
690
//					+ "]");
691
		}
692

  
693
		// initialize the symbol subset for this test
694
		symbols = TestISymbol.getNewSymbolInstances();
695

  
696
		// initialize the legends for this test
697
		ILegend[] allLegends = TestILegend.getNewLegendInstances();
698
		ArrayList clegends = new ArrayList();
699
		ArrayList intervalLegends = new ArrayList();
700
		for (int i = 0; i < allLegends.length; i++) {
701
			if (allLegends[i] instanceof AbstractIntervalLegend) {
702
				intervalLegends.add(allLegends[i]);
703
			} else if (allLegends[i] instanceof IClassifiedLegend) {
704
				clegends.add(allLegends[i]);
705
			}
706

  
707
			if (allLegends[i] instanceof IClassifiedVectorLegend) {
708
				IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i];
709
				cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] });
710
//				cvl.setFeatureStore(mockDataSource);
711

  
712
			}
713
		}
714

  
715
		this.classifiedLegends = (IClassifiedVectorLegend[]) clegends
716
				.toArray(new IClassifiedVectorLegend[clegends.size()]);
717
		this.intervalLegends =
718
				(AbstractIntervalLegend[]) intervalLegends
719
				.toArray(new AbstractIntervalLegend[intervalLegends.size()]);
720
	}
721

  
722
	/**
723
	 * This method is used to add symbols to a legend.That is, it takes an array
724
	 * of IClassifiedVectorialLegend which is empty andm, using a second array
725
	 * of objects (values), the first one is filled.Also, a hash table is filled
726
	 * too using the array of objects (it will be useful in some tests to check
727
	 * that a symbol can be taken using a feature) .
728
	 *
729
	 * @param legend
730
	 * @return
731
	 */
732
	private void fillClassifiedLegend(IClassifiedVectorLegend legend,
733
			Object[] values) {
734
		// initialize the hash table
735
		symTable = new Hashtable();
736

  
737
		// to add symbols to the legend and the hash table
738
		for (int j = 0; j < values.length; j++) {
739

  
740
			ISymbol sym = symbols[j % symbols.length];
741
			legend.addSymbol(values[j], sym);
742
			symTable.put(values[j], sym);
743
		}
744
	}
745

  
746
	/**
747
	 * This test ensures that when a legend is filled, the number of symbols
748
	 * added is correct. To do it, is checked that the number of symbols of a
749
	 * legend is the same as the length of the array of example values that we
750
	 * have.
751
	 *
752
	 * @throws ReadDriverException
753
	 */
754
	public void testICLAdittion() throws ReadException {
755

  
756
		// Fills the legend
757
		for (int i = 0; i < classifiedLegends.length; i++) {
758
			fillClassifiedLegend(classifiedLegends[i], sampleValues);
759
		}
760

  
761
		for (int i = 0; i < classifiedLegends.length; i++) {
762
			assertEquals(classifiedLegends[i].getClass().getName()
763
					+ " fails with the comparation of the number of symbols",
764
					classifiedLegends[i].getSymbols().length,
765
					sampleValues.length);
766
		}
767

  
768
	}
769

  
770
	/**
771
	 * This test ensures that the symbols that we have previously added to a
772
	 * legend are accessible using its features.To do it, this test compares the
773
	 * symbol taken from the legend with the symbol taken from the hashTable
774
	 * (using the same feature).
775
	 * @throws Exception 
776
	 */
777
	public void testICLCheckValueSymbols() throws Exception {
778
		// fills the legends
779
		for (int i = 0; i < classifiedLegends.length; i++) {
780
			fillClassifiedLegend(classifiedLegends[i], sampleValues);
781
		}
782

  
783
		for (int i = 0; i < classifiedLegends.length; i++) {
784
			// For each feature
785
			for (int j = 0; j < features.length; j++) {
786
				Feature myFeature = features[i];
787
				// takes the value of the field that identifies the feature
788
				Object val = myFeature.get(FIELDID);
789
				// the last value is used to access to the hash table to obtain
790
				// a symbol
791
				ISymbol tableSym = (ISymbol) symTable.get(val);
792

  
793
				IClassifiedVectorLegend leg = classifiedLegends[i];
794
				// takes the symbol from a legend using the feature
795
				ISymbol legendSym = leg.getSymbolByFeature(myFeature);
796
				// compares that both symbols are the same
797
				assertEquals(legendSym.getClass().getName()
798
						+ " fails with the comparation of the class symbols",
799
						legendSym, tableSym);
800
			}
801
		}
802
	}
803

  
804
}
tags/v2_0_0_Build_2008/extensions/org.gvsig.symbology/src/test/java/org/gvsig/symbology/fmap/mapcontext/rendering/legend/TestAbstractIntervalLegend.java
1
 /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.symbology.fmap.mapcontext.rendering.legend;
42

  
43
import java.awt.Dimension;
44
import java.awt.Rectangle;
45
import java.util.ArrayList;
46
import java.util.Hashtable;
47
import java.util.Iterator;
48
import java.util.List;
49
import java.util.Set;
50

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

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

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

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

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

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

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

  
134

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

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

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

  
152
		public boolean allowWrite() {
153

  
154
			return false;
155
		}
156

  
157
		public void beginEditingGroup(String description)
158
				throws NeedEditingModeException {
159

  
160

  
161
		}
162

  
163
		public boolean canWriteGeometry(int gvSIGgeometryType)
164
				throws DataException {
165

  
166
			return false;
167
		}
168

  
169
		public void cancelEditing() throws DataException {
170

  
171

  
172
		}
173

  
174
		public FeatureSelection createFeatureSelection() throws DataException {
175

  
176
			return null;
177
		}
178

  
179
		public FeatureIndex createIndex(FeatureType featureType,
180
				String attributeName, String indexName) throws DataException {
181

  
182
			return null;
183
		}
184

  
185
		public EditableFeature createNewFeature() throws DataException {
186

  
187
			return null;
188
		}
189

  
190
		public EditableFeature createNewFeature(FeatureType type,
191
				Feature defaultValues) throws DataException {
192

  
193
			return null;
194
		}
195

  
196
		public EditableFeature createNewFeature(FeatureType type,
197
				boolean defaultValues) throws DataException {
198

  
199
			return null;
200
		}
201

  
202
		public EditableFeature createNewFeature(boolean defaultValues)
203
				throws DataException {
204

  
205
			return null;
206
		}
207

  
208
		public void delete(Feature feature) throws DataException {
209

  
210

  
211
		}
212

  
213
		public void edit() throws DataException {
214

  
215

  
216
		}
217

  
218
		public void edit(int mode) throws DataException {
219

  
220

  
221
		}
222

  
223
		public void endEditingGroup() throws NeedEditingModeException {
224

  
225

  
226
		}
227

  
228
		public void finishEditing() throws DataException {
229

  
230

  
231
		}
232

  
233
		public FeatureType getDefaultFeatureType() throws DataException {
234

  
235
			return null;
236
		}
237

  
238
		public Envelope getEnvelope() {
239

  
240
			return null;
241
		}
242

  
243
		public Feature getFeatureByReference(FeatureReference reference)
244
				throws DataException {
245

  
246
			return null;
247
		}
248

  
249
		public Feature getFeatureByReference(FeatureReference reference,
250
				FeatureType featureType) throws DataException {
251

  
252
			return null;
253
		}
254

  
255
		public FeatureSelection getFeatureSelection() throws DataException {
256

  
257
			return null;
258
		}
259

  
260
		public FeatureSet getFeatureSet() throws DataException {
261

  
262
			return null;
263
		}
264

  
265
		public FeatureSet getFeatureSet(FeatureQuery featureQuery)
266
				throws DataException {
267

  
268
			return null;
269
		}
270

  
271
		public void getFeatureSet(FeatureQuery featureQuery, Observer observer)
272
				throws DataException {
273

  
274

  
275
		}
276

  
277
		public void getFeatureSet(Observer observer) throws DataException {
278

  
279

  
280
		}
281

  
282
		public List getFeatureTypes() throws DataException {
283

  
284
			return null;
285
		}
286

  
287
		public FeatureIndexes getIndexes() {
288

  
289
			return null;
290
		}
291

  
292
		public FeatureLocks getLocks() throws DataException {
293

  
294
			return null;
295
		}
296

  
297
		public DataStoreParameters getParameters() {
298

  
299
			return null;
300
		}
301

  
302
		public IProjection getSRSDefaultGeometry() throws DataException {
303

  
304
			return null;
305
		}
306

  
307
		public FeatureStoreTransforms getTransforms() {
308

  
309
			return null;
310
		}
311

  
312
		public void insert(EditableFeature feature) throws DataException {
313

  
314

  
315
		}
316

  
317
		public boolean isAppendModeSupported() {
318

  
319
			return false;
320
		}
321

  
322
		public boolean isAppending() {
323

  
324
			return false;
325
		}
326

  
327
		public boolean isEditing() {
328

  
329
			return false;
330
		}
331

  
332
		public boolean isLocksSupported() {
333

  
334
			return false;
335
		}
336

  
337

  
338
		public void setSelection(FeatureSet selection) throws DataException {
339

  
340

  
341
		}
342
		public void update(EditableFeatureType featureType)
343
				throws DataException {
344

  
345

  
346
		}
347

  
348
		public void update(EditableFeature feature) throws DataException {
349

  
350

  
351
		}
352

  
353
		public void validateFeatures(int mode) throws DataException {
354

  
355

  
356
		}
357

  
358
		public DataSet createSelection() throws DataException {
359

  
360
			return null;
361
		}
362

  
363
		public void dispose() {
364

  
365

  
366
		}
367

  
368
		public Iterator getChildren() {
369

  
370
			return null;
371
		}
372

  
373
		public DataSet getDataSet() throws DataException {
374

  
375
			return null;
376
		}
377

  
378
		public DataSet getDataSet(DataQuery dataQuery) throws DataException {
379

  
380
			return null;
381
		}
382

  
383
		public void getDataSet(Observer observer) throws DataException {
384

  
385

  
386
		}
387

  
388
		public void getDataSet(DataQuery dataQuery, Observer observer)
389
				throws DataException {
390

  
391

  
392
		}
393

  
394
		public DataServerExplorer getExplorer() throws DataException {
395

  
396
			return null;
397
		}
398

  
399
		public String getName() {
400

  
401
			return null;
402
		}
403

  
404
		public DataSet getSelection() throws DataException {
405

  
406
			return null;
407
		}
408

  
409
		public void refresh() throws DataException {
410

  
411

  
412
		}
413

  
414
		public void setSelection(DataSet selection) throws DataException {
415

  
416

  
417
		}
418

  
419
		public void beginComplexNotification() {
420

  
421

  
422
		}
423

  
424
		public void disableNotifications() {
425

  
426

  
427
		}
428

  
429
		public void enableNotifications() {
430

  
431

  
432
		}
433

  
434
		public void endComplexNotification() {
435

  
436

  
437
		}
438

  
439
		public void addObserver(Observer o) {
440

  
441

  
442
		}
443

  
444
		public void deleteObserver(Observer o) {
445

  
446

  
447
		}
448

  
449
		public void deleteObservers() {
450

  
451

  
452
		}
453

  
454
		public void saveToState(PersistentState state)
455
				throws PersistenceException {
456

  
457

  
458
		}
459

  
460
		public void loadFromState(PersistentState state) throws PersistenceException {
461

  
462

  
463
		}
464

  
465
		public FeatureQuery createFeatureQuery() {
466

  
467
			return null;
468
		}
469

  
470
		public boolean canRedo() {
471

  
472
			return false;
473
		}
474

  
475
		public boolean canUndo() {
476

  
477
			return false;
478
		}
479

  
480
		public List getRedoInfos() {
481

  
482
			return null;
483
		}
484

  
485
		public List getUndoInfos() {
486

  
487
			return null;
488
		}
489

  
490
		public void redo() throws RedoException {
491

  
492

  
493
		}
494

  
495
		public void redo(int num) throws RedoException {
496

  
497

  
498
		}
499

  
500
		public void undo() throws UndoException {
501

  
502

  
503
		}
504

  
505
		public void undo(int num) throws UndoException {
506

  
507

  
508
		}
509

  
510
		public FeatureIndex createIndex(FeatureType featureType,
511
				String attributeName, String indexName, Observer observer)
512
				throws DataException {
513

  
514
			return null;
515
		}
516

  
517
		public Object getMetadataID() {
518

  
519
			return null;
520
		}
521

  
522
		public void delegate(DynObject dynObject) {
523

  
524

  
525
		}
526

  
527
		public DynClass getDynClass() {
528

  
529
			return null;
530
		}
531

  
532
		public Object getDynValue(String name) throws DynFieldNotFoundException {
533

  
534
			return null;
535
		}
536

  
537
		public boolean hasDynValue(String name) {
538

  
539
			return false;
540
		}
541

  
542
		public void implement(DynClass dynClass) {
543

  
544

  
545
		}
546

  
547
		public Object invokeDynMethod(String name, DynObject context)
548
				throws DynMethodException {
549

  
550
			return null;
551
		}
552

  
553
		public Object invokeDynMethod(int code, DynObject context)
554
				throws DynMethodException {
555

  
556
			return null;
557
		}
558

  
559
		public void setDynValue(String name, Object value)
560
				throws DynFieldNotFoundException {
561

  
562

  
563
		}
564

  
565
		/*
566
		 * (non-Javadoc)
567
		 *
568
		 * @see org.gvsig.metadata.Metadata#getMetadataChildren()
569
		 */
570
		public Set getMetadataChildren() {
571

  
572
			return null;
573
		}
574

  
575
		/*
576
		 * (non-Javadoc)
577
		 *
578
		 * @see org.gvsig.metadata.Metadata#getMetadataName()
579
		 */
580
		public String getMetadataName() {
581

  
582
			return null;
583
		}
584

  
585
		public FeatureType getFeatureType(String featureTypeId)
586
				throws DataException {
587

  
588
			return null;
589
		}
590

  
591
		public DataQuery createQuery() {
592

  
593
			return null;
594
		}
595

  
596
		public long getFeatureCount() throws DataException {
597

  
598
			return 0;
599
		}
600

  
601
		public void accept(Visitor visitor, DataQuery dataQuery)
602
				throws BaseException {
603
		}
604

  
605
		public void accept(Visitor visitor) throws BaseException {
606
		}
607

  
608
		public void createCache(String name,
609
				DynObject parameters) throws DataException {
610
			// Do nothing
611
		}
612

  
613
		public FeatureCache getCache() {
614
			return null;
615
		}
616

  
617
		public void clear() {
618
			// Nothing to do
619
		}
620

  
621
		public void export(DataServerExplorer explorer, String provider,
622
				NewFeatureStoreParameters params) throws DataException {
623
			// Nothing to do
624
		}
625

  
626
		public String getProviderName() {
627
			return null;
628
		}
629
	}
630

  
631
	 private static final FInterval interval0=new FInterval(0,2);
632
	 private static final FInterval interval1=new FInterval(3,5);
633
	 private static final FInterval interval2=new FInterval(6,8);
634
	 private static final FInterval interval3=new FInterval(9,11);
635
	// private static final Value interval4;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff