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