Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGPS / src / org / gvsig / gps / GPSExtension.java @ 4749

History | View | Annotate | Download (3.51 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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

    
42
/* CVS MESSAGES:
43
*
44
* $Id: GPSExtension.java 4749 2006-04-05 17:08:18Z jaume $
45
* $Log$
46
* Revision 1.3  2006-04-05 17:08:18  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.2  2006/04/05 16:02:09  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.1  2006/04/03 16:10:27  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.1  2006/03/31 09:55:34  jaume
56
* *** empty log message ***
57
*
58
*
59
*/
60
package org.gvsig.gps;
61

    
62
import java.awt.Color;
63
import java.awt.geom.Point2D;
64
import java.util.ArrayList;
65

    
66
import org.gvsig.gps.panel.GPSControlPanel;
67
import org.gvsig.gps.panel.TestPanel;
68

    
69
import com.iver.andami.PluginServices;
70
import com.iver.andami.plugins.Extension;
71
import com.iver.cit.gvsig.fmap.MapControl;
72
import com.iver.cit.gvsig.fmap.core.FPoint2D;
73
import com.iver.cit.gvsig.fmap.core.FShape;
74
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
75
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
76
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
77
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
78
import com.iver.cit.gvsig.fmap.rendering.FGraphic;
79
import com.iver.cit.gvsig.gui.View;
80

    
81
public class GPSExtension implements Extension{
82

    
83
        public void inicializar() {
84
                // TODO Auto-generated method stub
85
                
86
        }
87

    
88
        public void execute(String actionCommand) {
89
                
90
                PluginServices.getMDIManager().addView(new GPSControlPanel());
91
        }
92

    
93
        public boolean isEnabled() {
94
                return true;
95
        }
96

    
97
        public boolean isVisible() {
98
                return true;
99
        }
100

    
101
        public void drawPoint(View[] views, FSymbol symbol, Point2D location) {
102
                //if (views == null || point == null) return;
103
                if (location == null || location.getX()==0 || location.getY()==0) return;
104
                if (views == null) 
105
                {
106
                        com.iver.andami.ui.mdiManager.View[] aViews = PluginServices.getMDIManager().getAllViews();
107
                        ArrayList gvViews = new ArrayList();
108
                        for (int i = 0; i < aViews.length; i++) {
109
                                if (aViews[i] instanceof View) {
110
                                        gvViews.add((View) aViews[i]);
111
                                }
112
                        }
113
                        views = (View[]) gvViews.toArray(new View[0]);
114
                }
115
                
116
                if (symbol == null) {
117
                        symbol = new FSymbol(FShape.POINT, Color.ORANGE);
118
                        symbol.setSize(10);
119
                }
120
                
121
                for (int i = 0; i < views.length; i++) {
122
                        MapControl mc = views[i].getMapControl();
123
                        GraphicLayer graph = mc.getMapContext().getGraphicsLayer();
124
                        graph.clearAllGraphics();
125
                        graph.clearSymbolsGraphics();
126
                        
127
                        graph.addSymbol(symbol);
128
                        graph.addGraphic(new FGraphic(ShapeFactory.createPoint2D(new FPoint2D(location)), 0));
129
                        mc.drawGraphics();
130
                }
131
        }
132
}