Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / toolselectrgb / SelectRGBListener.java @ 19224

History | View | Annotate | Download (2.21 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.rastertools.toolselectrgb;
20

    
21
import java.awt.geom.Point2D;
22
import java.awt.image.BufferedImage;
23

    
24
import com.iver.andami.PluginServices;
25
import com.iver.cit.gvsig.fmap.MapControl;
26
import com.iver.cit.gvsig.fmap.tools.SelectImageListenerImpl;
27
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
28
/**
29
 * Extensi?n de la clase SelectImageListenerImple de FMap. Esta clase permite
30
 * capturar el evento de la selecci?n de un punto RGB sobre la vista
31
 * 
32
 * 22/02/2008
33
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
34
 */
35
public class SelectRGBListener extends SelectImageListenerImpl {
36
        private ISelectRGB selectRGB;
37

    
38
        /**
39
         * Contructor
40
         * @param mapCtrl
41
         */
42
        public SelectRGBListener(MapControl mapCtrl, ISelectRGB selectRGB) {
43
                super(mapCtrl);
44
                this.selectRGB = selectRGB;
45
        }
46

    
47
        /* (non-Javadoc)
48
         * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
49
         */
50
        public void point(PointEvent event) {
51
                super.point(event);
52

    
53
                Point2D point2D = event.getPoint();
54

    
55
                if (PluginServices.getMainFrame() != null)
56
                        PluginServices.getMainFrame().enableControls();
57

    
58
                BufferedImage image = mapCtrl.getImage();
59
                int value = image.getRGB((int) point2D.getX(), (int) point2D.getY());
60
                int r = (value >> 16) & 0xff;
61
                int g = (value >> 8) & 0xff;
62
                int b = value & 0xff;
63
                
64
                selectRGB.actionRGBSelected(r, g, b);
65
        }
66
}