svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / georeferencing / view / ViewDialog.java @ 18236
History | View | Annotate | Download (5.79 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.BorderLayout; |
22 |
import java.awt.geom.Point2D; |
23 |
import java.awt.geom.Rectangle2D; |
24 |
import java.awt.image.BufferedImage; |
25 |
|
26 |
import org.gvsig.rastertools.georeferencing.ui.zoom.IExtensionRequest; |
27 |
import org.gvsig.rastertools.georeferencing.ui.zoom.ViewControl; |
28 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.GCPsGraphicLayer; |
29 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.GPGraphic; |
30 |
import org.gvsig.rastertools.georeferencing.ui.zoom.layers.ZoomCursorGraphicLayer; |
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 panel con la vista a georreferenciar
|
38 |
*
|
39 |
* 22/12/2007
|
40 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
41 |
*/
|
42 |
public class ViewDialog extends BaseZoomView implements IWindow { |
43 |
private static final long serialVersionUID = 1L; |
44 |
private GCPsGraphicLayer graphicLayer = null; |
45 |
private ZoomCursorGraphicLayer zoomCursorGraphic = null; |
46 |
private int w = 640; |
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 |
* @param posX Posici?n en X
|
55 |
* @param posY Posici?n en Y
|
56 |
* @param w Tama?o en pixeles de ancho
|
57 |
* @param h Tama?o en pixeles de alto
|
58 |
*/
|
59 |
public ViewDialog(int posX, int posY, int w, int h) { |
60 |
setPosition(posX, posY); |
61 |
setWindowsSize(w, h); |
62 |
init(); |
63 |
} |
64 |
|
65 |
/**
|
66 |
* Asigna la posici?n de la ventana
|
67 |
* @param posX Posici?n en X
|
68 |
* @param posY Posici?n en Y
|
69 |
*/
|
70 |
public void setPosition(int posX, int posY) { |
71 |
this.posX = posX;
|
72 |
this.posY = posY;
|
73 |
} |
74 |
|
75 |
/**
|
76 |
* Asigna el tama?o de la ventana
|
77 |
* @param w Tama?o en pixeles de ancho
|
78 |
* @param h Tama?o en pixeles de alto
|
79 |
*/
|
80 |
public void setWindowsSize(int w, int h) { |
81 |
this.w = w;
|
82 |
this.h = h;
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* Inicializaci?n de los componentes gr?ficos
|
87 |
*/
|
88 |
private void init() { |
89 |
setLayout(new BorderLayout()); |
90 |
add(getZoomPixelControl(), BorderLayout.CENTER);
|
91 |
getPixelGraphicLayer(); |
92 |
getZoomCursorGraphicLayer(); |
93 |
} |
94 |
|
95 |
/**
|
96 |
* Asigna los par?metros de dibujado para el raster
|
97 |
* @param img Buffer con un ?rea de datos
|
98 |
* @param ext Rectangle2D del ?rea de datos dada
|
99 |
* @param pixelSize Tama?o de pixel
|
100 |
* @param center Punto del ?rea de datos donde se quiere centrar el dibujado del buffer
|
101 |
*/
|
102 |
public void setPixelDrawParams(BufferedImage img, Rectangle2D ext, double pixelSize, Point2D center) { |
103 |
getZoomPixelControl().setDrawParams(img, ext, pixelSize, center) ; |
104 |
} |
105 |
|
106 |
/**
|
107 |
* Obtiene el panel de control de zoom de coordenadas pixel
|
108 |
* @return
|
109 |
*/
|
110 |
public ViewControl getZoomPixelControl() {
|
111 |
if(zoomPixelControl == null) |
112 |
zoomPixelControl = new ViewControl(ViewControl.RIGHT_CONTROL);
|
113 |
return zoomPixelControl;
|
114 |
} |
115 |
|
116 |
/**
|
117 |
* Registra un objeto IExtensionRequest para que no se aplique un escalado sobre
|
118 |
* el buffer pasado por par?metro. Alternativamente a la aplicaci?n de este escalado
|
119 |
* se ejecutar? el m?todo request del interfaz para que el cliente pueda pasar un
|
120 |
* nuevo buffer con escala 1:1 y con la extensi?n correspondiente al zoom.
|
121 |
* @param er
|
122 |
*/
|
123 |
public void setExtensionRequest(IExtensionRequest er) { |
124 |
zoomPixelControl.setExtensionRequest(er); |
125 |
} |
126 |
|
127 |
/**
|
128 |
* Obtiene el panel de control de zoom de coordenadas pixel
|
129 |
* @return
|
130 |
*/
|
131 |
public GCPsGraphicLayer getPixelGraphicLayer() {
|
132 |
if(graphicLayer == null) { |
133 |
graphicLayer = new GCPsGraphicLayer(GPGraphic.PIXEL, getZoomPixelControl());
|
134 |
graphicLayer.setShowNumber(false);
|
135 |
graphicLayer.setShowLabel(false);
|
136 |
getZoomPixelControl().setGraphicLayer(graphicLayer); |
137 |
} |
138 |
return graphicLayer;
|
139 |
} |
140 |
|
141 |
/**
|
142 |
* Obtiene el la capa gr?fica con la ventana de zoom
|
143 |
* @return
|
144 |
*/
|
145 |
public ZoomCursorGraphicLayer getZoomCursorGraphicLayer() {
|
146 |
if(zoomCursorGraphic == null) { |
147 |
zoomCursorGraphic = new ZoomCursorGraphicLayer(w / 2, h / 2, 40, 20); |
148 |
getZoomPixelControl().setGraphicLayer(zoomCursorGraphic); |
149 |
} |
150 |
return zoomCursorGraphic;
|
151 |
} |
152 |
|
153 |
/**
|
154 |
* Activa o desactiva el mostrado de informaci?n
|
155 |
* @param showInfo
|
156 |
*/
|
157 |
public void setShowInfo(boolean show) { |
158 |
zoomPixelControl.getCanvas().setShowInfo(show); |
159 |
} |
160 |
|
161 |
/**
|
162 |
* Asigna el ancho y el alto de la ventana del cursor
|
163 |
* @param w Ancho
|
164 |
* @param h Alto
|
165 |
*/
|
166 |
public void setZoomCursorSize(int w, int h) { |
167 |
getZoomCursorGraphicLayer().setCursorSize(w, h); |
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 | WindowInfo.MAXIMIZABLE);
|
176 |
//if (getClippingPanel().getFLayer() != null)
|
177 |
//m_viewinfo.setAdditionalInfo(getClippingPanel().getFLayer().getName());
|
178 |
m_viewinfo.setTitle(PluginServices.getText(this, "view_panel")); |
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 |
} |
186 |
|