Statistics
| Revision:

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 @ 1691

History | View | Annotate | Download (4.28 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
        public void setTool(int tool, ToolListener listener) {
133
                if(tool == GeoreferencingSwingLibrary.SELECT_POINT_TOOL)
134
                        this.tool = new SelectPointTool(getCanvas(), listener);
135
                if(tool == GeoreferencingSwingLibrary.ZOOM_RECTANGLE_TOOL)
136
                        this.tool = new ZoomRectangleTool(getCanvas(), listener);
137
                if(tool == GeoreferencingSwingLibrary.PAN_TOOL)
138
                        this.tool = new PanTool(getCanvas(), listener);
139
        }
140
}