Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / georeferencing / view / ZoomRasterDialog.java @ 17838

History | View | Annotate | Download (4.85 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 javax.swing.JPanel;
28

    
29
import org.gvsig.rastertools.georeferencing.ui.zoom.CenterPointGraphicLayer;
30
import org.gvsig.rastertools.georeferencing.ui.zoom.GPGraphic;
31
import org.gvsig.rastertools.georeferencing.ui.zoom.ZoomControl;
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 raster a georreferenciar.
39
 * 
40
 * 22/12/2007
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class ZoomRasterDialog extends JPanel implements IWindow {
44
        private static final long         serialVersionUID = 1L;
45
        private ZoomControl               zoomPixelControl = null;
46
        private CenterPointGraphicLayer   pixelGraphicLayer = null;
47
        
48
        private int                       w = 320;
49
        private int                       h = 100; 
50
        private int                       posX = 0;
51
        private int                       posY = 0;
52
        
53
        /**
54
         * Constructor.
55
         * Crea la composici?n de controles de zoom.
56
         */
57
        public ZoomRasterDialog(int posX, int posY, int w, int h) {
58
                setPosition(posX, posY);
59
                setWindowsSize(w, h);
60
                init();
61
        }
62
        
63
        /**
64
         * Asigna la posici?n de la ventana
65
         * @param posX Posici?n en X
66
         * @param posY Posici?n en Y
67
         */
68
        public void setPosition(int posX, int posY) {
69
                this.posX = posX;
70
                this.posY = posY;
71
        }
72
        
73
        /**
74
         * Asigna la posici?n de la ventana
75
         * @param posX Posici?n en X
76
         * @param posY Posici?n en Y
77
         */
78
        public void setWindowsSize(int w, int h) {
79
                this.w = w;
80
                this.h = h;
81
        }
82
        
83
        /**
84
         * Inicializaci?n de los componentes gr?ficos
85
         */
86
        private void init() {
87
                setLayout(new GridBagLayout());
88
                setPreferredSize(new java.awt.Dimension(w, h)); 
89
                
90
                GridBagConstraints gb = new GridBagConstraints();
91
                gb.insets = new java.awt.Insets(0, 0, 0, 0);
92
                gb.gridy = 0;
93
                gb.gridx = 0;
94
                gb.weightx = 1D; //El espacio sobrante se distribuye horizontalmente
95
                gb.weighty = 1D; //El espacio sobrante se distribuye verticalmente
96
                gb.fill = GridBagConstraints.BOTH; //El componente se hace tan ancho como espacio disponible tiene
97
                gb.anchor = GridBagConstraints.NORTH; //Alineamos las cajas arriba
98
                add(getZoomPixelControl(), gb);
99
        }
100
        
101
        /**
102
         * Obtiene el panel de control de zoom de coordenadas pixel
103
         * @return
104
         */
105
        public ZoomControl getZoomPixelControl() {
106
                if(zoomPixelControl == null)
107
                        zoomPixelControl = new ZoomControl(ZoomControl.LEFT_CONTROL);
108
                return zoomPixelControl;
109
        }
110
        
111
        /**
112
         * Obtiene el panel de control de zoom de coordenadas pixel
113
         * @return
114
         */
115
        public CenterPointGraphicLayer getPixelGraphicLayer() {
116
                if(pixelGraphicLayer == null) {
117
                        pixelGraphicLayer = new CenterPointGraphicLayer(GPGraphic.PIXEL, getZoomPixelControl());
118
                        pixelGraphicLayer.setShowNumber(false);
119
                        pixelGraphicLayer.setShowLabel(false);
120
                        getZoomPixelControl().setGraphicLayer(pixelGraphicLayer);
121
                }
122
                return pixelGraphicLayer;
123
        }
124
                
125
        /**
126
         * Asigna los par?metros de dibujado para el raster
127
         * @param img Buffer con un ?rea de datos
128
         * @param ext Rectangle2D del ?rea de datos dada 
129
         * @param pixelSize Tama?o de pixel
130
         * @param center Punto del ?rea de datos donde se quiere centrar el dibujado del buffer
131
         */
132
        public void setPixelDrawParams(BufferedImage img, Rectangle2D ext, double pixelSize, Point2D center) {
133
                getZoomPixelControl().setDrawParams(img, ext, pixelSize, center) ;
134
        }
135

    
136
        /*
137
         * (non-Javadoc)
138
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
139
         */
140
        public WindowInfo getWindowInfo() {
141
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
142
                //if (getClippingPanel().getFLayer() != null)
143
                        //m_viewinfo.setAdditionalInfo(getClippingPanel().getFLayer().getName());
144
                m_viewinfo.setTitle(PluginServices.getText(this, "zooms_control"));
145
                m_viewinfo.setX(posX);
146
                m_viewinfo.setY(posY);
147
                m_viewinfo.setHeight(h);
148
                m_viewinfo.setWidth(w);
149
                return m_viewinfo;
150
        }
151
}