Revision 37647

View differences:

tags/v_2_0_0_Build_2043/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/tools/persistence/ColorPersistenceFactoryTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.tools.persistence;
28

  
29
import java.awt.Color;
30

  
31
import org.easymock.MockControl;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34
import org.gvsig.tools.persistence.PersistenceManager;
35
import org.gvsig.tools.persistence.PersistentState;
36

  
37
/**
38
 * Unit tests for the class {@link ColorPersistenceFactory}.
39
 * 
40
 * @author gvSIG team
41
 */
42
public class ColorPersistenceFactoryTest extends
43
		AbstractLibraryAutoInitTestCase {
44

  
45
	private ColorPersistenceFactory factory;
46
	private MockControl stateControl;
47
	private PersistentState state;
48
	private Color color;
49

  
50
	protected void doSetUp() throws Exception {
51
		PersistenceManager persistenceManager = ToolsLocator
52
				.getPersistenceManager();
53
		factory = (ColorPersistenceFactory) persistenceManager.getFactories()
54
				.get(Color.class);
55
		stateControl = MockControl.createNiceControl(PersistentState.class);
56
		state = (PersistentState) stateControl.getMock();
57
		color = Color.magenta;
58
	}
59

  
60
	/**
61
	 * Test method for
62
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.ColorPersistenceFactory#createFromState(org.gvsig.tools.persistence.PersistentState, java.lang.Class)}
63
	 * .
64
	 */
65
	public void testCreateFromState() throws Exception {
66
		stateControl.expectAndReturn(state
67
				.getInt(ColorPersistenceFactory.FIELD_RED), color.getRed());
68
		stateControl.expectAndReturn(state
69
				.getInt(ColorPersistenceFactory.FIELD_GREEN), color.getGreen());
70
		stateControl.expectAndReturn(state
71
				.getInt(ColorPersistenceFactory.FIELD_BLUE), color.getBlue());
72
		stateControl.expectAndReturn(state
73
				.getInt(ColorPersistenceFactory.FIELD_ALPHA), color.getAlpha());
74
		stateControl.replay();
75

  
76
		Color newColor = (Color) factory.createFromState(state);
77
		assertTrue(newColor.equals(color));
78

  
79
		stateControl.verify();
80
	}
81

  
82
	/**
83
	 * Test method for
84
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.ColorPersistenceFactory#saveToState(org.gvsig.tools.persistence.PersistentState, java.lang.Object)}
85
	 * .
86
	 */
87
	public void testSaveToState() throws Exception {
88
		state.set(ColorPersistenceFactory.FIELD_RED, color.getRed());
89
		state.set(ColorPersistenceFactory.FIELD_GREEN, color.getGreen());
90
		state.set(ColorPersistenceFactory.FIELD_BLUE, color.getBlue());
91
		state.set(ColorPersistenceFactory.FIELD_ALPHA, color.getAlpha());
92
		stateControl.replay();
93

  
94
		factory.saveToState(state, color);
95

  
96
		stateControl.verify();
97
	}
98

  
99
}
tags/v_2_0_0_Build_2043/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/tools/persistence/Point2DPersistenceFactoryTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.tools.persistence;
28

  
29
import java.awt.geom.Point2D;
30

  
31
import org.easymock.MockControl;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34
import org.gvsig.tools.persistence.PersistenceManager;
35
import org.gvsig.tools.persistence.PersistentState;
36

  
37
/**
38
 * Unit tests for the class {@link Point2DPersistenceFactory}.
39
 * 
40
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
41
 */
42
public class Point2DPersistenceFactoryTest extends
43
		AbstractLibraryAutoInitTestCase {
44

  
45
	private Point2DPersistenceFactory factory;
46
	private MockControl stateControl;
47
	private PersistentState state;
48
	private Point2D point;
49

  
50
	protected void doSetUp() throws Exception {
51
		PersistenceManager persistenceManager = ToolsLocator
52
				.getPersistenceManager();
53
		factory = (Point2DPersistenceFactory) persistenceManager.getFactories()
54
				.get(Point2D.class);
55
		stateControl = MockControl.createNiceControl(PersistentState.class);
56
		state = (PersistentState) stateControl.getMock();
57
		double x = Math.random() * 1000d;
58
		double y = Math.random() * 1000d;
59
		point = new Point2D.Double(x, y);
60
	}
61

  
62
	/**
63
	 * Test method for
64
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.Point2DPersistenceFactory#createFromState(PersistentState, Class)}
65
	 * .
66
	 */
67
	public void testCreateFromState() throws Exception {
68
		stateControl.expectAndReturn(state
69
				.getDouble(Point2DPersistenceFactory.FIELD_X), point.getX());
70
		stateControl.expectAndReturn(state
71
				.getDouble(Point2DPersistenceFactory.FIELD_Y), point.getY());
72
		stateControl.replay();
73

  
74
		Point2D newPoint = (Point2D) factory.createFromState(state);
75
		assertTrue(newPoint.equals(point));
76

  
77
		stateControl.verify();
78
	}
79

  
80
	/**
81
	 * Test method for
82
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.Point2DPersistenceFactory#saveToState(org.gvsig.tools.persistence.PersistentState, java.lang.Object)}
83
	 * .
84
	 */
85
	public void testSaveToState() throws Exception {
86
		state.set(Point2DPersistenceFactory.FIELD_X, point.getX());
87
		state.set(Point2DPersistenceFactory.FIELD_Y, point.getY());
88
		stateControl.replay();
89

  
90
		factory.saveToState(state, point);
91

  
92
		stateControl.verify();
93
	}
94
}
tags/v_2_0_0_Build_2043/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/tools/persistence/DimensionPersistenceFactoryTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.tools.persistence;
28

  
29
import java.awt.Dimension;
30

  
31
import org.easymock.MockControl;
32

  
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
35
import org.gvsig.tools.persistence.PersistenceManager;
36
import org.gvsig.tools.persistence.PersistentState;
37

  
38
/**
39
 * Unit tests for the class {@link DimensionPersistenceFactory}.
40
 * 
41
 * @author gvSIG team
42
 */
43
public class DimensionPersistenceFactoryTest extends
44
		AbstractLibraryAutoInitTestCase {
45

  
46
	private DimensionPersistenceFactory factory;
47
	private MockControl stateControl;
48
	private PersistentState state;
49
	private Dimension dimension;
50

  
51
	protected void doSetUp() throws Exception {
52
		PersistenceManager persistenceManager = ToolsLocator
53
				.getPersistenceManager();
54
		factory = (DimensionPersistenceFactory) persistenceManager
55
				.getFactories().get(Dimension.class);
56
		stateControl = MockControl.createNiceControl(PersistentState.class);
57
		state = (PersistentState) stateControl.getMock();
58
		dimension = new Dimension(320, 200);
59
	}
60

  
61
	/**
62
	 * Test method for
63
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory#createFromState(org.gvsig.tools.persistence.PersistentState, java.lang.Class)}
64
	 * .
65
	 */
66
	public void testCreateFromState() throws Exception {
67
		stateControl.expectAndReturn(state
68
				.getInt(DimensionPersistenceFactory.FIELD_WIDTH), dimension.width);			
69
		stateControl.expectAndReturn(state
70
				.getInt(DimensionPersistenceFactory.FIELD_HEIGHT), dimension.height);				
71
		stateControl.replay();
72

  
73
		Dimension newDimension = (Dimension) factory.createFromState(state);
74
		assertTrue(newDimension.equals(dimension));
75

  
76
		stateControl.verify();
77
	}
78

  
79
	/**
80
	 * Test method for
81
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.DimensionPersistenceFactory#saveToState(org.gvsig.tools.persistence.PersistentState, java.lang.Object)}
82
	 * .
83
	 */
84
	public void testSaveToState() throws Exception {
85
		state.set(DimensionPersistenceFactory.FIELD_WIDTH, dimension.width);
86
		state.set(DimensionPersistenceFactory.FIELD_HEIGHT, dimension.height);
87
				
88
		stateControl.replay();
89

  
90
		factory.saveToState(state, dimension);
91

  
92
		stateControl.verify();
93
	}
94

  
95
}
tags/v_2_0_0_Build_2043/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/tools/persistence/FontPersistenceFactoryTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.tools.persistence;
28

  
29
import java.awt.Font;
30

  
31
import org.easymock.MockControl;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34
import org.gvsig.tools.persistence.PersistenceManager;
35
import org.gvsig.tools.persistence.PersistentState;
36

  
37
/**
38
 * Unit tests for the class {@link FontPersistenceFactory}.
39
 * 
40
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
41
 */
42
public class FontPersistenceFactoryTest extends AbstractLibraryAutoInitTestCase {
43

  
44
	private FontPersistenceFactory factory;
45
	private MockControl stateControl;
46
	private PersistentState state;
47
	private Font font;
48

  
49
	protected void doSetUp() throws Exception {
50
		PersistenceManager persistenceManager = ToolsLocator
51
				.getPersistenceManager();
52
		factory = (FontPersistenceFactory) persistenceManager.getFactories()
53
				.get(Font.class);
54
		stateControl = MockControl.createNiceControl(PersistentState.class);
55
		state = (PersistentState) stateControl.getMock();
56
		font = new Font("Arial", Font.BOLD, 18);
57
	}
58

  
59
	/**
60
	 * Test method for
61
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory#createFromState(org.gvsig.tools.persistence.PersistentState, java.lang.Class)}
62
	 * .
63
	 */
64
	public void testCreateFromState() throws Exception {
65
		stateControl.expectAndReturn(state
66
				.getString(FontPersistenceFactory.FIELD_NAME), font.getName());
67
		stateControl.expectAndReturn(state
68
				.getInt(FontPersistenceFactory.FIELD_STYLE), font.getStyle());
69
		stateControl.expectAndReturn(state
70
				.getInt(FontPersistenceFactory.FIELD_SIZE), font.getSize());
71
		stateControl.replay();
72

  
73
		Font newFont = (Font) factory.createFromState(state);
74
		assertTrue(newFont.equals(font));
75

  
76
		stateControl.verify();
77
	}
78

  
79
	/**
80
	 * Test method for
81
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.FontPersistenceFactory#saveToState(org.gvsig.tools.persistence.PersistentState, java.lang.Object)}
82
	 * .
83
	 */
84
	public void testSaveToState() throws Exception {
85
		state.set(FontPersistenceFactory.FIELD_NAME, font.getName());
86
		state.set(FontPersistenceFactory.FIELD_STYLE, font.getStyle());
87
		state.set(FontPersistenceFactory.FIELD_SIZE, font.getSize());
88
		stateControl.replay();
89

  
90
		factory.saveToState(state, font);
91

  
92
		stateControl.verify();
93
	}
94

  
95
}
tags/v_2_0_0_Build_2043/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/tools/persistence/Rectangle2DPersistenceFactoryTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.tools.persistence;
28

  
29
import java.awt.geom.Rectangle2D;
30

  
31
import org.easymock.MockControl;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
34
import org.gvsig.tools.persistence.PersistenceManager;
35
import org.gvsig.tools.persistence.PersistentState;
36

  
37
/**
38
 * Unit tests for the class {@link Rectangle2DPersistenceFactory}.
39
 * 
40
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
41
 */
42
public class Rectangle2DPersistenceFactoryTest extends
43
		AbstractLibraryAutoInitTestCase {
44

  
45
	private Rectangle2DPersistenceFactory factory;
46
	private MockControl stateControl;
47
	private PersistentState state;
48
	private Rectangle2D rectangle;
49

  
50
	protected void doSetUp() throws Exception {
51
		PersistenceManager persistenceManager = ToolsLocator
52
				.getPersistenceManager();
53
		factory = (Rectangle2DPersistenceFactory) persistenceManager
54
				.getFactories().get(Rectangle2D.class);
55
		stateControl = MockControl.createNiceControl(PersistentState.class);
56
		state = (PersistentState) stateControl.getMock();
57
		double x = Math.random() * 1000d;
58
		double y = Math.random() * 1000d;
59
		rectangle = new Rectangle2D.Double(x, y, 320, 200);
60
	}
61

  
62
	/**
63
	 * Test method for
64
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.Rectangle2DPersistenceFactory#createFromState(PersistentState, Class)}
65
	 * .
66
	 */
67
	public void testCreateFromState() throws Exception {
68
		stateControl.expectAndReturn(state
69
				.getDouble(Rectangle2DPersistenceFactory.FIELD_X), rectangle
70
				.getX());
71
		stateControl.expectAndReturn(state
72
				.getDouble(Rectangle2DPersistenceFactory.FIELD_Y), rectangle
73
				.getY());
74
		stateControl.expectAndReturn(state
75
				.getDouble(Rectangle2DPersistenceFactory.FIELD_WIDTH),
76
				rectangle.getWidth());
77
		stateControl.expectAndReturn(state
78
				.getDouble(Rectangle2DPersistenceFactory.FIELD_HEIGHT),
79
				rectangle.getHeight());
80
		stateControl.replay();
81

  
82
		Rectangle2D newRectangle = (Rectangle2D) factory.createFromState(state);
83

  
84
		System.out.println("Orig x = " + rectangle.getX() + " - New x = "
85
				+ newRectangle.getX());
86
		assertEquals(rectangle.getX(), newRectangle.getX(), 0.0d);
87
		System.out.println("Orig y = " + rectangle.getY() + " - New y = "
88
				+ newRectangle.getY());
89
		assertEquals(rectangle.getY(), newRectangle.getY(), 0.0d);
90
		System.out.println("Orig width = " + rectangle.getWidth()
91
				+ " - New width = " + newRectangle.getWidth());
92
		assertEquals(rectangle.getWidth(), newRectangle.getWidth(), 0.0d);
93
		System.out.println("Orig height = " + rectangle.getHeight()
94
				+ " - New height = " + newRectangle.getHeight());
95
		assertEquals(rectangle.getHeight(), newRectangle.getHeight(), 0.0d);
96

  
97
		assertTrue(newRectangle.equals(rectangle));
98

  
99
		stateControl.verify();
100
	}
101

  
102
	/**
103
	 * Test method for
104
	 * {@link org.gvsig.fmap.mapcontext.tools.persistence.Rectangle2DPersistenceFactory#saveToState(org.gvsig.tools.persistence.PersistentState, java.lang.Object)}
105
	 * .
106
	 */
107
	public void testSaveToState() throws Exception {
108
		state.set(Rectangle2DPersistenceFactory.FIELD_X, rectangle.getX());
109
		state.set(Rectangle2DPersistenceFactory.FIELD_Y, rectangle.getY());
110
		state.set(Rectangle2DPersistenceFactory.FIELD_WIDTH, rectangle
111
				.getWidth());
112
		state.set(Rectangle2DPersistenceFactory.FIELD_HEIGHT, rectangle
113
				.getHeight());
114
		stateControl.replay();
115

  
116
		factory.saveToState(state, rectangle);
117

  
118
		stateControl.verify();
119
	}
120
}
tags/v_2_0_0_Build_2043/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/impl/DefaultMapContextManagerTest.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {DiSiD Technologies}  {{Task}}
26
 */
27
package org.gvsig.fmap.mapcontext.impl;
28

  
29
import java.awt.Graphics2D;
30
import java.awt.image.BufferedImage;
31
import java.util.Map;
32

  
33
import org.cresques.cts.ICoordTrans;
34

  
35
import org.gvsig.compat.print.PrintAttributes;
36
import org.gvsig.fmap.crs.CRSFactory;
37
import org.gvsig.fmap.dal.exception.ReadException;
38
import org.gvsig.fmap.dal.feature.Feature;
39
import org.gvsig.fmap.dal.feature.FeatureQuery;
40
import org.gvsig.fmap.dal.feature.FeatureStore;
41
import org.gvsig.fmap.mapcontext.MapContext;
42
import org.gvsig.fmap.mapcontext.MapContextDrawer;
43
import org.gvsig.fmap.mapcontext.MapContextException;
44
import org.gvsig.fmap.mapcontext.MapContextRuntimeException;
45
import org.gvsig.fmap.mapcontext.ViewPort;
46
import org.gvsig.fmap.mapcontext.layers.FLayers;
47
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
48
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
49
import org.gvsig.fmap.mapcontext.rendering.legend.LegendException;
50
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendReader;
51
import org.gvsig.fmap.mapcontext.rendering.legend.driver.ILegendWriter;
52
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener;
53
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
54
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
55
import org.gvsig.tools.evaluator.Evaluator;
56
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
57
import org.gvsig.tools.observer.Observer;
58
import org.gvsig.tools.persistence.PersistentState;
59
import org.gvsig.tools.persistence.exception.PersistenceException;
60
import org.gvsig.tools.task.Cancellable;
61

  
62
/**
63
 * @author <a href="mailto:cordinyana@gvsig.org">C?sar Ordi?ana</a>
64
 */
65
public class DefaultMapContextManagerTest extends
66
AbstractLibraryAutoInitTestCase {
67

  
68
    private DefaultMapContextManager manager;
69

  
70
    protected void doSetUp() throws Exception {
71
        manager = new DefaultMapContextManager();
72

  
73
        manager.registerLegend("DummyLegend", DummyVectorLegend.class);
74
        manager.setDefaultVectorLegend("DummyLegend");
75
        manager.registerLegendReader("Dummy", DummyLegendReader.class);
76
        manager.registerLegendWriter("DummyLegend", "Dummy", DummyLegendWriter.class);
77
    }
78

  
79
    protected void tearDown() throws Exception {
80
        super.tearDown();
81
    }
82

  
83
    /**
84
     * Test method for
85
     * {@link org.gvsig.fmap.mapcontext.impl.DefaultMapContextManager#createDefaultMapContextDrawerInstance()}
86
     * .
87
     */
88
    public void testGetDefaultMapContextDrawerInstance() throws Exception {
89

  
90
        manager.setDefaultMapContextDrawer(DummyMapContextDrawer.class);
91

  
92
        MapContextDrawer drawer = manager
93
        .createDefaultMapContextDrawerInstance();
94

  
95
        assertNotNull("The created MapContextDrawer instance can't be null",
96
            drawer);
97
        assertTrue(
98
            "The created MapContextDrawer is not instance of the registered class"
99
            + DummyMapContextDrawer.class,
100
            drawer instanceof DummyMapContextDrawer);
101
    }
102

  
103
    /**
104
     * Test method for
105
     * {@link org.gvsig.fmap.mapcontext.impl.DefaultMapContextManager#setDefaultMapContextDrawer(java.lang.Class)}
106
     * .
107
     */
108
    public void testSetDefaultMapContextDrawer() throws Exception {
109

  
110
        // First, try to register an invalid class
111
        try {
112
            manager.setDefaultMapContextDrawer(Object.class);
113
            fail("Error, a class that does not implement the MapContextDrawer "
114
                + "interface has been accepted");
115
        } catch (MapContextRuntimeException e) {
116
            // OK
117
        }
118

  
119
        // Next, try to register a valid class
120
        manager.setDefaultMapContextDrawer(DummyMapContextDrawer.class);
121
    }
122

  
123
    public void testCreateGraphicsLayer() throws Exception {
124
        assertNotNull(manager.createGraphicsLayer(CRSFactory.getCRS("EPSG:23030")));
125
    }
126

  
127
    public void testCreateDefaultVectorLegend() throws Exception {
128

  
129
        IVectorLegend legend = manager.createDefaultVectorLegend(1);
130
        assertNotNull(legend);
131
        assertTrue(legend instanceof DummyVectorLegend);
132
    }
133

  
134
    public void testRegisterCreateLegend() throws Exception {
135

  
136
        manager.registerLegend("DummyLegend", DummyVectorLegend.class);
137

  
138
        ILegend legend = manager.createLegend("DummyLegend");
139
        assertNotNull(legend);
140
        assertTrue(legend instanceof DummyVectorLegend);
141

  
142
        assertNull(manager.createLegend("NONE"));
143
    }
144

  
145
    public void testRegisterCreateLegendReader() throws Exception {
146

  
147
        manager.registerLegendReader("Dummy", DummyLegendReader.class);
148

  
149
        ILegendReader legendReader = manager.createLegendReader("Dummy");
150
        assertNotNull(legendReader);
151
        assertTrue(legendReader instanceof DummyLegendReader);
152

  
153
        assertNull(manager.createLegendReader("NONE"));
154
    }
155

  
156
    public void testRegisterCreateLegendWriter() throws Exception {
157

  
158
        manager.registerLegend("DummyLegend", DummyVectorLegend.class);
159

  
160
        manager.registerLegendWriter("DummyLegend", "Dummy",
161
            DummyLegendWriter.class);
162

  
163
        // Test the registered writer is created
164
        ILegendWriter legendWriter = manager.createLegendWriter("DummyLegend",
165
        "Dummy");
166
        assertNotNull(legendWriter);
167
        assertTrue(legendWriter instanceof DummyLegendWriter);
168

  
169
        // Test non registered cases
170
        assertNull(manager.createLegendWriter("NONE", "Dummy"));
171
        assertNull(manager.createLegendWriter("DummyLegend", "NONE"));
172
        assertNull(manager.createLegendWriter("NONE", "NONE"));
173
    }
174

  
175
    public static class DummyMapContextDrawer implements MapContextDrawer {
176

  
177
        public void dispose() {
178
        }
179

  
180
        public void draw(FLayers root, BufferedImage image, Graphics2D g,
181
            Cancellable cancel, double scale) throws ReadException {
182
        }
183

  
184
        public void print(FLayers root, Graphics2D g, Cancellable cancel,
185
            double scale, PrintAttributes properties) throws ReadException {
186
        }
187

  
188
        public void setMapContext(MapContext mapContext) {
189
        }
190

  
191
        public void setViewPort(ViewPort viewPort) {
192
        }
193

  
194
    }
195

  
196
    public static class DummyLegendReader implements ILegendReader {
197

  
198
    }
199

  
200
    public static class DummyLegendWriter implements ILegendWriter {
201

  
202
    }
203

  
204
    public static class DummyVectorLegend implements IVectorLegend {
205

  
206
        public void draw(BufferedImage image, Graphics2D graphics2d,
207
            ViewPort viewPort, Cancellable cancel, double scale,
208
            Map queryParameters, ICoordTrans coordTrans,
209
            FeatureStore featureStore, FeatureQuery featureQuery) throws LegendException {
210
            // Empty method
211
        }
212

  
213
        public void draw(BufferedImage image, Graphics2D graphics2d,
214
            ViewPort viewPort, Cancellable cancel, double scale,
215
            Map queryParameters, ICoordTrans coordTrans,
216
            FeatureStore featureStore) throws LegendException {
217
            // Empty method
218
        }
219

  
220
        public int getShapeType() {
221
            // Empty method
222
            return 0;
223
        }
224

  
225
        public ISymbol getSymbolByFeature(Feature feat)
226
        throws MapContextException {
227
            // Empty method
228
            return null;
229
        }
230

  
231
        public boolean isSuitableForShapeType(int shapeType) {
232
            // Empty method
233
            return false;
234
        }
235

  
236
        public boolean isUseDefaultSymbol() {
237
            // Empty method
238
            return false;
239
        }
240

  
241
        public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
242
            double scale, Map queryParameters, ICoordTrans coordTrans,
243
            FeatureStore featureStore, PrintAttributes properties)
244
        throws LegendException {
245
            // Empty method
246
        }
247

  
248
        public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
249
            double scale, Map queryParameters, ICoordTrans coordTrans,
250
            FeatureStore featureStore, FeatureQuery featureQuery, PrintAttributes properties)
251
        throws LegendException {
252
            // Empty method
253
        }
254

  
255
        public void setDefaultSymbol(ISymbol s) {
256
            // Empty method
257
        }
258

  
259
        public void setShapeType(int shapeType) {
260
            // Empty method
261
        }
262

  
263
        public void useDefaultSymbol(boolean b) {
264
            // Empty method
265
        }
266

  
267
        public void addLegendListener(LegendContentsChangedListener listener) {
268
            // Empty method
269
        }
270

  
271
        public ILegend cloneLegend() {
272
            // Empty method
273
            return null;
274
        }
275

  
276
        public Object clone() throws CloneNotSupportedException {
277
            // TODO Auto-generated method stub
278
            return super.clone();
279
        }
280

  
281
        public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
282
            // Empty method
283
        }
284

  
285
        public ISymbol getDefaultSymbol() {
286
            // Empty method
287
            return null;
288
        }
289

  
290
        public LegendContentsChangedListener[] getListeners() {
291
            // Empty method
292
            return null;
293
        }
294

  
295
        public void removeLegendListener(LegendContentsChangedListener listener) {
296
            // Empty method
297
        }
298

  
299
        public void loadFromState(PersistentState state)
300
        throws PersistenceException {
301
            // Empty method
302
        }
303

  
304
        public void saveToState(PersistentState state)
305
        throws PersistenceException {
306
            // Empty method
307
        }
308

  
309
        public void addDrawingObserver(Observer observer) {
310
            // Empty method
311
        }
312

  
313
        public void deleteDrawingObserver(Observer observer) {
314
            // Empty method
315
        }
316

  
317
        public void deleteDrawingObservers() {
318
            // Empty method
319
        }
320
    }
321
}
tags/v_2_0_0_Build_2043/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/persistence/MapContextPersistenceTest.java
1
package org.gvsig.fmap.mapcontext.persistence;
2

  
3
import java.awt.Color;
4
import java.awt.Dimension;
5
import java.awt.geom.Rectangle2D;
6
import java.io.File;
7
import java.io.FileInputStream;
8
import java.io.FileOutputStream;
9

  
10
import org.gvsig.fmap.crs.CRSFactory;
11
import org.gvsig.fmap.dal.feature.FeatureStore;
12
import org.gvsig.fmap.geom.Geometry.TYPES;
13
import org.gvsig.fmap.geom.primitive.Envelope;
14
import org.gvsig.fmap.geom.primitive.impl.Envelope2D;
15
import org.gvsig.fmap.mapcontext.MapContext;
16
import org.gvsig.fmap.mapcontext.MapContextLocator;
17
import org.gvsig.fmap.mapcontext.ViewPort;
18
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException;
19
import org.gvsig.fmap.mapcontext.layers.FLayer;
20
import org.gvsig.fmap.mapcontext.layers.FLayers;
21
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
22
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
23
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend;
24
import org.gvsig.fmap.mapcontext.rendering.symbol.DummyVectorLegend;
25
import org.gvsig.tools.ToolsLocator;
26
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
27
import org.gvsig.tools.persistence.Persistent;
28
import org.gvsig.tools.persistence.PersistentState;
29
import org.slf4j.Logger;
30
import org.slf4j.LoggerFactory;
31

  
32
public class MapContextPersistenceTest extends AbstractLibraryAutoInitTestCase {
33

  
34
	final static private Logger logger =
35
			LoggerFactory.getLogger(MapContextPersistenceTest.class);
36

  
37
	protected void doSetUp() throws Exception {
38
		DummyVectorLegend.registerPersistent();
39
		DummyDBFeatureStore.registerPersistent();
40
		DummyFileFeatureStore.registerPersistent();
41

  
42
		MapContextLocator.getMapContextManager().registerLegend("DummyLegend",
43
				DummyVectorLegend.class);
44
		MapContextLocator.getMapContextManager().setDefaultVectorLegend(
45
				"DummyLegend");
46
	}
47
	
48
	private File getTempFile() throws Exception {
49

  
50
		File tempFile = File.createTempFile("persisted_mapcontext", ".xml");
51
		if (tempFile.exists())
52
			tempFile.delete();
53
		tempFile.createNewFile();
54
		
55
		System.out.println("TEMP FILE: " + tempFile.getAbsolutePath());
56
		return tempFile;
57
	}
58
	
59
	public void testMapContext() throws Exception {
60
		ViewPort vp = getViewPort();
61
		logger.debug("Creating mapcontext...");
62
		MapContext mc = new MapContext(vp);
63
		addDummyLayers(mc);
64
		doTestPersist(mc);
65
	}
66

  
67
	public void noTestFLyrs() throws Exception {
68
		
69
		int lyr_count = 3;
70
		// testPersist(mc);
71
		FLyrVect[] lyr = new FLyrVect[lyr_count];
72
		FeatureStore[] fs = new FeatureStore[lyr_count];
73
		FLayers lyrs = new FLayers();
74
		
75
		for (int i=0; i<lyr_count; i++) {
76
			fs[i] = new DummyFileFeatureStore("" + System.currentTimeMillis());
77
			lyr[i] = createLayer(fs[i]);
78
			lyr[i].setName("Layer " + (i+System.currentTimeMillis()));
79
			lyr[i].setIsLabeled(false);
80
			try { lyr[i].setLegend(new DummyVectorLegend(TYPES.SOLID)); } catch (LegendLayerException e) {
81
				assertTrue("Error while creating legend: " + e.getMessage(), false);
82
			}
83
			lyrs.addLayer(lyr[i]);
84
			lyr[i].dispose();
85
		}
86
		
87
		for (int i=0; i<lyr_count; i++) {
88
			fs[i] = new DummyDBFeatureStore("" + System.currentTimeMillis());
89
			lyr[i] = createLayer(fs[i]);
90
			lyr[i].setName("Layer " + (10000 + i + System.currentTimeMillis()));
91
			lyr[i].setIsLabeled(false);
92
			try { lyr[i].setLegend(new DummyVectorLegend(TYPES.SOLID)); } catch (LegendLayerException e) {
93
				assertTrue("Error while creating legend: " + e.getMessage(), false);
94
			}
95
			lyrs.addLayer(lyr[i]);
96
			lyr[i].dispose();
97
		}
98
		
99
		doTestPersist(lyrs);
100
	}
101
	
102
	
103
	
104
	private ViewPort getViewPort() {
105
		
106
		ViewPort vp = new ViewPort(CRSFactory.getCRS("EPSG:4326"));
107
		vp.setImageSize(new Dimension(640, 480));
108
		Envelope env = new Envelope2D(0, 0, 1000000, 1000000);
109
		vp.setEnvelope(env);
110
		env = new Envelope2D(200000, 200000, 500000, 500000);
111
		vp.setEnvelope(env);
112
		env = new Envelope2D(300000, 300000, 300000, 300000);
113
		vp.setEnvelope(env);
114
		env = new Envelope2D(400000, 400000, 200000, 200000);
115
		vp.setEnvelope(env);
116
		env = new Envelope2D(440000, 440000, 100000, 100000);
117
		vp.setEnvelope(env);
118
		env = new Envelope2D(480000, 480000, 30000, 30000);
119
		vp.setEnvelope(env);
120
		vp.setBackColor(Color.YELLOW);
121
		vp.setClipRect(new Rectangle2D.Double(0, 0, 10, 10));
122
		return vp;
123
	}
124

  
125
	private void addDummyLayers(MapContext mcon) throws Exception {
126
		
127
		FLayers resp = new FLayers();
128
		resp.setMapContext(mcon);
129
		resp.setName("root layer");
130
		
131
		FLayers aux = new FLayers();
132
		aux.setMapContext(mcon);
133
		aux.setName("Group");
134
		
135
		FLyrVect lyr = null;
136
		IVectorLegend lgn = null;
137
		FeatureStore fs = null;
138
		
139
		logger.debug("Adding dummy layers...");
140
			
141
		fs = new DummyFileFeatureStore("1");
142
		lyr = createLayer(fs);
143
		lyr.setName("Layer 1");
144
		try { lyr.setLegend(new DummyVectorLegend(TYPES.SOLID)); } catch (LegendLayerException e) { }
145
		
146
		aux.addLayer(lyr);
147
		lyr.dispose();
148
		
149
		fs = new DummyDBFeatureStore("A");
150
		lyr = createLayer(fs);
151
		lyr.setName("Layer A");
152
		try { lyr.setLegend(new DummyVectorLegend(TYPES.SOLID)); } catch (LegendLayerException e) { }
153

  
154
		aux.addLayer(lyr);
155
		lyr.dispose();
156
		
157
		fs = new DummyFileFeatureStore("2");
158
		lyr = createLayer(fs);
159
		lyr.setName("Layer 2");
160
		try { lyr.setLegend(new DummyVectorLegend(TYPES.SOLID)); } catch (LegendLayerException e) { }
161

  
162
		aux.addLayer(lyr);
163
		lyr.dispose();
164
		
165
		fs = new DummyDBFeatureStore("B");
166
		lyr = createLayer(fs);
167
		lyr.setName("Layer 1");
168
		try { lyr.setLegend(new DummyVectorLegend(TYPES.SOLID)); } catch (LegendLayerException e) { }
169
		
170
		resp.addLayer(lyr);
171
		resp.addLayer(aux);
172
		lyr.dispose();
173
		aux.dispose();
174
		
175
		mcon.getLayers().addLayer(resp);
176
		resp.dispose();
177
	}
178

  
179
	private FLyrVect createLayer(FeatureStore fs) throws Exception {
180
		
181
		FLyrVect resp = new FLyrVect();
182
		resp.setDataStore(fs);
183
		resp.wakeUp();
184
		resp.load();
185
		return resp;
186
	}
187

  
188
	private void doTestPersist(Persistent p) throws Exception {
189
		
190
		System.out.println("Starting persistence test for class: " + p.getClass().getName());
191

  
192
		File perfile = getTempFile();
193
		FileOutputStream fos = new FileOutputStream(perfile);
194
		System.out.println("Getting state for class: " + p.getClass().getName());
195
		PersistentState pst = ToolsLocator.getPersistenceManager().getState(p);
196
		System.out.println("Saving state...");
197

  
198
		System.out.println("Saving state...");
199
		ToolsLocator.getPersistenceManager().saveState(pst, fos);
200
		System.out.println("Saving state... done.");
201

  
202
		fos.close();
203

  
204
		// ==============================================
205
		// ==============================================
206
		System.out.println("Is now persisted: " + p.getClass().getName());
207
		// ==============================================
208

  
209
		// if (true) return;
210

  
211
		System.out.println("Opening persistence file...");
212
		FileInputStream fis = new FileInputStream(perfile);
213

  
214
		System.out.println("Loading state from file...");
215
		pst = ToolsLocator.getPersistenceManager().loadState(fis);
216

  
217
		System.out.println("Instantiating " + p.getClass().getName()
218
				+ " from state, pst = " + pst);
219
		Object p2 = ToolsLocator.getPersistenceManager().create(pst);
220

  
221
		System.out.println("Comparing original and current...");
222
		comparePersistent(p, p2);
223

  
224
		System.out.println("Successful mapcontext persistence test!");
225
		
226
	}
227

  
228
	
229
	// FeatureStore, ILegend, ViewPort
230
	private void comparePersistent(Persistent p, Object p2) {
231
		
232
		if (p2.getClass().getName().compareTo(p.getClass().getName()) == 0) {
233
			
234
			if (p instanceof MapContext) {
235
				compareMapContexts((MapContext) p, (MapContext) p2);
236
			} else {
237
				if (p instanceof FLayer) {
238
					compareLayers((FLayer) p, (FLayer) p2);
239
				} else {
240
					if (p instanceof FeatureStore) {
241
						compareStore((FeatureStore) p, (FeatureStore) p2);
242
					} else {
243
						if (p instanceof ILegend) {
244
							compareLegend((ILegend) p, (ILegend) p2);
245
						} else {
246
							if (p instanceof ViewPort) {
247
								compareViewPorts((ViewPort) p, (ViewPort) p2);
248
							} else {
249
								fail("Did not compare: " + p.getClass().getName());
250
							}
251
						}
252
					}
253
				}
254
			}
255
		} else {
256
			fail("Comparing different classes (?)");
257
		}
258
		
259
	}
260

  
261
	private void compareMapContexts(MapContext m1, MapContext m2) {
262
		
263
		logger.debug("Getting viewports to compare...");
264
		ViewPort vp1 = m1.getViewPort();
265
		ViewPort vp2 = m2.getViewPort();
266
		
267
		compareViewPorts(vp1, vp2);
268

  
269
		logger.debug("Getting root flayers to compare...");
270
		FLayers lyr1 = m1.getLayers();
271
		FLayers lyr2 = m2.getLayers();
272
		compareLayers(lyr1, lyr2);
273
	}
274

  
275
	private void compareLayers(FLayer l1, FLayer l2) {
276
		
277
		logger.debug("Comparing layers...");
278

  
279
		assertTrue("Layers of diff type!", l1.getClass().getName().compareTo(l2.getClass().getName()) == 0);
280
		if (l1 instanceof FLayers) {
281
			
282
			logger.debug("(type FLayers)...");
283
			FLayers ls1 = (FLayers) l1;
284
			FLayers ls2 = (FLayers) l2;
285
			assertEquals(ls1.getLayersCount(), ls2.getLayersCount());
286
			int sz = ls2.getLayersCount();
287
			for (int i=0; i<sz; i++) {
288
				compareLayers(ls1.getLayer(i), ls2.getLayer(i));
289
			}
290
			
291
		} else {
292
			if (l1 instanceof FLyrVect) {
293
				
294
				logger.debug("(type FLyrVect)...");
295
				FLyrVect ls1 = (FLyrVect) l1;
296
				FLyrVect ls2 = (FLyrVect) l2;
297
				compareVectLayers(ls1, ls2);
298
				
299
			} else {
300
				
301
			}
302
		}
303

  
304
	}
305

  
306
	private void compareVectLayers(FLyrVect l1, FLyrVect l2) {
307
		compareLegend(l1.getLegend(), l2.getLegend());
308
		compareStore(l1.getFeatureStore(), l2.getFeatureStore());
309
	}
310

  
311
	private void compareStore(FeatureStore fs1,
312
			FeatureStore fs2) {
313
		
314
		logger.debug("Comparing stores...");
315
		assertTrue("Diff stores!", fs1.getName().compareTo(fs2.getName()) == 0);
316
	}
317

  
318
	private void compareLegend(ILegend l1, ILegend l2) {
319

  
320
		logger.debug("Comparing legends...");
321
		IVectorLegend vl1 = (IVectorLegend) l1;
322
		IVectorLegend vl2 = (IVectorLegend) l2;
323
		assertTrue("Diff legends!", vl1.getShapeType() == vl2.getShapeType());
324
		
325
	}
326

  
327
	private void compareViewPorts(ViewPort vp1, ViewPort vp2) {
328

  
329

  
330
		logger.debug("Comparing viewports...");
331
		
332
		assertEquals(
333
				vp1.getAdjustedEnvelope().getMinimum(0),
334
				vp2.getAdjustedEnvelope().getMinimum(0),
335
				0.00000000000001);
336
		assertEquals(
337
				vp1.getAdjustedEnvelope().getMinimum(1),
338
				vp2.getAdjustedEnvelope().getMinimum(1),
339
				0.00000000000001);
340
		assertEquals(
341
				vp1.getAdjustedEnvelope().getMaximum(0),
342
				vp2.getAdjustedEnvelope().getMaximum(0),
343
				0.00000000000001);
344
		assertEquals(
345
				vp1.getAdjustedEnvelope().getMaximum(1),
346
				vp2.getAdjustedEnvelope().getMaximum(1),
347
				0.00000000000001);
348
	}
349
	
350
}
0 351

  
tags/v_2_0_0_Build_2043/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/persistence/DummyDBFeatureStore.java
1
package org.gvsig.fmap.mapcontext.persistence;
2

  
3
import java.util.Collection;
4
import java.util.Iterator;
5
import java.util.List;
6
import java.util.Set;
7

  
8
import org.cresques.cts.IProjection;
9
import org.gvsig.fmap.dal.DataQuery;
10
import org.gvsig.fmap.dal.DataServerExplorer;
11
import org.gvsig.fmap.dal.DataSet;
12
import org.gvsig.fmap.dal.DataStoreParameters;
13
import org.gvsig.fmap.dal.exception.DataException;
14
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
15
import org.gvsig.fmap.dal.feature.EditableFeature;
16
import org.gvsig.fmap.dal.feature.EditableFeatureType;
17
import org.gvsig.fmap.dal.feature.Feature;
18
import org.gvsig.fmap.dal.feature.FeatureCache;
19
import org.gvsig.fmap.dal.feature.FeatureIndex;
20
import org.gvsig.fmap.dal.feature.FeatureIndexes;
21
import org.gvsig.fmap.dal.feature.FeatureLocks;
22
import org.gvsig.fmap.dal.feature.FeatureQuery;
23
import org.gvsig.fmap.dal.feature.FeatureReference;
24
import org.gvsig.fmap.dal.feature.FeatureSelection;
25
import org.gvsig.fmap.dal.feature.FeatureSet;
26
import org.gvsig.fmap.dal.feature.FeatureStore;
27
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms;
28
import org.gvsig.fmap.dal.feature.FeatureType;
29
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters;
30
import org.gvsig.fmap.dal.feature.exception.NeedEditingModeException;
31
import org.gvsig.fmap.geom.primitive.Envelope;
32
import org.gvsig.timesupport.Interval;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.dynobject.DynClass;
35
import org.gvsig.tools.dynobject.DynObject;
36
import org.gvsig.tools.dynobject.DynStruct;
37
import org.gvsig.tools.dynobject.exception.DynFieldNotFoundException;
38
import org.gvsig.tools.dynobject.exception.DynMethodException;
39
import org.gvsig.tools.exception.BaseException;
40
import org.gvsig.tools.observer.Observer;
41
import org.gvsig.tools.persistence.PersistenceManager;
42
import org.gvsig.tools.persistence.PersistentState;
43
import org.gvsig.tools.persistence.exception.PersistenceException;
44
import org.gvsig.tools.undo.RedoException;
45
import org.gvsig.tools.undo.UndoException;
46
import org.gvsig.tools.visitor.Visitor;
47

  
48
public class DummyDBFeatureStore implements FeatureStore {
49

  
50
	private String name = "[empty]";
51

  
52
	public DummyDBFeatureStore() {
53
		
54
	}
55
	
56
	public DummyDBFeatureStore(String id) {
57
		name = "[DATABASE FEATURE STORE - " + id + "]";
58
	}
59

  
60
	public boolean allowWrite() {
61
		// TODO Auto-generated method stub
62
		return false;
63
	}
64

  
65
	public void beginEditingGroup(String description)
66
			throws NeedEditingModeException {
67
		// TODO Auto-generated method stub
68

  
69
	}
70

  
71
	public boolean canWriteGeometry(int gvSIGgeometryType) throws DataException {
72
		// TODO Auto-generated method stub
73
		return false;
74
	}
75

  
76
	public void cancelEditing() throws DataException {
77
		// TODO Auto-generated method stub
78

  
79
	}
80

  
81
	public FeatureQuery createFeatureQuery() {
82
		// TODO Auto-generated method stub
83
		return null;
84
	}
85

  
86
	public FeatureSelection createFeatureSelection() throws DataException {
87
		// TODO Auto-generated method stub
88
		return null;
89
	}
90

  
91
	public FeatureIndex createIndex(FeatureType featureType,
92
			String attributeName, String indexName) throws DataException {
93
		// TODO Auto-generated method stub
94
		return null;
95
	}
96

  
97
	public FeatureIndex createIndex(FeatureType featureType,
98
			String attributeName, String indexName, Observer observer)
99
			throws DataException {
100
		// TODO Auto-generated method stub
101
		return null;
102
	}
103

  
104
	public EditableFeature createNewFeature() throws DataException {
105
		// TODO Auto-generated method stub
106
		return null;
107
	}
108

  
109
	public EditableFeature createNewFeature(FeatureType type,
110
			Feature defaultValues) throws DataException {
111
		// TODO Auto-generated method stub
112
		return null;
113
	}
114

  
115
	public EditableFeature createNewFeature(FeatureType type,
116
			boolean defaultValues) throws DataException {
117
		// TODO Auto-generated method stub
118
		return null;
119
	}
120

  
121
	public EditableFeature createNewFeature(boolean defaultValues)
122
			throws DataException {
123
		// TODO Auto-generated method stub
124
		return null;
125
	}
126

  
127
	public void delete(Feature feature) throws DataException {
128
		// TODO Auto-generated method stub
129

  
130
	}
131

  
132
	public void edit() throws DataException {
133
		// TODO Auto-generated method stub
134

  
135
	}
136

  
137
	public void edit(int mode) throws DataException {
138
		// TODO Auto-generated method stub
139

  
140
	}
141

  
142
	public void endEditingGroup() throws NeedEditingModeException {
143
		// TODO Auto-generated method stub
144

  
145
	}
146

  
147
	public void export(DataServerExplorer explorer,
148
			String providerName,
149
			NewFeatureStoreParameters params) throws DataException {
150
		// TODO Auto-generated method stub
151

  
152
	}
153

  
154
	public void finishEditing() throws DataException {
155
		// TODO Auto-generated method stub
156

  
157
	}
158

  
159
	public FeatureType getDefaultFeatureType() throws DataException {
160
		return new DummyFileFeatureStore.DummyFeatureType();
161
	}
162

  
163
	public Envelope getEnvelope() throws DataException {
164
		// TODO Auto-generated method stub
165
		return null;
166
	}
167

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

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

  
180
	public long getFeatureCount() throws DataException {
181
		// TODO Auto-generated method stub
182
		return 0;
183
	}
184

  
185
	public FeatureSelection getFeatureSelection() throws DataException {
186
		// TODO Auto-generated method stub
187
		return null;
188
	}
189

  
190
	public FeatureSet getFeatureSet() throws DataException {
191
		// TODO Auto-generated method stub
192
		return null;
193
	}
194

  
195
	public FeatureSet getFeatureSet(FeatureQuery featureQuery)
196
			throws DataException {
197
		// TODO Auto-generated method stub
198
		return null;
199
	}
200

  
201
	public void getFeatureSet(FeatureQuery featureQuery, Observer observer)
202
			throws DataException {
203
		// TODO Auto-generated method stub
204

  
205
	}
206

  
207
	public void getFeatureSet(Observer observer) throws DataException {
208
		// TODO Auto-generated method stub
209

  
210
	}
211

  
212
	public FeatureType getFeatureType(String featureTypeId)
213
			throws DataException {
214
		// TODO Auto-generated method stub
215
		return null;
216
	}
217

  
218
	public List getFeatureTypes() throws DataException {
219
		// TODO Auto-generated method stub
220
		return null;
221
	}
222

  
223
	public FeatureIndexes getIndexes() {
224
		// TODO Auto-generated method stub
225
		return null;
226
	}
227

  
228
	public FeatureLocks getLocks() throws DataException {
229
		// TODO Auto-generated method stub
230
		return null;
231
	}
232

  
233
	public DataStoreParameters getParameters() {
234
		// TODO Auto-generated method stub
235
		return null;
236
	}
237

  
238
	public IProjection getSRSDefaultGeometry() throws DataException {
239
		// TODO Auto-generated method stub
240
		return null;
241
	}
242

  
243
	public FeatureStoreTransforms getTransforms() {
244
		// TODO Auto-generated method stub
245
		return null;
246
	}
247

  
248
	public void insert(EditableFeature feature) throws DataException {
249
		// TODO Auto-generated method stub
250

  
251
	}
252

  
253
	public boolean isAppendModeSupported() {
254
		// TODO Auto-generated method stub
255
		return false;
256
	}
257

  
258
	public boolean isAppending() {
259
		// TODO Auto-generated method stub
260
		return false;
261
	}
262

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

  
268
	public boolean isLocksSupported() {
269
		// TODO Auto-generated method stub
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff