Statistics
| Revision:

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

History | View | Annotate | Download (5.56 KB)

1 17838 nbrodin
/* 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 18251 nbrodin
import org.gvsig.rastertools.georeferencing.ui.zoom.IExtensionRequest;
28 18308 nbrodin
import org.gvsig.rastertools.georeferencing.ui.zoom.IGraphicLayer;
29 18216 nbrodin
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewControl;
30 17838 nbrodin
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 18236 nbrodin
public class ZoomRasterDialog extends BaseZoomView implements IWindow {
42 17838 nbrodin
        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 18321 nbrodin
         * 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 17838 nbrodin
         * Inicializaci?n de los componentes gr?ficos
91
         */
92
        private void init() {
93
                setLayout(new GridBagLayout());
94
                setPreferredSize(new java.awt.Dimension(w, h));
95
96
                GridBagConstraints gb = new GridBagConstraints();
97
                gb.insets = new java.awt.Insets(0, 0, 0, 0);
98
                gb.gridy = 0;
99
                gb.gridx = 0;
100
                gb.weightx = 1D; //El espacio sobrante se distribuye horizontalmente
101
                gb.weighty = 1D; //El espacio sobrante se distribuye verticalmente
102
                gb.fill = GridBagConstraints.BOTH; //El componente se hace tan ancho como espacio disponible tiene
103
                gb.anchor = GridBagConstraints.NORTH; //Alineamos las cajas arriba
104 18308 nbrodin
                add(getControl(), gb);
105 17838 nbrodin
        }
106
107
        /**
108 18251 nbrodin
         * Registra un objeto IExtensionRequest para que no se aplique un escalado sobre
109
         * el buffer pasado por par?metro. Alternativamente a la aplicaci?n de este escalado
110
         * se ejecutar? el m?todo request del interfaz para que el cliente pueda pasar un
111
         * nuevo buffer con escala 1:1 y con la extensi?n correspondiente al zoom.
112
         * @param er
113
         */
114
        public void setExtensionRequest(IExtensionRequest er) {
115
                zoomPixelControl.setExtensionRequest(er);
116
        }
117
118 18308 nbrodin
        /*
119
         * (non-Javadoc)
120
         * @see org.gvsig.rastertools.georeferencing.view.BaseZoomView#addGraphicLayer(org.gvsig.rastertools.georeferencing.ui.zoom.IGraphicLayer)
121
         */
122
        public void addGraphicLayer(IGraphicLayer graphicLayer) {
123
                getControl().setGraphicLayer(graphicLayer);
124
        }
125
126 18251 nbrodin
        /**
127 17838 nbrodin
         * Obtiene el panel de control de zoom de coordenadas pixel
128
         * @return
129
         */
130 18308 nbrodin
        public ViewControl getControl() {
131 17909 nbrodin
                if(zoomPixelControl == null) {
132 18216 nbrodin
                        zoomPixelControl = new ViewControl(ViewControl.LEFT_CONTROL);
133
                        zoomPixelControl.hideButton(ViewControl.PREV_ZOOM);
134
                        zoomPixelControl.hideButton(ViewControl.FULL_VIEW);
135
                        zoomPixelControl.hideButton(ViewControl.SELECT_ZOOM_AREA);
136 18251 nbrodin
                        zoomPixelControl.hideButton(ViewControl.ZOOM_INCREASE);
137
                        zoomPixelControl.hideButton(ViewControl.ZOOM_DECREASE);
138 17909 nbrodin
                }
139 17838 nbrodin
                return zoomPixelControl;
140
        }
141 18346 nbrodin
142 17838 nbrodin
        /**
143
         * Asigna los par?metros de dibujado para el raster
144
         * @param img Buffer con un ?rea de datos
145
         * @param ext Rectangle2D del ?rea de datos dada
146
         * @param pixelSize Tama?o de pixel
147
         * @param center Punto del ?rea de datos donde se quiere centrar el dibujado del buffer
148
         */
149 18251 nbrodin
        public void setDrawParams(BufferedImage img, Rectangle2D ext, double pixelSize, Point2D center) {
150 18308 nbrodin
                getControl().setDrawParams(img, ext, pixelSize, center) ;
151 17838 nbrodin
        }
152
153
        /*
154
         * (non-Javadoc)
155
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
156
         */
157
        public WindowInfo getWindowInfo() {
158
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
159
                //if (getClippingPanel().getFLayer() != null)
160
                        //m_viewinfo.setAdditionalInfo(getClippingPanel().getFLayer().getName());
161
                m_viewinfo.setTitle(PluginServices.getText(this, "zooms_control"));
162
                m_viewinfo.setX(posX);
163
                m_viewinfo.setY(posY);
164
                m_viewinfo.setHeight(h);
165
                m_viewinfo.setWidth(w);
166
                return m_viewinfo;
167
        }
168
}