Revision 47476 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.labeling.app/org.gvsig.labeling.app.mainplugin/src/main/java/org/gvsig/labeling/symbol/CharacterMarkerSymbol.java

View differences:

CharacterMarkerSymbol.java
39 39
 *   dac@iver.es
40 40
 */
41 41

  
42
/* CVS MESSAGES:
43
 *
44
 * $Id: CharacterMarkerSymbol.java 14501 2007-10-08 15:47:31Z jdominguez $
45
 * $Log$
46
 * Revision 1.27  2007-09-21 12:25:32  jaume
47
 * cancellation support extended down to the IGeometry and ISymbol level
48
 *
49
 * Revision 1.26  2007/08/09 07:20:03  jvidal
50
 * javadoc
51
 *
52
 * Revision 1.25  2007/07/23 06:52:25  jaume
53
 * default selection color refactored, moved to MapContext
54
 *
55
 * Revision 1.24  2007/07/18 06:54:34  jaume
56
 * continuing with cartographic support
57
 *
58
 * Revision 1.23  2007/07/03 10:58:29  jaume
59
 * first refactor on CartographicSupport
60
 *
61
 * Revision 1.22  2007/06/29 13:07:01  jaume
62
 * +PictureLineSymbol
63
 *
64
 * Revision 1.21  2007/06/07 06:50:40  jaume
65
 * *** empty log message ***
66
 *
67
 * Revision 1.20  2007/05/29 15:46:37  jaume
68
 * *** empty log message ***
69
 *
70
 * Revision 1.19  2007/05/28 15:36:42  jaume
71
 * *** empty log message ***
72
 *
73
 * Revision 1.18  2007/05/17 09:32:06  jaume
74
 * *** empty log message ***
75
 *
76
 * Revision 1.17  2007/05/09 16:07:26  jaume
77
 * *** empty log message ***
78
 *
79
 * Revision 1.16  2007/05/09 11:05:28  jaume
80
 * *** empty log message ***
81
 *
82
 * Revision 1.15  2007/05/08 08:47:40  jaume
83
 * *** empty log message ***
84
 *
85
 * Revision 1.14  2007/04/26 11:41:00  jaume
86
 * attempting to let defining size in world units
87
 *
88
 * Revision 1.13  2007/04/20 07:11:11  jaume
89
 * *** empty log message ***
90
 *
91
 * Revision 1.12  2007/04/19 16:01:27  jaume
92
 * *** empty log message ***
93
 *
94
 * Revision 1.11  2007/04/19 14:21:30  jaume
95
 * *** empty log message ***
96
 *
97
 * Revision 1.10  2007/03/26 14:24:13  jaume
98
 * implemented Print
99
 *
100
 * Revision 1.9  2007/03/21 11:37:00  jaume
101
 * *** empty log message ***
102
 *
103
 * Revision 1.8  2007/03/21 11:02:17  jaume
104
 * *** empty log message ***
105
 *
106
 * Revision 1.7  2007/03/09 11:20:56  jaume
107
 * Advanced symbology (start committing)
108
 *
109
 * Revision 1.5.2.8  2007/02/21 07:34:09  jaume
110
 * labeling starts working
111
 *
112
 * Revision 1.5.2.7  2007/02/16 10:54:12  jaume
113
 * multilayer splitted to multilayerline, multilayermarker,and  multilayerfill
114
 *
115
 * Revision 1.5.2.6  2007/02/15 16:23:44  jaume
116
 * *** empty log message ***
117
 *
118
 * Revision 1.5.2.5  2007/02/14 09:58:37  jaume
119
 * *** empty log message ***
120
 *
121
 * Revision 1.5.2.4  2007/02/12 15:15:20  jaume
122
 * refactored interval legend and added graduated symbol legend
123
 *
124
 * Revision 1.5.2.3  2007/02/09 07:47:04  jaume
125
 * Isymbol moved
126
 *
127
 * Revision 1.5.2.2  2007/02/05 14:59:04  jaume
128
 * *** empty log message ***
129
 *
130
 * Revision 1.5.2.1  2007/01/30 18:10:45  jaume
131
 * start commiting labeling stuff
132
 *
133
 * Revision 1.5  2007/01/25 16:25:23  jaume
134
 * *** empty log message ***
135
 *
136
 * Revision 1.4  2007/01/24 17:58:22  jaume
137
 * new features and architecture error fixes
138
 *
139
 * Revision 1.3  2007/01/16 11:50:44  jaume
140
 * *** empty log message ***
141
 *
142
 * Revision 1.2  2007/01/10 16:39:41  jaume
143
 * ISymbol now belongs to com.iver.cit.gvsig.fmap.core.symbols package
144
 *
145
 * Revision 1.1  2007/01/10 16:31:36  jaume
146
 * *** empty log message ***
147
 *
148
 * Revision 1.6  2006/12/04 17:13:39  fjp
149
 * *** empty log message ***
150
 *
151
 * Revision 1.5  2006/11/14 11:10:27  jaume
152
 * *** empty log message ***
153
 *
154
 * Revision 1.4  2006/11/09 18:39:05  jaume
155
 * *** empty log message ***
156
 *
157
 * Revision 1.3  2006/11/08 10:56:47  jaume
158
 * *** empty log message ***
159
 *
160
 * Revision 1.2  2006/11/06 17:08:45  jaume
161
 * *** empty log message ***
162
 *
163
 * Revision 1.1  2006/10/31 16:16:34  jaume
164
 * *** empty log message ***
165
 *
166
 * Revision 1.4  2006/10/30 19:30:35  jaume
167
 * *** empty log message ***
168
 *
169
 * Revision 1.3  2006/10/29 23:53:49  jaume
170
 * *** empty log message ***
171
 *
172
 * Revision 1.2  2006/10/26 16:27:33  jaume
173
 * support for composite marker symbols (not tested)
174
 *
175
 * Revision 1.1  2006/10/25 10:50:41  jaume
176
 * movement of classes and gui stuff
177
 *
178
 * Revision 1.3  2006/10/24 19:54:16  jaume
179
 * added IPersistence
180
 *
181
 * Revision 1.2  2006/10/24 08:02:51  jaume
182
 * *** empty log message ***
183
 *
184
 * Revision 1.1  2006/10/18 07:54:06  jaume
185
 * *** empty log message ***
186
 *
187
 *
188
 */
189 42
package org.gvsig.labeling.symbol;
190 43

  
191 44
import java.awt.Color;
......
198 51
import java.awt.geom.AffineTransform;
199 52
import java.awt.geom.Point2D;
200 53
import java.awt.image.BufferedImage;
201

  
202 54
import org.gvsig.compat.print.PrintAttributes;
203 55
import org.gvsig.fmap.dal.feature.Feature;
204 56
import org.gvsig.fmap.geom.Geometry;
205 57
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
206
import org.gvsig.fmap.geom.Geometry.TYPES;
207 58
import org.gvsig.fmap.geom.GeometryLocator;
208 59
import org.gvsig.fmap.geom.GeometryManager;
209
import org.gvsig.fmap.geom.exception.CreateGeometryException;
210 60
import org.gvsig.fmap.geom.primitive.Envelope;
211 61
import org.gvsig.fmap.mapcontext.MapContext;
212 62
import org.gvsig.fmap.mapcontext.ViewPort;
213 63
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
214 64
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
215
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
216 65
import org.gvsig.labeling.lang.LabelClassUtils;
217
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
66
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol_v2;
67
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.AbstractMarkerSymbol;
218 68
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMask;
219 69
import org.gvsig.tools.ToolsLocator;
220 70
import org.gvsig.tools.dynobject.DynStruct;
221 71
import org.gvsig.tools.persistence.PersistenceManager;
72
import static org.gvsig.tools.persistence.PersistenceManager.PERSISTENCE_NAMESPACE;
222 73
import org.gvsig.tools.persistence.PersistentState;
223 74
import org.gvsig.tools.persistence.exception.PersistenceException;
224 75
import org.gvsig.tools.task.Cancellable;
......
231 82
 * more agile.
232 83
 * @author   jaume dominguez faus - jaume.dominguez@iver.es
233 84
 */
234
public class CharacterMarkerSymbol implements IMarkerSymbol {
85
public class CharacterMarkerSymbol extends AbstractMarkerSymbol implements IMarkerSymbol_v2 {
235 86

  
236 87
	private static Logger logger =
237 88
			LoggerFactory.getLogger(CharacterMarkerSymbol.class);
......
243 94
	private int unicode;
244 95
	private ISymbol selectionSymbol;
245 96
	private VisualCorrection visualCorrection;
246
	private double size;
247 97

  
248
	private boolean isShapeVisible = true;
249
	private String desc = "";
98
//	private boolean isShapeVisible = true;
99
//	private String desc = "";
250 100

  
251
	private IMask mask;
252
	private int unit = -1;
253
	private int referenceSystem = CartographicSupport.WORLD;
101
//	private double size;
102
//	private Color color = Color.BLACK;
103
//	private Point2D offset = new Point2D.Double();
104
//	private IMask mask;
105
//	private double rotation_radians = 0;
254 106

  
107
//	private int unit = -1;
108
//	private int referenceSystem = CartographicSupport.WORLD;
109

  
255 110
	private int alpha = 255;
256
	private Point2D offset = new Point2D.Double();
257 111

  
258 112
	/*
259 113
	 *
260 114
	 */
261
	private double rotation_radians = 0;
262
	private Color color = Color.BLACK;
263 115

  
264 116
	private static GeometryManager geoman = GeometryLocator.getGeometryManager();
265 117

  
......
294 146
	 * @return font
295 147
	 */
296 148
	public Font getFont() {
297
		return font;
149
            if(font == null){
150
                font = new Font("Arial", Font.PLAIN, (int) Math.round(getSize()));
151
            }
152
            return font;
298 153
	}
299 154
	/**
300 155
	 * Sets the font that will be used to define the symbol
......
302 157
	 */
303 158
	public void setFont(Font font) {
304 159
		this.font = font;
160
                this.setSize(this.font.getSize());
305 161
	}
162
    
163
        @Override
164
    public ISymbol getSymbolForSelection() {
165
        if (selectionSymbol == null) {
166
            selectionSymbol = (ISymbol) LabelClassUtils.clone(this);
167
            selectionSymbol.setColor(MapContext.getSelectionColor());
168
        } else {
169
            selectionSymbol.setColor(MapContext.getSelectionColor());
170
        }
171
        if (selectionSymbol instanceof CartographicSupport) {
172
            ((CartographicSupport) selectionSymbol).setUnit(this.getUnit());
173
        }
306 174

  
307
	public ISymbol getSymbolForSelection() {
308
		if (selectionSymbol == null) {
309
			selectionSymbol = (ISymbol) LabelClassUtils.clone(this);
310
			selectionSymbol.setColor(MapContext.getSelectionColor());
311
		}else{
312
		    selectionSymbol.setColor(MapContext.getSelectionColor());
313
		}
314
		return selectionSymbol;
315
	}
175
        return selectionSymbol;
176
    }
316 177

  
317 178

  
318 179
	public void draw(Graphics2D g,
319 180
			AffineTransform affineTransform, Geometry geom,
320
			Feature feat, Cancellable cancel) {
181
			Feature feat, Cancellable cancel, Rectangle r) {
321 182

  
322
		g.setColor(getColor());
323
		double theta = getRotation();
183
                double size_d = getCartographicSize();
184
//                size_d = this.getPrintSize(properties, size_d);
185
                size_d = this.getAdjustedSize(r, size_d);
324 186

  
325
		int xOffset = (int) getOffset().getX(); // * multiplicador d'unitats;
326
		int yOffset = (int) getOffset().getY(); // * multiplicador d'unitats
187
		double theta = getEfectiveRotationInRadians(feat);
327 188

  
328
		double size = getSize();
329
		if (size < 0.0001) {
189
		int xOffset = (int) getEfectiveOffset(feat).getX(); 
190
		int yOffset = (int) getEfectiveOffset(feat).getY(); 
191

  
192
		if (size_d < 0.0001) {
330 193
			return;
331 194
		}
332 195

  
......
334 197
		try {
335 198
			cen = geom.centroid();
336 199
		} catch (Exception e) {
337
			logger.error("While getting centroid", e);
200
			logger.warn("While getting centroid", e);
201
                        return;
338 202
		}
203
        g.setColor(getColor());
339 204

  
340 205
		Point2D p = new Point2D.Double(cen.getX(), cen.getY());
341 206

  
342 207
		if (isVisuallyCorrected()) {
343
			size *= visualCorrection.sizeScale;
344
			p.setLocation(p.getX() - xOffset*size*visualCorrection.xOffsetScale, p.getY() - yOffset*size*visualCorrection.yOffsetScale);
208
			size_d *= visualCorrection.sizeScale;
209
			p.setLocation(p.getX() - xOffset*size_d*visualCorrection.xOffsetScale, p.getY() - yOffset*size_d*visualCorrection.yOffsetScale);
345 210

  
346 211
		}
347
		g.setFont(getFont().deriveFont((float)size));
212
		g.setFont(getFont().deriveFont((float)size_d));
348 213

  
349 214
		g.translate((int) (p.getX() + xOffset), (int) (p.getY()  + yOffset));
350
		if (theta != 0)	g.rotate(theta);
215
		if (theta != 0)	{
216
                    g.rotate(theta);
217
                }
351 218

  
352 219
		char[] text = new char[] { (char) unicode };
353 220

  
......
362 229
			 		draw(g, null, mask.getHaloShape(markerShape), feat, cancel);
363 230

  
364 231
		}
365
		g.drawChars(text, 0, text.length, - (int) (size*0.4), (int) (size*0.4));
232
		g.drawChars(text, 0, text.length, - (int) (size_d*0.4), (int) (size_d*0.4));
366 233

  
367 234

  
368
		if (theta!=0) g.rotate(-theta);
235
		if (theta!=0) {
236
                    g.rotate(-theta);
237
                }
369 238
		g.translate(-(int) (p.getX() + xOffset), - (int) (p.getY() + yOffset));
370 239
	}
371 240

  
......
412 281
	*/
413 282

  
414 283

  
415
	public double getSize() {
416
		return size;
417
	}
284
//	public double getSize() {
285
//		return size;
286
//	}
418 287

  
419 288
	public void setSize(double size) {
420
		this.size = size;
289
		super.setSize(size);
290
                //NOTE: No hay que llamar al setFont
421 291
		font = new Font(font.getName(), font.getStyle(), (int) Math.round(size));
422 292
	}
423 293
	/**
......
456 326
			} catch (Exception e) {
457 327
				logger.error("While creating point", e);
458 328
			}
459
			clone.draw(aGraphics, new AffineTransform(), pCenter, null, null);
329
			clone.draw(aGraphics, new AffineTransform(), pCenter, null, null, null);
460 330

  
461 331
			int realTop    = -1;
462 332
			int realBottom = -1;
......
507 377
				}
508 378
			}
509 379

  
510
			int realWidth = bi.getWidth() - realRight-realLeft;
380
			int realWidth = bi.getWidth() - realRight - realLeft;
511 381
			int realHeight = bi.getHeight() - realBottom - realTop;
512 382

  
513 383
			visualCorrection = new VisualCorrection();
......
538 408
			Geometry geom, float[] distances,
539 409
			ViewPort viewPort, int dpi) {
540 410

  
541
		float cs = (float) getCartographicSize(viewPort, dpi, geom);
411
//		float cs = (float) getCartographicSize(viewPort, dpi, geom);
412
		float cs = (float) this.getEfectiveSize(null);
542 413
		distances[0] = cs;
543 414
		distances[1] = cs;
544 415
	}
......
579 450
		return this.getColor().getRGB();
580 451
	}
581 452

  
582
	public String getDescription() {
583
		return desc;
584
	}
453
//        @Override
454
//	public String getDescription() {
455
//		return desc;
456
//	}
457
//
458
//	public boolean isShapeVisible() {
459
//		return isShapeVisible;
460
//	}
461
//
462
//	public void setDescription(String d) {
463
//		desc = d;
464
//	}
585 465

  
586
	public boolean isShapeVisible() {
587
		return isShapeVisible;
588
	}
466
//	public int getSymbolType() {
467
//		return Geometry.TYPES.POINT;
468
//	}
589 469

  
590
	public void setDescription(String d) {
591
		desc = d;
592
	}
593

  
594
	public int getSymbolType() {
595
		return Geometry.TYPES.POINT;
596
	}
597

  
470
        @Override
598 471
	public boolean isSuitableFor(Geometry geom) {
599 472
		return geom.getType() == Geometry.TYPES.POINT
600 473
				|| geom.getType() == Geometry.TYPES.MULTIPOINT;
601 474
	}
602 475

  
603
	public void drawInsideRectangle(Graphics2D g,
604
			AffineTransform scaleInstance, Rectangle r,
605
			PrintAttributes properties) throws SymbolDrawingException {
476
//	public void drawInsideRectangle(Graphics2D g,
477
//			AffineTransform scaleInstance, Rectangle r,
478
//			PrintAttributes properties) throws SymbolDrawingException {
479
//
480
//
481
//		org.gvsig.fmap.geom.primitive.Point center = null;
482
//		try {
483
//			center = geoman.createPoint(
484
//					r.getCenterX(), r.getCenterY(), SUBTYPES.GEOM2D);
485
//		} catch (CreateGeometryException e) {
486
//			throw new SymbolDrawingException(TYPES.POINT);
487
//		}
488
//
489
//		if (properties==null) {
490
//			draw(g, scaleInstance, center, null, null);
491
//		} else {
492
//			double originalSize = getSize();
493
//			double size=originalSize;
494
//			int pq = properties.getPrintQuality();
495
//			if (pq == PrintAttributes.PRINT_QUALITY_HIGH) {
496
//				size *= (double) 600/72;
497
//			} else {
498
//				if (pq == PrintAttributes.PRINT_QUALITY_NORMAL) {
499
//					size *= (double) 300/72;
500
//				} else {
501
////					unitFactor *= 72; (which is the same than doing nothing)
502
//				}
503
//			}
504
//			setSize(size);
505
//			print(g, scaleInstance, center, properties);
506
//			setSize(originalSize);
507
//		}
508
//
509
//	}
606 510

  
607 511

  
608
		org.gvsig.fmap.geom.primitive.Point center = null;
609
		try {
610
			center = geoman.createPoint(
611
					r.getCenterX(), r.getCenterY(), SUBTYPES.GEOM2D);
612
		} catch (CreateGeometryException e) {
613
			throw new SymbolDrawingException(TYPES.POINT);
614
		}
615

  
616
		if (properties==null) {
617
			draw(g, scaleInstance, center, null, null);
618
		} else {
619
			double originalSize = getSize();
620
			double size=originalSize;
621
			int pq = properties.getPrintQuality();
622
			if (pq == PrintAttributes.PRINT_QUALITY_HIGH) {
623
				size *= (double) 600/72;
624
			} else {
625
				if (pq == PrintAttributes.PRINT_QUALITY_NORMAL) {
626
					size *= (double) 300/72;
627
				} else {
628
//					unitFactor *= 72; (which is the same than doing nothing)
629
				}
630
			}
631
			setSize(size);
632
			print(g, scaleInstance, center, properties);
633
			setSize(originalSize);
634
		}
635

  
636
	}
637

  
638

  
639 512
	public void print(Graphics2D g, AffineTransform at, Geometry geom,
640 513
			PrintAttributes properties) {
641 514

  
......
654 527
		draw(g,at,geom,null,null);
655 528
	}
656 529

  
657
	public void setUnit(int unitIndex) {
658
		unit = unitIndex;
659
	}
530
//	public void setUnit(int unitIndex) {
531
//		unit = unitIndex;
532
//	}
533
//
534
//	public int getUnit() {
535
//		return unit;
536
//	}
537
//
538
//	public int getReferenceSystem() {
539
//		return this.referenceSystem;
540
//	}
541
//
542
//	public void setReferenceSystem(int rs) {
543
//		this.referenceSystem = rs;
544
//	}
545
//
546
//	public double toCartographicSize(ViewPort viewPort, double dpi,
547
//			Geometry geom) {
548
//
549
//		double oldSize = getSize();
550
//		setCartographicSize(getCartographicSize(viewPort, dpi, geom), geom);
551
//		return oldSize;	}
552
//
553
//	public void setCartographicSize(double cartographicSize, Geometry geom) {
554
//		setSize(cartographicSize);
555
//	}
556
//
557
//	public double getCartographicSize(ViewPort viewPort, double dpi,
558
//			Geometry geom) {
559
//
560
//		return SymbolUtils.getCartographicLength(this,
561
//									  getSize(),
562
//									  viewPort,
563
//									  dpi);
564
//	}
660 565

  
661
	public int getUnit() {
662
		return unit;
663
	}
566
//	public double getRotation() {
567
//		return rotation_radians;
568
//	}
569
//
570
//	public void setRotation(double rot) {
571
//		rotation_radians = rot;
572
//	}
573
//
574
//	public Point2D getOffset() {
575
//		return offset;
576
//	}
577
//
578
//	public void setOffset(Point2D off) {
579
//		offset = off;
580
//	}
581
//
582
//	public Color getColor() {
583
//		return color;
584
//	}
585
//
586
//	public void setColor(Color co) {
587
//		color = co;
588
//	}
664 589

  
665
	public int getReferenceSystem() {
666
		return this.referenceSystem;
667
	}
668

  
669
	public void setReferenceSystem(int rs) {
670
		this.referenceSystem = rs;
671
	}
672

  
673
	public double toCartographicSize(ViewPort viewPort, double dpi,
674
			Geometry geom) {
675

  
676
		double oldSize = getSize();
677
		setCartographicSize(getCartographicSize(viewPort, dpi, geom), geom);
678
		return oldSize;	}
679

  
680
	public void setCartographicSize(double cartographicSize, Geometry geom) {
681
		setSize(cartographicSize);
682
	}
683

  
684
	public double getCartographicSize(ViewPort viewPort, double dpi,
685
			Geometry geom) {
686

  
687
		return SymbolUtils.getCartographicLength(this,
688
									  getSize(),
689
									  viewPort,
690
									  dpi);
691
	}
692

  
693
	public double getRotation() {
694
		return rotation_radians;
695
	}
696

  
697
	public void setRotation(double rot) {
698
		rotation_radians = rot;
699
	}
700

  
701
	public Point2D getOffset() {
702
		return offset;
703
	}
704

  
705
	public void setOffset(Point2D off) {
706
		offset = off;
707
	}
708

  
709
	public Color getColor() {
710
		return color;
711
	}
712

  
713
	public void setColor(Color co) {
714
		color = co;
715
	}
716

  
717 590
	public void setAlpha(int a) {
718 591
		alpha = a;
719 592
	}
720 593

  
721
	public IMask getMask() {
722
		return mask;
723
	}
594
//	public IMask getMask() {
595
//		return mask;
596
//	}
597
//
598
//	public void setMask(IMask m) {
599
//		mask = m;
600
//	}
724 601

  
725
	public void setMask(IMask m) {
726
		mask = m;
727
	}
728

  
729 602
	// =========================================
730 603

  
731 604
	public void loadFromState(PersistentState state) throws PersistenceException {
605
            
606
            super.loadFromState(state);
732 607

  
733
		if (state.hasValue("vc_xOffsetScale")) {
608
//		if (state.hasValue("mask")) {
609
//			this.mask = (IMask) state.get("mask");
610
//		} else {
611
//			this.mask = null;
612
//		}
613
//		// ==============================================
614
//		this.color = (Color) state.get("color");
615
//		double aux = state.getDouble("size");
616
//		this.setSize(aux);
617
//		this.rotation_radians = state.getDouble("rotation");
618
//		this.desc = state.getString("desc");
619
//		this.isShapeVisible = state.getBoolean("isShapeVisible");
620

  
621
//                state.set("unit", getUnit());
622
//                state.set("referenceSystem", getReferenceSystem());
623

  
624
                if(state.isNull("offset")) {
625
                    double x = state.getDouble("xOffset");
626
                    double y = state.getDouble("yOffset");
627
                    this.setOffset(new Point2D.Double(x, y));
628
                }
629
                
630
                if (state.hasValue("vc_xOffsetScale")) {
734 631
			this.visualCorrection = new VisualCorrection();
735 632
			this.visualCorrection.xOffsetScale = state.getDouble("vc_xOffsetScale");
736 633
			this.visualCorrection.yOffsetScale = state.getDouble("vc_yOffsetScale");
......
738 635
		} else {
739 636
			this.visualCorrection = null;
740 637
		}
741
		if (state.hasValue("mask")) {
742
			this.mask = (IMask) state.get("mask");
743
		} else {
744
			this.mask = null;
745
		}
746
		// ==============================================
747
		this.color = (Color) state.get("color");
748
		this.font = (Font) state.get("font");
749 638

  
750
		double aux = state.getDouble("size");
751
		this.setSize(aux);
639
                this.font = (Font) state.get("font");
752 640

  
753 641
		this.unicode = state.getInt("unicode");
754
		this.desc = state.getString("desc");
755
		this.isShapeVisible = state.getBoolean("isShapeVisible");
756

  
757
		double x = state.getDouble("xOffset");
758
		double y = state.getDouble("yOffset");
759
		this.offset = new Point2D.Double(x, y);
760

  
761
		this.rotation_radians = state.getDouble("rotation");
762
		this.unit = state.getInt("unit");
763
		this.referenceSystem = state.getInt("referenceSystem");
764 642
	}
765 643

  
766 644
	public void saveToState(PersistentState state) throws PersistenceException {
645
            
646
            super.saveToState(state);
767 647

  
768
		if (this.visualCorrection != null) {
648
//		if (this.mask != null) {
649
//			state.set("mask", this.mask);
650
//		}
651
//		state.set("color", this.color);
652
//		state.set("size", this.size);
653
//		state.set("rotation", this.rotation_radians);
654
//		state.set("desc", this.desc);
655
//		state.set("isShapeVisible", this.isShapeVisible);
656
//                setUnit(state.getInt("unit"));
657
//                setReferenceSystem(state.getInt("referenceSystem"));
658

  
659
                //Mantenemos estas dos l?neas por compatibilidad pero deber?an eliminarse
660
		state.set("xOffset", this.getOffset().getX());
661
		state.set("yOffset", this.getOffset().getY());
662
                if (this.visualCorrection != null) {
769 663
			state.set("vc_xOffsetScale", this.visualCorrection.xOffsetScale);
770 664
			state.set("vc_yOffsetScale", this.visualCorrection.yOffsetScale);
771 665
			state.set("vc_sizeScale", this.visualCorrection.sizeScale);
772 666
		}
773
		if (this.mask != null) {
774
			state.set("mask", this.mask);
775
		}
776 667
		// ==================================================
777
		state.set("color", this.color);
778 668
		state.set("font", this.font);
779
		state.set("size", this.size);
780 669
		state.set("unicode", this.unicode);
781
		state.set("desc", this.desc);
782
		state.set("isShapeVisible", this.isShapeVisible);
783
		state.set("xOffset", this.offset.getX());
784
		state.set("yOffset", this.offset.getY());
785
		state.set("rotation", this.rotation_radians);
786
		state.set("unit", this.unit);
787
		state.set("referenceSystem", this.referenceSystem);
788
	}
670
    }
789 671

  
672

  
790 673
	public static void registerPersistent() {
791 674

  
792 675
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
......
799 682
					null
800 683
			);
801 684

  
802
			definition.addDynFieldObject("color").setClassOfValue(Color.class).setMandatory(true);
803
			definition.addDynFieldObject("font").setClassOfValue(Font.class).setMandatory(true);
804
			definition.addDynFieldDouble("size").setMandatory(true);
805
			definition.addDynFieldInt("unicode").setMandatory(true);
806
			definition.addDynFieldString("desc").setMandatory(true);
807
			definition.addDynFieldBoolean("isShapeVisible").setMandatory(true);
685
                        definition.extend(manager.getDefinition(MARKER_SYMBOL_PERSISTENCE_DEFINITION_NAME));
686
//			definition.addDynFieldObject("color").setClassOfValue(Color.class).setMandatory(true);
687
//			definition.addDynFieldDouble("size").setMandatory(true);
688
//			definition.addDynFieldDouble("rotation").setMandatory(true);
689
//			definition.addDynFieldInt("unit").setMandatory(true);
690
//			definition.addDynFieldInt("referenceSystem").setMandatory(true);
691
//			definition.addDynFieldObject("mask").setClassOfValue(IMask.class).setMandatory(false);
692
//			definition.addDynFieldString("desc").setMandatory(true);
693
//			definition.addDynFieldBoolean("isShapeVisible").setMandatory(true);
694
	
695
                        //Por compatibilidad mantenemos estas dos l?neas aunque deber?an eliminarse
808 696
			definition.addDynFieldDouble("xOffset").setMandatory(true);
809 697
			definition.addDynFieldDouble("yOffset").setMandatory(true);
810
			definition.addDynFieldDouble("rotation").setMandatory(true);
811
			definition.addDynFieldInt("unit").setMandatory(true);
812
			definition.addDynFieldInt("referenceSystem").setMandatory(true);
813
			definition.addDynFieldObject("mask").setClassOfValue(IMask.class).setMandatory(false);
698

  
699
                        definition.addDynFieldObject("font").setClassOfValue(Font.class).setMandatory(true);
700
			definition.addDynFieldInt("unicode").setMandatory(true);
814 701
			// =====================
815 702
			definition.addDynFieldDouble("vc_xOffsetScale").setMandatory(false);
816 703
			definition.addDynFieldDouble("vc_yOffsetScale").setMandatory(false);

Also available in: Unified diff