Revision 162 org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/serializer/GeoPointListRmfSerializer.java

View differences:

GeoPointListRmfSerializer.java
105 105
	public static final String MAPX     = "MapX";
106 106
	public static final String MAPY     = "MapY";
107 107
	public static final String ACTIVE   = "Active";
108
	public static final String LEFTCP   = "LeftCenterPoint";
109
	public static final String RIGHTCP  = "RightCenterPoint";
110
	public static final String X        = "X";
111
	public static final String Y        = "Y";
112
	public static final String LEFTVP   = "LeftViewPort";
113
	public static final String RIGHTVP  = "RightViewPort";
114 108
	public static final String PROJ     = "Proj";
115 109
	public static final String BBOX     = "Bbox";
116 110
	public static final String PX       = "Px";
......
120 114
	public static final String PDIM     = "Pdim";
121 115
	public static final String WIDTH    = "Width";
122 116
	public static final String HEIGHT   = "Height";
123
	public static final String ZOOM     = "Zoom";
124 117
	public static final String LYR      = "Layer";
125 118

  
126 119
	private GeoPointList  gpList = null;
......
130 123
	 * Registra GeoPointRmfSerializer en los puntos de extension de Serializer
131 124
	 */
132 125
	public static void register() {
133
		ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager();
134
		ExtensionPoint point=extensionPoints.get("Serializer");
126
		ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
127
		ExtensionPoint point = extensionPoints.get("Serializer");
135 128
		point.append("GeoPoint", "", GeoPointListRmfSerializer.class);
136 129
	}
137 130

  
......
159 152
	}
160 153

  
161 154
	/**
162
	 * Parsea un bloque correspondiente a un punto central
163
	 * @param gp
164
	 * @param parser
165
	 * @param parseableTag
166
	 * @throws NumberFormatException
167
	 * @throws XmlPullParserException
168
	 * @throws IOException
169
	 */
170
	/*private void parserCenterPoint(GeoPoint gp, KXmlParser parser, String parseableTag) throws NumberFormatException, XmlPullParserException, IOException {
171
		boolean end = false;
172
		boolean begin = true;
173
		boolean tagOk = false;
174
		int tag = parser.next();
175
		while (!end) {
176
			switch(tag) {
177
			case KXmlParser.START_TAG:
178
				if(parser.getName() != null){
179
					if (parser.getName().compareTo(parseableTag) == 0) {
180
						tagOk = true;
181
						begin = false;
182
					} else {
183
						if(begin)//Condicion de salida
184
							return;
185
					}
186
				}
187
				break;
188
			case KXmlParser.END_TAG:
189
				if (parser.getName().compareTo(parseableTag) == 0)
190
					end = true;
191
				break;
192
			case KXmlParser.TEXT:
193
				if(tagOk) {
194
					if(parseableTag.compareTo("LeftCenterPoint") == 0) {
195
						double x = Double.valueOf(parserString(parser, X, null)).doubleValue();
196
						double y = Double.valueOf(parserString(parser, Y, null)).doubleValue();
197
						gp.leftCenterPoint = new Point2D.Double(x, y);
198
					}
199
					if(parseableTag.compareTo("RightCenterPoint") == 0) {
200
						double x = Double.valueOf(parserString(parser, X, null)).doubleValue();
201
						double y = Double.valueOf(parserString(parser, Y, null)).doubleValue();
202
						gp.rightCenterPoint = new Point2D.Double(x, y);
203
					}
204
					tagOk = false;
205
				}
206
				break;
207
			}
208
			if (!end)
209
				tag = parser.next();
210
		}
211
	}*/
212

  
213
	/**
214
	 * Parsea un bloque correspondiente a un punto central
215
	 * @param gp
216
	 * @param parser
217
	 * @param parseableTag
218
	 * @throws NumberFormatException
219
	 * @throws XmlPullParserException
220
	 * @throws IOException
221
	 */
222
	/*private void parserBoundingBox(GeoPoint gp, KXmlParser parser, String parseableTag) throws NumberFormatException, XmlPullParserException, IOException {
223
		boolean end = false;
224
		boolean tagOk = false;
225
		int tag = parser.next();
226
		while (!end) {
227
			switch(tag) {
228
			case KXmlParser.START_TAG:
229
				if(parser.getName() != null){
230
					if (parser.getName().compareTo(BBOX) == 0)
231
						tagOk = true;
232
				}
233
				break;
234
			case KXmlParser.END_TAG:
235
				if (parser.getName().compareTo(BBOX) == 0)
236
					end = true;
237
				break;
238
			case KXmlParser.TEXT:
239
				if(tagOk) {
240
					if(parseableTag.compareTo("LeftViewPort") == 0) {
241
						double x = Double.valueOf(parserString(parser, PX, null)).doubleValue();
242
						double y = Double.valueOf(parserString(parser, PY, null)).doubleValue();
243
						double w = Double.valueOf(parserString(parser, WCWIDTH, null)).doubleValue();
244
						double h = Double.valueOf(parserString(parser, WCHEIGHT, null)).doubleValue();
245
						gp.leftViewPort.setExtent(new Extent(x, y, x + w, y - h));
246
					}
247
					if(parseableTag.compareTo("RightViewPort") == 0) {
248
						double x = Double.valueOf(parserString(parser, PX, null)).doubleValue();
249
						double y = Double.valueOf(parserString(parser, PY, null)).doubleValue();
250
						double w = Double.valueOf(parserString(parser, WCWIDTH, null)).doubleValue();
251
						double h = Double.valueOf(parserString(parser, WCHEIGHT, null)).doubleValue();
252
						gp.rightViewPort.setExtent(new Extent(x, y, x + w, y - h));
253
					}
254
					tagOk = false;
255
				}
256
				break;
257
			}
258
			if (!end)
259
				tag = parser.next();
260
		}
261
	}*/
262

  
263
	/**
264
	 * Parsea un bloque correspondiente a un punto central
265
	 * @param gp
266
	 * @param parser
267
	 * @param parseableTag
268
	 * @throws NumberFormatException
269
	 * @throws XmlPullParserException
270
	 * @throws IOException
271
	 */
272
	/*private void parserDimension(GeoPoint gp, KXmlParser parser, String parseableTag) throws NumberFormatException, XmlPullParserException, IOException {
273
		boolean end = false;
274
		boolean tagOk = false;
275
		int tag = parser.next();
276
		while (!end) {
277
			switch(tag) {
278
			case KXmlParser.START_TAG:
279
				if(parser.getName() != null){
280
					if (parser.getName().compareTo(PDIM) == 0)
281
						tagOk = true;
282
				}
283
				break;
284
			case KXmlParser.END_TAG:
285
				if (parser.getName().compareTo(PDIM) == 0)
286
					end = true;
287
				break;
288
			case KXmlParser.TEXT:
289
				if(tagOk) {
290
					if(parseableTag.compareTo("LeftViewPort") == 0) {
291
						double x = Double.valueOf(parserString(parser, WIDTH, null)).doubleValue();
292
						double y = Double.valueOf(parserString(parser, HEIGHT, null)).doubleValue();
293
						//gp.leftViewPort.setSize(x, y);
294
					}
295
					if(parseableTag.compareTo("RightViewPort") == 0) {
296
						double x = Double.valueOf(parserString(parser, WIDTH, null)).doubleValue();
297
						double y = Double.valueOf(parserString(parser, HEIGHT, null)).doubleValue();
298
						//gp.rightViewPort.setSize(x, y);
299
					}
300
					tagOk = false;
301
				}
302
				break;
303
			}
304
			if (!end)
305
				tag = parser.next();
306
		}
307
	}*/
308

  
309
	/**
310
	 * Parsea un viewport contenido en un punto de control
311
	 * @param gp
312
	 * @param parser
313
	 * @param parseableTag
314
	 * @throws XmlPullParserException
315
	 * @throws IOException
316
	 */
317
	/*private void parserViewPort(GeoPoint gp, KXmlParser parser, String parseableTag) throws XmlPullParserException, IOException {
318
		boolean end = false;
319
		if(parseableTag.compareTo("LeftViewPort") == 0) {
320
			gp.leftViewPort = new ViewPortData();
321
			gp.leftViewPort.mat = new AffineTransform();
322
		}
323
		if(parseableTag.compareTo("RightViewPort") == 0) {
324
			gp.rightViewPort = new ViewPortData();
325
			gp.rightViewPort.mat = new AffineTransform();
326
		}
327
		int tag = parser.next();
328
		while (!end) {
329
			switch(tag) {
330
			case KXmlParser.START_TAG:
331
				if(parser.getName() != null){
332
					if (parser.getName().compareTo(parseableTag) == 0) {
333
						String proj = parserString(parser, PROJ, null);
334
						parserBoundingBox(gp, parser, parseableTag);
335
						parserDimension(gp, parser, parseableTag);
336
						if(parseableTag.compareTo("LeftViewPort") == 0)
337
							gp.zoomLeft = Double.valueOf(parserString(parser, ZOOM, null)).doubleValue();
338
						if(parseableTag.compareTo("RightViewPort") == 0)
339
							gp.zoomRight = Double.valueOf(parserString(parser, ZOOM, null)).doubleValue();
340
					}
341
				}
342
				break;
343
			case KXmlParser.END_TAG:
344
				if (parser.getName().compareTo(parseableTag) == 0)
345
					end = true;
346
				break;
347
			case KXmlParser.TEXT:
348
				break;
349
			}
350
			if (!end)
351
				tag = parser.next();
352
		}
353
	}*/
354

  
355
	/**
356 155
	 * Parsea un punto de control completo
357 156
	 * @param gp
358 157
	 * @param parser
......
371 170
		double my = Double.parseDouble(parserString(parser, MAPY, null));
372 171
		gp.mapPoint = new Point2D.Double(mx, my);
373 172
		gp.active = Boolean.valueOf(parserString(parser, ACTIVE, null)).booleanValue();
374
		/*parserCenterPoint(gp, parser, "LeftCenterPoint");
375
		parserCenterPoint(gp, parser, "RightCenterPoint");
376
		parserViewPort(gp, parser, "LeftViewPort");
377
		parserViewPort(gp, parser, "RightViewPort");*/
378 173
	}
379 174

  
380 175
	/*
......
452 247
		StringBuffer b = new StringBuffer();
453 248

  
454 249
		b.append("<" + MAIN_TAG + ">\n");
455
		/*b.append("\t<" + LYR + ">\n");
456
		if(viewPort != null && viewPort.pxSize != null) {
457
			String proj = "";
458
			if(viewPort.getProjection() != null)
459
				proj = viewPort.getProjection().getAbrev();
460
			putProperty(b, PROJ, proj, 3);
461
			b.append("\t\t\t<" + BBOX + ">\n");
462
			putProperty(b, PX, viewPort.getExtent().getMin().getX(), 4);
463
			putProperty(b, PY, viewPort.getExtent().getMax().getY(), 4);
464
			putProperty(b, WCWIDTH, viewPort.getExtent().width(), 4);
465
			putProperty(b, WCHEIGHT, viewPort.getExtent().height(), 4);
466
			b.append("\t\t\t</" + BBOX + ">\n");
467
			b.append("\t\t\t<" + PDIM + ">\n");
468
			putProperty(b, WIDTH, viewPort.pxSize.getX(), 4);
469
			putProperty(b, HEIGHT, viewPort.pxSize.getY(), 4);
470
			b.append("\t\t\t</" + PDIM + ">\n");
471
		} else {
472
			putProperty(b, PROJ, "", 3);
473
			b.append("\t\t\t<" + BBOX + ">\n");
474
			putProperty(b, PX, 0.0, 4);
475
			putProperty(b, PY, 0.0, 4);
476
			putProperty(b, WCWIDTH, 0.0, 4);
477
			putProperty(b, WCHEIGHT, 0.0, 4);
478
			b.append("\t\t\t</" + BBOX + ">\n");
479
			b.append("\t\t\t<" + PDIM + ">\n");
480
			putProperty(b, WIDTH, 0.0, 4);
481
			putProperty(b, HEIGHT, 0.0, 4);
482
			b.append("\t\t\t</" + PDIM + ">\n");
483
		}
484
		b.append("\t</" + LYR + ">\n");*/
485 250
		for (int i = 0; i < gpList.size(); i++) {
486 251
			GeoPoint point = gpList.get(i);
487 252
			b.append("\t<" + GEOPOINT + " n=\"" + i + "\">\n");
......
490 255
			putProperty(b, MAPX, point.mapPoint.getX(), 2);
491 256
			putProperty(b, MAPY, point.mapPoint.getY(), 2);
492 257
			putProperty(b, ACTIVE, String.valueOf(point.active), 2);
493

  
494
			/*if(point.leftCenterPoint != null) {
495
				b.append("\t\t<" + LEFTCP + ">\n");
496
				putProperty(b, X, point.leftCenterPoint.getX(), 3);
497
				putProperty(b, Y, point.leftCenterPoint.getY(), 3);
498
				b.append("\t\t</" + LEFTCP + ">\n");
499
			}
500

  
501
			if(point.rightCenterPoint != null) {
502
				b.append("\t\t<" + RIGHTCP + ">\n");
503
				putProperty(b, X, point.rightCenterPoint.getX(), 3);
504
				putProperty(b, Y, point.rightCenterPoint.getY(), 3);
505
				b.append("\t\t</" + RIGHTCP + ">\n");
506
			}
507

  
508
			String proj = "";
509

  
510
			if(point.leftViewPort != null) {
511
				b.append("\t\t<" + LEFTVP + ">\n");
512

  
513
				if(point.leftViewPort.getProjection() != null)
514
					proj = point.leftViewPort.getProjection().getAbrev();
515
				putProperty(b, PROJ, proj, 3);
516
				b.append("\t\t\t<" + BBOX + ">\n");
517
				putProperty(b, PX, point.leftViewPort.getExtent().getMin().getX(), 4);
518
				putProperty(b, PY, point.leftViewPort.getExtent().getMax().getY(), 4);
519
				putProperty(b, WCWIDTH, point.leftViewPort.getExtent().width(), 4);
520
				putProperty(b, WCHEIGHT, point.leftViewPort.getExtent().height(), 4);
521
				b.append("\t\t\t</" + BBOX + ">\n");
522

  
523
				b.append("\t\t\t<" + PDIM + ">\n");
524
				putProperty(b, WIDTH, GeoPoint.WIDTH_WINDOW, 4);
525
				putProperty(b, HEIGHT, GeoPoint.HEIGHT_WINDOW, 4);
526
				b.append("\t\t\t</" + PDIM + ">\n");
527
				putProperty(b, ZOOM, point.zoomLeft, 3);
528

  
529
				b.append("\t\t</" + LEFTVP + ">\n");
530
			}
531

  
532
			if(point.rightViewPort != null) {
533
				b.append("\t\t<" + RIGHTVP + ">\n");
534

  
535
				proj = "";
536
				if(point.rightViewPort.getProjection() != null)
537
					proj = point.rightViewPort.getProjection().getAbrev();
538
				putProperty(b, PROJ, proj, 3);
539
				b.append("\t\t\t<" + BBOX + ">\n");
540
				putProperty(b, PX, point.rightViewPort.getExtent().getMin().getX(), 4);
541
				putProperty(b, PY, point.rightViewPort.getExtent().getMax().getY(), 4);
542
				putProperty(b, WCWIDTH, point.rightViewPort.getExtent().width(), 4);
543
				putProperty(b, WCHEIGHT, point.rightViewPort.getExtent().height(), 4);
544
				b.append("\t\t\t</" + BBOX + ">\n");
545

  
546
				b.append("\t\t\t<" + PDIM + ">\n");
547
				putProperty(b, WIDTH, GeoPoint.WIDTH_WINDOW, 4);
548
				putProperty(b, HEIGHT, GeoPoint.HEIGHT_WINDOW, 4);
549
				b.append("\t\t\t</" + PDIM + ">\n");
550
				putProperty(b, ZOOM, point.zoomRight, 3);
551

  
552
				b.append("\t\t</" + RIGHTVP + ">\n");
553
			}*/
554

  
555 258
			b.append("\t</" + GEOPOINT + ">\n");
556 259
		}
557 260
		b.append("</" + MAIN_TAG + ">\n");

Also available in: Unified diff