Revision 6713
org.gvsig.raster/tags/org.gvsig.raster-2.2.59/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.59</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.mapcontext.operation</artifactId> |
|
90 |
<scope>runtime</scope> |
|
91 |
</dependency> |
|
92 |
<dependency> |
|
93 |
<groupId>org.gvsig</groupId> |
|
94 |
<artifactId>org.gvsig.fmap.dal.file.shp</artifactId> |
|
95 |
<scope>compile</scope> |
|
96 |
</dependency> |
|
97 |
<dependency> |
|
98 |
<groupId>org.gvsig</groupId> |
|
99 |
<artifactId>org.gvsig.fmap.dal.file.dbf</artifactId> |
|
100 |
<scope>compile</scope> |
|
101 |
</dependency> |
|
102 |
<dependency> |
|
103 |
<groupId>org.gvsig</groupId> |
|
104 |
<artifactId>org.gvsig.utils</artifactId> |
|
105 |
<scope>compile</scope> |
|
106 |
</dependency> |
|
107 |
<dependency> |
|
108 |
<groupId>org.gvsig</groupId> |
|
109 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
110 |
<scope>compile</scope> |
|
111 |
</dependency> |
|
112 |
<dependency> |
|
113 |
<groupId>org.gvsig</groupId> |
|
114 |
<artifactId>org.gvsig.symbology.lib.api</artifactId> |
|
115 |
<scope>compile</scope> |
|
116 |
</dependency> |
|
117 |
<!--<dependency> |
|
118 |
<groupId>org.gvsig</groupId> |
|
119 |
<artifactId>org.gvsig.symbology.lib.impl</artifactId> |
|
120 |
<scope>compile</scope> |
|
121 |
</dependency>--> |
|
122 |
<dependency> |
|
123 |
<groupId>org.gvsig</groupId> |
|
124 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
125 |
<scope>compile</scope> |
|
126 |
</dependency> |
|
127 |
<dependency> |
|
128 |
<groupId>org.gvsig</groupId> |
|
129 |
<artifactId>org.gvsig.ui</artifactId> |
|
130 |
<scope>compile</scope> |
|
131 |
</dependency> |
|
132 |
<dependency> |
|
133 |
<groupId>org.gvsig</groupId> |
|
134 |
<artifactId>org.gvsig.i18n</artifactId> |
|
135 |
<scope>compile</scope> |
|
136 |
</dependency> |
|
137 |
</dependencies> |
|
138 |
</project> |
|
0 | 139 |
org.gvsig.raster/tags/org.gvsig.raster-2.2.59/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.59/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.59/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.59/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.59/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.59/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.59/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultFLyrRaster.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.Dimension; |
|
25 |
import java.awt.Graphics2D; |
|
26 |
import java.awt.Point; |
|
27 |
import java.awt.Rectangle; |
|
28 |
import java.awt.geom.AffineTransform; |
|
29 |
import java.awt.geom.NoninvertibleTransformException; |
|
30 |
import java.awt.geom.Point2D; |
|
31 |
import java.awt.geom.Rectangle2D; |
|
32 |
import java.awt.image.BufferedImage; |
|
33 |
import java.io.File; |
|
34 |
import java.io.IOException; |
|
35 |
import java.net.URI; |
|
36 |
import java.util.ArrayList; |
|
37 |
import java.util.HashMap; |
|
38 |
import java.util.List; |
|
39 |
import java.util.Set; |
|
40 |
|
|
41 |
import org.cresques.cts.IProjection; |
|
42 |
import org.gvsig.compat.print.PrintAttributes; |
|
43 |
import org.gvsig.fmap.crs.CRSFactory; |
|
44 |
import org.gvsig.fmap.dal.DataStore; |
|
45 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
46 |
import org.gvsig.fmap.dal.coverage.RasterLibrary; |
|
47 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
48 |
import org.gvsig.fmap.dal.coverage.RasterManager; |
|
49 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
50 |
import org.gvsig.fmap.dal.coverage.datastruct.ColorItem; |
|
51 |
import org.gvsig.fmap.dal.coverage.datastruct.ColorTableLibrary; |
|
52 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
53 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
|
54 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
55 |
import org.gvsig.fmap.dal.coverage.datastruct.ViewPortData; |
|
56 |
import org.gvsig.fmap.dal.coverage.exception.FileNotOpenException; |
|
57 |
import org.gvsig.fmap.dal.coverage.exception.FilePaletteException; |
|
58 |
import org.gvsig.fmap.dal.coverage.exception.FilterManagerException; |
|
59 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
|
60 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSetViewException; |
|
61 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
62 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
63 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
64 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
65 |
import org.gvsig.fmap.dal.coverage.exception.ROIException; |
|
66 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
67 |
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException; |
|
68 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilter; |
|
69 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
|
70 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
|
71 |
import org.gvsig.fmap.dal.coverage.grid.render.Render; |
|
72 |
import org.gvsig.fmap.dal.coverage.grid.render.VisualPropertyEvent; |
|
73 |
import org.gvsig.fmap.dal.coverage.grid.render.VisualPropertyListener; |
|
74 |
import org.gvsig.fmap.dal.coverage.process.TaskEventManager; |
|
75 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
76 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
77 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterFileStoreParameters; |
|
78 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
|
79 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
80 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
81 |
import org.gvsig.fmap.dal.coverage.store.props.Statistics; |
|
82 |
import org.gvsig.fmap.dal.coverage.util.CRSUtils; |
|
83 |
import org.gvsig.fmap.dal.coverage.util.ColorConversion; |
|
84 |
import org.gvsig.fmap.dal.coverage.util.FileUtils; |
|
85 |
import org.gvsig.fmap.dal.coverage.util.Historical; |
|
86 |
import org.gvsig.fmap.dal.coverage.util.MathUtils; |
|
87 |
import org.gvsig.fmap.dal.coverage.util.ProviderServices; |
|
88 |
import org.gvsig.fmap.dal.coverage.util.RasterUtils; |
|
89 |
import org.gvsig.fmap.dal.exception.CloseException; |
|
90 |
import org.gvsig.fmap.dal.exception.DataException; |
|
91 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
92 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
93 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProviderServices; |
|
94 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
95 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
96 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
97 |
import org.gvsig.fmap.geom.GeometryManager; |
|
98 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
99 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
100 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
101 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
|
102 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
|
103 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
104 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
105 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
106 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
107 |
import org.gvsig.fmap.mapcontext.exceptions.ReloadLayerException; |
|
108 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
109 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
|
110 |
import org.gvsig.fmap.mapcontext.layers.LayerChangeSupport; |
|
111 |
import org.gvsig.fmap.mapcontext.layers.LayerListener; |
|
112 |
import org.gvsig.fmap.mapcontext.layers.Tiling; |
|
113 |
import org.gvsig.fmap.mapcontext.layers.operations.Classifiable; |
|
114 |
import org.gvsig.fmap.mapcontext.layers.operations.InfoByPoint; |
|
115 |
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer; |
|
116 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
117 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.listeners.LegendListener; |
|
118 |
import org.gvsig.raster.fmap.legend.ColorTableLegend; |
|
119 |
import org.gvsig.raster.roi.ROI; |
|
120 |
import org.gvsig.raster.util.RasterNotLoadException; |
|
121 |
import org.gvsig.tools.ToolsLocator; |
|
122 |
import org.gvsig.tools.dynobject.DynClass; |
|
123 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
124 |
import org.gvsig.tools.dynobject.DynObjectSet; |
|
125 |
import org.gvsig.tools.dynobject.DynStruct; |
|
126 |
import org.gvsig.tools.exception.BaseException; |
|
127 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
128 |
import org.gvsig.tools.persistence.PersistentState; |
|
129 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
130 |
import org.gvsig.tools.persistence.exception.PersistenceRuntimeException; |
|
131 |
import org.gvsig.tools.task.Cancellable; |
|
132 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
133 |
import org.gvsig.tools.task.TaskStatusManager; |
|
134 |
import org.gvsig.tools.task.impl.BaseTaskStatus; |
|
135 |
import org.slf4j.Logger; |
|
136 |
import org.slf4j.LoggerFactory; |
|
137 |
|
|
138 |
/** |
|
139 |
* Raster layer |
|
140 |
* |
|
141 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
142 |
*/ |
|
143 |
@SuppressWarnings("deprecation") |
|
144 |
public class DefaultFLyrRaster extends FLyrDefault implements FLyrRaster, Multiresolution, InfoByPoint, Classifiable, |
|
145 |
IRasterLayerActions, ILayerState, VisualPropertyListener, SingleLayer { |
|
146 |
|
|
147 |
private static final Logger LOG = LoggerFactory.getLogger(DefaultFLyrRaster.class); |
|
148 |
|
|
149 |
public static final String PERSISTENT_NAME = "FLyrRasterSE_Persistent"; |
|
150 |
public static final String PERSISTENT_DESCRIPTION = "FLyrRasterSE Persistent"; |
|
151 |
private RasterManager rManager = RasterLocator.getManager(); |
|
152 |
private boolean mustTileDraw = false; |
|
153 |
private boolean mustTilePrint = true; |
|
154 |
private int maxTileDrawWidth = 200; |
|
155 |
private int maxTileDrawHeight = 200; |
|
156 |
private int maxTilePrintWidth = 1500; |
|
157 |
private int maxTilePrintHeight = 1500; |
|
158 |
private boolean firstLoad = false; |
|
159 |
private boolean removeRasterFlag = true; |
|
160 |
protected RasterDataStore dataStore = null; |
|
161 |
protected Render render = null; |
|
162 |
private int posX = 0; |
|
163 |
private int posY = 0; |
|
164 |
private double posXWC = 0; |
|
165 |
private int posYWC = 0; |
|
166 |
private int r = 0; |
|
167 |
private int g = 0; |
|
168 |
private int b = 0; |
|
169 |
private LayerChangeSupport layerChangeSupport = new LayerChangeSupport(); |
|
170 |
private FLyrState state = new FLyrState(); |
|
171 |
protected ILegend lastLegend = null; |
|
172 |
protected ColorTable colorTableLoadedFromProject = null; |
|
173 |
protected boolean loadedFromProject = false; |
|
174 |
private RasterDrawStrategy strategy = null; |
|
175 |
static private IConfiguration configuration = new DefaultLayerConfiguration(); |
|
176 |
protected int zoomLevel = 1; |
|
177 |
public boolean recalcLevel = true; |
|
178 |
private URI uri = null; |
|
179 |
|
|
180 |
private static GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
181 |
private static final Logger logger = LoggerFactory.getLogger(DefaultFLyrRaster.class); |
|
182 |
protected FileUtils fileUtil = RasterLocator.getManager().getFileUtils(); |
|
183 |
protected RasterUtils rasterUtil = RasterLocator.getManager().getRasterUtils(); |
|
184 |
protected CRSUtils crsUtil = RasterLocator.getManager().getCRSUtils(); |
|
185 |
protected MathUtils mathUtil = RasterLocator.getManager().getMathUtils(); |
|
186 |
|
|
187 |
public class RasterTaskStatus extends BaseTaskStatus { |
|
188 |
Cancellable c = null; |
|
189 |
|
|
190 |
public RasterTaskStatus(String tittle, Cancellable c) { |
|
191 |
super(tittle); |
|
192 |
this.c = c; |
|
193 |
} |
|
194 |
|
|
195 |
public boolean isCancellationRequested() { |
|
196 |
if(c != null) |
|
197 |
return this.c.isCanceled(); |
|
198 |
return false; |
|
199 |
} |
|
200 |
|
|
201 |
public void cancelRequest() { |
|
202 |
if(c != null) |
|
203 |
this.c.setCanceled(true); |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* Lista de transformaciones afines que son aplicadas. Esta lista es |
|
209 |
* simplemente un historico que no se utiliza. Es posible utilizarlo para |
|
210 |
* recuperar transformaciones anteriores. |
|
211 |
*/ |
|
212 |
private Historical affineTransformList = null; |
|
213 |
protected String readingData = null; |
|
214 |
//It is set to true if the method init has been called at least once |
|
215 |
private boolean layerInitialize = false; |
|
216 |
|
|
217 |
public DefaultFLyrRaster() { |
|
218 |
affineTransformList = rManager.createHistoricalService(); |
|
219 |
} |
|
220 |
|
|
221 |
public static void registerDynClass() { |
|
222 |
DynObjectManager manager = ToolsLocator.getDynObjectManager(); |
|
223 |
DynClass dynClass = manager.add("RasterInfo", "Raster layer Info by point"); |
|
224 |
dynClass.setNamespace("InfoByPoint"); |
|
225 |
dynClass.addDynFieldString("File"); |
|
226 |
dynClass.addDynFieldString("View Point"); |
|
227 |
dynClass.addDynFieldString("Pixel Point"); |
|
228 |
dynClass.addDynFieldString("RGB"); |
|
229 |
dynClass.addDynFieldString("CMYK"); |
|
230 |
dynClass.addDynFieldString("HSL"); |
|
231 |
dynClass.addDynFieldString("Band Value"); |
|
232 |
dynClass.addDynFieldString("World Point"); |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Builds a new raster layer |
|
237 |
* @param fileName |
|
238 |
* @return |
|
239 |
* @throws RasterNotLoadException |
|
240 |
* @throws LoadLayerException |
|
241 |
*/ |
|
242 |
public static DefaultFLyrRaster createLayer(String layerName, File file) throws LoadLayerException { |
|
243 |
ProviderServices provServ = RasterLocator.getManager().getProviderServices(); |
|
244 |
RasterDataParameters storeParameters = provServ.createParameters(file.getName()); |
|
245 |
storeParameters.setURI(file.toURI()); |
|
246 |
|
|
247 |
MapContextManager mcm = MapContextLocator.getMapContextManager(); |
|
248 |
DefaultFLyrRaster lyr = (DefaultFLyrRaster) mcm.createLayer(layerName, storeParameters); |
|
249 |
|
|
250 |
return lyr; |
|
251 |
} |
|
252 |
|
|
253 |
public void setName(String name) { |
|
254 |
super.setName(name); |
|
255 |
|
|
256 |
//Si la capa tiene nombre acivamos el estado awake |
|
257 |
if(name != null) |
|
258 |
try { |
|
259 |
if(isClosed()) |
|
260 |
enableAwake(); |
|
261 |
} catch (NotAvailableStateException e) { |
|
262 |
logger.error("Fallo el estado de open. Closed=" + isClosed() + " Active=" + isOpen(), this, e); |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
public void wakeUp(){ |
|
267 |
try { |
|
268 |
reload(); |
|
269 |
enableAwake(); |
|
270 |
} catch (ReloadLayerException | NotAvailableStateException e) { |
|
271 |
// No se ha podido recuperar la capa con exito |
|
272 |
} |
|
273 |
} |
|
274 |
|
|
275 |
public void load() throws LoadLayerException { |
|
276 |
if (isStopped() || getDataStore() == null) |
|
277 |
return; |
|
278 |
|
|
279 |
enableStopped(); // Paramos la capa mientras se hace un load |
|
280 |
|
|
281 |
boolean test = false; |
|
282 |
DataStoreParameters params = getDataStore().getParameters(); |
|
283 |
DataStoreParameters p = params; |
|
284 |
if (params != null) { |
|
285 |
if(params instanceof TileDataParameters) { |
|
286 |
uri = ((RasterDataParameters)params).getURI(); |
|
287 |
if(uri == null) |
|
288 |
p = (DataStoreParameters)((TileDataParameters)params).getDataParameters(); |
|
289 |
} |
|
290 |
if(uri == null) { |
|
291 |
if(params instanceof RasterDataParameters) |
|
292 |
uri = ((RasterDataParameters)p).getURI(); |
|
293 |
} |
|
294 |
} |
|
295 |
|
|
296 |
try { |
|
297 |
if(!getDataStore().isOpen()) |
|
298 |
dataStore = rManager.getProviderServices().open(params); |
|
299 |
else |
|
300 |
dataStore.reload(); |
|
301 |
} catch (NotSupportedExtensionException e) { |
|
302 |
throw new LoadLayerException(this.getName()); |
|
303 |
} catch (RasterDriverException e) { |
|
304 |
throw new LoadLayerException(this.getName()); |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
public void setLayerInitialized(boolean initialized) { |
|
309 |
layerInitialize = initialized; |
|
310 |
} |
|
311 |
|
|
312 |
/** |
|
313 |
* Acciones de inicializaci?n despu?s de que la fuente de datos |
|
314 |
* de la capa est? asignada. |
|
315 |
* @throws FilePaletteException |
|
316 |
*/ |
|
317 |
public void init() throws LoadLayerException, FilePaletteException { |
|
318 |
layerInitialize = true; |
|
319 |
|
|
320 |
if (getDataStore() == null) |
|
321 |
throw new LoadLayerException("Formato no valido", new IOException()); |
|
322 |
|
|
323 |
render = getDataStore().getRender(); |
|
324 |
render.addVisualPropertyListener(this); |
|
325 |
initFilters(); |
|
326 |
|
|
327 |
//Inicializaci?n del historico de transformaciones |
|
328 |
affineTransformList.clear(); |
|
329 |
affineTransformList.add(this.getAffineTransform()); |
|
330 |
|
|
331 |
try { |
|
332 |
if(!isOpen()) |
|
333 |
enableOpen(); |
|
334 |
} catch (NotAvailableStateException e) { |
|
335 |
throw new LoadLayerException("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), e); |
|
336 |
} |
|
337 |
} |
|
338 |
|
|
339 |
public IProjection readProjection() throws RasterDriverException { |
|
340 |
try { |
|
341 |
crsUtil.setCRSFactory(CRSFactory.cp); |
|
342 |
if( getDataStore() == null ) |
|
343 |
return null; |
|
344 |
return crsUtil.convertWktToIProjection(getDataStore().getWktProjection()); |
|
345 |
} catch (Exception e) { |
|
346 |
throw new RasterDriverException("Problems converting from WKT to IProjection", e); |
|
347 |
} catch (Error e) { |
|
348 |
e.printStackTrace(); |
|
349 |
return null; |
|
350 |
} |
|
351 |
} |
|
352 |
|
|
353 |
/** |
|
354 |
* Crea el objeto renderizador de raster |
|
355 |
* @return Rendering |
|
356 |
*/ |
|
357 |
public Render getRender() { |
|
358 |
if (render == null) { |
|
359 |
if(getDataStore() != null) { |
|
360 |
render = getDataStore().getRender(); |
|
361 |
render.addVisualPropertyListener(this); |
|
362 |
} |
|
363 |
} |
|
364 |
return render; |
|
365 |
} |
|
366 |
|
|
367 |
public URI getURI() { |
|
368 |
return uri; |
|
369 |
} |
|
370 |
|
|
371 |
public void setNoDataTransparent(boolean t) { |
|
372 |
getNoDataValue().setNoDataTransparent(t); |
|
373 |
if(getRender().getRenderingTransparency() != null) { |
|
374 |
getRender().getRenderingTransparency().setNoData(getDataStore().getNoDataValue()); |
|
375 |
getRender().getRenderingTransparency().activeTransparency(); |
|
376 |
} |
|
377 |
} |
|
378 |
|
|
379 |
/** |
|
380 |
* Initializes the filter list to render this raster layer |
|
381 |
* @throws FilePaletteException |
|
382 |
*/ |
|
383 |
protected void initFilters() throws FilePaletteException { |
|
384 |
if(getDataType() == null) |
|
385 |
return; |
|
386 |
|
|
387 |
RasterFilterList filterList = rManager.createEmptyFilterList(getDataType()[0]); |
|
388 |
if(loadedFromProject) { |
|
389 |
filterList = getDataStore().getRender().getFilterList(); |
|
390 |
} |
|
391 |
|
|
392 |
if(getDataStore() == null) |
|
393 |
return; |
|
394 |
|
|
395 |
if(getDataStore().getNoDataValue() != null) { |
|
396 |
getDataStore().getNoDataValue().load(); |
|
397 |
} |
|
398 |
|
|
399 |
filterList.setInitDataType(getDataType()[0]); |
|
400 |
|
|
401 |
// Quitamos la leyenda |
|
402 |
lastLegend = null; |
|
403 |
|
|
404 |
try { |
|
405 |
//Si en la carga del proyecto se carg? una tabla de color asignamos esta |
|
406 |
if(colorTableLoadedFromProject != null) { |
|
407 |
setLastLegend(colorTableLoadedFromProject); |
|
408 |
RasterFilterListManager colorTableManager = filterList.getManagerByID("ColorTable"); |
|
409 |
Params params = filterList.createEmptyFilterParams(); |
|
410 |
params.setParam("colorTable", colorTableLoadedFromProject); |
|
411 |
colorTableManager.addFilter(params); |
|
412 |
} else |
|
413 |
//sino ponemos la tabla asociada al raster |
|
414 |
if (getDataStore().getColorTable() != null) { |
|
415 |
ColorTable table = getDataStore().getColorTable(); |
|
416 |
setLastLegend(table); |
|
417 |
RasterFilterListManager colorTableManager = filterList.getManagerByID("ColorTable"); |
|
418 |
Params params = filterList.createEmptyFilterParams(); |
|
419 |
params.setParam("colorTable", table); |
|
420 |
colorTableManager.addFilter(params); |
|
421 |
} else //sino hace lo que dice en las preferencias |
|
422 |
if(getDataStore().needEnhanced() || |
|
423 |
(loadedFromProject && filterList.get("enhanced_stretch") != null)) |
|
424 |
loadEnhancedOrColorTable(filterList); |
|
425 |
colorTableLoadedFromProject = null; |
|
426 |
|
|
427 |
getRender().setFilterList(filterList); |
|
428 |
// Inicializo la transparencia para el render |
|
429 |
/*if(!loadedFromProject) { |
|
430 |
getRender().setLastTransparency(getDataStore().getTransparency().cloneTransparency()); |
|
431 |
}*/ |
|
432 |
loadedFromProject = false; |
|
433 |
} catch (FilterTypeException e) { |
|
434 |
//Ha habido un error en la asignaci?n de filtros por los que no se a?ade ninguno. |
|
435 |
logger.error("Error a?adiendo filtros en la inicializaci?n de capa " + this.getName() + " Datatype=" + this.getDataType(), null, e); |
|
436 |
} catch (FilterManagerException e) { |
|
437 |
//Ha habido un error en la asignaci?n de filtros por los que no se a?ade ninguno. |
|
438 |
logger.error("Error a?adiendo filtros en la inicializaci?n de capa " + this.getName() + " Datatype=" + this.getDataType(), null, e); |
|
439 |
} |
|
440 |
} |
|
441 |
|
|
442 |
/** |
|
443 |
* Mira la configuracion para saber si debe cargar un realce o una tabla |
|
444 |
* de color por defecto |
|
445 |
* @param filterManager |
|
446 |
* @throws FilterTypeException |
|
447 |
* @throws FilePaletteException |
|
448 |
*/ |
|
449 |
private void loadEnhancedOrColorTable(RasterFilterList filterList) throws FilterTypeException, FilterManagerException, FilePaletteException { |
|
450 |
String colorTableName = null; |
|
451 |
if(configuration != null) |
|
452 |
colorTableName = configuration.getValueString("loadlayer_usecolortable", (String) null); |
|
453 |
|
|
454 |
String palettesPath = System.getProperty("user.home") + |
|
455 |
File.separator + |
|
456 |
"gvSIG" + // PluginServices.getArguments()[0] + |
|
457 |
File.separator + "colortable"; |
|
458 |
|
|
459 |
Statistics stats = getDataStore().getStatistics(); |
|
460 |
ColorTableLibrary colorTableLibrary = rManager.getDataStructFactory().getColorTableLibrary(); |
|
461 |
|
|
462 |
if (colorTableName != null) |
|
463 |
try { |
|
464 |
stats.calculate(RasterLibrary.statisticsScale); |
|
465 |
if (getDataStore().getBandCount() == 1) { |
|
466 |
ArrayList<String> fileList = colorTableLibrary.getPaletteFileList(palettesPath); |
|
467 |
for (int i = 0; i < fileList.size(); i++) { |
|
468 |
ArrayList<ColorItem> paletteItems = new ArrayList<ColorItem>(); |
|
469 |
String paletteName = colorTableLibrary.loadPalette(palettesPath, (String) fileList.get(i), paletteItems); |
|
470 |
if (paletteName.equals(colorTableName)) { |
|
471 |
if (paletteItems.size() <= 0) |
|
472 |
continue; |
|
473 |
|
|
474 |
ColorTable colorTable = colorTableLibrary.createColorTable(); |
|
475 |
colorTable.setName(paletteName); |
|
476 |
colorTable.createPaletteFromColorItems(paletteItems, true); |
|
477 |
colorTable.setInterpolated(true); |
|
478 |
|
|
479 |
colorTable.createColorTableInRange(stats.getMinimun(), stats.getMaximun(), true); |
|
480 |
|
|
481 |
setLastLegend(colorTable); |
|
482 |
|
|
483 |
RasterFilterListManager colorTableManager = filterList.getManagerByID("ColorTable"); |
|
484 |
Params params = filterList.createEmptyFilterParams(); |
|
485 |
params.setParam("colorTable", colorTable); |
|
486 |
colorTableManager.addFilter(params); |
|
487 |
return; |
|
488 |
} |
|
489 |
} |
|
490 |
} |
|
491 |
} catch (FileNotOpenException e) { |
|
492 |
// No podemos aplicar el filtro |
|
493 |
} catch (RasterDriverException e) { |
|
494 |
// No podemos aplicar el filtro |
|
495 |
} catch (ProcessInterruptedException e) { |
|
496 |
// El usuario ha cancelado el proceso |
|
497 |
} |
|
498 |
|
|
499 |
RasterFilterListManager enhancementManager = filterList.getManagerByID("EnhancementStretch"); |
|
500 |
RasterFilter f = filterList.getByName("enhanced_stretch"); |
|
501 |
if(f == null) { |
|
502 |
Params params = filterList.createEmptyFilterParams(); |
|
503 |
params.setParam("stats", stats); |
|
504 |
params.setParam("remove", new Boolean(false)); |
|
505 |
params.setParam("renderBands", getRender().getRenderColorInterpretation().buildRenderBands()); |
|
506 |
params.setParam("stretchs", null);//coge el LinearStretchParams por defecto |
|
507 |
params.setParam("rgb", new Boolean(true)); |
|
508 |
enhancementManager.addFilter(params); |
|
509 |
} |
|
510 |
} |
|
511 |
|
|
512 |
public boolean isReproyectable() { |
|
513 |
if (getDataStore() == null) |
|
514 |
return false; |
|
515 |
return getDataStore().isReproyectable(); |
|
516 |
} |
|
517 |
|
|
518 |
/** |
|
519 |
* @throws ReadException |
|
520 |
* @throws ReadDriverException |
|
521 |
* @see com.iver.cit.gvsig.fmap.layers.LayerOperations#draw(java.awt.image.BufferedImage, |
|
522 |
* java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, |
|
523 |
* com.iver.utiles.swing.threads.Cancellable) |
|
524 |
*/ |
|
525 |
public void draw(BufferedImage image, Graphics2D g, ViewPort vp, Cancellable cancel, double scale) throws ReadException { |
|
526 |
TaskEventManager task = rManager.getRasterTask(); |
|
527 |
task.setEvent(null); |
|
528 |
|
|
529 |
if(!layerInitialize) { |
|
530 |
if (getDataStore() != null) |
|
531 |
try { |
|
532 |
this.init(); |
|
533 |
} catch (FilePaletteException e) { |
|
534 |
throw new ReadException("Error in raster legend", e); |
|
535 |
} catch (LoadLayerException e) { |
|
536 |
throw new ReadException("Error initializing the layer", e); |
|
537 |
} |
|
538 |
} |
|
539 |
|
|
540 |
try { |
|
541 |
if (!isOpen()) |
|
542 |
return; |
|
543 |
|
|
544 |
enableStopped(); |
|
545 |
// callLegendChanged(null); |
|
546 |
|
|
547 |
//Solo el zoom normal recalcula el nivel dependiendo de la escala. El zoom por niveles asigna |
|
548 |
//?l el nivel de zoom por lo que no habr? que recalcularlo. |
|
549 |
if(recalcLevel) { |
|
550 |
double pixelSize = vp.getEnvelope().getLength(0) / (double)vp.getImageWidth(); |
|
551 |
zoomLevel = getDataStore().getNearestLevel(pixelSize); |
|
552 |
} |
|
553 |
recalcLevel = true; |
|
554 |
|
|
555 |
strategy = new RasterDrawStrategy(getMapContext(), this); |
|
556 |
strategy.stackStrategy(); |
|
557 |
HashMap<DefaultFLyrRaster, Boolean> tStr = strategy.getStrategy(); |
|
558 |
if (tStr != null && |
Also available in: Unified diff