Revision 2416
org.gvsig.raster/tags/gvSIGv2_1_0_Build_2218/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/gvSIGv2_1_0_Build_2218/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/gvSIGv2_1_0_Build_2218/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/gvSIGv2_1_0_Build_2218/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/gvSIGv2_1_0_Build_2218/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/GeorefPanListenerImpl.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.Image; |
|
25 |
import java.awt.geom.Point2D; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
|
|
28 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
29 |
import org.gvsig.fmap.geom.GeometryManager; |
|
30 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
31 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
32 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
33 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
34 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
35 |
import org.gvsig.fmap.mapcontrol.tools.Events.MoveEvent; |
|
36 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PanListener; |
|
37 |
import org.slf4j.Logger; |
|
38 |
import org.slf4j.LoggerFactory; |
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
/** |
|
43 |
* Implementaci?n de la interfaz PanListener como herramienta para realizar el |
|
44 |
* Pan. |
|
45 |
* |
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
47 |
*/ |
|
48 |
public class GeorefPanListenerImpl implements PanListener { |
|
49 |
private static final GeometryManager geomManager = GeometryLocator.getGeometryManager(); |
|
50 |
private static final Logger logger = LoggerFactory.getLogger(GeorefPanListenerImpl.class); |
|
51 |
// private final Image ipan = new ImageIcon(MapControl.class.getResource( |
|
52 |
// "images/CruxCursor.png")).getImage(); |
|
53 |
// private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(ipan, |
|
54 |
// new Point(16, 16), ""); |
|
55 |
private MapControl mapControl; |
|
56 |
private DefaultFLyrRaster lyrRaster = null; |
|
57 |
private String pathToFile = null; |
|
58 |
|
|
59 |
|
|
60 |
/** |
|
61 |
* Crea un nuevo RectangleListenerImpl. |
|
62 |
* |
|
63 |
* @param mapControl MapControl. |
|
64 |
*/ |
|
65 |
public GeorefPanListenerImpl(MapControl mapControl) { |
|
66 |
this.mapControl = mapControl; |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PanListener#move(java.awt.geom.Point2D, |
|
71 |
* java.awt.geom.Point2D) |
|
72 |
*/ |
|
73 |
@SuppressWarnings("deprecation") |
|
74 |
public void move(MoveEvent event) { |
|
75 |
ViewPort vp = mapControl.getMapContext().getViewPort(); |
|
76 |
|
|
77 |
Point2D from = vp.toMapPoint(event.getFrom()); |
|
78 |
Point2D to = vp.toMapPoint(event.getTo()); |
|
79 |
|
|
80 |
Rectangle2D.Double r = new Rectangle2D.Double(); |
|
81 |
Rectangle2D extent = vp.getExtent(); |
|
82 |
r.x = extent.getX() - (to.getX() - from.getX()); |
|
83 |
r.y = extent.getY() - (to.getY() - from.getY()); |
|
84 |
r.width = extent.getWidth(); |
|
85 |
r.height = extent.getHeight(); |
|
86 |
Envelope env; |
|
87 |
try { |
|
88 |
env = geomManager.createEnvelope(r.getMinX(), r.getMinY(), r |
|
89 |
.getMaxX(), r.getMaxY(), SUBTYPES.GEOM2D); |
|
90 |
vp.setEnvelope(env); |
|
91 |
} catch (CreateEnvelopeException e) { |
|
92 |
logger.error("Error creating the envelope", e); |
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
// mapControl.drawMap(); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing() |
|
102 |
*/ |
|
103 |
public boolean cancelDrawing() { |
|
104 |
return true; |
|
105 |
} |
|
106 |
|
|
107 |
/** |
|
108 |
* @return Returns the lyrRaster. |
|
109 |
*/ |
|
110 |
public DefaultFLyrRaster getLyrRaster() { |
|
111 |
return lyrRaster; |
|
112 |
} |
|
113 |
|
|
114 |
/** |
|
115 |
* @param lyrRaster The lyrRaster to set. |
|
116 |
*/ |
|
117 |
public void setLyrRaster(DefaultFLyrRaster lyrRaster) { |
|
118 |
this.lyrRaster = lyrRaster; |
|
119 |
} |
|
120 |
|
|
121 |
/** |
|
122 |
* @return Returns the pathToFile. |
|
123 |
*/ |
|
124 |
public String getPathToFile() { |
|
125 |
return pathToFile; |
|
126 |
} |
|
127 |
|
|
128 |
/** |
|
129 |
* @param pathToFile The pathToFile to set. |
|
130 |
*/ |
|
131 |
public void setPathToFile(String pathToFile) { |
|
132 |
this.pathToFile = pathToFile; |
|
133 |
} |
|
134 |
|
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
137 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getImageCursor() |
|
138 |
*/ |
|
139 |
public Image getImageCursor() { |
|
140 |
return null; |
|
141 |
} |
|
142 |
} |
|
0 | 143 |
org.gvsig.raster/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/RasterDrawStrategy.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.fmap.layers; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.HashMap; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
29 |
import org.gvsig.fmap.dal.coverage.grid.render.Render; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
32 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
33 |
|
|
34 |
/** |
|
35 |
* Aplica estrategias de dibujado para las capas raster. Hace que las |
|
36 |
* capas que est?n ocultas por otras no sean dibujadas. Esta estrategia tiene que ser |
|
37 |
* aplicada a capas raster de FMap por falta de eficiencia en el dibujado. Esta clase |
|
38 |
* es totalmente dependiente de FMap y puede ser eliminada en caso de que este no exita. |
|
39 |
* 28/11/2007 |
|
40 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
41 |
*/ |
|
42 |
public class RasterDrawStrategy { |
|
43 |
|
|
44 |
/** |
|
45 |
* Cada mapContext existente lleva asociadad una estrategia de dibujado |
|
46 |
*/ |
|
47 |
public static HashMap<MapContext, HashMap<DefaultFLyrRaster, Boolean>> |
|
48 |
mapContextStrategy = new HashMap<MapContext, HashMap<DefaultFLyrRaster, Boolean>> (); |
|
49 |
|
|
50 |
private MapContext mapContext = null; |
|
51 |
private DefaultFLyrRaster lyrRaster = null; |
|
52 |
|
|
53 |
/** |
|
54 |
* Estructura de datos para almacenar la asociaci?n entre el extent de una capa |
|
55 |
* y su informaci?n de transparencia. Esta es necesaria para la comprobaci?n de si la |
|
56 |
* capa con la que se est? intersectando tiene transparencia o no la tiene. Con esto |
|
57 |
* se puede decidir si dibujar la capa actual o no. |
|
58 |
* 16/06/2008 |
|
59 |
* @author Nacho Brodin nachobrodin@gmail.com |
|
60 |
*/ |
|
61 |
public class LayerIntersection { |
|
62 |
public Extent extent = null; |
|
63 |
public boolean hasTransparency = false; |
|
64 |
/** |
|
65 |
* Constructor. Asigna el Extent y la informaci?n de transparencia |
|
66 |
* @param ext Extent |
|
67 |
* @param transp Transparencia |
|
68 |
*/ |
|
69 |
public LayerIntersection(Extent ext, boolean transp) { |
|
70 |
this.extent = ext; |
|
71 |
this.hasTransparency = transp; |
|
72 |
} |
|
73 |
} |
|
74 |
/** |
|
75 |
* Al constructor le pasamos el contexto de dibujado para la toma de decisi?n. |
|
76 |
* @param mapContext Context |
|
77 |
* @throws ExpansionFileReadException |
|
78 |
* @throws ReadDriverException |
|
79 |
*/ |
|
80 |
public RasterDrawStrategy(MapContext mapContext, DefaultFLyrRaster lyrRaster) { |
|
81 |
this.mapContext = mapContext; |
|
82 |
this.lyrRaster = lyrRaster; |
|
83 |
} |
|
84 |
|
|
85 |
/** |
|
86 |
* <P> |
|
87 |
* Estrategia de dibujado para las capas raster que hace que si |
|
88 |
* una capa est? oculta completamente por otra que no tiene transparencias entonces |
|
89 |
* esta no ser? dibujada. |
|
90 |
* </P> |
|
91 |
* <P> |
|
92 |
* La estrategia la calcula solo la primera capa raster que aparezca. El resto |
|
93 |
* de las capas la preguntaran a esta. |
|
94 |
* </P> |
|
95 |
* <P> |
|
96 |
* <code>Estrategia:</code> |
|
97 |
* Analizamos la lista de capas desde la primera que se dibuja en el TOC hasta la ?ltima |
|
98 |
* <UL> |
|
99 |
* <LI>Si la capa tiene rotaci?n se dibuja siempre.</LI> |
|
100 |
* <LI>Si la capa no est? activa en el TOC no se dibuja nunca</LI> |
|
101 |
* <LI>Si la capa no es transparente y no hay extents en la lista se dibuja y se a?ade el extent a la lista</LI> |
|
102 |
* <LI>Si el extent de la capa intersecta con uno de la lista</LI> |
|
103 |
* </UL> |
|
104 |
* Comprobamos si est? detr?s de un extent de la lista. Si es as? no se dibuja |
|
105 |
* Si no est? est? detr?s de un extent comprobamos si tiene transparencias |
|
106 |
* Si no tiene transparencias a?adimos el extent a la lista |
|
107 |
* </P> |
|
108 |
* @param lyrs |
|
109 |
* @throws ReadDriverException |
|
110 |
* @throws ExpansionFileReadException |
|
111 |
*/ |
|
112 |
public void stackStrategy() { |
|
113 |
if(mapContext == null || lyrRaster == null) |
|
114 |
return; |
|
115 |
|
|
116 |
ArrayList<FLayer> listLayers = new ArrayList<FLayer>(); |
|
117 |
FLayers lyrs = mapContext.getLayers(); |
|
118 |
listLayers = getLayerList(lyrs, listLayers); |
|
119 |
|
|
120 |
ArrayList<LayerIntersection> extentList = new ArrayList<LayerIntersection>(); |
|
121 |
|
|
122 |
//Solo la primera capa calcula la estrategia. Las dem?s se la preguntan a esta. |
|
123 |
|
|
124 |
//Calculamos cual es la primera capa raster de FLayers y contamos cuantas capas raster hay |
|
125 |
int posFirstRasterLayer = 0; |
|
126 |
int nRasterLayers = 0; |
|
127 |
boolean firstTime = true; |
|
128 |
for (int i = 0; i < listLayers.size(); i++) { |
|
129 |
FLayer lyr = (FLayer) listLayers.get(i); |
|
130 |
if(firstTime && lyr instanceof DefaultFLyrRaster && lyr.isVisible()) { |
|
131 |
posFirstRasterLayer = i; |
|
132 |
firstTime = false; |
|
133 |
} |
|
134 |
if(lyr instanceof DefaultFLyrRaster) |
|
135 |
nRasterLayers ++; |
|
136 |
} |
|
137 |
|
|
138 |
//Si hay solo una capa raster no se calcula ninguna estrategia |
|
139 |
if(nRasterLayers == 1) { |
|
140 |
mapContextStrategy.put(mapContext, null); |
|
141 |
return; |
|
142 |
} |
|
143 |
|
|
144 |
//Si no es la primera capa se obtiene la estrategia que calcul? la primera capa |
|
145 |
if(lyrRaster != listLayers.get(posFirstRasterLayer)) { |
|
146 |
if(!(listLayers.get(posFirstRasterLayer) instanceof DefaultFLyrRaster)) |
|
147 |
return; |
|
148 |
mapContextStrategy.put(mapContext, ((DefaultFLyrRaster)listLayers.get(posFirstRasterLayer)).getRasterStrategy()); |
|
149 |
return; |
|
150 |
} |
|
151 |
|
|
152 |
HashMap<DefaultFLyrRaster, Boolean> layersToPaint = new HashMap<DefaultFLyrRaster, Boolean>(); |
|
153 |
|
|
154 |
//Calculo de estrategia. Solo llega aqu? la primera capa. |
|
155 |
//La lista de capas en FLayers est? en orden inverso a lo que aparece en el TOC, es decir, la ?ltima capa |
|
156 |
//del TOC es la primera de la lista de FLayers y la primera del TOC es la ?ltima de la lista. |
|
157 |
for (int i = (listLayers.size() - 1); i >= 0; i--) { |
|
158 |
FLayer lyr = (FLayer) listLayers.get(i); |
|
159 |
|
|
160 |
if (!(lyr instanceof DefaultFLyrRaster)) |
|
161 |
continue; |
|
162 |
|
|
163 |
DefaultFLyrRaster rLyr = ((DefaultFLyrRaster)lyr); |
|
164 |
|
|
165 |
if(rLyr.getRender() == null || rLyr.getRender().getFilterList() == null || rLyr.getFullEnvelope() == null) |
|
166 |
continue; |
|
167 |
|
|
168 |
//Si no est? activa y/o visible no se dibuja nunca |
|
169 |
if(!rLyr.isVisible()) { |
|
170 |
layersToPaint.put(rLyr, new Boolean(false)); |
|
171 |
continue; |
|
172 |
} |
|
173 |
|
|
174 |
//Si tiene rotaci?n se dibuja siempre |
|
175 |
if(rLyr.getAffineTransform() != null) { |
|
176 |
if( rLyr.getAffineTransform().getShearX() != 0 || |
|
177 |
rLyr.getAffineTransform().getShearY() != 0) { |
|
178 |
layersToPaint.put(rLyr, new Boolean(true)); |
|
179 |
continue; |
|
180 |
} |
|
181 |
} |
|
182 |
|
|
183 |
//Si es la primera metemos el extent en la lista y se dibuja |
|
184 |
//Si no es la primera y no intersecta con ning?n extent. Metemos el extent y dibujamos |
|
185 |
LayerIntersection li = areIntersecting(extentList, rLyr); |
|
186 |
if((i == (listLayers.size() - 1)) || li == null) { |
|
187 |
boolean colorTableAlpha = false; |
|
188 |
if(rLyr.getRender().getFilterList() != null) { |
|
189 |
Render render = rLyr.getRender(); |
|
190 |
if(render != null) { |
|
191 |
if(render.getColorTable() != null) |
|
192 |
colorTableAlpha = render.getColorTable().hasAlpha(); |
|
193 |
} |
|
194 |
} |
|
195 |
extentList.add(new LayerIntersection(rLyr.getFullRasterExtent(), (rLyr.existsAlphaBand() || rLyr.isTransparent() || colorTableAlpha))); |
|
196 |
layersToPaint.put(rLyr, new Boolean(true)); |
|
197 |
continue; |
|
198 |
} |
|
199 |
|
|
200 |
//Si con la que intersecta no tiene transparencia no se dibuja |
|
201 |
if(li != null && !li.hasTransparency) { |
|
202 |
layersToPaint.put(rLyr, new Boolean(false)); |
|
203 |
continue; |
|
204 |
} |
|
205 |
|
|
206 |
if(!rLyr.isTransparent()) |
|
207 |
li.hasTransparency = false; |
|
208 |
layersToPaint.put(rLyr, new Boolean(true)); |
|
209 |
} |
|
210 |
|
|
211 |
mapContextStrategy.put(mapContext, layersToPaint); |
|
212 |
} |
|
213 |
|
|
214 |
|
|
215 |
/** |
|
216 |
* Obtiene la lista de capas del TOC. Si hay capas agrupadas lo tiene en cuenta y mira |
|
217 |
* dentro de la agrupaci?n. |
|
218 |
* @param srcLyrs |
|
219 |
* @param destLyrs |
|
220 |
* @return |
|
221 |
*/ |
|
222 |
public static ArrayList<FLayer> getLayerList(FLayers srcLyrs, ArrayList<FLayer> destLyrs) { |
|
223 |
for (int i = 0; i < srcLyrs.getLayersCount(); i++) { |
|
224 |
if(srcLyrs.getLayer(i) instanceof DefaultFLyrRaster) |
|
225 |
destLyrs.add(srcLyrs.getLayer(i)); |
|
226 |
if(srcLyrs.getLayer(i) instanceof FLayers) |
|
227 |
destLyrs = getLayerList((FLayers)srcLyrs.getLayer(i), destLyrs); |
|
228 |
} |
|
229 |
return destLyrs; |
|
230 |
} |
|
231 |
|
|
232 |
/** |
|
233 |
* Comprueba si la capa que se pasa por par?metro est? oculta por alguno |
|
234 |
* de los extent de la lista |
|
235 |
* @param extentList Lista de extensiones |
|
236 |
* @param lyr Capa raster |
|
237 |
* @return |
|
238 |
*/ |
|
239 |
private LayerIntersection areIntersecting(ArrayList<LayerIntersection> extentList, DefaultFLyrRaster lyr) { |
|
240 |
for (int i = 0; i < extentList.size(); i++) { |
|
241 |
Extent ex = lyr.getFullRasterExtent(); |
|
242 |
Extent ex1 = ((LayerIntersection)extentList.get(i)).extent; |
|
243 |
if(RasterLocator.getManager().getRasterUtils().isInside(ex, ex1)) |
|
244 |
return ((LayerIntersection)extentList.get(i)); |
|
245 |
} |
|
246 |
return null; |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* Obtiene un TreeMap con la lista de capas que se dibujan. Si se al TreeMap se |
|
251 |
* le pasa como par?metro una capa raster y devuelve null es que no se dibuja. |
|
252 |
* |
|
253 |
* @return TreeMap con la lista de capas a dibujar. |
|
254 |
*/ |
|
255 |
public HashMap<DefaultFLyrRaster, Boolean> getStrategy() { |
|
256 |
return (HashMap<DefaultFLyrRaster, Boolean>)mapContextStrategy.get(mapContext); |
|
257 |
} |
|
258 |
} |
|
0 | 259 |
org.gvsig.raster/tags/gvSIGv2_1_0_Build_2218/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/StatusLayerRaster.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.fmap.layers; |
|
23 |
|
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.List; |
|
26 |
|
|
27 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Params; |
|
29 |
import org.gvsig.fmap.dal.coverage.datastruct.TransparencyRange; |
|
30 |
import org.gvsig.fmap.dal.coverage.exception.FileNotFoundInListException; |
|
31 |
import org.gvsig.fmap.dal.coverage.exception.FilterManagerException; |
|
32 |
import org.gvsig.fmap.dal.coverage.exception.FilterTypeException; |
|
33 |
import org.gvsig.fmap.dal.coverage.exception.InvalidSourceException; |
|
34 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
35 |
import org.gvsig.fmap.dal.coverage.exception.OperationNotSupportedException; |
|
36 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
37 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterList; |
|
38 |
import org.gvsig.fmap.dal.coverage.grid.RasterFilterListManager; |
|
39 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.props.ColorInterpretation; |
|
41 |
import org.gvsig.fmap.dal.coverage.store.props.ColorTable; |
|
42 |
import org.gvsig.fmap.dal.coverage.store.props.Transparency; |
|
43 |
import org.gvsig.tools.ToolsLocator; |
|
44 |
import org.gvsig.tools.dynobject.DynStruct; |
|
45 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
46 |
import org.gvsig.tools.persistence.PersistentState; |
|
47 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
/** |
|
52 |
* Esta clase almacena el estado de un raster en cuanto a las caracteristicas |
|
53 |
* de opacidad, bandas y filtros. Estas caracter?sticas pueden ser salvadas a |
|
54 |
* un xml y recuperadas por la capa a trav?s de las funciones setXMLEntity y |
|
55 |
* getXMLEntity |
|
56 |
* |
|
57 |
* @deprecated |
|
58 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
59 |
*/ |
|
60 |
public class StatusLayerRaster implements IStatusRaster { |
|
61 |
|
|
62 |
public static String defaultClass = "org.gvsig.fmap.raster.layers.StatusLayerRaster"; |
|
63 |
|
|
64 |
//Valor de opacidad global de la imagen |
|
65 |
public int transparency = 255; |
|
66 |
|
|
67 |
//Rangos de transparencia |
|
68 |
public ArrayList<TransparencyRange> |
|
69 |
ranges = new ArrayList<TransparencyRange>(); |
|
70 |
|
|
71 |
//(Selecci?n de bandas)N?mero de banda asignado al Rojo, verde y azul |
|
72 |
public int bandR = 0; |
|
73 |
public int bandG = 1; |
|
74 |
public int bandB = 2; |
|
75 |
|
|
76 |
public List<String> files = new ArrayList<String>(); |
|
77 |
|
|
78 |
//Filtros para poder montar una nueva pila |
|
79 |
public List<String> filters = new ArrayList<String>(); |
|
80 |
private DefaultFLyrRaster layer = null; |
|
81 |
private int alphaBandNumber = -1; |
|
82 |
|
|
83 |
//Utilizado para la persistencia |
|
84 |
private boolean loadClass = false; |
|
85 |
|
|
86 |
public void loadFromState(PersistentState state, DefaultFLyrRaster layer)throws PersistenceException { |
|
87 |
// this.layer = layer; |
|
88 |
// //RECUPERAR PROPIEDADES |
|
89 |
// |
|
90 |
// //Recuperamos las propiedades de los filtros |
|
91 |
// for(int i = 0; i < xml.getPropertyCount(); i++) { |
|
92 |
// if(xml.getPropertyName(i).startsWith("filter.")) |
|
93 |
// filters.add(xml.getPropertyName(i) + "=" + xml.getPropertyValue(i)); |
|
94 |
// } |
|
95 |
// |
|
96 |
// //Rangos de transparencia |
|
97 |
// if (xml.contains("filter.transparency.active") && xml.getBooleanProperty("filter.transparency.active")) { |
|
98 |
// int i = 0; |
|
99 |
// String value = null; |
|
100 |
// while(true) { |
|
101 |
// if(xml.contains("filter.transparency.transparencyRange" + i)) { |
|
102 |
// value = xml.getStringProperty("filter.transparency.transparencyRange" + i); |
|
103 |
// int alpha = 0; |
|
104 |
// if(value.indexOf("@") != 0) { |
|
105 |
// try { |
|
106 |
// alpha = Integer.parseInt(value.substring(value.indexOf("@") + 1, value.length())); |
|
107 |
// } catch (NumberFormatException e) { |
|
108 |
// alpha = 0; |
|
109 |
// } |
|
110 |
// if(value.indexOf("@") != -1) |
|
111 |
// value = value.substring(0, value.indexOf("@")); |
|
112 |
// } |
|
113 |
// TransparencyRange range = new TransparencyRange(value); |
|
114 |
// if(alpha != 0) |
|
115 |
// range.setAlpha(alpha); |
|
116 |
// ranges.add(range); |
|
117 |
// } else |
|
118 |
// break; |
|
119 |
// i ++; |
|
120 |
// } |
|
121 |
// } |
|
122 |
// |
|
123 |
// if(xml.contains("filter.transparency.bandnumber")) |
|
124 |
// alphaBandNumber = xml.getIntProperty("filter.transparency.bandnumber"); |
|
125 |
// |
|
126 |
// if (xml.contains("raster.opacityLevel")) { |
|
127 |
// transparency = xml.getIntProperty("raster.opacityLevel"); |
|
128 |
// //Esto soluciona un problema de compatibilidad entre branch v10 y HEAD. Eliminar en futuras versiones |
|
129 |
// if(nameClass != null && nameClass.compareTo("com.iver.cit.gvsig.fmap.layers.StatusLayerRaster") == 0) |
|
130 |
// transparency = 255 - transparency; |
|
131 |
// } |
|
132 |
// |
|
133 |
// if (xml.contains("raster.bandR")) |
|
134 |
// bandR = xml.getIntProperty("raster.bandR"); |
|
135 |
// |
|
136 |
// if (xml.contains("raster.bandG")) |
|
137 |
// bandG = xml.getIntProperty("raster.bandG"); |
|
138 |
// |
|
139 |
// if (xml.contains("raster.bandB")) |
|
140 |
// bandB = xml.getIntProperty("raster.bandB"); |
|
141 |
// |
|
142 |
// |
|
143 |
// int cont = 0; |
|
144 |
// while(true && cont < 50) { |
|
145 |
// if (xml.contains("raster.file" + cont)) { |
|
146 |
// files.add(xml.getStringProperty("raster.file" + cont)); |
|
147 |
// cont++; |
|
148 |
// }else |
|
149 |
// break; |
|
150 |
// } |
|
151 |
} |
|
152 |
|
|
153 |
|
|
154 |
@SuppressWarnings("unchecked") |
|
155 |
public void loadFromState(PersistentState state) |
|
156 |
throws PersistenceException { |
|
157 |
this.transparency = state.getInt("transparency"); |
|
158 |
this.bandR = state.getInt("bandR"); |
|
159 |
this.bandG = state.getInt("bandG"); |
|
160 |
this.bandB = state.getInt("bandB"); |
|
161 |
this.alphaBandNumber = state.getInt("alphaBandNumber"); |
|
162 |
this.loadClass = state.getBoolean("loadClass"); |
|
163 |
|
|
164 |
this.layer = (DefaultFLyrRaster)state.get("layer"); |
|
165 |
|
|
166 |
this.ranges = new ArrayList(state.getList("ranges")); |
|
167 |
this.files = new ArrayList(state.getList("files")); |
|
168 |
this.filters = new ArrayList(state.getList("filters")); |
|
169 |
} |
|
170 |
|
|
171 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
172 |
state.set("transparency", this.transparency); |
|
173 |
state.set("bandR", this.bandR); |
|
174 |
state.set("bandG", this.bandG); |
|
175 |
state.set("bandB", this.bandB); |
|
176 |
state.set("alphaBandNumber", this.alphaBandNumber); |
|
177 |
state.set("loadClass",this.loadClass); |
|
178 |
state.set("layer", this.layer); |
|
179 |
state.set("ranges", this.ranges); |
|
180 |
state.set("files", this.files); |
|
181 |
state.set("filters",this.filters); |
|
182 |
} |
|
183 |
|
|
184 |
public void setStateProperties(boolean loadClass, DefaultFLyrRaster layer) throws PersistenceException { |
|
185 |
this.layer = layer; |
|
186 |
this.loadClass = loadClass; |
|
187 |
} |
|
188 |
|
|
189 |
public static void registerPersistence() { |
|
190 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
191 |
DynStruct definition = manager.addDefinition(StatusLayerRaster.class, |
|
192 |
"StatusLayerRaster_Persistent", |
|
193 |
"StatusLayerRaster Persistent definition (FIXME loadClass)", null, null); |
|
194 |
definition.addDynFieldInt("transparency"); |
|
195 |
definition.addDynFieldInt("bandR").setMandatory(true); |
|
196 |
definition.addDynFieldInt("bandG").setMandatory(true); |
|
197 |
definition.addDynFieldInt("bandB").setMandatory(true); |
|
198 |
definition.addDynFieldInt("alphaBandNumber"); |
|
199 |
definition.addDynFieldBoolean("loadClass"); |
|
200 |
|
|
201 |
definition.addDynFieldObject("layer") |
|
202 |
.setClassOfValue(DefaultFLyrRaster.class); |
|
203 |
|
|
204 |
definition.addDynFieldList("ranges") |
|
205 |
.setClassOfItems(TransparencyRange.class); |
|
206 |
|
|
207 |
definition.addDynFieldList("files") |
|
208 |
.setClassOfItems(String.class); |
|
209 |
|
|
210 |
definition.addDynFieldList("filters") |
|
211 |
.setClassOfItems(String.class); |
|
212 |
} |
|
213 |
|
|
214 |
public List<String> getFilters() { |
|
215 |
return this.filters; |
|
216 |
} |
|
217 |
|
|
218 |
public void applyStatus(DefaultFLyrRaster layer) throws NotSupportedExtensionException, RasterDriverException, FilterTypeException, FileNotFoundInListException, OperationNotSupportedException, FilterManagerException, InvalidSourceException { |
|
219 |
|
|
220 |
//Eliminamos el fichero inicial y cargamos las bandas si hay para que se carguen |
|
221 |
//en el orden correcto |
|
222 |
if(layer instanceof DefaultFLyrRaster) { |
|
223 |
if(files != null && files.size() != 0){ |
|
224 |
//((FLyrRasterSE)layer).delFile((String)files.get(0)); |
|
225 |
for (int i = 1; i < files.size(); i++) |
|
226 |
((DefaultFLyrRaster)layer).addFile((String)files.get(i)); |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
//Asigna las bandas |
|
231 |
String[] valuesCI = new String[layer.getDataStore().getBandCount()]; |
|
232 |
valuesCI[bandR] = ColorInterpretation.RED_BAND; |
|
233 |
valuesCI[bandG] = ColorInterpretation.GREEN_BAND; |
|
234 |
valuesCI[bandB] = ColorInterpretation.BLUE_BAND; |
|
235 |
ColorInterpretation ci = RasterLocator.getManager().getDataStructFactory().createColorInterpretation(valuesCI); |
|
236 |
if(layer.getRender() != null) |
|
237 |
layer.getRender().setRenderColorInterpretation(ci); |
|
238 |
|
|
239 |
//Asigna la transparencia |
|
240 |
Transparency transp = layer.getRender().getRenderingTransparency(); |
|
241 |
if(transp != null && transparency != 255) { |
|
242 |
transp.setOpacity(transparency); |
|
243 |
transp.activeTransparency(); |
|
244 |
} |
|
245 |
|
|
246 |
//Rangos de transparencia |
|
247 |
if(transp != null && ranges != null) { |
|
248 |
transp.setTransparencyRangeList(ranges); |
|
249 |
transp.activeTransparency(); |
|
250 |
} |
|
251 |
|
|
252 |
//Banda de transparencia |
|
253 |
if(transp != null && alphaBandNumber != -1) { |
|
254 |
transp.setTransparencyBand(alphaBandNumber); |
|
255 |
transp.activeTransparency(); |
|
256 |
} |
|
257 |
|
|
258 |
//Filtros |
|
259 |
/*if (layer.getRender().getFilterList() != null) { |
|
260 |
layer.getRender().getFilterList().createFilterListFromStrings((ArrayList<String>)filters); |
|
261 |
enhancedCompV10((ArrayList<String>)filters, layer); |
|
262 |
//sortFilters(layer.getRenderFilterList()); |
|
263 |
}*/ |
|
264 |
|
|
265 |
//Refrescamos todas las vistas |
|
266 |
layer.getMapContext().invalidate(); |
|
267 |
/*IWindow[] w = PluginServices.getMDIManager().getAllWindows(); |
|
268 |
for (int i = 0; i < w.length; i++) { |
|
269 |
if(w[i] != null && w[i] instanceof AbstractViewPanel) |
|
270 |
((AbstractViewPanel)w[i]).getMapControl().getMapContext().invalidate(); |
|
271 |
}*/ |
|
272 |
} |
|
273 |
|
|
274 |
/** |
|
275 |
* M?todo para mantener la compatibilidad con la v10 del realce. El realce de la v10 no |
|
276 |
* aporta suficiente informaci?n por lo que se a?ade un filtro de realce generico v1.9 |
|
277 |
* @param filterArguments |
|
278 |
* @param layer |
|
279 |
* @param filterListManager |
|
280 |
* @throws FilterTypeException |
|
281 |
* @throws FilterManagerException |
|
282 |
*/ |
|
283 |
public static void enhancedCompV10(ArrayList<String> filterArguments, DefaultFLyrRaster layer) throws FilterTypeException, FilterManagerException { |
|
284 |
RasterFilterList filterList = layer.getRender().getFilterList(); |
|
285 |
filterList.remove("enhanced_stretch"); |
|
286 |
filterList.remove("tailTrim"); |
|
287 |
|
|
288 |
/*boolean removed = false; |
|
289 |
RasterFilterList list = layer.getRender().getFilterList(); |
|
290 |
for (int i = 0; i < list.lenght(); i++) { |
|
291 |
RasterFilter f = list.get(i); |
|
292 |
if(f instanceof TailTrimFilter || f instanceof LinearEnhancementFilter) { |
|
293 |
list.remove(f.getName()); |
|
294 |
removed = true; |
|
295 |
} |
|
296 |
} |
|
297 |
if(removed) |
|
298 |
list.controlTypes();*/ |
|
299 |
|
|
300 |
//Para compatibilidad de realce con proyectos antiguos |
|
301 |
for (int i = 0; i < filterArguments.size(); i++) { |
|
302 |
if(((String)filterArguments.get(i)).startsWith("filter.enhanced.active=true")) { |
|
303 |
RasterFilterListManager enhancementManager = filterList.getManagerByID("EnhancementStretch"); |
|
304 |
Params params = filterList.createEmptyFilterParams(); |
|
305 |
params.setParam("stats", ((RasterDataStore)layer.getDataStore()).getStatistics()); |
|
306 |
params.setParam("remove", new Boolean(false)); |
|
307 |
params.setParam("renderBands", layer.getRender().getRenderColorInterpretation().buildRenderBands()); |
|
308 |
params.setParam("stretchs", null);//coge el LinearStretchParams por defecto |
|
309 |
enhancementManager.addFilter(params); |
|
310 |
} |
|
311 |
} |
|
312 |
} |
|
313 |
|
|
314 |
public int[] getRenderBands() { |
|
315 |
return new int[]{bandR, bandG, bandB}; |
|
316 |
} |
|
317 |
|
|
318 |
public RasterFilterList getFilterList() throws FilterTypeException { |
|
319 |
/*RasterManager rManager = RasterLocator.getManager(); |
|
320 |
try { |
|
321 |
RasterFilterList filterList = layer.getRender().getFilterList(); |
|
322 |
if(filterList != null) |
|
323 |
filterList.createFilterListFromStrings((ArrayList<String>)filters); |
|
324 |
else { |
|
325 |
filterList = rManager.createEmptyFilterList(Buffer.TYPE_BYTE); |
|
326 |
} |
|
327 |
|
|
328 |
return filterList; |
|
329 |
} catch (NullPointerException e) { |
|
330 |
return null; |
|
331 |
}*/ |
|
332 |
return null; |
|
333 |
} |
|
334 |
|
|
335 |
public ColorTable getColorTable() throws FilterTypeException { |
|
336 |
return layer.getRender().getColorTable(); |
|
337 |
} |
|
338 |
|
|
339 |
public List<String> getFilterArguments() { |
|
340 |
return filters; |
|
341 |
} |
|
342 |
|
|
343 |
String nameClass = null; |
|
344 |
/** |
|
345 |
* Asigna el nombre de la clase que se ha leido desde el proyecto |
|
346 |
* @param nameClass |
|
347 |
*/ |
|
348 |
public void setNameClass(String nameClass) { |
|
349 |
this.nameClass = nameClass; |
|
350 |
} |
|
351 |
} |
|
0 | 352 |
org.gvsig.raster/tags/gvSIGv2_1_0_Build_2218/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 |
Also available in: Unified diff