Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / view / ZoomRasterDialog.java @ 18530

History | View | Annotate | Download (5.73 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.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.georeferencing.ui.zoom.IExtensionRequest;
28
import org.gvsig.georeferencing.ui.zoom.IGraphicLayer;
29
import org.gvsig.georeferencing.ui.zoom.ViewControl;
30

    
31
import com.iver.andami.PluginServices;
32
import com.iver.andami.ui.mdiManager.IWindow;
33
import com.iver.andami.ui.mdiManager.WindowInfo;
34

    
35
/**
36
 * Panel que contiene el control de zoom para el raster a georreferenciar.
37
 * 
38
 * 22/12/2007
39
 * @author Nacho Brodin (nachobrodin@gmail.com)
40
 */
41
public class ZoomRasterDialog extends BaseZoomView implements IWindow {
42
        private static final long         serialVersionUID = 1L;
43
        
44
        private int                       w = 320;
45
        private int                       h = 100; 
46
        private int                       posX = 0;
47
        private int                       posY = 0;
48
        
49
        /**
50
         * Constructor.
51
         * Crea la composici?n de controles de zoom.
52
         */
53
        public ZoomRasterDialog(int posX, int posY, int w, int h) {
54
                setPosition(posX, posY);
55
                setWindowsSize(w, h);
56
                init();
57
        }
58
        
59
        /**
60
         * Asigna la posici?n de la ventana
61
         * @param posX Posici?n en X
62
         * @param posY Posici?n en Y
63
         */
64
        public void setPosition(int posX, int posY) {
65
                this.posX = posX;
66
                this.posY = posY;
67
        }
68
        
69
        /**
70
         * Asigna la posici?n de la ventana
71
         * @param posX Posici?n en X
72
         * @param posY Posici?n en Y
73
         */
74
        public void setWindowsSize(int w, int h) {
75
                this.w = w;
76
                this.h = h;
77
        }
78
        
79
        /**
80
         * Asigna el valor para el flag minxMaxyUL. Este flag informa de que la esquina 
81
         * superior izquierda corresponde con el valor de m?nimo X y m?ximo Y. En caso 
82
         * de ser false esta esquina ser?a de m?nimo X y m?nimo Y.
83
         * @param v
84
         */
85
        public void setMinxMaxyUL(boolean v) {
86
                getCanvas().setMinxMaxyUL(v);
87
        }
88
        
89
        /**
90
         * Activa o desactiva el mostrado de informaci?n
91
         * @param showInfo
92
         */
93
        public void setShowInfo(boolean show) {
94
                zoomPixelControl.getCanvas().setShowInfo(show);
95
        }
96
        
97
        /**
98
         * Inicializaci?n de los componentes gr?ficos
99
         */
100
        private void init() {
101
                setLayout(new GridBagLayout());
102
                setPreferredSize(new java.awt.Dimension(w, h)); 
103
                
104
                GridBagConstraints gb = new GridBagConstraints();
105
                gb.insets = new java.awt.Insets(0, 0, 0, 0);
106
                gb.gridy = 0;
107
                gb.gridx = 0;
108
                gb.weightx = 1D; //El espacio sobrante se distribuye horizontalmente
109
                gb.weighty = 1D; //El espacio sobrante se distribuye verticalmente
110
                gb.fill = GridBagConstraints.BOTH; //El componente se hace tan ancho como espacio disponible tiene
111
                gb.anchor = GridBagConstraints.NORTH; //Alineamos las cajas arriba
112
                add(getControl(), gb);
113
        }
114
        
115
        /**
116
         * Registra un objeto IExtensionRequest para que no se aplique un escalado sobre
117
         * el buffer pasado por par?metro. Alternativamente a la aplicaci?n de este escalado
118
         * se ejecutar? el m?todo request del interfaz para que el cliente pueda pasar un 
119
         * nuevo buffer con escala 1:1 y con la extensi?n correspondiente al zoom.
120
         * @param er
121
         */
122
        public void setExtensionRequest(IExtensionRequest er) {
123
                zoomPixelControl.setExtensionRequest(er);
124
        }
125
        
126
        /*
127
         * (non-Javadoc)
128
         * @see org.gvsig.rastertools.georeferencing.view.BaseZoomView#addGraphicLayer(org.gvsig.rastertools.georeferencing.ui.zoom.IGraphicLayer)
129
         */
130
        public void addGraphicLayer(IGraphicLayer graphicLayer) {
131
                getControl().setGraphicLayer(graphicLayer);
132
        }
133
        
134
        /**
135
         * Obtiene el panel de control de zoom de coordenadas pixel
136
         * @return
137
         */
138
        public ViewControl getControl() {
139
                if(zoomPixelControl == null) {
140
                        zoomPixelControl = new ViewControl(ViewControl.LEFT_CONTROL);
141
                        zoomPixelControl.hideButton(ViewControl.PREV_ZOOM);
142
                        zoomPixelControl.hideButton(ViewControl.FULL_VIEW);
143
                        zoomPixelControl.hideButton(ViewControl.SELECT_ZOOM_AREA);
144
                        zoomPixelControl.hideButton(ViewControl.ZOOM_INCREASE);
145
                        zoomPixelControl.hideButton(ViewControl.ZOOM_DECREASE);
146
                        zoomPixelControl.hideButton(ViewControl.PAN);
147
                }
148
                return zoomPixelControl;
149
        }
150
                        
151
        /**
152
         * Asigna los par?metros de dibujado para el raster
153
         * @param img Buffer con un ?rea de datos
154
         * @param ext Rectangle2D del ?rea de datos dada 
155
         * @param pixelSize Tama?o de pixel
156
         * @param center Punto del ?rea de datos donde se quiere centrar el dibujado del buffer
157
         */
158
        public void setDrawParams(BufferedImage img, Rectangle2D ext, double pixelSize, Point2D center) {
159
                getControl().setDrawParams(img, ext, pixelSize, center) ;
160
        }
161

    
162
        /*
163
         * (non-Javadoc)
164
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
165
         */
166
        public WindowInfo getWindowInfo() {
167
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
168
                //if (getClippingPanel().getFLayer() != null)
169
                        //m_viewinfo.setAdditionalInfo(getClippingPanel().getFLayer().getName());
170
                m_viewinfo.setTitle(PluginServices.getText(this, "zooms_control"));
171
                m_viewinfo.setX(posX);
172
                m_viewinfo.setY(posY);
173
                m_viewinfo.setHeight(h);
174
                m_viewinfo.setWidth(w);
175
                return m_viewinfo;
176
        }
177
}