Revision 9312

View differences:

org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4

  
5
	<modelVersion>4.0.0</modelVersion>
6
	<artifactId>org.gvsig.raster.fmap</artifactId>
7
	<packaging>jar</packaging>
8
	<name>org.gvsig.raster.fmap</name>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.raster</artifactId>
12
		<version>2.2.90</version>
13
	</parent>	
14
	<dependencies>
15
        <dependency>
16
            <groupId>org.gvsig</groupId>
17
            <artifactId>org.gvsig.raster.lib.api</artifactId>
18
            <scope>compile</scope>
19
        </dependency>
20
        <dependency>
21
            <groupId>org.gvsig</groupId>
22
            <artifactId>org.gvsig.projection.api</artifactId>
23
            <scope>compile</scope>
24
        </dependency>
25
        <dependency>
26
            <groupId>org.gvsig</groupId>
27
            <artifactId>org.gvsig.projection.cresques.impl</artifactId>
28
            <scope>runtime</scope>
29
        </dependency>
30
         <dependency>
31
            <groupId>org.gvsig</groupId>
32
            <artifactId>org.gvsig.compat.api</artifactId>
33
            <scope>compile</scope>
34
        </dependency>
35
        <dependency>
36
            <groupId>org.gvsig</groupId>
37
            <artifactId>org.gvsig.compat.se</artifactId>
38
            <scope>compile</scope>
39
        </dependency>
40
        <dependency>
41
            <groupId>org.gvsig</groupId>
42
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
43
            <scope>compile</scope>
44
        </dependency>
45
        <dependency>
46
            <groupId>org.gvsig</groupId>
47
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
48
            <scope>compile</scope>
49
        </dependency>
50
        <dependency>
51
            <groupId>org.gvsig</groupId>
52
            <artifactId>org.gvsig.fmap.dal.file.lib</artifactId>
53
            <scope>compile</scope>
54
        </dependency>
55
        <dependency>
56
            <groupId>org.gvsig</groupId>
57
            <artifactId>org.gvsig.fmap.dal.spi</artifactId>
58
            <scope>compile</scope>
59
        </dependency>
60
        <dependency>
61
            <groupId>org.gvsig</groupId>
62
            <artifactId>org.gvsig.fmap.geometry.api</artifactId>
63
            <scope>compile</scope>
64
        </dependency>
65
        <!--
66
        <dependency>
67
            <groupId>org.gvsig</groupId>
68
            <artifactId>org.gvsig.fmap.geometry.generalpath</artifactId>
69
            <scope>runtime</scope>
70
        </dependency>
71
        <dependency>
72
            <groupId>org.gvsig</groupId>
73
            <artifactId>org.gvsig.fmap.geometry.operation</artifactId>
74
            <scope>runtime</scope>
75
        </dependency>
76
        -->
77
        <dependency>
78
            <groupId>org.gvsig</groupId>
79
            <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
80
            <scope>compile</scope>
81
        </dependency>
82
        <dependency>
83
            <groupId>org.gvsig</groupId>
84
            <artifactId>org.gvsig.fmap.mapcontext.impl</artifactId>
85
            <scope>runtime</scope>
86
        </dependency>
87
        <dependency>
88
            <groupId>org.gvsig</groupId>
89
            <artifactId>org.gvsig.fmap.dal.file.shp</artifactId>
90
            <scope>compile</scope>
91
        </dependency>
92
        <dependency>
93
            <groupId>org.gvsig</groupId>
94
            <artifactId>org.gvsig.fmap.dal.file.dbf</artifactId>
95
            <scope>compile</scope>
96
        </dependency>
97
        <dependency>
98
            <groupId>org.gvsig</groupId>
99
            <artifactId>org.gvsig.utils</artifactId>
100
            <scope>compile</scope>
101
        </dependency>
102
        <dependency>
103
            <groupId>org.gvsig</groupId>
104
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
105
            <scope>compile</scope>
106
        </dependency>
107
        <dependency>
108
            <groupId>org.gvsig</groupId>
109
            <artifactId>org.gvsig.symbology.lib.api</artifactId>
110
            <scope>compile</scope>
111
        </dependency>
112
        <!--<dependency>
113
            <groupId>org.gvsig</groupId>
114
            <artifactId>org.gvsig.symbology.lib.impl</artifactId>
115
            <scope>compile</scope>
116
        </dependency>-->
117
        <dependency>
118
            <groupId>org.gvsig</groupId>
119
            <artifactId>org.gvsig.fmap.control</artifactId>
120
            <scope>compile</scope>
121
        </dependency>
122
        <dependency>
123
            <groupId>org.gvsig</groupId>
124
            <artifactId>org.gvsig.ui</artifactId>
125
            <scope>compile</scope>
126
        </dependency>
127
		 <dependency>
128
            <groupId>org.gvsig</groupId>
129
            <artifactId>org.gvsig.i18n</artifactId>
130
            <scope>compile</scope>
131
        </dependency>
132
	</dependencies>
133
</project>
0 134

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.raster.fmap.FmapRasterLibrary
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/FmapRasterLibrary.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
package org.gvsig.raster.fmap;
24

  
25
import org.gvsig.fmap.dal.DALLibrary;
26
import org.gvsig.fmap.dal.coverage.RasterLibrary;
27
import org.gvsig.fmap.dal.raster.CoverageStore;
28
import org.gvsig.fmap.mapcontext.MapContextLibrary;
29
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
30
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster;
31
import org.gvsig.raster.fmap.legend.ColorTableLegend;
32
import org.gvsig.tools.library.AbstractLibrary;
33
import org.gvsig.tools.library.Library;
34
import org.gvsig.tools.library.LibraryException;
35

  
36
/**
37
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
38
 */
39
public class FmapRasterLibrary extends AbstractLibrary {
40

  
41
	@SuppressWarnings("deprecation")
42
	public FmapRasterLibrary() {
43
		super(FmapRasterLibrary.class, Library.TYPE.IMPL);
44
		require(DALLibrary.class);
45
		require(MapContextLibrary.class);
46
		require(RasterLibrary.class);
47
	}
48
	
49
	@Override
50
	protected void doInitialize() throws LibraryException {
51
	}
52

  
53
	@Override
54
	protected void doPostInitialize() throws LibraryException {
55
		DefaultFLyrRaster.registerPersistence();
56
		//StatusLayerRaster.registerPersistence();
57
		ColorTableLegend.registerPersistence();
58
		LayerFactory.getInstance().registerLayerToUseForStore(
59
				CoverageStore.class,
60
				DefaultFLyrRaster.class);
61
	}
62
}
63

  
0 64

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/tool/behavior/TransformedRectangleBehavior.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
package org.gvsig.raster.fmap.tool.behavior;
23

  
24
import java.awt.BasicStroke;
25
import java.awt.Color;
26
import java.awt.Image;
27
import java.awt.Point;
28
import java.awt.Rectangle;
29
import java.awt.RenderingHints;
30
import java.awt.event.MouseEvent;
31
import java.awt.geom.AffineTransform;
32
import java.awt.geom.NoninvertibleTransformException;
33
import java.awt.geom.Point2D;
34
import java.awt.geom.Rectangle2D;
35
import java.awt.image.BufferedImage;
36

  
37
import org.gvsig.fmap.IconThemeHelper;
38
import org.gvsig.fmap.geom.GeometryLocator;
39
import org.gvsig.fmap.geom.GeometryManager;
40
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
41
import org.gvsig.fmap.geom.exception.CreateEnvelopeException;
42
import org.gvsig.fmap.geom.primitive.Envelope;
43
import org.gvsig.fmap.mapcontext.ViewPort;
44
import org.gvsig.fmap.mapcontrol.MapControlDrawer;
45
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
46
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
47
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent;
48
import org.gvsig.fmap.mapcontrol.tools.Listeners.RectangleListener;
49
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
50
import org.slf4j.Logger;
51
import org.slf4j.LoggerFactory;
52

  
53

  
54
/**
55
 * Comportamiento de una selecci?n por rectangulo con una transformaci?n
56
 * aplicada. El resultado visual es la selecci?n como un rectangulo com?n con
57
 * el rectangulo transformado superpuesto.
58
 *
59
 * @author Nacho Brodin (nachobrodin@gmail.com)
60
 *
61
 */
62
@SuppressWarnings("deprecation")
63
public class TransformedRectangleBehavior extends Behavior {
64
	private static final GeometryManager	geomManager		 = GeometryLocator.getGeometryManager();
65
	private static final Logger 			logger 			 = LoggerFactory.getLogger(GeometryManager.class);
66
	/**
67
	 * First point of the rectangle area, that represents a corner.
68
	 */
69
	private Point2D             			m_FirstPoint     = null;
70

  
71
	/**
72
	 * Second point of the rectangle area, that represents the opposite corner of the first,
73
	 *  along the diagonal.
74
	 */
75
	private Point2D              			m_LastPoint     = null;
76

  
77
	/**
78
	 * Tool listener used to work with the <code>MapControl</code> object.
79
	 *
80
	 * @see #getListener()
81
	 * @see #setListener(ToolListener)
82
	 */
83
	private RectangleListener   			listener        = null;
84
	private AffineTransform      			at              = null;
85
	private BasicStroke          			stroke          = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[]{5.0f}, 0.0f);
86

  
87
	/**
88
	 * <p>Creates a new behavior for selecting rectangle areas.</p>
89
	 *
90
	 * @param zili listener used to permit this object to work with the associated <code>MapControl</code>
91
	 */
92
	public TransformedRectangleBehavior(RectangleListener zili) {
93
		listener = zili;
94
	}
95

  
96
	/**
97
	 * Asigna la matriz de transformaci?n para el cuadro externo.
98
	 * @param at AffineTransform
99
	 */
100
	public void setAffineTransform(AffineTransform at) {
101
		this.at = at;
102
	}
103

  
104
	/* (non-Javadoc)
105
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getImageCursor()
106
	 */
107
	public Image getImageCursor(){
108
		return IconThemeHelper.getImage("rectangle-select-cursor");
109
	}
110
	
111
	/*
112
	 * (non-Javadoc)
113
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
114
	 */
115
	public void paintComponent(MapControlDrawer mapControlDrawer) {
116
		BufferedImage img = getMapControl().getImage();
117
		RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
118
		hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
119
		mapControlDrawer.setRenderingHints(hints);
120
		mapControlDrawer.drawImage(img, 0, 0);
121
		mapControlDrawer.setColor(Color.black);
122
		//g.setXORMode(Color.white);
123

  
124
		// Borramos el anterior
125
		Rectangle r = new Rectangle();
126

  
127
		// Dibujamos el actual
128
		if ((m_FirstPoint != null) && (m_LastPoint != null)) {
129
			r.setFrameFromDiagonal(m_FirstPoint, m_LastPoint);
130
			mapControlDrawer.drawRect(r.x, r.y, r.width, r.height);
131
		}
132

  
133
		//Dibujamos el cuadro exterior
134
		if(at != null) {
135
			Point2D.Double ul = new Point2D.Double(r.x, r.y);
136
			Point2D.Double ur = new Point2D.Double(r.x + r.width, r.y);
137
			Point2D.Double ll = new Point2D.Double(r.x, r.y + r.height);
138
			Point2D.Double lr = new Point2D.Double(r.x + r.width, r.y + r.height);
139

  
140
			Point2D center = new Point2D.Double((r.width) / 2.0, (r.height) / 2.0);
141
			AffineTransform T1 = new AffineTransform(1D, 0, 0, 1, -center.getX(), -center.getY());
142
			AffineTransform R1 = new AffineTransform(1D, at.getShearY() / at.getScaleY(), at.getShearX() / at.getScaleX(), 1, 0, 0);
143
			AffineTransform T2 = new AffineTransform(1D, 0, 0, 1, center.getX(), center.getY());
144
			T2.concatenate(R1);
145
			T2.concatenate(T1);
146

  
147
			try {
148
				T2.inverseTransform(ul, ul);
149
				T2.inverseTransform(ll, ll);
150
				T2.inverseTransform(ur, ur);
151
				T2.inverseTransform(lr, lr);
152

  
153
				Point2D.Double ptMin = new Point2D.Double(	Math.min(Math.min(ul.getX(), ur.getX()), Math.min(ll.getX(), lr.getX())),
154
															Math.min(Math.min(ul.getY(), ur.getY()), Math.min(ll.getY(), lr.getY())));
155
				Point2D.Double ptMax = new Point2D.Double(	Math.max(Math.max(ul.getX(), ur.getX()), Math.max(ll.getX(), lr.getX())),
156
															Math.max(Math.max(ul.getY(), ur.getY()), Math.max(ll.getY(), lr.getY())));
157
				double w = ptMax.getX() - ptMin.getX();
158
				double h = ptMax.getY() - ptMin.getY();
159

  
160
				mapControlDrawer.setStroke(stroke);
161
				mapControlDrawer.transform(T2);
162
				mapControlDrawer.drawRect((int)ptMin.getX(), (int)ptMin.getY(), (int)w, (int)h);
163
				mapControlDrawer.transform(at.createInverse());
164
			} catch (NoninvertibleTransformException e) {
165
				return;
166
			}
167
		}
168
		//g.setPaintMode();
169
	}
170

  
171
	/*
172
	 * (non-Javadoc)
173
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mousePressed(java.awt.event.MouseEvent)
174
	 */
175
	public void mousePressed(MouseEvent e) {
176
		if (e.getButton() == MouseEvent.BUTTON1) {
177
			m_FirstPoint = e.getPoint();
178
			getMapControl().repaint();
179
		}
180
		if (listener.cancelDrawing()) {
181
			getMapControl().cancelDrawing();
182
			getMapControl().repaint();
183
		}
184
	}
185

  
186
	/*
187
	 * (non-Javadoc)
188
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseReleased(java.awt.event.MouseEvent)
189
	 */
190
	public void mouseReleased(MouseEvent e) throws BehaviorException {
191
	    if (m_FirstPoint == null) return;
192
		Point2D p1;
193
		Point2D p2;
194
		Point pScreen = e.getPoint();
195

  
196
		ViewPort vp = getMapControl().getMapContext().getViewPort();
197

  
198
		p1 = vp.toMapPoint(m_FirstPoint);
199
		p2 = vp.toMapPoint(pScreen);
200

  
201
		if (e.getButton() == MouseEvent.BUTTON1) {
202
			//	Fijamos el nuevo extent
203
			double minX = Math.min(p1.getX(), p2.getX());
204
			double minY = Math.min(p1.getY(), p2.getY());
205
			double maxX = Math.max(p1.getX(), p2.getX());
206
			double maxY = Math.max(p1.getY(), p2.getY());
207
			Envelope env = null;
208
			try {
209
				env = geomManager.createEnvelope(minX, minY, maxX, maxY, SUBTYPES.GEOM2D);
210
			} catch (CreateEnvelopeException e1) {
211
				logger.error("Error creating the envelope", e);
212
			}
213

  
214
			Rectangle2D rectPixel = new Rectangle();
215
			rectPixel.setFrameFromDiagonal(m_FirstPoint, pScreen);
216

  
217
			EnvelopeEvent event = new EnvelopeEvent(env, e, rectPixel);
218
			listener.rectangle(event);
219
		}
220

  
221
		m_FirstPoint = null;
222
		m_LastPoint = null;
223
	}
224

  
225
	/*
226
	 * (non-Javadoc)
227
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#mouseDragged(java.awt.event.MouseEvent)
228
	 */
229
	public void mouseDragged(MouseEvent e) {
230
		m_LastPoint = e.getPoint();
231
		getMapControl().repaint();
232
	}
233

  
234
	/**
235
	 * <p>Sets a tool listener to work with the <code>MapControl</code> using this behavior.</p>
236
	 *
237
	 * @param listener a <code>RectangleListener</code> object for this behavior
238
	 */
239
	public void setListener(ToolListener listener) {
240
		this.listener = (RectangleListener) listener;
241
	}
242

  
243
	/*
244
	 * (non-Javadoc)
245
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
246
	 */
247
	public ToolListener getListener() {
248
		return listener;
249
	}
250
}
0 251

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/tool/SaveRasterListenerImpl.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
package org.gvsig.raster.fmap.tool;
23

  
24
import java.awt.Image;
25
import java.awt.geom.Rectangle2D;
26

  
27
import org.gvsig.fmap.geom.primitive.Envelope;
28
import org.gvsig.fmap.mapcontrol.MapControl;
29
import org.gvsig.fmap.mapcontrol.tools.Events.EnvelopeEvent;
30
import org.gvsig.fmap.mapcontrol.tools.Listeners.RectangleListener;
31

  
32

  
33

  
34
/**
35
* Implementaci?n de la interfaz RectangleListener como herramienta para
36
* realizar un Salvado a Raster.
37
*
38
* @author Nacho Brodin (nachobrodin@gmail.com)
39
*/
40
public class SaveRasterListenerImpl implements RectangleListener {
41
	protected MapControl mapCtrl;
42

  
43
	protected Rectangle2D pixelRect = null;
44
	protected Envelope rect = null;
45

  
46
	/**
47
	 * Crea un nuevo RectangleListenerImpl.
48
	 *
49
	 * @param mapCtrl MapControl.
50
	 */
51
	public SaveRasterListenerImpl(MapControl mapCtrl) {
52
		this.mapCtrl = mapCtrl;
53
	}
54

  
55
	/**
56
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener#rectangle(com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent)
57
	 */
58
	public void rectangle(EnvelopeEvent event) {
59
		rect = event.getWorldCoordRect();
60
		pixelRect = event.getPixelCoordRect();
61
	}
62

  
63
//	/**
64
//	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
65
//	 */
66
//	public Cursor getCursor() {
67
//		return cur;
68
//	}
69

  
70
	/**
71
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
72
	 */
73
	public boolean cancelDrawing() {
74
	    System.out.println("cancelDrawing del SaveRasterListenerImpl");
75
		return true;
76
	}
77

  
78
	public Image getImageCursor() {
79
		return null;
80
	}
81

  
82
}
0 83

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/legend/ImageLegend.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
package org.gvsig.raster.fmap.legend;
23

  
24
import java.awt.Image;
25

  
26
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend;
27
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
28
import org.gvsig.fmap.mapcontext.rendering.legend.IRasterLegend;
29
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener;
30
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
31
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
32
import org.gvsig.tools.persistence.PersistentState;
33
import org.gvsig.tools.persistence.exception.PersistenceException;
34

  
35
/**
36
 * This object is for rasters which returns its legend as a image
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 *
39
 */
40
public class ImageLegend implements IRasterLegend, IHasImageLegend {
41
	private Image    image = null;
42
	
43
	public ImageLegend(Image image) {
44
		this.image = image;
45
	}
46
	
47
	public Image getImageLegend() {
48
		return image;
49
	}
50
	
51
	public Object clone() throws CloneNotSupportedException {
52
		return new ImageLegend(image);
53
	}
54
	
55
	public void addLegendListener(LegendContentsChangedListener listener) {
56
		
57
	}
58

  
59
	public ILegend cloneLegend() {
60
		try {
61
			return (ILegend)clone();
62
		} catch (CloneNotSupportedException e) {
63
		}
64
		return null;
65
	}
66

  
67
	public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
68
		
69
	}
70

  
71
	public ISymbol getDefaultSymbol() {
72
		return null;
73
	}
74

  
75
	public LegendContentsChangedListener[] getListeners() {
76
		return null;
77
	}
78

  
79
	public void removeLegendListener(LegendContentsChangedListener listener) {
80
		
81
	}
82

  
83
	public void loadFromState(PersistentState state)
84
			throws PersistenceException {
85
		
86
	}
87

  
88
	public void saveToState(PersistentState state) throws PersistenceException {
89
		
90
	}
91

  
92
	public String getPathImage() {
93
		return null;
94
	}
95

  
96
}
0 97

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/legend/ColorTableLegend.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
package org.gvsig.raster.fmap.legend;
23

  
24
import java.awt.Color;
25
import java.util.Arrays;
26
import java.util.List;
27

  
28
import org.gvsig.fmap.dal.coverage.RasterLocator;
29
import org.gvsig.fmap.dal.coverage.datastruct.ColorItem;
30
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
31
import org.gvsig.fmap.dal.coverage.util.MathUtils;
32
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend;
33
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend;
34
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener;
35
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
36
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
37
import org.gvsig.symbology.SymbologyLocator;
38
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
39
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
40
import org.gvsig.tools.ToolsLocator;
41
import org.gvsig.tools.dynobject.DynStruct;
42
import org.gvsig.tools.persistence.PersistenceManager;
43
import org.gvsig.tools.persistence.PersistentState;
44
import org.gvsig.tools.persistence.exception.PersistenceException;
45

  
46
/**
47
 * Leyenda para tablas de color aplicadas a un raster.
48
 *
49
 * @version 27/06/2007
50
 * @author Nacho Brodin (nachobrodin@gmail.com)
51
 */
52
public class ColorTableLegend implements IClassifiedLegend, ILegend {
53
	public static final String  COLOR_TABLE_LEGEND_DYNCLASS_NAME = "ColorTableLegend";
54
	private static final String FIELD_SYMBOLS                    = "symbols";
55
	private static final String FIELD_DESCRIPTIONS               = "descriptions";
56

  
57
	private ISymbol[]           symbols                          = null;
58
	private String[]            desc                             = null;
59

  
60
	/**
61
	 * Crea una leyenda de tipo ColorTableLegend a partir de un objeto ColorTable
62
	 * @param colorTable
63
	 * @return ColorTableLegend
64
	 */
65
	public static ColorTableLegend createLegend(ColorTable colorTable) {
66
		if ((colorTable == null) || (colorTable.getColorItems() == null))
67
			return null;
68
		MathUtils math = RasterLocator.getManager().getMathUtils();
69
		
70
		ILineSymbol line = SymbologyLocator.getSymbologyManager().createSimpleLineSymbol();
71
		line.setLineColor(Color.BLACK);
72
		ISymbol[] symbol = new ISymbol[colorTable.getColorItems().size()];
73
		String[] desc = new String[colorTable.getColorItems().size()];
74

  
75
		String nameClass = null;
76
		for (int i = 0; i < colorTable.getColorItems().size(); i++) {
77
			IFillSymbol s = SymbologyLocator.getSymbologyManager().createSimpleFillSymbol();
78
			s.setOutline(line);
79
			s.setFillColor(((ColorItem) colorTable.getColorItems().get(i)).getColor());
80
			nameClass = ((ColorItem) colorTable.getColorItems().get(i)).getNameClass();
81
			if ((nameClass == null) || (nameClass.equals(""))){
82
				if (i < (colorTable.getColorItems().size() - 1)){
83
					desc[i] = "[" + math.format(((ColorItem) colorTable.getColorItems().get(i)).getValue(), 2) + " , " + math.format(((ColorItem) colorTable.getColorItems().get(i + 1)).getValue(), 2) + "[ ";
84
				}else{
85
					desc[i] = "[" + math.format(((ColorItem) colorTable.getColorItems().get(i)).getValue(), 2) + "] ";
86
				}
87
			}else{
88
				desc[i] = ((ColorItem) colorTable.getColorItems().get(i)).getNameClass();
89
			}	
90
			symbol[i] = s;
91
		}
92

  
93
		return new ColorTableLegend(symbol, desc);
94
	}
95

  
96
	/**
97
	 * Leyenda para tablas de color raster.
98
	 * @param s Lista de simbolos
99
	 * @param d Lista de descripciones de simbolos
100
	 */
101
	public ColorTableLegend(ISymbol[] s, String[] d) {
102
		symbols = s;
103
		desc = d;
104
	}
105

  
106
	/**
107
	 * Empty constructor used only for persistence purposes.
108
	 */
109
	public ColorTableLegend() {
110
	}
111

  
112
	/*
113
	 * (non-Javadoc)
114
	 * @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getDescriptions()
115
	 */
116
	public String[] getDescriptions() {
117
		return desc;
118
	}
119

  
120
	/*
121
	 * (non-Javadoc)
122
	 * @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getSymbols()
123
	 */
124
	public ISymbol[] getSymbols() {
125
		return symbols;
126
	}
127

  
128
	/*
129
	 * (non-Javadoc)
130
	 * @see com.iver.cit.gvsig.fmap.rendering.IClassifiedLegend#getValues()
131
	 */
132
	public Object[] getValues() {
133
		return desc;
134
	}
135

  
136
	/*
137
	 * (non-Javadoc)
138
	 * @see com.iver.cit.gvsig.fmap.rendering.ILegend#cloneLegend()
139
	 */
140
	public ILegend cloneLegend() {
141
		return null;
142
	}
143

  
144
	/*
145
	 * (non-Javadoc)
146
	 * @see com.iver.cit.gvsig.fmap.rendering.ILegend#getDefaultSymbol()
147
	 */
148
	public ISymbol getDefaultSymbol() {
149
		return null;
150
	}
151

  
152
	/*
153
	 * (non-Javadoc)
154
	 * @see com.iver.cit.gvsig.fmap.rendering.ILegend#getSLDString(java.lang.String)
155
	 */
156
	public String getSLDString(String layerName) {
157
		return null;
158
	}
159

  
160
	/*
161
	 * (non-Javadoc)
162
	 * @see com.iver.utiles.IPersistance#getClassName()
163
	 */
164
	public String getClassName() {
165
		return null;
166
	}
167

  
168
	public void addLegendListener(LegendContentsChangedListener listener) {
169
		// TODO Auto-generated method stub
170
	}
171

  
172
	public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
173
		// TODO Auto-generated method stub
174
		
175
	}
176

  
177
	public LegendContentsChangedListener[] getListeners() {
178
		// TODO Auto-generated method stub
179
		return null;
180
	}
181

  
182
	
183
	public void removeLegendListener(LegendContentsChangedListener listener) {
184
		// TODO Auto-generated method stub
185
	}
186

  
187
	@Override
188
	public Object clone() throws CloneNotSupportedException {
189
		// TODO Auto-generated method stub
190
		return super.clone();
191
	}
192

  
193
	private void setDescriptions(String[] descriptions) {
194
		this.desc = descriptions;
195
	}
196

  
197
	private void setSymbols(ISymbol[] symbols) {
198
		this.symbols = symbols;
199
	}
200

  
201
	@SuppressWarnings("unchecked")
202
	public void loadFromState(PersistentState state)
203
			throws PersistenceException {
204
		List<ISymbol> symbols = (List<ISymbol>) state.get(FIELD_SYMBOLS);
205
		setSymbols(symbols.toArray(new ISymbol[symbols.size()]));
206

  
207
		List<String> descriptions =
208
				(List<String>) state.get(FIELD_DESCRIPTIONS);
209
		setDescriptions(descriptions.toArray(new String[descriptions.size()]));
210
	}
211

  
212
	public void saveToState(PersistentState state) throws PersistenceException {
213
		state.set(FIELD_SYMBOLS, Arrays.asList(getSymbols()));
214
		state.set(FIELD_DESCRIPTIONS, Arrays.asList(getDescriptions()));
215
	}
216

  
217
	public static void registerPersistence() {
218
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
219
		DynStruct definition = manager.addDefinition(
220
				ColorTableLegend.class,
221
				COLOR_TABLE_LEGEND_DYNCLASS_NAME,
222
				COLOR_TABLE_LEGEND_DYNCLASS_NAME + " Persistence definition",
223
				null, 
224
				null
225
		);
226

  
227
		// Symbols
228
		definition.addDynFieldList(FIELD_SYMBOLS).setClassOfItems(ISymbol.class).setMandatory(true);
229
		// Descriptions
230
		definition.addDynFieldList(FIELD_DESCRIPTIONS).setClassOfItems(String.class).setMandatory(true);
231

  
232
	}
233

  
234
}
0 235

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/ILayerState.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
package org.gvsig.raster.fmap.layers;
23

  
24
public interface ILayerState {
25

  
26
	public static final int UNDEFINED    = -1;
27
	public static final int OPEN         = 0;
28
	public static final int CLOSED       = 1;
29
	public static final int AWAKE        = 2;
30
	public static final int STOPPED      = 3;
31
		
32
	/**
33
	 * Consulta si una capa est? lecantada o no. Una capa levantada
34
	 * significa que no est? open pero tampoco est? closed. Tiene asignadas los valores
35
	 * a las variables para abrir los ficheros o descargar las imagenes pero la acci?n no
36
	 * ser? efectiva hasta que no se haga un open. En ese momento deja de estar awake y pasa 
37
	 * a open. De la misma forma est?ndo awake podemos hacer un close.
38
	 * 
39
	 * @return true si est? levantada y false si no lo est?. Si est? a false no sabemos nada
40
	 * del estado en que se encuentra.
41
	 */
42
	public boolean isAwake();
43
	
44
	/**
45
	 * Asigna el flag que dice si una capa est? levantada. Una capa levantada
46
	 * significa que no est? open pero tampoco est? closed. Tiene asignadas los valores
47
	 * a las variables para abrir los ficheros o descargar las imagenes pero la acci?n no
48
	 * ser? efectiva hasta que no se haga un open. En ese momento deja de estar awake y pasa 
49
	 * a open. De la misma forma est?ndo awake podemos hacer un close.
50
	 *  
51
	 *  @throws NotAvailableStateException Excepci?n lanzada si no es posible alcanzar el estado
52
	 */
53
	public void enableAwake() throws NotAvailableStateException;
54
	
55
	/**
56
	 * Consulta si una capa est? abierta o no. Una capa est? abierta cuando los 
57
	 * archivos a los que referencia est?n abiertos o descargados y las estructuras
58
	 * de memoria de gvSIG cargadas con los datos de cabecera y propiedades, es decir lista
59
	 * para renderizar o leer informaci?n. Que una capa no est? open no significa que deba
60
	 * estar closed, puede estar awake.
61
	 * 
62
	 * @return true si est? abierta o false si no lo est?.
63
	 */
64
	public boolean isOpen();
65
	
66
	/**
67
	 * Asigna una capa como abierta. Una capa est? abierta cuando los 
68
	 * archivos a los que referencia est?n abiertos o descargados y las estructuras
69
	 * de memoria de gvSIG cargadas con los datos de cabecera y propiedades, es decir lista
70
	 * para renderizar o leer informaci?n. Que una capa no est? open no significa que deba
71
	 * estar closed, puede estar awake.
72
	 * 
73
	 * @throws NotAvailableStateException Excepci?n lanzada si no es posible alcanzar el estado
74
	 */
75
	public void enableOpen() throws NotAvailableStateException;
76
		
77
	/**
78
	 * Consulta si una capa est? cerrada o no. Una capa est? cerrada cuando no se ha asignado
79
	 * todavia una fuente de datos a la misma por lo cual no ser? posible hacer ninguna operaci?n
80
	 * de consulta. Que una capa no est? closed no significa que deba estar open, puede estar awake.
81
	 * 
82
	 * @return true si est? abierta o false si no lo est?.
83
	 */
84
	public boolean isClosed();
85
	
86
	/**
87
	 * Asigna una capa como cerrada. Una capa est? cerrada cuando no se ha asignado
88
	 * todavia una fuente de datos a la misma por lo cual no ser? posible hacer ninguna operaci?n
89
	 * de consulta. Que una capa no est? closed no significa que deba estar open, puede estar awake.
90
	 * 
91
	 * @throws NotAvailableStateException Excepci?n lanzada si no es posible alcanzar el estado
92
	 */
93
	public void enableClosed() throws NotAvailableStateException;
94
	
95
	/**
96
	 * Consulta el estado de detenci?n. En este estado la capa no puede ser abierta.
97
	 * Existen motivos por los cuales una capa no debe ser accedida por ning?n motivo 
98
	 * aunque el dataset est? abierto y las estructuras cargadas, en este caso se define un
99
	 * estado de detenci?n. Cuando una capa es detenida recuerda el estado del que sal?a y lo
100
	 * recupera al ser reanudada.
101
	 * 
102
	 * @return true si est? detenida y false si no lo est?.
103
	 */
104
	public boolean isStopped();
105
	
106
	/**
107
	 * Activa la detenci?n de la capa. En este estado la capa no puede ser abierta.
108
	 * Existen motivos por los cuales una capa no debe ser accedida por ning?n motivo 
109
	 * aunque el dataset est? abierto y las estructuras cargadas, en este caso se define un
110
	 * estado de detenci?n. Cuando una capa es detenida recuerda el estado del que sal?a y lo
111
	 * recupera al ser reanudada.
112
	 * 
113
	 * @param stopped
114
	 * @throws NotAvailableStateException
115
	 */
116
	public void enableStopped();
117
	
118
	/**
119
	 * Desactiva la detenci?n de la capa. En este estado la capa no puede ser abierta.
120
	 * Existen motivos por los cuales una capa no debe ser accedida por ning?n motivo 
121
	 * aunque el dataset est? abierto y las estructuras cargadas, en este caso se define un
122
	 * estado de detenci?n. Cuando una capa es detenida recuerda el estado del que sal?a y lo
123
	 * recupera al ser reanudada.
124
	 * 
125
	 * @param stopped
126
	 */
127
	public void disableStopped();	
128
}
0 129

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/IRasterLayerActions.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
package org.gvsig.raster.fmap.layers;
23

  
24
/**
25
 * Definici?n de acciones soportadas para una capa. Distintas capas que hereden de 
26
 * FLyrRasterSE pueden soportar distintos tipos de acciones.
27
 * @version 23/08/2007
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 *
30
 */
31
public interface IRasterLayerActions {
32
	public static int ZOOM_PIXEL_RESOLUTION = 0;
33
	public static int CLIPPING              = 1;
34
	public static int HISTOGRAM             = 2;
35
	public static int RASTER_PROPERTIES     = 3;
36
	public static int SAVEAS                = 4;
37
	public static int FILTER                = 5;
38
	public static int COLOR_TABLE           = 6;
39
	public static int FLYRASTER_BAR_TOOLS   = 7;
40
	public static int BANDS_FILE_LIST       = 8;
41
	public static int BANDS_RGB             = 9;
42
	public static int TRANSPARENCY          = 10;
43
	public static int OPACITY               = 11;
44
	public static int BRIGHTNESSCONTRAST    = 12;
45
	public static int ENHANCED              = 13;
46
	public static int PANSHARPENING         = 14;
47
	public static int GEOLOCATION           = 15;
48
	public static int CREATEOVERVIEWS       = 16;
49
	public static int REPROJECT             = 17;
50
	public static int SELECT_LAYER          = 18;
51
	public static int SAVE_COLORINTERP      = 19;
52
	public static int REMOTE_ACTIONS        = 20;
53
	public static int STATS                 = 21;
54
	public static int NODATA                = 22;
55
	public static int TAILTRIM              = 23;
56
	
57
	/**
58
   * Controla si una acci?n est? activa o no para una determinada capa. De esta
59
   * forma una determinada capa puede desactivar una entrada del TOC que no le
60
   * interese que aparezca.
61
   * @param action Acci?n definida en LayerActionSupported
62
   * @return true si est? activa y false si no lo est?.
63
   */
64
	public boolean isActionEnabled(int action);
65
}
0 66

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DynObjectIteratorRasterInfo.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
package org.gvsig.raster.fmap.layers;
23

  
24
import java.util.ArrayList;
25

  
26
import org.gvsig.fmap.dal.feature.Feature;
27
import org.gvsig.tools.dispose.DisposableIterator;
28
import org.gvsig.tools.dynobject.DynObject;
29
import org.gvsig.tools.dynobject.DynObjectSet;
30

  
31
/**
32
 * {@link DynObject} implementation to facade a iterator of a WMTSInfo
33
 * and allow to be used as a {@link DynObjectSet} iterator.
34
 * 
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 * @version $Id$
37
 * 
38
 */
39
public class DynObjectIteratorRasterInfo implements DisposableIterator {
40

  
41
    private ArrayList<Object> infoList = new ArrayList<Object>();
42
    private int               index    = -1;
43

  
44
    /**
45
     * Creates a new DynObjects iterator facade over a feature iterator.
46
     * Each WMTSInfo will be returned through a new or reused
47
     * {@link DynObjectWMTSInfo} which allows the {@link Feature} to be
48
     * used like a DynObject.
49
     * 
50
     * @param featureIterator
51
     *            to facade
52
     * @param featureFacade
53
     *            if not null this object will be reused as the facade for the
54
     *            Feature objects of the feature iterator
55
     */
56
    public DynObjectIteratorRasterInfo(Object info) {
57
        this.infoList.add(info);
58
        index = 0;
59
    }
60
    
61
    public void addObject(Object info) {
62
    	this.infoList.add(info);
63
    	if(index == -1)
64
    		index = 0;
65
    }
66

  
67
    public synchronized void dispose() {
68
    	this.infoList.clear();
69
    	index = -1;
70
    }
71

  
72
    public synchronized boolean hasNext() {
73
        return (infoList.size() == 0 || index >= infoList.size()) ? false : true;
74
    }
75

  
76
    public synchronized Object next() {
77
        Object o = infoList.get(index);
78
        index ++;
79
        return o;
80
    }
81

  
82
    public synchronized void remove() {
83
    	if(index < infoList.size() && index >= 0) {
84
    		index --;
85
    		infoList.remove(index);
86
    	}
87
    }
88
    
89
    public long getSize() {
90
        return infoList.size();
91
    }
92
}
0 93

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DynObjectSetRasterInfo.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
package org.gvsig.raster.fmap.layers;
23

  
24
import org.gvsig.fmap.dal.feature.FeatureSet;
25
import org.gvsig.tools.ToolsLocator;
26
import org.gvsig.tools.dispose.DisposableIterator;
27
import org.gvsig.tools.dynobject.DynClass;
28
import org.gvsig.tools.dynobject.DynField;
29
import org.gvsig.tools.dynobject.DynObject;
30
import org.gvsig.tools.dynobject.DynObjectSet;
31
import org.gvsig.tools.dynobject.impl.DefaultDynObject;
32
import org.gvsig.tools.exception.BaseException;
33
import org.gvsig.tools.observer.Observable;
34
import org.gvsig.tools.observer.Observer;
35
import org.gvsig.tools.observer.impl.BaseWeakReferencingObservable;
36
import org.gvsig.tools.visitor.Visitor;
37

  
38
/**
39
 * {@link DynObject} implementation to facade of a {@link FeatureSet} and allow
40
 * to be used as a {@link DynObjectSet}.
41
 * 
42
 * @author Nacho Brodin (nachobrodin@gmail.com)
43
 * @version $Id$
44
 */
45
public class DynObjectSetRasterInfo extends BaseWeakReferencingObservable
46
    implements DynObjectSet, Observer {
47
	private DynObjectIteratorRasterInfo   ite      = null;
48
	private DynClass                      dynClass = null;
49
	
50
    /**
51
     * Creates a new facade over a given info, with fast dynobject
52
     * iteration.
53
     */
54
    public DynObjectSetRasterInfo() {
55
        dynClass =
56
            ToolsLocator.getDynObjectManager().createDynClass(
57
                "RasterInfoByPoint", "Raster", "Raster point information");
58
    }
59

  
60
    /**
61
     * Adds a field to the DynObject
62
     * @param name
63
     * @param object
64
     * @param order
65
     */
66
    public void addField(String name, Object object, int order) {
67
    	DynField field = dynClass.addDynField(name);
68
    	field.setDefaultFieldValue(object);
69
    	if(order != -1)
70
    		field.setOrder(order);
71
    	DefaultDynObject dynObject = new DefaultDynObject(dynClass);
72
    	ite = new DynObjectIteratorRasterInfo(dynObject);
73
    }
74
    
75
    public void dispose() {
76

  
77
    }
78

  
79
    public void accept(final Visitor visitor, long firstValueIndex) throws BaseException {
80
    	while(ite.hasNext()) {
81
    		visitor.visit(ite.next());
82
    	}
83
    }
84

  
85
    public void accept(final Visitor visitor) throws BaseException {
86
    	while(ite.hasNext()) {
87
    		visitor.visit(ite.next());
88
    	}
89
    }
90

  
91
    public long getSize() throws BaseException {
92
       return ite.getSize();
93
    }
94

  
95
    public DisposableIterator iterator(long index) throws BaseException {
96
        return iterator();
97
    }
98

  
99
    public DisposableIterator iterator() throws BaseException {
100
    	return ite;
101
    }
102

  
103
    public boolean isEmpty() throws BaseException {
104
    	return (getSize() == 0);
105
    }
106

  
107
    public boolean isDeleteEnabled() {
108
    	return true;
109
    }
110

  
111
    public void delete(DynObject dynObject) throws BaseException {
112

  
113
    }
114

  
115
    public boolean isUpdateEnabled() {
116
    	return true;
117
    }
118

  
119
    public void update(DynObject dynObject) throws BaseException {
120
    }
121

  
122
    public void update(Observable observable, Object notification) {
123
    }
124
}
0 125

  
org.gvsig.raster/tags/org.gvsig.raster-2.2.90/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/FLyrRaster.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
package org.gvsig.raster.fmap.layers;
23

  
24
import java.awt.Graphics2D;
25
import java.awt.geom.AffineTransform;
26
import java.awt.geom.Point2D;
27
import java.awt.image.BufferedImage;
28
import java.io.File;
29
import java.net.URI;
30
import java.util.ArrayList;
31
import java.util.List;
32

  
33
import org.cresques.cts.IProjection;
34

  
35
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
36
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
37
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException;
38
import org.gvsig.fmap.dal.coverage.exception.ROIException;
39
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
40
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
41
import org.gvsig.fmap.dal.coverage.grid.render.Render;
42
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
43
import org.gvsig.fmap.dal.coverage.store.props.ColorTable;
44
import org.gvsig.fmap.dal.coverage.util.Historical;
45
import org.gvsig.fmap.dal.exception.ReadException;
46
import org.gvsig.fmap.geom.primitive.Envelope;
47
import org.gvsig.fmap.mapcontext.MapContext;
48
import org.gvsig.fmap.mapcontext.ViewPort;
49
import org.gvsig.fmap.mapcontext.layers.FLayer;
50
import org.gvsig.fmap.mapcontext.layers.LayerListener;
51
import org.gvsig.raster.roi.ROI;
52
import org.gvsig.tools.task.Cancellable;
53

  
54
/**
55
 * All kind of raster layers should implement this interface.
56
 *
57
 * @author Nacho Brodin (nachobrodin@gmail.com)
58
 */
59
@SuppressWarnings("deprecation")
60
public interface FLyrRaster extends FLayer {
61
	/**
62
	 * Sets the layer as initialized. That's implies that the layer has
63
	 * the right filters and is opened,
64
	 * @param initialized
65
	 */
66
	public void setLayerInitialized(boolean initialized);
67

  
68
	/**
69
	 * Gets the uniform resource identifier
70
	 * @return
71
	 */
72
	public URI getURI();
73

  
74
	/**
75
	 * Returns true if a color table exists
76
	 * @return
77
	 */
78
	public boolean existColorTable();
79

  
80
	/**
81
	 * Define la ultima leyenda valida de la capa o se pone a null para que la
82
	 * capa busque una leyenda valida.
83
	 * @param ct
84
	 */
85
	public void setLastLegend(ColorTable ct);
86

  
87
	/**
88
	 * Crea el objeto renderizador de raster
89
	 * @return Rendering
90
	 */
91
	public Render getRender();
92

  
93
	/**
94
	 * Gets the MapContext object
95
	 * @return
96
	 */
97
	public MapContext getMapContext();
98

  
99
	/**
100
	 * Gets the full extent
101
	 * @return
102
	 */
103
	public Extent getFullRasterExtent();
104

  
105
	/**
106
	 * Gets the DataStore
107
	 * @return
108
	 */
109
	public RasterDataStore getDataStore();
110

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff