gvsig-raster / org.gvsig.raster.georeferencing / trunk / org.gvsig.raster.georeferencing / org.gvsig.raster.georeferencing.swing / org.gvsig.raster.georeferencing.swing.impl / src / main / java / org / gvsig / raster / georeferencing / swing / impl / view / BaseZoomView.java @ 1717
History | View | Annotate | Download (5.48 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.georeferencing.swing.impl.view; |
23 |
|
24 |
import java.awt.Graphics2D; |
25 |
import java.awt.geom.Point2D; |
26 |
import java.awt.geom.Rectangle2D; |
27 |
import java.awt.image.BufferedImage; |
28 |
|
29 |
import javax.swing.JPanel; |
30 |
|
31 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingSwingLibrary; |
32 |
import org.gvsig.raster.georeferencing.swing.impl.tool.BaseViewTool; |
33 |
import org.gvsig.raster.georeferencing.swing.impl.tool.PanTool; |
34 |
import org.gvsig.raster.georeferencing.swing.impl.tool.SelectPointTool; |
35 |
import org.gvsig.raster.georeferencing.swing.impl.tool.ZoomRectangleTool; |
36 |
import org.gvsig.raster.georeferencing.swing.view.GeoreferencingView; |
37 |
import org.gvsig.raster.georeferencing.swing.view.IGraphicLayer; |
38 |
import org.gvsig.raster.georeferencing.swing.view.ToolListener; |
39 |
import org.gvsig.raster.georeferencing.swing.view.ViewListener; |
40 |
|
41 |
/**
|
42 |
* Clase de la que heredan los dialogos de vista y zoom que utilizan
|
43 |
* el ViewControl. Contiene m?todos generales para el acceso a informaci?n
|
44 |
* del control.
|
45 |
*
|
46 |
* 20/01/2008
|
47 |
* @author Nacho Brodin nachobrodin@gmail.com
|
48 |
*/
|
49 |
public abstract class BaseZoomView extends JPanel implements GeoreferencingView { |
50 |
private static final long serialVersionUID = -8041978144045965049L; |
51 |
protected ViewControl zoomPixelControl = null; |
52 |
protected BaseViewTool tool = null; |
53 |
|
54 |
public JPanel getComponent() { |
55 |
return this; |
56 |
} |
57 |
|
58 |
public void setViewListener(ViewListener listener) { |
59 |
} |
60 |
|
61 |
/**
|
62 |
* Obtiene el graphics del canvas
|
63 |
* @return
|
64 |
*/
|
65 |
public Graphics2D getCanvasGraphic() { |
66 |
return (Graphics2D) zoomPixelControl.getCanvas().getGraphics(); |
67 |
} |
68 |
|
69 |
/**
|
70 |
* Obtiene el ancho del canvas
|
71 |
* @return
|
72 |
*/
|
73 |
public int getCanvasWidth() { |
74 |
return zoomPixelControl.getCanvasWith();
|
75 |
} |
76 |
|
77 |
/**
|
78 |
* Obtiene el alto del canvas
|
79 |
* @return
|
80 |
*/
|
81 |
public int getCanvasHeight() { |
82 |
return zoomPixelControl.getCanvasHeight();
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* Asigna el tama?o del cursor en pixeles del canvas
|
87 |
* @param w Ancho
|
88 |
* @param h Alto
|
89 |
*/
|
90 |
public void setCursorSize(int w, int h) { |
91 |
} |
92 |
|
93 |
/**
|
94 |
* Asigna la posici?n del cursor en el canvas
|
95 |
* @param x Posici?n en X
|
96 |
* @param y Posici?n en Y
|
97 |
*/
|
98 |
public void setCursorPosition(int x, int y) { |
99 |
} |
100 |
|
101 |
/**
|
102 |
* Asigna los par?metros de dibujado para el raster
|
103 |
* @param img Buffer con un ?rea de datos
|
104 |
* @param ext Rectangle2D del ?rea de datos dada
|
105 |
* @param pixelSize Tama?o de pixel
|
106 |
* @param center Punto del ?rea de datos donde se quiere centrar el dibujado del buffer
|
107 |
*/
|
108 |
public abstract void setDrawParams(BufferedImage img, Rectangle2D ext, double pixelSize, Point2D center); |
109 |
|
110 |
/**
|
111 |
* A?ade una capa gr?fica al canvas. Esta debe heredar de IGraphicLayer
|
112 |
* para que pueda ser dibujada sobre el mismo.
|
113 |
* @param gl
|
114 |
*/
|
115 |
public abstract void addGraphicLayer(IGraphicLayer graphicLayer); |
116 |
|
117 |
/**
|
118 |
* Obtiene el panel de control de la vista
|
119 |
* @return
|
120 |
*/
|
121 |
public abstract ViewControl getControl(); |
122 |
|
123 |
/**
|
124 |
* Obtiene el canvas asociado
|
125 |
* @return CanvasZone
|
126 |
*/
|
127 |
public CanvasZone getCanvas() {
|
128 |
return zoomPixelControl.getCanvas();
|
129 |
} |
130 |
|
131 |
/**
|
132 |
* Selecciona una herramienta a partir de su clase. Si el argumento es null
|
133 |
* elimina cualquier herramienta seleccionada.
|
134 |
* @param tool
|
135 |
*/
|
136 |
public void selectTool(int tool, boolean select) { |
137 |
if(tool == GeoreferencingSwingLibrary.ZOOM_RECTANGLE_TOOL)
|
138 |
getControl().selectTool(ZoomRectangleTool.class, select); |
139 |
if(tool == GeoreferencingSwingLibrary.SELECT_POINT_TOOL)
|
140 |
getControl().selectTool(SelectPointTool.class, select); |
141 |
if(tool == GeoreferencingSwingLibrary.PAN_TOOL)
|
142 |
getControl().selectTool(PanTool.class, select); |
143 |
} |
144 |
|
145 |
public void setSelectZoomAreaButtonSelected(boolean select) { |
146 |
getControl().getBSelectZoomArea().setSelected(select); |
147 |
} |
148 |
|
149 |
public void setMoveButtonSelected(boolean select) { |
150 |
getControl().getBMove().setSelected(select); |
151 |
} |
152 |
|
153 |
public void setTool(int tool, ToolListener listener) { |
154 |
if(tool == GeoreferencingSwingLibrary.SELECT_POINT_TOOL)
|
155 |
this.tool = new SelectPointTool(getCanvas(), listener); |
156 |
if(tool == GeoreferencingSwingLibrary.ZOOM_RECTANGLE_TOOL)
|
157 |
this.tool = new ZoomRectangleTool(getCanvas(), listener); |
158 |
if(tool == GeoreferencingSwingLibrary.PAN_TOOL)
|
159 |
this.tool = new PanTool(getCanvas(), listener); |
160 |
} |
161 |
|
162 |
/**
|
163 |
* Gets the selected tool
|
164 |
* @return
|
165 |
*/
|
166 |
public int getToolSelected() { |
167 |
if(getControl().getToolSelected() instanceof SelectPointTool) |
168 |
return GeoreferencingSwingLibrary.SELECT_POINT_TOOL;
|
169 |
if(getControl().getToolSelected() instanceof PanTool) |
170 |
return GeoreferencingSwingLibrary.PAN_TOOL;
|
171 |
if(getControl().getToolSelected() instanceof ZoomRectangleTool) |
172 |
return GeoreferencingSwingLibrary.ZOOM_RECTANGLE_TOOL;
|
173 |
return -1; |
174 |
} |
175 |
} |