Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / com / iver / cit / gvsig / fmap / layers / FLyrPoints.java @ 2962

History | View | Annotate | Download (4.54 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.fmap.layers;
42

    
43
import java.awt.Color;
44
import java.awt.Graphics2D;
45
import java.awt.geom.Point2D;
46
import java.awt.geom.Rectangle2D;
47
import java.awt.image.BufferedImage;
48
import java.util.ArrayList;
49

    
50
import com.iver.andami.PluginServices;
51
import com.iver.cit.gvsig.fmap.DriverException;
52
import com.iver.cit.gvsig.fmap.ViewPort;
53
import com.iver.cit.gvsig.fmap.operations.Cancellable;
54
import com.iver.cit.gvsig.gui.View;
55

    
56

    
57
/**
58
 * Clase de capa de marcado de puntos sobre una vista. Dibuja un puntero sobre 
59
 * cada punto en la vista.
60
 *
61
 * @author Nacho Brodin (brodin_ign@gva.es)
62
 */
63
public class FLyrPoints extends FLyrDefault {
64
        
65
        public class GeoPoint{
66
                public Point2D pixelPoint = null;
67
                public Point2D mapPoint = null;
68
                public GeoPoint(Point2D p, Point2D m){
69
                        this.pixelPoint = p;
70
                        this.mapPoint = m;
71
                }
72
        }
73
        
74
        private ArrayList pointList = new ArrayList();
75
        private final int DIAM_CIRCLE = 18;
76
        private String lastTool = null;
77
                        
78
        /**
79
         * Dibujado de la capa de raster georeferenciado aplicando la 
80
         * transformaci?n del viewPort.
81
         */
82
        public void draw(BufferedImage image, Graphics2D g, ViewPort vp,
83
                        Cancellable cancel,double scale) throws DriverException {
84
                View theView = (View) PluginServices.getMDIManager().getActiveView();
85
                BufferedImage img = theView.getMapControl().getImage();
86
                g.drawImage(img, 0, 0, null);
87
                g.setColor(Color.red);
88
                                
89
                for(int i=0; i<pointList.size();i++){
90
                        //Point2D pto = vp.fromMapPoint((Point2D)pointList.get(i));
91
                        Point2D pto = ((GeoPoint)pointList.get(i)).pixelPoint;
92
                        int dpto = (DIAM_CIRCLE >> 1);
93
                        g.drawOval(        (int)pto.getX() - dpto, 
94
                                                (int)pto.getY() - dpto, 
95
                                                DIAM_CIRCLE, 
96
                                                DIAM_CIRCLE);
97
                        int incr = 5;
98
                        g.drawLine((int)pto.getX(), (int)pto.getY() - dpto - incr, (int)pto.getX(), (int)pto.getY() + dpto + incr);
99
                        g.drawLine((int)pto.getX() - dpto - incr, (int)pto.getY(), (int)pto.getX() + dpto + incr, (int)pto.getY());
100
                        
101
                }
102
        }
103
        
104
        /* (non-Javadoc)
105
         * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable, double)
106
         */
107
        public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
108
                        double scale) throws DriverException {
109
                // TODO Auto-generated method stub
110

    
111
        }
112
        
113
        /**
114
         * A?ade un punto a la lista
115
         * @param point punto para la lista
116
         */
117
        public void addPoint(Point2D pixel, Point2D map){
118
                pointList.add(new GeoPoint(pixel, map));
119
        }
120
        
121
        /**
122
         * Actualiza un punto de la lista de una posici?n determinada
123
         * @param point punto para la lista
124
         */
125
        public void updatePoint(Point2D pixel, Point2D map, int pos){
126
                GeoPoint gp = (GeoPoint)pointList.get(pos);
127
                if(pixel != null)
128
                        gp.pixelPoint = pixel;
129
                if(map != null)
130
                        gp.mapPoint = map;
131
        }
132
        
133
        /**
134
         * Devuelve el n?mero de puntos de la lista
135
         * @return
136
         */
137
        public int getCountPoints(){
138
                return pointList.size();
139
        }
140
                
141
        /**
142
         * Obtiene el extent de la capa
143
         * @return extent en Rectangle2D.
144
         */
145
        public Rectangle2D getFullExtent()throws DriverException {
146
                View theView = (View) PluginServices.getMDIManager().getActiveView();
147
                return theView.getMapControl().getMapContext().getViewPort().getExtent();
148
        }
149
        
150
        /**
151
         * @return Returns the lastTool.
152
         */
153
        public String getLastTool() {
154
                return lastTool;
155
        }
156
        
157
        /**
158
         * @param lastTool The lastTool to set.
159
         */
160
        public void setLastTool(String lastTool) {
161
                this.lastTool = lastTool;
162
        }
163
}