Revision 7271 org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/infobypoint/viewtool/InfoByPixelPointViewTool.java
InfoByPixelPointViewTool.java | ||
---|---|---|
2 | 2 |
* |
3 | 3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
4 | 4 |
* of the Valencian Government (CIT) |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
9 | 9 |
* of the License, or (at your option) any later version. |
10 |
*
|
|
10 |
* |
|
11 | 11 |
* This program is distributed in the hope that it will be useful, |
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
15 |
*
|
|
15 |
* |
|
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 | 19 |
* MA 02110-1301, USA. |
20 |
*
|
|
20 |
* |
|
21 | 21 |
*/ |
22 | 22 |
package org.gvsig.raster.wms.app.wmsclient.infobypoint.viewtool; |
23 | 23 |
|
... | ... | |
51 | 51 |
/** |
52 | 52 |
* Extensi?n de la clase SelectImageListenerImple de FMap. Esta clase permite |
53 | 53 |
* capturar el evento de la selecci?n de un punto RGB sobre la vista |
54 |
*
|
|
54 |
* |
|
55 | 55 |
* 22/02/2008 |
56 | 56 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
57 | 57 |
*/ |
... | ... | |
63 | 63 |
private FLayers layers = null; |
64 | 64 |
private List<String> list = null; |
65 | 65 |
private MainInfoByPointDialog dialog = null; |
66 |
|
|
66 |
|
|
67 | 67 |
/** |
68 | 68 |
* Reference to the <code>MapControl</code> object that uses. |
69 | 69 |
*/ |
70 | 70 |
protected MapControl mapCtrl; |
71 | 71 |
|
72 | 72 |
/** |
73 |
* World equivalent coordinates of the point 2D
|
|
73 |
* World equivalent coordinates of the point 2D |
|
74 | 74 |
*/ |
75 | 75 |
protected Point2D wcPoint = null; |
76 |
|
|
76 |
|
|
77 | 77 |
/** |
78 | 78 |
* Contructor |
79 | 79 |
* @param mapCtrl |
80 | 80 |
*/ |
81 | 81 |
public InfoByPixelPointViewTool( |
82 |
MapControl mapCtrl,
|
|
82 |
MapControl mapCtrl, |
|
83 | 83 |
InfoByPointDataModel model, |
84 | 84 |
MainInfoByPointDialog dialog) { |
85 | 85 |
this.mapCtrl = mapCtrl; |
... | ... | |
100 | 100 |
int r = (value >> 16) & 0xff; |
101 | 101 |
int g = (value >> 8) & 0xff; |
102 | 102 |
int b = value & 0xff; |
103 |
|
|
103 |
|
|
104 | 104 |
double[] cmyk = conv.RGBtoCMYK(r & 0xff, g & 0xff, b & 0xff, 1D); |
105 |
|
|
105 |
|
|
106 | 106 |
double[] hsl = conv.RGBtoHSL(r & 0xff, g & 0xff, b & 0xff); |
107 | 107 |
hsl[0] = (int)(255.0 * hsl[0] / 360.0 + 0.5); |
108 | 108 |
hsl[2] = (int) (hsl[2] * 255. + 0.5); |
109 | 109 |
hsl[1] = (int) (hsl[1] * 255. + 0.5); |
110 |
|
|
110 |
|
|
111 | 111 |
Point2D mapPoint = viewPort.toMapPoint(point2D); |
112 |
|
|
112 |
|
|
113 | 113 |
model.setARGB(r, g, b); |
114 | 114 |
model.setCMYK(cmyk); |
115 | 115 |
model.setHSL(hsl[0], hsl[1], hsl[2]); |
116 | 116 |
model.setViewPoint(point2D.getX(), point2D.getY()); |
117 | 117 |
model.setWorldPoint(mapPoint.getX(), mapPoint.getY()); |
118 |
|
|
118 |
|
|
119 | 119 |
//Raster dependent |
120 |
|
|
120 |
|
|
121 | 121 |
list.clear(); |
122 | 122 |
FLyrWMS selected = null; |
123 | 123 |
for (int i = layers.getLayersCount() - 1; i >= 0; i--) { |
... | ... | |
131 | 131 |
} |
132 | 132 |
} |
133 | 133 |
} |
134 |
|
|
134 |
|
|
135 | 135 |
if(selected != null) { |
136 | 136 |
Point2D rasterPoint = selected.getDataStore().worldToRaster(mapPoint); |
137 | 137 |
model.setNumberOfBands(selected.getDataStore().getBandCount()); |
138 | 138 |
model.setBandValues(getBandValues(selected.getDataStore(), rasterPoint)); |
139 | 139 |
model.setPixelPoint(rasterPoint.getX(), rasterPoint.getY()); |
140 |
|
|
141 |
Point p = new Point(); |
|
142 |
p.setLocation(point2D.getX(), point2D.getY()); |
|
143 |
try { |
|
144 |
DynObjectSetWMSInfo dos = (DynObjectSetWMSInfo)selected.getInfo(p, 0D, null, true); |
|
145 |
String txt = dos.getInfoElement(); |
|
146 |
if(dos.getTypeInfo().compareTo("text/plain") == 0) |
|
147 |
dialog.setWMSInfoText(txt, dos.getTypeInfo()); |
|
148 |
else if(dos.getTypeInfo().compareTo("text/html") == 0) { |
|
149 |
int beginIndex = txt.indexOf("<html"); |
|
150 |
if(beginIndex > 0) |
|
151 |
txt = txt.substring(beginIndex, txt.length()); |
|
152 |
dialog.setWMSInfoText(txt, "text/html"); |
|
153 |
} else if(dos.getTypeInfo().endsWith("vnd.ogc.gml") || dos.getTypeInfo().compareTo("text/xml") == 0) { |
|
154 |
dialog.setWMSInfoText(txt, "text/xml"); |
|
155 |
}else |
|
156 |
dialog.setWMSInfoText(txt, "text/html"); |
|
157 |
|
|
158 |
} catch (LoadLayerException e) { |
|
159 |
e.printStackTrace(); |
|
160 |
} catch (DataException e) { |
|
161 |
e.printStackTrace(); |
|
162 |
} |
|
140 | 163 |
} else { |
141 | 164 |
list.clear(); |
142 | 165 |
list.add("..."); |
... | ... | |
145 | 168 |
model.setPixelPoint(-1, -1); |
146 | 169 |
} |
147 | 170 |
model.setLayerList(list); |
148 |
|
|
149 |
Point p = new Point(); |
|
150 |
p.setLocation(point2D.getX(), point2D.getY()); |
|
151 |
try { |
|
152 |
DynObjectSetWMSInfo dos = (DynObjectSetWMSInfo)selected.getInfo(p, 0D, null, true); |
|
153 |
String txt = dos.getInfoElement(); |
|
154 |
if(dos.getTypeInfo().compareTo("text/plain") == 0) |
|
155 |
dialog.setWMSInfoText(txt, dos.getTypeInfo()); |
|
156 |
else if(dos.getTypeInfo().compareTo("text/html") == 0) { |
|
157 |
int beginIndex = txt.indexOf("<html"); |
|
158 |
if(beginIndex > 0) |
|
159 |
txt = txt.substring(beginIndex, txt.length()); |
|
160 |
dialog.setWMSInfoText(txt, "text/html"); |
|
161 |
} else if(dos.getTypeInfo().endsWith("vnd.ogc.gml") || dos.getTypeInfo().compareTo("text/xml") == 0) { |
|
162 |
dialog.setWMSInfoText(txt, "text/xml"); |
|
163 |
}else |
|
164 |
dialog.setWMSInfoText(txt, "text/html"); |
|
165 |
|
|
166 |
} catch (LoadLayerException e) { |
|
167 |
e.printStackTrace(); |
|
168 |
} catch (DataException e) { |
|
169 |
e.printStackTrace(); |
|
170 |
} |
|
171 |
|
|
171 | 172 |
model.notifyObservers(); |
172 | 173 |
} |
173 |
|
|
174 |
|
|
174 | 175 |
/** |
175 | 176 |
* Loads the values of a pixel point |
176 | 177 |
* @param dataStore |
... | ... | |
209 | 210 |
for (int i = 0; i < dataStore.getBandCount(); i++) { |
210 | 211 |
res[i] = Double.NaN; |
211 | 212 |
} |
212 |
}
|
|
213 |
} |
|
213 | 214 |
return res; |
214 | 215 |
} |
215 | 216 |
|
Also available in: Unified diff