Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / pixelincrease / PixelIncreaseBehavior.java @ 12127

History | View | Annotate | Download (2.81 KB)

1 11593 nacho
/* 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.pixelincrease;
20
21
import java.awt.event.MouseEvent;
22
23
import com.iver.andami.PluginServices;
24
import com.iver.andami.ui.mdiManager.IWindow;
25
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
26
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
27
import com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener;
28
import com.iver.cit.gvsig.project.documents.view.gui.IView;
29
30
/**
31
 * Behavior para que se a?ada a los Behavior del Mapcontrol y poder
32
 * gestionar el evento de mover el rat?n sobre la vista de gvSIG.
33
 *
34
 * 12-may-2007
35
 * @author Nacho Brodin (nachobrodin@gmail.com)
36
 */
37
public class PixelIncreaseBehavior extends Behavior {
38
39
        private PixelncreaseDialog dialog = null;
40
41
        /**
42
         * Constructor. Asigna el dialogo
43
         * @param dialog
44
         */
45
        public PixelIncreaseBehavior(PixelncreaseDialog dialog) {
46
                this.dialog = dialog;
47
        }
48
49
        /*
50
         *  (non-Javadoc)
51
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#getListener()
52
         */
53
        public ToolListener getListener() {
54
                return null;
55
        }
56
57
        /*
58
         *  (non-Javadoc)
59
         * @see com.iver.cit.gvsig.fmap.tools.Behavior.IBehavior#mouseMoved(java.awt.event.MouseEvent)
60
         */
61
        public void mouseMoved(MouseEvent e) throws BehaviorException {
62
                IView view = null;
63
                IWindow active = PluginServices.getMDIManager().getActiveWindow();
64
                if(active instanceof IView) {
65 11624 nacho
                        dialog.clear = false;
66 11593 nacho
                        view = (IView)active;
67
                        if(!dialog.getView().equals(view))
68
                                dialog.setView(view);
69
                        //Calcula la posici?n donde se empezar? a dibujar en el componente. Para ello en ancho y el alto del componente
70
                        //se ponen en la misma escala que la vista (w / scale), se calcula el punto medio del componente y se le resta el punto seleccionado
71
                        //en la vista
72
                        int pX = ((dialog.getWidth() / dialog.getScale()) >> 1) - e.getX();
73
                        int pY = ((dialog.getHeight() / dialog.getScale()) >> 1) - e.getY();
74 11601 nacho
                        dialog.pixX = (int)e.getPoint().getX();
75
                        dialog.pixY = (int)e.getPoint().getY();
76 11593 nacho
                        dialog.setPosX(pX);
77
                        dialog.setPosY(pY);
78
                        dialog.repaint();
79
                }
80
        }
81
82
}