Revision 21156

View differences:

branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/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.fmap.mapcontext.rendering;
42

  
43
import java.awt.Dimension;
44
import java.awt.Rectangle;
45
import java.io.IOException;
46
import java.sql.Types;
47
import java.util.ArrayList;
48
import java.util.Hashtable;
49
import java.util.Iterator;
50
import java.util.List;
51

  
52
import org.gvsig.data.CloseException;
53
import org.gvsig.data.DataCollection;
54
import org.gvsig.data.DataException;
55
import org.gvsig.data.DataExplorer;
56
import org.gvsig.data.DataStoreParameters;
57
import org.gvsig.data.InitializeException;
58
import org.gvsig.data.OpenException;
59
import org.gvsig.data.ReadException;
60
import org.gvsig.data.WriteException;
61
import org.gvsig.data.commands.CommandsRecord;
62
import org.gvsig.data.vectorial.Feature;
63
import org.gvsig.data.vectorial.FeatureAttributeDescriptor;
64
import org.gvsig.data.vectorial.FeatureID;
65
import org.gvsig.data.vectorial.FeatureStore;
66
import org.gvsig.data.vectorial.FeatureType;
67
import org.gvsig.exceptions.BaseException;
68
import org.gvsig.fmap.geom.Geometry;
69
import org.gvsig.fmap.geom.GeometryFactory;
70
import org.gvsig.fmap.geom.GeometryManager;
71
import org.gvsig.fmap.geom.primitive.GeneralPathX;
72
import org.gvsig.fmap.mapcontext.rendering.legend.AbstractIntervalLegend;
73
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend;
74
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedVectorLegend;
75
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
76
import org.gvsig.fmap.mapcontext.rendering.symbol.TestISymbol;
77
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
78
import org.gvsig.metadata.IMetadata;
79
import org.gvsig.util.observer.Observer;
80

  
81
import junit.framework.TestCase;
82

  
83

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

  
94
	private static final Integer v0 = new Integer(0);
95
	private static final Integer v1 = new Integer(1);
96
	private static final Integer v2 = new Integer(2);
97
	private static final Integer v3 = new Integer(3);
98

  
99
	private static final String FIELD3 = "field3";
100
	private static final String FIELD2 = "field2";
101
	private static final String FIELD1 = "field1";
102
	private static final String FIELD0 = "field0";
103
	private static final int FIELDID = 0;
104

  
105
	private static final Integer[] feature0Values = new Integer[] { v0, v1, v2, v3, };
106
	private static final Integer[] feature1Values = new Integer[] { v3, v0, v1, v2, };
107
	private static final Integer[] feature2Values = new Integer[] { v2, v3, v0, v1, };
108
	private static final Integer[] feature3Values = new Integer[] { v1, v2, v3, v0, };
109

  
110
	private static final Integer[][] featureValues = new Integer[][] {
111
		feature0Values,
112
		feature1Values,
113
		feature2Values,
114
		feature3Values,};
115

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

  
118

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

  
126
	private AbstractIntervalLegend[] intervalLegends;
127
	private MockDataSource mockDataSource = new MockDataSource();
128

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

  
136
		public DataCollection getDataCollection(FeatureType type, String filter, String order) throws ReadException {
137
			// TODO Auto-generated method stub
138
			return null;
139
		}
140

  
141
		public DataCollection getDataCollection(String[] fields, String filter, String order) throws ReadException {
142
			// TODO Auto-generated method stub
143
			return null;
144
		}
145

  
146
		public void getDataCollection(FeatureType type, String filter, String order, Observer observer) throws DataException {
147
			// TODO Auto-generated method stub
148

  
149
		}
150

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

  
154
		}
155

  
156
		public void getDataCollection(Observer observer) {
157
			// TODO Auto-generated method stub
158

  
159
		}
160

  
161
		public Feature getFeatureByID(FeatureID id) throws ReadException {
162
			// TODO Auto-generated method stub
163
			return null;
164
		}
165

  
166
		public Feature getFeatureByID(FeatureID id, FeatureType featureType) throws ReadException {
167
			// TODO Auto-generated method stub
168
			return null;
169
		}
170

  
171
		public FeatureType getDefaultFeatureType() {
172
			// TODO Auto-generated method stub
173
			return null;
174
		}
175

  
176
		public List getFeatureTypes() {
177
			// TODO Auto-generated method stub
178
			return null;
179
		}
180

  
181
		public Feature createFeature(FeatureType type, boolean defaultValues) throws InitializeException {
182
			// TODO Auto-generated method stub
183
			return null;
184
		}
185

  
186
		public Feature createDefaultFeature(boolean defaultValues) throws InitializeException {
187
			// TODO Auto-generated method stub
188
			return null;
189
		}
190

  
191
		public void update(Feature feature) throws DataException {
192
			// TODO Auto-generated method stub
193

  
194
		}
195

  
196
		public void delete(Feature feature) throws DataException {
197
			// TODO Auto-generated method stub
198

  
199
		}
200

  
201
		public void insert(Feature feature) throws DataException {
202
			// TODO Auto-generated method stub
203

  
204
		}
205

  
206
		public void update(FeatureAttributeDescriptor attributeDescriptor) throws DataException {
207
			// TODO Auto-generated method stub
208

  
209
		}
210

  
211
		public void delete(FeatureAttributeDescriptor attributeDescriptor) throws DataException {
212
			// TODO Auto-generated method stub
213

  
214
		}
215

  
216
		public void insert(FeatureAttributeDescriptor attributeDescriptor) throws DataException {
217
			// TODO Auto-generated method stub
218

  
219
		}
220

  
221
		public void disableNotifications() {
222
			// TODO Auto-generated method stub
223

  
224
		}
225

  
226
		public void enableNotifications() {
227
			// TODO Auto-generated method stub
228

  
229
		}
230

  
231
		public boolean isLocked(FeatureID id) {
232
			// TODO Auto-generated method stub
233
			return false;
234
		}
235

  
236
		public boolean lock(FeatureID id) {
237
			// TODO Auto-generated method stub
238
			return false;
239
		}
240

  
241
		public boolean isWithDefaultLegend() {
242
			// TODO Auto-generated method stub
243
			return false;
244
		}
245

  
246
		public Object getDefaultLegend() throws ReadException {
247
			// TODO Auto-generated method stub
248
			return null;
249
		}
250

  
251
		public Object getDefaultLabelingStrategy() {
252
			// TODO Auto-generated method stub
253
			return null;
254
		}
255

  
256
		public boolean canAlterFeatureType() {
257
			// TODO Auto-generated method stub
258
			return false;
259
		}
260

  
261
		public DataStoreParameters getParameters() {
262
			// TODO Auto-generated method stub
263
			return null;
264
		}
265

  
266
		public String getName() {
267
			// TODO Auto-generated method stub
268
			return null;
269
		}
270

  
271
		public void init(DataStoreParameters parameters) throws InitializeException {
272
			// TODO Auto-generated method stub
273

  
274
		}
275

  
276
		public void open() throws OpenException {
277
			// TODO Auto-generated method stub
278

  
279
		}
280

  
281
		public void refresh() throws OpenException, InitializeException {
282
			// TODO Auto-generated method stub
283

  
284
		}
285

  
286
		public void close() throws CloseException {
287
			// TODO Auto-generated method stub
288

  
289
		}
290

  
291
		public void dispose() throws CloseException {
292
			// TODO Auto-generated method stub
293

  
294
		}
295

  
296
		public DataCollection getDataCollection() throws ReadException {
297
			// TODO Auto-generated method stub
298
			return null;
299
		}
300

  
301
		public DataCollection getSelection() {
302
			// TODO Auto-generated method stub
303
			return null;
304
		}
305

  
306
		public void setSelection(DataCollection selection) {
307
			// TODO Auto-generated method stub
308

  
309
		}
310

  
311
		public DataCollection createSelection() {
312
			// TODO Auto-generated method stub
313
			return null;
314
		}
315

  
316
		public Iterator getChilds() {
317
			// TODO Auto-generated method stub
318
			return null;
319
		}
320

  
321
		public boolean isEditable() {
322
			// TODO Auto-generated method stub
323
			return false;
324
		}
325

  
326
		public void startEditing() throws ReadException {
327
			// TODO Auto-generated method stub
328

  
329
		}
330

  
331
		public void cancelEditing() {
332
			// TODO Auto-generated method stub
333

  
334
		}
335

  
336
		public void finishEditing() throws WriteException, ReadException {
337
			// TODO Auto-generated method stub
338

  
339
		}
340

  
341
		public boolean isEditing() {
342
			// TODO Auto-generated method stub
343
			return false;
344
		}
345

  
346
		public void undo() {
347
			// TODO Auto-generated method stub
348

  
349
		}
350

  
351
		public void redo() {
352
			// TODO Auto-generated method stub
353

  
354
		}
355

  
356
		public CommandsRecord getCommandsRecord() {
357
			// TODO Auto-generated method stub
358
			return null;
359
		}
360

  
361
		public void beginComplexNotification() {
362
			// TODO Auto-generated method stub
363

  
364
		}
365

  
366
		public void endComplexNotification() {
367
			// TODO Auto-generated method stub
368

  
369
		}
370

  
371
		public DataCollection getLocked() {
372
			// TODO Auto-generated method stub
373
			return null;
374
		}
375

  
376
		public void setLocked(DataCollection locked) {
377
			// TODO Auto-generated method stub
378

  
379
		}
380

  
381
		public DataCollection createLocked() {
382
			// TODO Auto-generated method stub
383
			return null;
384
		}
385

  
386
		public DataExplorer getExplorer() throws ReadException {
387
			// TODO Auto-generated method stub
388
			return null;
389
		}
390

  
391
		public void addObserver(Observer o) {
392
			// TODO Auto-generated method stub
393

  
394
		}
395

  
396
		public void deleteObserver(Observer o) {
397
			// TODO Auto-generated method stub
398

  
399
		}
400

  
401
		public void deleteObservers() {
402
			// TODO Auto-generated method stub
403

  
404
		}
405

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

  
462
	}
463

  
464
	//private static final FInterval interval0=new FInterval(0,2);
465
	//private static final FInterval interval1=new FInterval(3,5);
466
	//private static final FInterval interval2=new FInterval(6,2);
467
	//private static final FInterval interval3=new FInterval(9,2);
468
	// private static final Value interval4;
469
	// private static final Value interval5;
470
	// private static final Value interval6;
471
	// private static final Value interval7;
472
	// private static final Value interval8;
473
	// private static final Value interval9;
474

  
475
	Hashtable symTable;
476

  
477
	private IClassifiedVectorLegend[] classifiedLegends;
478
	private ISymbol[] symbols;
479
	private Object[] sampleValues = new Object[] { v0, v1, v2, v3, };
480
	private Feature[] features;
481

  
482
	// private FInterval[] intervals = new FInterval[] {
483
	// interval0,
484
	// interval1,
485
	// interval2,
486
	// interval3,
487
	// interval4,
488
	// interval5,
489
	// interval6,
490
	// interval7,
491
	// interval8,
492
	// interval9,
493
	// };
494

  
495
	protected void setUp() throws Exception {
496
		super.setUp();
497
		features = new Feature[4];
498

  
499
		// initialize test values
500
		for (int i = 0; i < features.length; i++) {
501
			GeometryFactory geomFactory=GeometryManager.getInstance().getGeometryFactory();
502
			// create the geometry associated to the feature
503
			int size = 200;
504
			Dimension d = new Dimension(size, size);
505
			Rectangle aShape = new Rectangle(i * size, i * size, d.width,
506
					d.height);
507
			Geometry geom = geomFactory.createPolyline2D(new GeneralPathX(
508
					aShape));
509

  
510
			/*
511
			 * create a full-featured Feature with randomed values at its fields
512
			 * to avoid testing over the same values each time
513
			 */
514
//			features[i] = new DefaultFeature(geom, featureValues[i], "[" + i
515
//					+ "]");
516
		}
517

  
518
		// initialize the symbol subset for this test
519
		symbols = TestISymbol.getNewSymbolInstances();
520

  
521
		// initialize the legends for this test
522
		ILegend[] allLegends = TestILegend.getNewLegendInstances();
523
		ArrayList clegends = new ArrayList();
524
		ArrayList intervalLegends = new ArrayList();
525
		for (int i = 0; i < allLegends.length; i++) {
526
			if (allLegends[i] instanceof AbstractIntervalLegend) // <- Tested
527
				intervalLegends.add(allLegends[i]);
528
			else if (allLegends[i] instanceof IClassifiedLegend) {
529
				clegends.add(allLegends[i]);
530
			}
531

  
532
			if (allLegends[i] instanceof IClassifiedVectorLegend) {
533
				IClassifiedVectorLegend cvl = (IClassifiedVectorLegend) allLegends[i];
534
				cvl.setClassifyingFieldNames(new String[] { fieldNames[FIELDID] });
535
				cvl.setFeatureStore(mockDataSource);
536

  
537
			}
538
		}
539

  
540
		this.classifiedLegends = (IClassifiedVectorLegend[]) clegends
541
				.toArray(new IClassifiedVectorLegend[clegends.size()]);
542
		this.intervalLegends = (AbstractIntervalLegend[]) intervalLegends
543
				.toArray(new AbstractIntervalLegend[intervalLegends.size()]);
544
	}
545

  
546
	/**
547
	 * This method is used to add symbols to a legend.That is, it takes an array
548
	 * of IClassifiedVectorialLegend which is empty andm, using a second array
549
	 * of objects (values), the first one is filled.Also, a hash table is filled
550
	 * too using the array of objects (it will be useful in some tests to check
551
	 * that a symbol can be taken using a feature) .
552
	 *
553
	 * @param legend
554
	 * @return
555
	 */
556
	private void fillClassifiedLegend(IClassifiedVectorLegend legend,
557
			Object[] values) {
558
		// initialize the hash table
559
		symTable = new Hashtable();
560

  
561
		// to add symbols to the legend and the hash table
562
		for (int j = 0; j < values.length; j++) {
563

  
564
			ISymbol sym = symbols[j % symbols.length];
565
			legend.addSymbol(values[j], sym);
566
			symTable.put(values[j], sym);
567
		}
568
	}
569

  
570
	/**
571
	 * This test ensures that when a legend is filled, the number of symbols
572
	 * added is correct. To do it, is checked that the number of symbols of a
573
	 * legend is the same as the length of the array of example values that we
574
	 * have.
575
	 *
576
	 * @throws ReadDriverException
577
	 */
578
	public void testICLAdittion() throws ReadException {
579

  
580
		// Fills the legend
581
		for (int i = 0; i < classifiedLegends.length; i++) {
582
			fillClassifiedLegend(classifiedLegends[i], sampleValues);
583
		}
584

  
585
		for (int i = 0; i < classifiedLegends.length; i++)
586
			assertEquals(classifiedLegends[i].getClassName()
587
					+ " fails with the comparation of the number of symbols",
588
					classifiedLegends[i].getSymbols().length,
589
					sampleValues.length);
590

  
591
	}
592

  
593
	/**
594
	 * This test ensures that the symbols that we have previously added to a
595
	 * legend are accessible using its features.To do it, this test compares the
596
	 * symbol taken from the legend with the symbol taken from the hashTable
597
	 * (using the same feature).
598
	 *
599
	 * @throws ReadDriverException
600
	 */
601

  
602
	public void testICLCheckValueSymbols() throws ReadException {
603
		// fills the legends
604
		for (int i = 0; i < classifiedLegends.length; i++) {
605
			fillClassifiedLegend(classifiedLegends[i], sampleValues);
606
		}
607

  
608
		for (int i = 0; i < classifiedLegends.length; i++) {
609
			// For each feature
610
			for (int j = 0; j < features.length; j++) {
611
				Feature myFeature = features[i];
612
				// takes the value of the field that identifies the feature
613
				Object val = myFeature.get(FIELDID);
614
				// the last value is used to access to the hash table to obtain
615
				// a symbol
616
				ISymbol tableSym = (ISymbol) symTable.get(val);
617

  
618
				IClassifiedVectorLegend leg = (IClassifiedVectorLegend) classifiedLegends[i];
619
				// takes the symbol from a legend using the feature
620
				ISymbol legendSym = leg.getSymbolByFeature(myFeature);
621
				// compares that both symbols are the same
622
				assertEquals(legendSym.getClassName()
623
						+ " fails with the comparation of the class symbols",
624
						legendSym, tableSym);
625
			}
626
		}
627
	}
628

  
629
}
branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/TestCartographicSupportForSymbol.java
1
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.geom.Rectangle2D;
45
import java.util.ArrayList;
46
import java.util.Random;
47

  
48
import junit.framework.TestCase;
49

  
50
import org.gvsig.fmap.AllTests;
51
import org.gvsig.fmap.geom.primitive.Point2D;
52
import org.gvsig.fmap.mapcontext.MapContext;
53
import org.gvsig.fmap.mapcontext.ViewPort;
54
import org.gvsig.fmap.mapcontext.rendering.symbol.AbstractSymbolTestCase;
55
import org.gvsig.fmap.mapcontext.rendering.symbol.SimpleFillSymbolTest;
56
import org.gvsig.fmap.mapcontext.rendering.symbol.SimpleLineSymbolTest;
57
import org.gvsig.fmap.mapcontext.rendering.symbol.SimpleMarkerSymbolTest;
58
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
59
import org.gvsig.fmap.mapcontext.rendering.symbols.IFillSymbol;
60
import org.gvsig.fmap.mapcontext.rendering.symbols.ILineSymbol;
61
import org.gvsig.fmap.mapcontext.rendering.symbols.IMarkerSymbol;
62
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
63
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
64

  
65
import com.iver.utiles.IPersistence;
66
import com.iver.utiles.NotExistInXMLEntity;
67
import com.iver.utiles.XMLEntity;
68

  
69
/**
70
 *
71
 * @author jaume dominguez faus - jaume.dominguez@iver.es
72
 */
73
public class TestCartographicSupportForSymbol extends TestCase {
74
	/**
75
	 * Geodesic vertex of the Micalet in Valencia (Spain) in <b>EPSG:23030</b>
76
	 */
77
	public static final Point2D valenciaUTM30 = new Point2D(725846.080, 4373022.720);
78

  
79
	/**
80
	 * Geodesic vertex of the Micalet in Valencia (Spain) in <b>EPSG:4326</b>
81
	 */
82
	public static final Point2D valenciaGeo = new Point2D(- (0+ 22/60 +  27.919/3600), 39 + 28/60 + 35.4276/3600);
83
	/**
84
	 * Extent that covers the whole Comunitat Valenciana in  <b>EPSG:23030</b>
85
	 */
86
	public static final Rectangle2D TEST_UTM30_EXTENT = new Rectangle2D.Double();
87
	{
88
		TEST_UTM30_EXTENT.setFrameFromDiagonal(
89
				4191037.369934333,
90
				626674.7454557443,
91

  
92
				4519266.460824658,
93
				797903.2656794232
94
		);
95
	}
96
	/**
97
	 * Extent that covers the whole Comunitat Valenciana in  <b>EPSG:4326</b>
98
	 */
99

  
100
	public static final Rectangle2D TEST_GEO_EXTENT = new Rectangle2D.Double();
101
	{
102
		TEST_GEO_EXTENT.setFrameFromDiagonal(
103

  
104
				-  (1 + (31/60) + (28.09/3600)),	// Western egde
105
				37 + (50/60) + (48.05/3600),		// Southern edge
106

  
107
				0 + (31/60) + (1.85/3600),		// Eastern edge
108
				40 + (47/60) + (21.36/3600)		// Northern edge
109

  
110
		);
111
	}
112

  
113
	public static final Rectangle2D TEST_EXTENT = new Rectangle2D.Double(
114
			4191037.369934333,
115
			626674.7454557443,
116

  
117
			4519266.460824658 - 4191037.369934333,
118
			797903.2656794232 -  626674.7454557443
119
	);
120
	private static ArrayList<AbstractSymbolTestCase> symbolsToTest;
121
	private ArrayList<CartographicSupport> csSymbols;
122

  
123
	/**
124
	 * Acceptable pixel tolerance error. 1 pixel of error is accetable since it is probably due to
125
	 * the java.awt.Graphics
126
	 */
127
	private static final double TOL = 1;
128

  
129
	double zooms[] = new double[] {
130
			1,
131
			2,
132
			1.2,
133
			10,
134
			0.5
135
	};
136

  
137

  
138

  
139
	public void setUp() {
140
		addSymbolTest(new SimpleFillSymbolTest());
141
		addSymbolTest(new SimpleLineSymbolTest());
142
		addSymbolTest(new SimpleMarkerSymbolTest());
143

  
144
		init();
145
	}
146

  
147
	protected void init() {
148

  
149
		// take the symbols added to the TestISymbol test
150
		ISymbol[] symbols = getNewSymbolInstances();
151

  
152
		csSymbols = new ArrayList<CartographicSupport>();
153
		for (int i = 0; i < symbols.length; i++) {
154
			if (symbols[i] instanceof CartographicSupport) {
155
				csSymbols.add((CartographicSupport) symbols[i]);
156
			}
157
		}
158
	}
159

  
160
	public static void addSymbolTest(AbstractSymbolTestCase symbolTestClass) {
161
		if (symbolsToTest == null) symbolsToTest = new ArrayList<AbstractSymbolTestCase>();
162
		symbolsToTest.add(symbolTestClass);
163
	}
164

  
165
	public static ISymbol[] getNewSymbolInstances() {
166
		ISymbol[] symbols = new ISymbol[symbolsToTest.size()];
167
		for (int i = 0; i < symbols.length; i++) {
168
			symbols[i] = symbolsToTest.get(i).newInstance();
169
		}
170
		return symbols;
171
	}
172

  
173

  
174
	public void testSymbolUnitDefinition() {
175
		for (int i = 0; i < csSymbols.size(); i++) {
176
			CartographicSupport symbol = csSymbols.get(i);
177

  
178
			int aRandomUnit = new Random().nextInt(7);
179

  
180

  
181
			symbol.setUnit(aRandomUnit);
182
			XMLEntity xml = ((IPersistence) symbol).getXMLEntity();
183
			String name = symbol.getClass().getName().substring(
184
					symbol.getClass().getName().lastIndexOf('.')+1,
185
					symbol.getClass().getName().length());
186

  
187
			try {
188
				assertTrue( ((ISymbol) symbol).getClassName()+" does not declare units correctly",
189
						symbol.getUnit() == xml.getIntProperty("unit"));
190
			} catch (NotExistInXMLEntity neiXMLEx) {
191
				fail(((ISymbol) symbol).getClassName()+ " does not declare field attribute in its XMLEntity");
192
			}
193
			symbol.setUnit(5);
194
			try {
195
				assertTrue( ((ISymbol) symbol).getClassName()+" does not apply changes to symbol",symbol.getUnit()== 5);
196
				assertTrue( ((ISymbol) symbol).getClassName()+" does not declare units correctly",
197
						5 == ((IPersistence) symbol).getXMLEntity().getIntProperty("unit"));
198
			} catch (NotExistInXMLEntity neiXMLEx) {
199
				fail(((ISymbol) symbol).getClassName()+ " does not declare field attribute in its XMLEntity");
200
			}
201

  
202
			xml.putProperty("unit", 3);
203
			ISymbol ts = SymbologyFactory.createSymbolFromXML(xml, xml.getStringProperty("desc"));
204
			assertTrue("The application of the UNIT value to the XMLEntity didn't have any effect ("+name+")", ((CartographicSupport) ts).getUnit() == 3);
205
		}
206

  
207
	}
208

  
209

  
210
	public void testSymbolReferenceSystemDefinition() {
211
		for (int i = 0; i < csSymbols.size(); i++) {
212
			CartographicSupport symbol = csSymbols.get(i);
213
			XMLEntity xml = ((IPersistence) symbol).getXMLEntity();
214
			String name = symbol.getClass().getName().substring(
215
					symbol.getClass().getName().lastIndexOf('.')+1,
216
					symbol.getClass().getName().length());
217
			try {
218
				assertTrue( ((ISymbol) symbol).getClassName()+" does not declare units correctly",
219
						symbol.getReferenceSystem() == xml.getIntProperty("referenceSystem"));
220
			} catch (NotExistInXMLEntity neiXMLEx) {
221
				fail(((ISymbol) symbol).getClassName()+ " does not declare referenceSystem field attribute in its XMLEntity");
222
			}
223
			symbol.setReferenceSystem(CartographicSupport.PAPER);
224
			try {
225
				assertTrue( ((ISymbol) symbol).getClassName()+" does not apply changes to symbol",symbol.getReferenceSystem()== CartographicSupport.PAPER);
226
				assertTrue( ((ISymbol) symbol).getClassName()+" does not declare referenceSystem correctly",
227
						CartographicSupport.PAPER == ((IPersistence) symbol).getXMLEntity().getIntProperty("referenceSystem"));
228
			} catch (NotExistInXMLEntity neiXMLEx) {
229
				fail(((ISymbol) symbol).getClassName()+ " does not declare referenceSystem field attribute in its XMLEntity ("+name+")");
230
			}
231

  
232
			symbol.setReferenceSystem(CartographicSupport.WORLD);
233
			try {
234
				assertTrue( ((ISymbol) symbol).getClassName()+" does not apply changes to symbol",symbol.getReferenceSystem()== CartographicSupport.WORLD);
235
				assertTrue( ((ISymbol) symbol).getClassName()+" does not declare referenceSystem correctly",
236
						CartographicSupport.WORLD == ((IPersistence) symbol).getXMLEntity().getIntProperty("referenceSystem"));
237
			} catch (NotExistInXMLEntity neiXMLEx) {
238
				fail(((ISymbol) symbol).getClassName()+ " does not declare referenceSystem field attribute in its XMLEntity");
239
			}
240

  
241
			xml.putProperty("referenceSystem", CartographicSupport.PAPER);
242
			ISymbol ts = SymbologyFactory.createSymbolFromXML(xml, xml.getStringProperty("desc"));
243
			assertTrue("The application of the REFERENCE SYSTEM value to the XMLEntity didn't have any effect ("+name+")", ((CartographicSupport) ts).getReferenceSystem() == CartographicSupport.PAPER);
244
		}
245
	}
246

  
247

  
248
	public void testDegreesUnits_MapReferenceSystem() {
249
		for (int j = 0; j < csSymbols.size(); j++) {
250
			CartographicSupport symbol = csSymbols.get(j);
251

  
252
			MapContext mc = AllTests.newMapContext(AllTests.TEST_DEFAULT_PROJECTION);
253
			ViewPort viewPort = mc.getViewPort();
254

  
255
			int unit = 8;
256
			Dimension dim = new Dimension(600, 600);
257
			viewPort.setImageSize(dim);
258

  
259

  
260
			/*
261
			 * will test with several extents but in the same map image size, so
262
			 * the scale issue is exercised as well.
263
			 */
264
			for (int i = 0; i < zooms.length; i++) {
265
				Rectangle2D extent = new Rectangle2D.Double(-30, -30, dim.getWidth()/zooms[i], dim.getHeight()/zooms[i]);
266

  
267
				viewPort.setMapUnits(unit);
268
				viewPort.setExtent(extent);
269

  
270

  
271
				String name = ((IPersistence) symbol).getClassName().substring(
272
						((IPersistence) symbol).getClassName().lastIndexOf('.')+1,
273
						((IPersistence) symbol).getClassName().length());
274

  
275
				CartographicSupport csSym = (CartographicSupport) symbol;
276
				csSym.setReferenceSystem(CartographicSupport.WORLD);
277
				double size = 30;
278

  
279
				csSym.setUnit(unit);
280

  
281

  
282

  
283
				if (symbol instanceof IMarkerSymbol) {
284

  
285
					IMarkerSymbol markerSym = (IMarkerSymbol) symbol;
286
					markerSym.setSize(size);
287
					csSym.toCartographicSize(
288
							viewPort,
289
							MapContext.getScreenDPI(),
290
							new Point2D(
291
									viewPort.getAdjustedExtent().getCenterX(),
292
									viewPort.getAdjustedExtent().getCenterY()
293
							)
294
					);
295
					double mySize = markerSym.getSize();
296
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
297
							"It returned "+markerSym.getSize()+" when expecting "+
298
							size+"*"+zooms[i]+"="+size*zooms[i],  Math.abs(mySize-size*zooms[i]) <= TOL );
299
				}
300

  
301
				if (symbol instanceof ILineSymbol) {
302

  
303
					ILineSymbol lineSym = (ILineSymbol) symbol;
304
					lineSym.setLineWidth(size);
305
					csSym.toCartographicSize(
306
							viewPort,
307
							MapContext.getScreenDPI(),
308
							new Point2D(
309
									viewPort.getAdjustedExtent().getCenterX(),
310
									viewPort.getAdjustedExtent().getCenterY()
311
							)
312
					);
313
					double mySize = lineSym.getLineStyle().getLineWidth();
314
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
315
							"It returned "+mySize+" when expecting "+
316
							size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
317
				}
318

  
319
				if (symbol instanceof IFillSymbol) {
320
					// this tests if symbol applies the cartographic support to its
321
					// outline, since is the only thing that may be resized
322
					IFillSymbol fillSym = (IFillSymbol) symbol;
323
					if (fillSym.getOutline() == null) {
324
						fillSym.setOutline(SymbologyFactory.createDefaultLineSymbol());
325
					}
326

  
327
					fillSym.getOutline().setLineWidth(size);
328

  
329
					csSym.toCartographicSize(
330
							viewPort,
331
							MapContext.getScreenDPI(),
332
							new Point2D(
333
									viewPort.getAdjustedExtent().getCenterX(),
334
									viewPort.getAdjustedExtent().getCenterY()
335
							)
336
					);
337
					double mySize = fillSym.getOutline().getLineStyle().getLineWidth();
338
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
339
							"It returned "+fillSym.getOutline().getLineWidth()+" when expecting "+
340
							size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
341
				}
342

  
343
			}
344
		}
345
	}
346

  
347

  
348
	public void testKilometersUnits_MapReferenceSystem() {
349
		for (int j = 0; j < csSymbols.size(); j++) {
350
			CartographicSupport symbol = csSymbols.get(j);
351
			MapContext mc = AllTests.newMapContext(AllTests.TEST_DEFAULT_MERCATOR_PROJECTION);
352
			ViewPort viewPort = mc.getViewPort();
353

  
354
			int unit = 0;
355
			Dimension dim = new Dimension(60, 60);
356
			viewPort.setImageSize(dim);
357

  
358

  
359
			/*
360
			 * will test with several extents but in the same map image size, so
361
			 * the scale issue is exercised as well.
362
			 */
363
			for (int i = 0; i < zooms.length; i++) {
364
				Rectangle2D extent = new Rectangle2D.Double(-30, -30, dim.getWidth()/zooms[i], dim.getHeight()/zooms[i]);
365

  
366
				viewPort.setMapUnits(unit);
367
				viewPort.setExtent(extent);
368

  
369

  
370
				String name = ((IPersistence) symbol).getClassName().substring(
371
						((IPersistence) symbol).getClassName().lastIndexOf('.')+1,
372
						((IPersistence) symbol).getClassName().length());
373

  
374
				CartographicSupport csSym = (CartographicSupport) symbol;
375
				csSym.setReferenceSystem(CartographicSupport.WORLD);
376
				double size = 30;
377

  
378
				csSym.setUnit(unit);
379

  
380

  
381

  
382

  
383
				if (symbol instanceof IMarkerSymbol) {
384

  
385
					IMarkerSymbol markerSym = (IMarkerSymbol) symbol;
386
					markerSym.setSize(size);
387
					csSym.toCartographicSize(
388
							viewPort,
389
							MapContext.getScreenDPI(),
390
							new Point2D(
391
									viewPort.getAdjustedExtent().getCenterX(),
392
									viewPort.getAdjustedExtent().getCenterY()
393
							)
394
					);
395
					double mySize = markerSym.getSize();
396
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
397
							"It returned "+markerSym.getSize()+" when expecting "+
398
							size+"*"+zooms[i]+"="+size*zooms[i],  Math.abs(mySize-size*zooms[i]) <= TOL );
399
				}
400

  
401
				if (symbol instanceof ILineSymbol) {
402

  
403
					ILineSymbol lineSym = (ILineSymbol) symbol;
404
					lineSym.setLineWidth(size);
405
					csSym.toCartographicSize(
406
							viewPort,
407
							MapContext.getScreenDPI(),
408
							new Point2D(
409
									viewPort.getAdjustedExtent().getCenterX(),
410
									viewPort.getAdjustedExtent().getCenterY()
411
							)
412
					);
413
					double mySize = lineSym.getLineStyle().getLineWidth();
414
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
415
							"It returned "+lineSym.getLineWidth()+" when expecting "+
416
							size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
417
				}
418

  
419
				if (symbol instanceof IFillSymbol) {
420
					// this tests if symbol applies the cartographic support to its
421
					// outline, since is the only thing that may be resized
422
					IFillSymbol fillSym = (IFillSymbol) symbol;
423
					if (fillSym.getOutline() == null) {
424
						fillSym.setOutline(SymbologyFactory.createDefaultLineSymbol());
425
					}
426

  
427
					fillSym.getOutline().setLineWidth(size);
428

  
429
					csSym.toCartographicSize(
430
							viewPort,
431
							MapContext.getScreenDPI(),
432
							new Point2D(
433
									viewPort.getAdjustedExtent().getCenterX(),
434
									viewPort.getAdjustedExtent().getCenterY()
435
							)
436
					);
437
					double mySize = fillSym.getOutline().getLineStyle().getLineWidth();
438
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
439
							"It returned "+fillSym.getOutline().getLineWidth()+" when expecting "+
440
							size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
441
				}
442

  
443
			}
444
		}
445

  
446
	}
447

  
448
	public void testMapInKilometersSymbolInMeters_MapReferenceSystem() {
449
		for (int j = 0; j < csSymbols.size(); j++) {
450
			CartographicSupport symbol = csSymbols.get(j);
451

  
452
			MapContext mc = AllTests.newMapContext(AllTests.TEST_DEFAULT_MERCATOR_PROJECTION);
453
			ViewPort viewPort = mc.getViewPort();
454

  
455
			int mapUnit = 0;
456
			int symbolUnit = 1;
457
			Dimension dim = new Dimension(60, 60);
458
			viewPort.setImageSize(dim);
459

  
460

  
461
			/*
462
			 * will test with several extents but in the same map image size, so
463
			 * the scale issue is exercised as well.
464
			 */
465
			for (int i = 0; i < zooms.length; i++) {
466
				Rectangle2D extent = new Rectangle2D.Double(-30, -30, dim.getWidth()/zooms[i], dim.getHeight()/zooms[i]);
467

  
468
				viewPort.setMapUnits(mapUnit);
469
				viewPort.setExtent(extent);
470
				double size = 30;
471

  
472

  
473
				String name = ((IPersistence) symbol).getClassName().substring(
474
						((IPersistence) symbol).getClassName().lastIndexOf('.')+1,
475
						((IPersistence) symbol).getClassName().length());
476

  
477

  
478
				CartographicSupport csSym = (CartographicSupport) symbol;
479
				csSym.setReferenceSystem(CartographicSupport.WORLD);
480

  
481
				csSym.setUnit(symbolUnit);
482

  
483
				if (symbol instanceof IMarkerSymbol) {
484

  
485
					IMarkerSymbol markerSym = (IMarkerSymbol) symbol;
486
					markerSym.setSize(size*MapContext.CHANGEM[mapUnit]); // 30m*1000 = 30 km
487
					csSym.toCartographicSize(
488
							viewPort,
489
							MapContext.getScreenDPI(),
490
							new Point2D(
491
									viewPort.getAdjustedExtent().getCenterX(),
492
									viewPort.getAdjustedExtent().getCenterY()
493
							)
494
					);
495
					double mySize = markerSym.getSize();
496
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
497
							"It returned "+markerSym.getSize()+" when expecting "+
498
							size+"*"+zooms[i]+"="+size*zooms[i],  Math.abs(mySize-size*zooms[i]) <= TOL );
499
				}
500

  
501
				if (symbol instanceof ILineSymbol) {
502

  
503
					ILineSymbol lineSym = (ILineSymbol) symbol;
504
					lineSym.setLineWidth(size*MapContext.CHANGEM[mapUnit]); // 30m*1000 = 30 km
505
					csSym.toCartographicSize(
506
							viewPort,
507
							MapContext.getScreenDPI(),
508
							new Point2D(
509
									viewPort.getAdjustedExtent().getCenterX(),
510
									viewPort.getAdjustedExtent().getCenterY()
511
							)
512
					);
513
					double mySize = lineSym.getLineStyle().getLineWidth();
514
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
515
							"It returned "+lineSym.getLineWidth()+" when expecting "+
516
							size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
517
				}
518

  
519
				if (symbol instanceof IFillSymbol) {
520
					// this tests if symbol applies the cartographic support to its
521
					// outline, since is the only thing that may be resized
522
					IFillSymbol fillSym = (IFillSymbol) symbol;
523
					if (fillSym.getOutline() == null) {
524
						fillSym.setOutline(SymbologyFactory.createDefaultLineSymbol());
525
					}
526

  
527
					fillSym.getOutline().setLineWidth(size*MapContext.CHANGEM[mapUnit]);
528

  
529
					csSym.toCartographicSize(
530
							viewPort,
531
							MapContext.getScreenDPI(),
532
							new Point2D(
533
									viewPort.getAdjustedExtent().getCenterX(),
534
									viewPort.getAdjustedExtent().getCenterY()
535
							)
536
					);
537
					double mySize = fillSym.getOutline().getLineStyle().getLineWidth();
538
					assertTrue("The Symbol '"+name+"' failed computing cartographic size. " +
539
							"It returned "+fillSym.getOutline().getLineWidth()+" when expecting "+
540
							size+"*"+zooms[i]+"="+size*zooms[i], Math.abs(mySize-size*zooms[i]) <= TOL );
541
				}
542

  
543
			}
544
		}
545
	}
546

  
547
}
branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/TestCartographySupport.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.fmap.mapcontext.rendering;
42

  
43
import junit.framework.TestSuite;
44

  
45
/**
46
 * @author jaume dominguez faus - jaume.dominguez@iver.es
47
 */
48
public class TestCartographySupport extends TestSuite {
49

  
50

  
51

  
52
}
branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/symbol/IDrawFillSymbol.java
1
package org.gvsig.fmap.mapcontext.rendering.symbol;
2

  
3
import org.gvsig.fmap.mapcontext.rendering.symbols.IFillSymbol;
4

  
5
public interface IDrawFillSymbol {
6

  
7
	IFillSymbol makeSymbolTransparent(IFillSymbol newSymbol);
8

  
9
	boolean isSuitableFor(IFillSymbol newSymbol);
10

  
11
}
branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/symbol/SimpleTextSymbolTest.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.symbol;
42

  
43
import org.gvsig.fmap.mapcontext.rendering.symbols.SimpleTextSymbol;
44

  
45
public class SimpleTextSymbolTest extends AbstractSymbolTestCase{
46
	public SimpleTextSymbolTest() {
47
		super(SimpleTextSymbol.class);
48
	}
49
}
branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/symbol/AbstractSymbolTestCase.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.symbol;
42

  
43
import junit.framework.TestCase;
44

  
45
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
46

  
47

  
48
public abstract class AbstractSymbolTestCase extends TestCase {
49
	protected Class symClazz;
50

  
51
	public AbstractSymbolTestCase(Class symClazz) {
52
		this.symClazz = symClazz;
53
	}
54

  
55
	public ISymbol newInstance() {
56
		try {
57
			return (ISymbol) symClazz.newInstance();
58
		} catch (Exception e) {
59
			fail("Failed installing symbol to test "+symClazz.getName());
60
			return null;
61
		}
62
	}
63
}
branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/symbol/SimpleFillSymbolTest.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.symbol;
42

  
43
import org.gvsig.fmap.mapcontext.rendering.symbols.SimpleFillSymbol;
44

  
45
public class SimpleFillSymbolTest extends AbstractSymbolTestCase{
46
	public SimpleFillSymbolTest() {
47
		super(SimpleFillSymbol.class);
48
	}
49
}
branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/symbol/SimpleLineSymbolTest.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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.symbol;
42

  
43
import org.gvsig.fmap.mapcontext.rendering.symbols.SimpleLineSymbol;
44

  
45
public class SimpleLineSymbolTest extends AbstractSymbolTestCase{
46
	public SimpleLineSymbolTest() {
47
		super(SimpleLineSymbol.class);
48
	}
49
}
branches/v2_0_0_prep/libraries/libFMap/src-test/org/gvsig/fmap/mapcontext/rendering/symbol/TestDrawFills.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff