svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / georeferencing / view / ZoomMapDialog.java @ 18277
History | View | Annotate | Download (5.58 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.ViewControl; |
29 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.CenterPointGraphicLayer; |
30 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.GPGraphic; |
31 |
|
32 |
import com.iver.andami.PluginServices; |
33 |
import com.iver.andami.ui.mdiManager.IWindow; |
34 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
35 |
|
36 |
/**
|
37 |
* Panel que contiene el control de zoom para el mapa.
|
38 |
*
|
39 |
* 22/12/2007
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
41 |
*/
|
42 |
public class ZoomMapDialog extends BaseZoomView implements IWindow { |
43 |
private static final long serialVersionUID = 1L; |
44 |
private CenterPointGraphicLayer mapGraphicLayer = null; |
45 |
|
46 |
private int w = 320; |
47 |
private int h = 100; |
48 |
private int posX = 0; |
49 |
private int posY = 0; |
50 |
|
51 |
/**
|
52 |
* Constructor.
|
53 |
* Crea la composici?n de controles de zoom.
|
54 |
*/
|
55 |
public ZoomMapDialog(int posX, int posY, int w, int h) { |
56 |
setPosition(posX, posY); |
57 |
setWindowsSize(w, h); |
58 |
init(); |
59 |
} |
60 |
|
61 |
/**
|
62 |
* Asigna la posici?n de la ventana
|
63 |
* @param posX Posici?n en X
|
64 |
* @param posY Posici?n en Y
|
65 |
*/
|
66 |
public void setPosition(int posX, int posY) { |
67 |
this.posX = posX;
|
68 |
this.posY = posY;
|
69 |
} |
70 |
|
71 |
/**
|
72 |
* Asigna la posici?n de la ventana
|
73 |
* @param posX Posici?n en X
|
74 |
* @param posY Posici?n en Y
|
75 |
*/
|
76 |
public void setWindowsSize(int w, int h) { |
77 |
this.w = w;
|
78 |
this.h = h;
|
79 |
} |
80 |
|
81 |
/**
|
82 |
* Inicializaci?n de los componentes gr?ficos
|
83 |
*/
|
84 |
private void init() { |
85 |
setLayout(new GridBagLayout()); |
86 |
setPreferredSize(new java.awt.Dimension(w, h));
|
87 |
|
88 |
GridBagConstraints gb = new GridBagConstraints(); |
89 |
gb.insets = new java.awt.Insets(0, 0, 0, 0); |
90 |
gb.gridy = 0;
|
91 |
gb.gridx = 0;
|
92 |
gb.weightx = 1D; //El espacio sobrante se distribuye horizontalmente |
93 |
gb.weighty = 1D; //El espacio sobrante se distribuye verticalmente |
94 |
gb.fill = GridBagConstraints.BOTH; //El componente se hace tan ancho como espacio disponible tiene |
95 |
gb.anchor = GridBagConstraints.NORTH; //Alineamos las cajas arriba |
96 |
add(getZoomMapControl(), gb); |
97 |
} |
98 |
|
99 |
/**
|
100 |
* Registra un objeto IExtensionRequest para que no se aplique un escalado sobre
|
101 |
* el buffer pasado por par?metro. Alternativamente a la aplicaci?n de este escalado
|
102 |
* se ejecutar? el m?todo request del interfaz para que el cliente pueda pasar un
|
103 |
* nuevo buffer con escala 1:1 y con la extensi?n correspondiente al zoom.
|
104 |
* @param er
|
105 |
*/
|
106 |
public void setExtensionRequest(IExtensionRequest er) { |
107 |
zoomPixelControl.setExtensionRequest(er); |
108 |
} |
109 |
|
110 |
/**
|
111 |
* Obtiene el panel de control de zoom de coordenadas de mapa
|
112 |
* @return
|
113 |
*/
|
114 |
public ViewControl getZoomMapControl() {
|
115 |
if(zoomPixelControl == null) { |
116 |
zoomPixelControl = new ViewControl(ViewControl.RIGHT_CONTROL);
|
117 |
zoomPixelControl.hideButton(ViewControl.PREV_ZOOM); |
118 |
zoomPixelControl.hideButton(ViewControl.FULL_VIEW); |
119 |
zoomPixelControl.hideButton(ViewControl.SELECT_ZOOM_AREA); |
120 |
zoomPixelControl.hideButton(ViewControl.ZOOM_INCREASE); |
121 |
zoomPixelControl.hideButton(ViewControl.ZOOM_DECREASE); |
122 |
zoomPixelControl.getCanvas().setShowInfo(true);
|
123 |
} |
124 |
return zoomPixelControl;
|
125 |
} |
126 |
|
127 |
/**
|
128 |
* Obtiene el panel de control de zoom de coordenadas de mapa
|
129 |
* @return
|
130 |
*/
|
131 |
public CenterPointGraphicLayer getMapGraphicLayer() {
|
132 |
if(mapGraphicLayer == null) { |
133 |
mapGraphicLayer = new CenterPointGraphicLayer(GPGraphic.MAP, getZoomMapControl());
|
134 |
mapGraphicLayer.setShowNumber(false);
|
135 |
mapGraphicLayer.setShowLabel(false);
|
136 |
getZoomMapControl().setGraphicLayer(mapGraphicLayer); |
137 |
} |
138 |
return mapGraphicLayer;
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* Asigna los par?metros de dibujado para el mapa
|
143 |
* @param img Buffer con un ?rea de datos
|
144 |
* @param ext Rectangle2D del ?rea de datos dada
|
145 |
* @param pixelSize Tama?o de pixel
|
146 |
* @param center Punto del ?rea de datos donde se quiere centrar el dibujado del buffer
|
147 |
*/
|
148 |
public void setDrawParams(BufferedImage img, Rectangle2D ext, double pixelSize, Point2D center) { |
149 |
getZoomMapControl().setDrawParams(img, ext, pixelSize, center) ; |
150 |
} |
151 |
|
152 |
/*
|
153 |
* (non-Javadoc)
|
154 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
155 |
*/
|
156 |
public WindowInfo getWindowInfo() {
|
157 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
|
158 |
//if (getClippingPanel().getFLayer() != null)
|
159 |
//m_viewinfo.setAdditionalInfo(getClippingPanel().getFLayer().getName());
|
160 |
m_viewinfo.setTitle(PluginServices.getText(this, "zooms_control")); |
161 |
m_viewinfo.setX(posX); |
162 |
m_viewinfo.setY(posY); |
163 |
m_viewinfo.setHeight(h); |
164 |
m_viewinfo.setWidth(w); |
165 |
return m_viewinfo;
|
166 |
} |
167 |
} |