gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / infobypoint / viewtool / InfoByPixelPointListener.java @ 1145
History | View | Annotate | Download (2.42 KB)
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.tools.app.basic.tool.infobypoint.viewtool; |
23 |
|
24 |
import java.awt.geom.Point2D; |
25 |
import java.awt.image.BufferedImage; |
26 |
|
27 |
import org.gvsig.andami.PluginServices; |
28 |
import org.gvsig.fmap.mapcontrol.MapControl; |
29 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
30 |
import org.gvsig.raster.tools.app.basic.tool.infobypoint.gui.InfoByPointDataModel; |
31 |
import org.gvsig.raster.tools.app.basic.tool.selectrasterlayer.SelectImageListImpl; |
32 |
|
33 |
/**
|
34 |
* Extensi?n de la clase SelectImageListenerImple de FMap. Esta clase permite
|
35 |
* capturar el evento de la selecci?n de un punto RGB sobre la vista
|
36 |
*
|
37 |
* 22/02/2008
|
38 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
39 |
*/
|
40 |
public class InfoByPixelPointListener extends SelectImageListImpl { |
41 |
private InfoByPointDataModel model = null; |
42 |
|
43 |
/**
|
44 |
* Contructor
|
45 |
* @param mapCtrl
|
46 |
*/
|
47 |
public InfoByPixelPointListener(MapControl mapCtrl, InfoByPointDataModel model) {
|
48 |
super(mapCtrl);
|
49 |
this.model = model;
|
50 |
} |
51 |
|
52 |
/* (non-Javadoc)
|
53 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
|
54 |
*/
|
55 |
public void point(PointEvent event) { |
56 |
super.point(event);
|
57 |
|
58 |
Point2D point2D = event.getPoint();
|
59 |
|
60 |
if (PluginServices.getMainFrame() != null) |
61 |
PluginServices.getMainFrame().enableControls(); |
62 |
|
63 |
BufferedImage image = mapCtrl.getImage();
|
64 |
int value = image.getRGB((int) point2D.getX(), (int) point2D.getY()); |
65 |
int r = (value >> 16) & 0xff; |
66 |
int g = (value >> 8) & 0xff; |
67 |
int b = value & 0xff; |
68 |
int a = image.getTransparency();
|
69 |
|
70 |
model.setARGB(a, r, g, b); |
71 |
} |
72 |
} |