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