Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / georeferencing / view / ZoomMapDialog.java @ 18321

History | View | Annotate | Download (6.2 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.georeferencing.view;
20

    
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23
import java.awt.geom.Point2D;
24
import java.awt.geom.Rectangle2D;
25
import java.awt.image.BufferedImage;
26

    
27
import org.gvsig.rastertools.georeferencing.ui.zoom.IExtensionRequest;
28
import org.gvsig.rastertools.georeferencing.ui.zoom.IGraphicLayer;
29
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewControl;
30
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.CenterPointGraphicLayer;
31
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.GPGraphic;
32

    
33
import com.iver.andami.PluginServices;
34
import com.iver.andami.ui.mdiManager.IWindow;
35
import com.iver.andami.ui.mdiManager.WindowInfo;
36

    
37
/**
38
 * Panel que contiene el control de zoom para el mapa.
39
 * 
40
 * 22/12/2007
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class ZoomMapDialog extends BaseZoomView implements IWindow {
44
        private static final long         serialVersionUID = 1L;
45
        private CenterPointGraphicLayer   mapGraphicLayer = null;
46

    
47
        private int                       w = 320;
48
        private int                       h = 100; 
49
        private int                       posX = 0;
50
        private int                       posY = 0;
51
        
52
        /**
53
         * Constructor.
54
         * Crea la composici?n de controles de zoom.
55
         */
56
        public ZoomMapDialog(int posX, int posY, int w, int h) {
57
                setPosition(posX, posY);
58
                setWindowsSize(w, h);
59
                init();
60
        }
61
        
62
        /**
63
         * Asigna la posici?n de la ventana
64
         * @param posX Posici?n en X
65
         * @param posY Posici?n en Y
66
         */
67
        public void setPosition(int posX, int posY) {
68
                this.posX = posX;
69
                this.posY = posY;
70
        }
71
        
72
        /**
73
         * Asigna la posici?n de la ventana
74
         * @param posX Posici?n en X
75
         * @param posY Posici?n en Y
76
         */
77
        public void setWindowsSize(int w, int h) {
78
                this.w = w;
79
                this.h = h;
80
        }
81
        
82
        /**
83
         * Asigna el valor para el flag minxMaxyUL. Este flag informa de que la esquina 
84
         * superior izquierda corresponde con el valor de m?nimo X y m?ximo Y. En caso 
85
         * de ser false esta esquina ser?a de m?nimo X y m?nimo Y.
86
         * @param v
87
         */
88
        public void setMinxMaxyUL(boolean v) {
89
                getCanvas().setMinxMaxyUL(v);
90
        }
91
        
92
        /*
93
         * (non-Javadoc)
94
         * @see org.gvsig.rastertools.georeferencing.view.BaseZoomView#addGraphicLayer(org.gvsig.rastertools.georeferencing.ui.zoom.IGraphicLayer)
95
         */
96
        public void addGraphicLayer(IGraphicLayer graphicLayer) {
97
                getControl().setGraphicLayer(graphicLayer);
98
        }
99
        
100
        /**
101
         * Inicializaci?n de los componentes gr?ficos
102
         */
103
        private void init() {
104
                setLayout(new GridBagLayout());
105
                setPreferredSize(new java.awt.Dimension(w, h)); 
106
                
107
                GridBagConstraints gb = new GridBagConstraints();
108
                gb.insets = new java.awt.Insets(0, 0, 0, 0);
109
                gb.gridy = 0;
110
                gb.gridx = 0;
111
                gb.weightx = 1D; //El espacio sobrante se distribuye horizontalmente
112
                gb.weighty = 1D; //El espacio sobrante se distribuye verticalmente
113
                gb.fill = GridBagConstraints.BOTH; //El componente se hace tan ancho como espacio disponible tiene
114
                gb.anchor = GridBagConstraints.NORTH; //Alineamos las cajas arriba
115
                add(getControl(), gb);
116
        }
117
        
118
        /**
119
         * Registra un objeto IExtensionRequest para que no se aplique un escalado sobre
120
         * el buffer pasado por par?metro. Alternativamente a la aplicaci?n de este escalado
121
         * se ejecutar? el m?todo request del interfaz para que el cliente pueda pasar un 
122
         * nuevo buffer con escala 1:1 y con la extensi?n correspondiente al zoom.
123
         * @param er
124
         */
125
        public void setExtensionRequest(IExtensionRequest er) {
126
                zoomPixelControl.setExtensionRequest(er);
127
        }
128
        
129
        /**
130
         * Obtiene el panel de control de zoom de coordenadas de mapa
131
         * @return
132
         */
133
        public ViewControl getControl() {
134
                if(zoomPixelControl == null) {
135
                        zoomPixelControl = new ViewControl(ViewControl.RIGHT_CONTROL);
136
                        zoomPixelControl.hideButton(ViewControl.PREV_ZOOM);
137
                        zoomPixelControl.hideButton(ViewControl.FULL_VIEW);
138
                        zoomPixelControl.hideButton(ViewControl.SELECT_ZOOM_AREA);
139
                        zoomPixelControl.hideButton(ViewControl.ZOOM_INCREASE);
140
                        zoomPixelControl.hideButton(ViewControl.ZOOM_DECREASE);
141
                        zoomPixelControl.getCanvas().setShowInfo(false);
142
                }
143
                return zoomPixelControl;
144
        }
145

    
146
        /**
147
         * Obtiene el panel de control de zoom de coordenadas de mapa
148
         * @return
149
         */
150
        public CenterPointGraphicLayer getMapGraphicLayer() {
151
                if(mapGraphicLayer == null) {
152
                        mapGraphicLayer = new CenterPointGraphicLayer(GPGraphic.MAP, getControl());
153
                        mapGraphicLayer.setShowNumber(false);
154
                        mapGraphicLayer.setShowLabel(false);
155
                        getControl().setGraphicLayer(mapGraphicLayer);
156
                }
157
                return mapGraphicLayer;
158
        }
159
        
160
        /**
161
         * Asigna los par?metros de dibujado para el mapa
162
         * @param img Buffer con un ?rea de datos
163
         * @param ext Rectangle2D del ?rea de datos dada 
164
         * @param pixelSize Tama?o de pixel
165
         * @param center Punto del ?rea de datos donde se quiere centrar el dibujado del buffer
166
         */
167
        public void setDrawParams(BufferedImage img, Rectangle2D ext, double pixelSize, Point2D center) {
168
                getControl().setDrawParams(img, ext, pixelSize, center) ;
169
        }
170
        
171
        /*
172
         * (non-Javadoc)
173
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
174
         */
175
        public WindowInfo getWindowInfo() {
176
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
177
                //if (getClippingPanel().getFLayer() != null)
178
                        //m_viewinfo.setAdditionalInfo(getClippingPanel().getFLayer().getName());
179
                m_viewinfo.setTitle(PluginServices.getText(this, "zooms_control"));
180
                m_viewinfo.setX(posX);
181
                m_viewinfo.setY(posY);
182
                m_viewinfo.setHeight(h);
183
                m_viewinfo.setWidth(w);
184
                return m_viewinfo;
185
        }
186
}