svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / georeferencing / view / ZoomRasterDialog.java @ 18321
History | View | Annotate | Download (6.19 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 raster a georreferenciar.
|
39 |
*
|
40 |
* 22/12/2007
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
42 |
*/
|
43 |
public class ZoomRasterDialog extends BaseZoomView implements IWindow { |
44 |
private static final long serialVersionUID = 1L; |
45 |
private CenterPointGraphicLayer pixelGraphicLayer = 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 ZoomRasterDialog(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 |
* Inicializaci?n de los componentes gr?ficos
|
94 |
*/
|
95 |
private void init() { |
96 |
setLayout(new GridBagLayout()); |
97 |
setPreferredSize(new java.awt.Dimension(w, h));
|
98 |
|
99 |
GridBagConstraints gb = new GridBagConstraints(); |
100 |
gb.insets = new java.awt.Insets(0, 0, 0, 0); |
101 |
gb.gridy = 0;
|
102 |
gb.gridx = 0;
|
103 |
gb.weightx = 1D; //El espacio sobrante se distribuye horizontalmente |
104 |
gb.weighty = 1D; //El espacio sobrante se distribuye verticalmente |
105 |
gb.fill = GridBagConstraints.BOTH; //El componente se hace tan ancho como espacio disponible tiene |
106 |
gb.anchor = GridBagConstraints.NORTH; //Alineamos las cajas arriba |
107 |
add(getControl(), gb); |
108 |
} |
109 |
|
110 |
/**
|
111 |
* Registra un objeto IExtensionRequest para que no se aplique un escalado sobre
|
112 |
* el buffer pasado por par?metro. Alternativamente a la aplicaci?n de este escalado
|
113 |
* se ejecutar? el m?todo request del interfaz para que el cliente pueda pasar un
|
114 |
* nuevo buffer con escala 1:1 y con la extensi?n correspondiente al zoom.
|
115 |
* @param er
|
116 |
*/
|
117 |
public void setExtensionRequest(IExtensionRequest er) { |
118 |
zoomPixelControl.setExtensionRequest(er); |
119 |
} |
120 |
|
121 |
/*
|
122 |
* (non-Javadoc)
|
123 |
* @see org.gvsig.rastertools.georeferencing.view.BaseZoomView#addGraphicLayer(org.gvsig.rastertools.georeferencing.ui.zoom.IGraphicLayer)
|
124 |
*/
|
125 |
public void addGraphicLayer(IGraphicLayer graphicLayer) { |
126 |
getControl().setGraphicLayer(graphicLayer); |
127 |
} |
128 |
|
129 |
/**
|
130 |
* Obtiene el panel de control de zoom de coordenadas pixel
|
131 |
* @return
|
132 |
*/
|
133 |
public ViewControl getControl() {
|
134 |
if(zoomPixelControl == null) { |
135 |
zoomPixelControl = new ViewControl(ViewControl.LEFT_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 |
} |
142 |
return zoomPixelControl;
|
143 |
} |
144 |
|
145 |
/**
|
146 |
* Obtiene el panel de control de zoom de coordenadas pixel
|
147 |
* @return
|
148 |
*/
|
149 |
public CenterPointGraphicLayer getPixelGraphicLayer() {
|
150 |
if(pixelGraphicLayer == null) { |
151 |
pixelGraphicLayer = new CenterPointGraphicLayer(GPGraphic.PIXEL, getControl());
|
152 |
pixelGraphicLayer.setShowNumber(false);
|
153 |
pixelGraphicLayer.setShowLabel(false);
|
154 |
getControl().setGraphicLayer(pixelGraphicLayer); |
155 |
} |
156 |
return pixelGraphicLayer;
|
157 |
} |
158 |
|
159 |
/**
|
160 |
* Asigna los par?metros de dibujado para el raster
|
161 |
* @param img Buffer con un ?rea de datos
|
162 |
* @param ext Rectangle2D del ?rea de datos dada
|
163 |
* @param pixelSize Tama?o de pixel
|
164 |
* @param center Punto del ?rea de datos donde se quiere centrar el dibujado del buffer
|
165 |
*/
|
166 |
public void setDrawParams(BufferedImage img, Rectangle2D ext, double pixelSize, Point2D center) { |
167 |
getControl().setDrawParams(img, ext, pixelSize, center) ; |
168 |
} |
169 |
|
170 |
/*
|
171 |
* (non-Javadoc)
|
172 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
173 |
*/
|
174 |
public WindowInfo getWindowInfo() {
|
175 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
|
176 |
//if (getClippingPanel().getFLayer() != null)
|
177 |
//m_viewinfo.setAdditionalInfo(getClippingPanel().getFLayer().getName());
|
178 |
m_viewinfo.setTitle(PluginServices.getText(this, "zooms_control")); |
179 |
m_viewinfo.setX(posX); |
180 |
m_viewinfo.setY(posY); |
181 |
m_viewinfo.setHeight(h); |
182 |
m_viewinfo.setWidth(w); |
183 |
return m_viewinfo;
|
184 |
} |
185 |
} |