Revision 4763

View differences:

trunk/extensions/extGPS/src/org/gvsig/gps/panel/TestPanel.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.5  2006-04-06 10:35:59  jaume
46
 * Revision 1.6  2006-04-07 11:10:26  jaume
47 47
 * *** empty log message ***
48 48
 *
49
 * Revision 1.5  2006/04/06 10:35:59  jaume
50
 * *** empty log message ***
51
 *
49 52
 * Revision 1.4  2006/04/05 17:08:18  jaume
50 53
 * *** empty log message ***
51 54
 *
......
246 249
								lblPosValue.setText("("+pDst.getX()+", "+pDst.getY()+")");
247 250
								
248 251
								GPSExtension ext = (GPSExtension) PluginServices.getExtension(GPSExtension.class);
249
								ext.drawSymbol(null, null, pDst);
252
								ext.drawSymbol(null, null, pDst, false);
250 253
							}
251 254
							
252 255
							public void signalLevelChanged(float level) {
trunk/extensions/extGPS/src/org/gvsig/gps/panel/GPSControlPanel.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.8  2006-04-07 08:27:48  jaume
46
 * Revision 1.9  2006-04-07 11:10:26  jaume
47 47
 * *** empty log message ***
48 48
 *
49
 * Revision 1.8  2006/04/07 08:27:48  jaume
50
 * *** empty log message ***
51
 *
49 52
 * Revision 1.7  2006/04/06 10:35:48  jaume
50 53
 * *** empty log message ***
51 54
 *
......
386 389
						model.putValue(kPos, "("+lon+", "+lat+")");
387 390
						tblStatus.tableChanged(e);	
388 391
						// esto igual ho hauria de canviar.
389
						((GPSExtension) thisExtension).drawSymbol(null, null, p);
392
						((GPSExtension) thisExtension).drawSymbol(null, null, p, false);
390 393
					}
391 394
					
392 395
					public void signalLevelChanged(float level) {
trunk/extensions/extGPS/src/org/gvsig/gps/GPSDriver.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.4  2006-04-07 08:27:48  jaume
46
* Revision 1.5  2006-04-07 11:10:26  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.4  2006/04/07 08:27:48  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.3  2006/04/06 10:34:46  jaume
50 53
* *** empty log message ***
51 54
*
......
70 73
import gnu.io.SerialPort;
71 74
import gnu.io.UnsupportedCommOperationException;
72 75

  
76
import java.io.BufferedWriter;
77
import java.io.File;
78
import java.io.FileWriter;
73 79
import java.io.IOException;
74 80
import java.io.InputStream;
75 81
import java.io.OutputStream;
......
79 85
import java.util.Iterator;
80 86

  
81 87
import org.gvsig.gps.listeners.GPSEventListener;
82
import org.gvsig.gps.parser.NMEA.*;
88
import org.gvsig.gps.parser.NMEA.GGASentence;
89
import org.gvsig.gps.parser.NMEA.IllegalSentenceException;
90
import org.gvsig.gps.parser.NMEA.NMEASentence;
91
import org.gvsig.gps.parser.NMEA.NMEASentenceFactory;
92
import org.gvsig.gps.parser.NMEA.RMCSentence;
93
import org.gvsig.gps.parser.NMEA.VTGSentence;
83 94

  
84 95
/**
85 96
 * Singleton class that handles the communication within the application and the
......
111 122

  
112 123
	private static GPSDriver instance = null;
113 124
	
125
	
126
	
127
	private static String fileName = "c:/gps points.txt";
128
	static BufferedWriter bw ;
129
	
114 130
	/**
115 131
	 * Public instantiation of the driver is forbidden.
116 132
	 */
......
119 135
	public static GPSDriver getInstance() {
120 136
		if (instance == null) 
121 137
			instance = new GPSDriver();
138
		if (bw == null)
139
			try {
140
				bw = new BufferedWriter(new FileWriter(new File(fileName)));
141
			} catch (IOException e) {
142
				// TODO Auto-generated catch block
143
				e.printStackTrace();
144
			}
122 145
		return instance;
123 146
	}
124 147
	
......
249 272
						// This is a valid record
250 273
						if (aux instanceof GGASentence) {
251 274
							GGASentence s = (GGASentence) aux;
275
							{
276
								try {
277
									bw.write(s.getLongitude() + "," + s.getLatitude()+"\n");
278
									bw.flush();
279
								} catch (IOException e) {
280
									// TODO Auto-generated catch block
281
									e.printStackTrace();
282
								}
283
							}
252 284
							l.newLonLatPositionReceived(s.getLongitude(), s.getLatitude());
253 285
						} else if (aux instanceof RMCSentence) {
254 286
							l.unhandledMessage(aux.toString());
trunk/extensions/extGPS/src/org/gvsig/gps/GPSExtension.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.5  2006-04-07 08:27:48  jaume
46
* Revision 1.6  2006-04-07 11:10:26  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.5  2006/04/07 08:27:48  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.4  2006/04/06 10:34:58  jaume
50 53
* *** empty log message ***
51 54
*
......
67 70

  
68 71
import java.awt.Color;
69 72
import java.awt.geom.Point2D;
73
import java.io.BufferedReader;
74
import java.io.File;
75
import java.io.FileNotFoundException;
76
import java.io.FileReader;
77
import java.io.IOException;
70 78
import java.util.ArrayList;
71 79

  
72 80
import org.cresques.cts.ICoordTrans;
......
75 83
import org.cresques.cts.gt2.CoordSys;
76 84
import org.cresques.cts.gt2.CoordTrans;
77 85
import org.gvsig.gps.panel.GPSControlPanel;
78
import org.gvsig.gps.panel.TestPanel;
79 86

  
80 87
import com.iver.andami.PluginServices;
81 88
import com.iver.andami.plugins.Extension;
......
83 90
import com.iver.cit.gvsig.fmap.core.FPoint2D;
84 91
import com.iver.cit.gvsig.fmap.core.FShape;
85 92
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
86
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
87 93
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
88 94
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
89 95
import com.iver.cit.gvsig.fmap.rendering.FGraphic;
......
97 103
	}
98 104

  
99 105
	public void execute(String actionCommand) {
100
		PluginServices.getMDIManager().addView(GPSControlPanel.getInstance());
106
		if (actionCommand.equals("GPS_CONTROL_PANEL"))
107
			PluginServices.getMDIManager().addView(GPSControlPanel.getInstance());
108
		else if (actionCommand.equals("PAINT_POINTS"))
109
			paintPointsFromFile(new File("c:/gps-capture"));
101 110
	}
102 111

  
103 112
	public boolean isEnabled() {
......
116 125
	 * @param views
117 126
	 * @param location
118 127
	 * @param symbol
128
	 * @param refreshing, tells if the view will be refreshed (last points will be removed)
119 129
	 */
120
	public void drawSymbol(View[] views, FSymbol symbol, Point2D location) {
130
	public void drawSymbol(View[] views, FSymbol symbol, Point2D location, boolean refreshing) {
121 131
		//if (views == null || point == null) return;
122 132
		if (location == null || location.getX()==0 || location.getY()==0) return;
123 133
		if (views == null) 
......
141 151
			MapControl mc = views[i].getMapControl();
142 152
			GraphicLayer graph = mc.getMapContext().getGraphicsLayer();
143 153
			
144
			// Remove old graphics
145
			graph.clearAllGraphics();
146
			graph.clearSymbolsGraphics();
154
			if (refreshing) {
155
				// Remove old graphics
156
				graph.clearAllGraphics();
157
				graph.clearSymbolsGraphics();
158
				mc.drawGraphics();
159
			}
147 160
			
148 161
			// Obtain the current view's projection
149 162
			IProjection reqProj = mc.getProjection();
......
165 178
			mc.drawGraphics();
166 179
		}
167 180
	}
181
	
182
	private void paintPointsFromFile(File f){
183
		try {
184
			com.iver.andami.ui.mdiManager.View[] aViews = PluginServices.getMDIManager().getAllViews();
185
			ArrayList gvViews = new ArrayList();
186
			
187
			for (int i = 0; i < aViews.length; i++) {
188
				if (aViews[i] instanceof View) {
189
					gvViews.add((View) aViews[i]);
190
				}
191
			}
192
			
193
			View[] views = (View[]) gvViews.toArray(new View[0]);
194
			for (int i = 0; i < views.length; i++) {
195
				views[i].getMapControl().getMapContext().getGraphicsLayer().clearAllGraphics();
196
			}
197
			
198
			BufferedReader br = new BufferedReader(new FileReader(f));
199
			String line;
200
			for (line = br.readLine(); line!=null; line = br.readLine()){
201
				String[] numbers = line.split(",");
202
				
203
				double lonOffset = 0D;
204
				double latOffset = 0D;
205
				double lon = Double.parseDouble(numbers[0]) - lonOffset;
206
				double lat = Double.parseDouble(numbers[1]) - latOffset;
207
				drawSymbol(null, null, new Point2D.Double(lon, lat), false);
208
			}
209
		} catch (FileNotFoundException e) {
210
			// TODO Auto-generated catch block
211
			e.printStackTrace();
212
		} catch (IOException e) {
213
			// TODO Auto-generated catch block
214
			e.printStackTrace();
215
		}
216
	}
168 217
}
trunk/extensions/extGPS/config/config.xml
8 8
			description="GPS Support"
9 9
			active="true"
10 10
			priority="1">
11
			<menu text="Archivo/GPS"
11
			<menu text="Archivo/GPS/gps_control_panel"
12 12
				key="g" mnemonic="g"
13 13
				tooltip="gps"
14
				action-command="GPS"
15
				position="10"/>
14
				action-command="GPS_CONTROL_PANEL"
15
				position="1"/>
16
			<menu text="Archivo/GPS/pinta_punts_capturats"
17
				key="g" mnemonic="g"
18
				tooltip="gps"
19
				action-command="PAINT_POINTS"
20
				position="2"/>
16 21
		</extension>	
17 22
	</extensions>
18 23
</plugin-config>

Also available in: Unified diff