Revision 15432
org.gvsig.raster/tags/org.gvsig.raster-2.2.172/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.172/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.172/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.172/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.172/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.172/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.172/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/ROILayerRaster.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.Color; |
|
25 |
|
|
26 |
import org.gvsig.raster.roi.ROI; |
|
27 |
|
|
28 |
/** |
|
29 |
* Clase que representa una regi?n de inter?s tal y como se asocia a una |
|
30 |
* capa raster, es decir, incluyendo un nombre y el color con el que se |
|
31 |
* representa. |
|
32 |
* |
|
33 |
* @author Diego Guerrero Sevilla (diego.guerrero@uclm.es) |
|
34 |
* |
|
35 |
*/ |
|
36 |
public class ROILayerRaster { |
|
37 |
|
|
38 |
private ROI roi = null; |
|
39 |
private Color color = null; |
|
40 |
private String name = null; |
|
41 |
|
|
42 |
/** |
|
43 |
* Constructor. |
|
44 |
* |
|
45 |
* @param roi |
|
46 |
* @param color |
|
47 |
* @param name |
|
48 |
*/ |
|
49 |
public ROILayerRaster(ROI roi, Color color, String name) { |
|
50 |
this.roi = roi; |
|
51 |
this.color = color; |
|
52 |
this.name = name; |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* |
|
57 |
* @return Color con el que la ROI se representa en la vista. |
|
58 |
*/ |
|
59 |
public Color getColor() { |
|
60 |
return color; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* |
|
65 |
* @param color Color con el que la ROI se representa en la vista. |
|
66 |
*/ |
|
67 |
public void setColor(Color color) { |
|
68 |
this.color = color; |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* |
|
73 |
* @return Nombre asociado a la ROI. |
|
74 |
*/ |
|
75 |
public String getName() { |
|
76 |
return name; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* |
|
81 |
* @param name Nombre asociado a la ROI. |
|
82 |
*/ |
|
83 |
public void setName(String name) { |
|
84 |
this.name = name; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* |
|
89 |
* @return Regi?n de Inter?s. |
|
90 |
*/ |
|
91 |
public ROI getRoi() { |
|
92 |
return roi; |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* |
|
97 |
* @param roi Regi?n de inter?s. |
|
98 |
*/ |
|
99 |
public void setRoi(ROI roi) { |
|
100 |
this.roi = roi; |
|
101 |
} |
|
102 |
} |
|
0 | 103 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.172/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultLayerConfiguration.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 |
* DefaultLayerConfiguration sirve para aquellos objetos que no puedan usar la |
|
25 |
* configuracion de PluginServices, devolviendo siempre el valor por defecto. |
|
26 |
* |
|
27 |
* @version 14/01/2008 |
|
28 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
29 |
*/ |
|
30 |
public class DefaultLayerConfiguration implements IConfiguration { |
|
31 |
|
|
32 |
/* |
|
33 |
* (non-Javadoc) |
|
34 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueBoolean(java.lang.String, java.lang.Boolean) |
|
35 |
*/ |
|
36 |
public Boolean getValueBoolean(String name, Boolean defaultValue) { |
|
37 |
return defaultValue; |
|
38 |
} |
|
39 |
|
|
40 |
/* |
|
41 |
* (non-Javadoc) |
|
42 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueDouble(java.lang.String, java.lang.Double) |
|
43 |
*/ |
|
44 |
public Double getValueDouble(String name, Double defaultValue) { |
|
45 |
return defaultValue; |
|
46 |
} |
|
47 |
|
|
48 |
/* |
|
49 |
* (non-Javadoc) |
|
50 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueFloat(java.lang.String, java.lang.Float) |
|
51 |
*/ |
|
52 |
public Float getValueFloat(String name, Float defaultValue) { |
|
53 |
return defaultValue; |
|
54 |
} |
|
55 |
|
|
56 |
/* |
|
57 |
* (non-Javadoc) |
|
58 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueInteger(java.lang.String, java.lang.Integer) |
|
59 |
*/ |
|
60 |
public Integer getValueInteger(String name, Integer defaultValue) { |
|
61 |
return defaultValue; |
|
62 |
} |
|
63 |
|
|
64 |
/* |
|
65 |
* (non-Javadoc) |
|
66 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueLong(java.lang.String, java.lang.Long) |
|
67 |
*/ |
|
68 |
public Long getValueLong(String name, Long defaultValue) { |
|
69 |
return defaultValue; |
|
70 |
} |
|
71 |
|
|
72 |
/* |
|
73 |
* (non-Javadoc) |
|
74 |
* @see org.gvsig.fmap.raster.conf.IConfiguration#getValueString(java.lang.String, java.lang.String) |
|
75 |
*/ |
|
76 |
public String getValueString(String name, String defaultValue) { |
|
77 |
return defaultValue; |
|
78 |
} |
|
79 |
} |
|
0 | 80 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.172/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/FLyrState.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 |
/** |
|
26 |
* Estados de una capa. Cada capa tiene uno o varios estados activos en cada instante. |
|
27 |
* Hay estados no compatibles entre si, es decir, no pueden estar activos a la vez en cada |
|
28 |
* instante. Por ejemplo, una capa no puede estar cerrada y renderizando ya que sus datos no |
|
29 |
* est?n accesibles para esa operaci?n. Los estados de una capa sir |
|
30 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
31 |
* |
|
32 |
*/ |
|
33 |
public class FLyrState implements ILayerState { |
|
34 |
private boolean open = false; |
|
35 |
private boolean closed = true; |
|
36 |
private boolean awake = false; |
|
37 |
private boolean stopped = false; |
|
38 |
|
|
39 |
private int lastBeforeStop = UNDEFINED; |
|
40 |
|
|
41 |
public boolean isAwake() { |
|
42 |
return awake; |
|
43 |
} |
|
44 |
|
|
45 |
public void enableAwake() throws NotAvailableStateException { |
|
46 |
if(awake) |
|
47 |
return; |
|
48 |
if(open == true || closed == true || stopped == true) { |
|
49 |
this.awake = true; |
|
50 |
stopped = closed = open = false; |
|
51 |
lastBeforeStop = UNDEFINED; |
|
52 |
} else |
|
53 |
throw new NotAvailableStateException("Awake state not available"); |
|
54 |
} |
|
55 |
|
|
56 |
public boolean isOpen() { |
|
57 |
return open; |
|
58 |
} |
|
59 |
|
|
60 |
public void enableOpen() throws NotAvailableStateException { |
|
61 |
if(stopped == true || awake == true) { |
|
62 |
this.open = true; |
|
63 |
stopped = closed = awake = false; |
|
64 |
lastBeforeStop = UNDEFINED; |
|
65 |
} else |
|
66 |
throw new NotAvailableStateException("Open state not available"); |
|
67 |
} |
|
68 |
|
|
69 |
public boolean isClosed() { |
|
70 |
return closed; |
|
71 |
} |
|
72 |
|
|
73 |
public void enableClosed() throws NotAvailableStateException { |
|
74 |
if(open == true || awake == true || stopped == true) { |
|
75 |
this.closed = true; |
|
76 |
stopped = open = awake = false; |
|
77 |
lastBeforeStop = UNDEFINED; |
|
78 |
} else |
|
79 |
throw new NotAvailableStateException("Closed state not available"); |
|
80 |
} |
|
81 |
|
|
82 |
public boolean isStopped() { |
|
83 |
return stopped; |
|
84 |
} |
|
85 |
|
|
86 |
public void enableStopped() { |
|
87 |
if(open == true || awake == true || closed == true) { |
|
88 |
lastBeforeStop = (open == true) ? OPEN : ((closed == true) ? CLOSED : ((awake == true) ? AWAKE : UNDEFINED)); |
|
89 |
if(lastBeforeStop != UNDEFINED) { |
|
90 |
stopped = true; |
|
91 |
closed = open = awake = false; |
|
92 |
} |
|
93 |
} |
|
94 |
} |
|
95 |
|
|
96 |
public void disableStopped() { |
|
97 |
if(stopped == true && lastBeforeStop != UNDEFINED) { |
|
98 |
switch(lastBeforeStop) { |
|
99 |
case OPEN: open = true; closed = awake = false; break; |
|
100 |
case CLOSED: closed = true; awake = open = false; break; |
|
101 |
case AWAKE: awake = true; closed = open = false; break; |
|
102 |
} |
|
103 |
stopped = false; |
|
104 |
lastBeforeStop = UNDEFINED; |
|
105 |
} |
|
106 |
} |
|
107 |
|
|
108 |
} |
|
0 | 109 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.172/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/IStatusRaster.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.List; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.coverage.exception.FileNotFoundInListException; |
|
27 |
import org.gvsig.fmap.dal.coverage.exception.FilterManagerException; |
|
28 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
|
29 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
30 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
31 |
import org.gvsig.fmap.dal.coverage.exception.OperationNotSupportedException; |
|
32 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
33 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
|
34 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
35 |
import org.gvsig.tools.persistence.Persistent; |
|
36 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
37 |
import org.gvsig.utils.XMLException; |
|
38 |
|
|
39 |
|
|
40 |
public interface IStatusRaster extends Persistent{ |
|
41 |
|
|
42 |
/** |
|
43 |
* Recupera en fichero XML algunas propiedades y filtros del raster |
|
44 |
* @param xml |
|
45 |
* @throws XMLException |
|
46 |
*/ |
|
47 |
//public void loadFromState(PersistentState state, FLyrRasterSE layer)throws PersistenceException; |
|
48 |
|
|
49 |
/** |
|
50 |
* Salva en fichero XML algunas propiedades y filtros de raster |
|
51 |
* @param xml |
|
52 |
* @throws XMLException |
|
53 |
*/ |
|
54 |
public void setStateProperties(boolean loadClass, DefaultFLyrRaster layer)throws PersistenceException; |
|
55 |
|
|
56 |
/** |
|
57 |
* Aplica el estado almacenado al FLyrRaster pasado por par?metro |
|
58 |
* @param adapter |
|
59 |
* @throws NotSupportedExtensionException Cuando la extensi?n no est? soportada |
|
60 |
* @throws RasterDriverException Cuando se produce un error en la lectura del fichero |
|
61 |
* @throws OperationNotSupportedException |
|
62 |
* @throws FileNotFoundInListException |
|
63 |
* @throws FilterManagerException |
|
64 |
* @throws InvalidSourceException |
|
65 |
*/ |
|
66 |
public void applyStatus(DefaultFLyrRaster layer) throws NotSupportedExtensionException, RasterDriverException, FilterTypeException, FileNotFoundInListException, OperationNotSupportedException, FilterManagerException, InvalidSourceException ; |
|
67 |
|
|
68 |
/** |
|
69 |
* Obtiene el listado de filtros para poder montar una pila |
|
70 |
* despu?s de la recuperaci?n desde el XML |
|
71 |
* @return |
|
72 |
*/ |
|
73 |
public List<String> getFilters(); |
|
74 |
|
|
75 |
/** |
|
76 |
* Obtiene el orden de renderizado de bandas cargado desde el proyecto |
|
77 |
* despu?s de hacer un setXMLEntity |
|
78 |
* @return Lista de enteros con el orden de renderizado |
|
79 |
*/ |
|
80 |
public int[] getRenderBands(); |
|
81 |
|
|
82 |
/** |
|
83 |
* Obtiene la lista de filtros cargada desde el proyecto despu?s de hacer un |
|
84 |
* setXMLEntity |
|
85 |
* @return RasterFilterList |
|
86 |
* @throws FilterTypeException |
|
87 |
*/ |
|
88 |
public RasterFilterList getFilterList() throws FilterTypeException; |
|
89 |
|
|
90 |
/** |
|
91 |
* Obtiene la lista de filtros cargada desde el proyecto despu?s de hacer un |
|
92 |
* setXMLEntity. No construye los filtros sino que devuelve una lista de par?metros |
|
93 |
* @return RasterFilterList |
|
94 |
*/ |
|
95 |
public List<String> getFilterArguments(); |
|
96 |
|
|
97 |
/** |
|
98 |
* Obtiene el ColorTable si hay un filtro de tabla de color en la lista |
|
99 |
* @return ColorTable |
|
100 |
* @throws FilterTypeException |
|
101 |
*/ |
|
102 |
public ColorTable getColorTable() throws FilterTypeException; |
|
103 |
} |
|
0 | 104 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.172/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/Multiresolution.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.geom.Point2D; |
|
25 |
|
|
26 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
27 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
28 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
29 |
|
|
30 |
/** |
|
31 |
* Layers with levels of multiresolution support |
|
32 |
* |
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
34 |
* |
|
35 |
*/ |
|
36 |
public interface Multiresolution { |
|
37 |
/** |
|
38 |
* Returns true if the multiresolution is enabled |
|
39 |
* @return |
|
40 |
*/ |
|
41 |
public boolean isEnabledMultiresolution(); |
|
42 |
|
|
43 |
/** |
|
44 |
* Gets the current zoom level |
|
45 |
* @return |
|
46 |
*/ |
|
47 |
public int getZoomLevel(); |
|
48 |
|
|
49 |
/** |
|
50 |
* Sets the current zoom level |
|
51 |
* @param zoomLevel |
|
52 |
*/ |
|
53 |
public void setZoomLevel(int zoomLevel); |
|
54 |
|
|
55 |
/** |
|
56 |
* Increase the current zoom level |
|
57 |
*/ |
|
58 |
public boolean increaseZoomLevel(); |
|
59 |
|
|
60 |
/** |
|
61 |
* Decrease the current zoom level |
|
62 |
*/ |
|
63 |
public boolean decreaseZoomLevel(); |
|
64 |
|
|
65 |
/** |
|
66 |
* Calculates the bounding box of a zoom level using a center defined in pixels. |
|
67 |
* It's possible to define the center in pixels because a level of resolution has |
|
68 |
* a pixel size. |
|
69 |
* @param center |
|
70 |
* center in world coordinates |
|
71 |
* @param level |
|
72 |
* level of resolution |
|
73 |
* @param w |
|
74 |
* width in pixels |
|
75 |
* @param h |
|
76 |
* height in pixels |
|
77 |
* @return |
|
78 |
*/ |
|
79 |
public Envelope getCoordsInLevel(Point2D center, int level, int w, int h) throws CreateEnvelopeException; |
|
80 |
|
|
81 |
/** |
|
82 |
* Sets a tile server to create a second level of cache. This second level will be |
|
83 |
* created if the cache structure is different to the current. |
|
84 |
* @param tileServer |
|
85 |
*/ |
|
86 |
public void setTileServer(Class<?> tileServer) throws InitializeException; |
|
87 |
} |
|
0 | 88 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.172/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/IConfiguration.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 IConfiguration { |
|
25 |
public Boolean getValueBoolean(String name, Boolean defaultValue); |
|
26 |
public Double getValueDouble(String name, Double defaultValue); |
|
27 |
public Float getValueFloat(String name, Float defaultValue); |
|
28 |
public Integer getValueInteger(String name, Integer defaultValue); |
|
29 |
public Long getValueLong(String name, Long defaultValue); |
|
30 |
public String getValueString(String name, String defaultValue); |
|
31 |
} |
|
0 | 32 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.172/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/NotAvailableStateException.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 |
* Excepci?n lanzada cuando se intenta poner una capa en un estado inaccesible. |
|
26 |
* |
|
27 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
28 |
* |
|
29 |
*/ |
|
30 |
public class NotAvailableStateException extends Exception { |
|
31 |
private static final long serialVersionUID = 1557651260026647067L; |
|
32 |
|
|
33 |
public NotAvailableStateException(String msg){ |
|
34 |
super(msg); |
|
35 |
} |
|
36 |
} |
|
0 | 37 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.172/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?. |
Also available in: Unified diff