Revision 47477

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.impl/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/symbol/impl/MultiShapeSymbol.java
33 33
import org.gvsig.fmap.geom.aggregate.Aggregate;
34 34
import org.gvsig.fmap.geom.type.GeometryType;
35 35
import org.gvsig.fmap.mapcontext.MapContextLocator;
36
import org.gvsig.fmap.mapcontext.ViewPort;
37 36
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport;
38 37
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
39
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2;
40 38
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
41 39
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.IMultiShapeSymbol;
42 40
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol;
43 41
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol;
44 42
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol;
45
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol_v2;
46 43
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ILineStyle;
47 44
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMask;
48 45
import org.gvsig.tools.ToolsLocator;
......
60 57
 * MultiShapeSymbol class allows to create a composition of several symbols with
61 58
 * different shapes and be treated as a single symbol.These shapes can be
62 59
 * marker,line or fill.
63
 * 
60
 *
64 61
 * @author 2005-2008 jaume dominguez faus - jaume.dominguez@iver.es
65 62
 * @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
66 63
 */
67 64
public class MultiShapeSymbol extends AbstractSymbol implements ILineSymbol, IMarkerSymbol, IFillSymbol, IMultiShapeSymbol {
68 65

  
69
	private static final Logger LOG = LoggerFactory.getLogger(MultiShapeSymbol.class); 
66
    private static final Logger LOG = LoggerFactory.getLogger(MultiShapeSymbol.class);
70 67

  
71
	public static final String MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME = "MultiShapeSymbol";
72
	
73
	private static final String FIELD_MARKER = "marker";
74
	private static final String FIELD_LINE = "line";
75
	private static final String FIELD_FILL = "fill";
76
	private static final String FIELD_DESCRIPTION = "description";
68
    public static final String MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME = "MultiShapeSymbol";
77 69

  
78
        @SuppressWarnings("FieldNameHidesFieldInSuperclass")
79
	public static final String SYMBOL_NAME = "multiShape";
80
	
81
	private IMarkerSymbol marker;
82
	private ILineSymbol line;
83
	private IFillSymbol fill;
84
	private IMask mask;
85
	private int referenceSystem;
86
	private MultiShapeSymbol symSelect;
87
	
88
	public MultiShapeSymbol() {
89
		super();
90
		marker = (IMarkerSymbol) createSymbol(IMarkerSymbol.SYMBOL_NAME);
91
		line = (ILineSymbol) createSymbol(ILineSymbol.SYMBOL_NAME);
92
		fill = (IFillSymbol) createSymbol(IFillSymbol.SYMBOL_NAME);
93
	}
94
	
95
	private ISymbol createSymbol(String symbolName) {
96
	        SymbolManager manager = MapContextLocator.getSymbolManager();
97
		return manager.createSymbol(symbolName);
98
	}
70
    private static final String FIELD_MARKER = "marker";
71
    private static final String FIELD_LINE = "line";
72
    private static final String FIELD_FILL = "fill";
73
    private static final String FIELD_DESCRIPTION = "description";
99 74

  
100
	public Color getLineColor() {
101
		return line.getColor();
102
	}
75
    @SuppressWarnings("FieldNameHidesFieldInSuperclass")
76
    public static final String SYMBOL_NAME = "multiShape";
103 77

  
104
        @Override
105
	public void setLineColor(Color color) {
106
		line.setLineColor(color);
107
	}
78
    private IMarkerSymbol marker;
79
    private ILineSymbol line;
80
    private IFillSymbol fill;
81
    private IMask mask;
82
    private int referenceSystem;
83
    private MultiShapeSymbol symSelect;
108 84

  
109
        @Override
110
	public ILineStyle getLineStyle() {
111
		return line.getLineStyle();
112
	}
85
    public MultiShapeSymbol() {
86
        super();
87
        marker = (IMarkerSymbol) createSymbol(IMarkerSymbol.SYMBOL_NAME);
88
        line = (ILineSymbol) createSymbol(ILineSymbol.SYMBOL_NAME);
89
        fill = (IFillSymbol) createSymbol(IFillSymbol.SYMBOL_NAME);
90
    }
113 91

  
114
        @Override
115
	public void setLineStyle(ILineStyle lineStyle) {
116
		line.setLineStyle(lineStyle);
117
	}
92
    private ISymbol createSymbol(String symbolName) {
93
        SymbolManager manager = MapContextLocator.getSymbolManager();
94
        return manager.createSymbol(symbolName);
95
    }
118 96

  
119
        @Override
120
	public void setLineWidth(double width) {
121
		line.setLineWidth(width);
122
	}
97
    public Color getLineColor() {
98
        return line.getColor();
99
    }
123 100

  
124
        @Override
125
	public double getLineWidth() {
126
		return line.getLineWidth();
127
	}
101
    @Override
102
    public void setLineColor(Color color) {
103
        line.setLineColor(color);
104
    }
128 105

  
129
        @Override
130
	public int getAlpha() {
131
		return line.getAlpha();
132
	}
106
    @Override
107
    public ILineStyle getLineStyle() {
108
        return line.getLineStyle();
109
    }
133 110

  
134
        @Override
135
	public void setAlpha(int outlineAlpha) {
136
		line.setAlpha(outlineAlpha);
137
	}
111
    @Override
112
    public void setLineStyle(ILineStyle lineStyle) {
113
        line.setLineStyle(lineStyle);
114
    }
138 115

  
139
        @Override
140
	public ISymbol getSymbolForSelection() {
141
		if (symSelect == null) {
142
			symSelect = new MultiShapeSymbol();
143
		}
116
    @Override
117
    public void setLineWidth(double width) {
118
        line.setLineWidth(width);
119
    }
144 120

  
145
		if (marker!=null){
146
			symSelect.setMarkerSymbol((IMarkerSymbol) marker.getSymbolForSelection());
147
		}
121
    @Override
122
    public double getLineWidth() {
123
        return line.getLineWidth();
124
    }
148 125

  
149
		if (line!=null){
150
			symSelect.setLineSymbol((ILineSymbol) line.getSymbolForSelection());
151
		}
126
    @Override
127
    public int getAlpha() {
128
        return line.getAlpha();
129
    }
152 130

  
153
		if (fill!=null ){
154
			symSelect.setFillSymbol((IFillSymbol) fill.getSymbolForSelection());
155
		}
131
    @Override
132
    public void setAlpha(int outlineAlpha) {
133
        line.setAlpha(outlineAlpha);
134
    }
156 135

  
157
                if (symSelect instanceof CartographicSupport) {
158
                    ((CartographicSupport) symSelect).setUnit(this.getUnit());
159
                }
160
		return symSelect;
136
    @Override
137
    public ISymbol getSymbolForSelection() {
138
        if (symSelect == null) {
139
            symSelect = new MultiShapeSymbol();
140
        }
161 141

  
162
	}
142
        if (marker != null) {
143
            symSelect.setMarkerSymbol((IMarkerSymbol) marker.getSymbolForSelection());
144
        }
163 145

  
164
        @Override
146
        if (line != null) {
147
            symSelect.setLineSymbol((ILineSymbol) line.getSymbolForSelection());
148
        }
149

  
150
        if (fill != null) {
151
            symSelect.setFillSymbol((IFillSymbol) fill.getSymbolForSelection());
152
        }
153

  
154
        if (symSelect instanceof CartographicSupport) {
155
            ((CartographicSupport) symSelect).setUnit(this.getUnit());
156
        }
157
        return symSelect;
158

  
159
    }
160

  
161
    @Override
165 162
    public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cancel, Rectangle r) {
166
	    GeometryType geometryType = geom.getGeometryType();
167
	    if (geometryType.isTypeOf(Geometry.TYPES.POINT)){
168
	        if (marker != null) {
169
                    if(marker instanceof CartographicSupport){
170
                        marker.setCartographicContext(this.getCartographicContext());
171
                    }
172
                    if(marker instanceof IMarkerSymbol_v2){
173
                        ((IMarkerSymbol_v2)marker).draw(g, affineTransform, geom, f, cancel, r);
174
                    } else {
175
                        marker.draw(g, affineTransform, geom, f, cancel);
176
                    }
177
	        }
178
	    }else if (geometryType.isTypeOf(Geometry.TYPES.CURVE)){
179
	        if (line != null) {
180
                    if(line instanceof CartographicSupport){
181
                        line.setCartographicContext(this.getCartographicContext());
182
                    }
183
                    if(line instanceof ISymbol_v2){
184
                        ((ISymbol_v2)line).draw(g, affineTransform, geom, f, cancel, r);
185
                    } else {
186
                        line.draw(g, affineTransform, geom, f, cancel);
187
                    }
188
	        }
189
	    }else if (geometryType.isTypeOf(Geometry.TYPES.SURFACE)){
190
	        if (fill != null) {
191
                    if(fill instanceof CartographicSupport){
192
                        fill.setCartographicContext(this.getCartographicContext());
193
                    }
194
                    if(fill instanceof ISymbol_v2){
195
                        ((ISymbol_v2)fill).draw(g, affineTransform, geom, f, cancel, r);
196
                    } else {
197
                        fill.draw(g, affineTransform, geom, f, cancel);
198
                    }
199
	        }			
200
	    }else if (geometryType.isTypeOf(Geometry.TYPES.AGGREGATE)){
201
	        Aggregate aggregate = (Aggregate)geom;
202
	        for (int i=0 ; i<aggregate.getPrimitivesNumber() ; i++){
203
	            draw(g, affineTransform, aggregate.getPrimitiveAt(i), f, cancel, r);
204
	        }
205
	    }
206
	}
207
	
208
//    @Override
209
//	public boolean isOneDotOrPixel(Geometry geom,
210
//			double[] positionOfDotOrPixel, ViewPort viewPort, int dpi) {
211
//		
212
//        GeometryType geomType = geom.getGeometryType();
213
//        if( geomType.isSubTypeOf(Geometry.TYPES.POINT) ) {
214
//           	if (marker != null) {
215
//				return marker.isOneDotOrPixel(geom, positionOfDotOrPixel, viewPort, dpi);
216
//			}
217
//
218
//        } else if( geomType.isSubTypeOf(Geometry.TYPES.CURVE) ) {
219
//            if (line != null) {
220
//                return line.isOneDotOrPixel(geom, positionOfDotOrPixel, viewPort, dpi);
221
//			}
222
//            
223
//        } else if( geomType.isSubTypeOf(Geometry.TYPES.SURFACE) ) {
224
//			if (fill != null) {
225
//				return fill.isOneDotOrPixel(geom, positionOfDotOrPixel, viewPort, dpi);
226
//			}
227
//            
228
//        }
229
//		if (!geom.isSimple()){
230
//			Aggregate aggregate = (Aggregate)geom;			
231
//			for (int i=0 ; i<aggregate.getPrimitivesNumber() ; i++){
232
//				if (!isOneDotOrPixel(aggregate.getPrimitiveAt(i), positionOfDotOrPixel, viewPort, dpi)){
233
//					return false;
234
//				}
235
//			}
236
//			return true;
237
//		}
238
//		return true;
239
//	}
163
        if (r != null) {
164
            double myWidth = (r.getWidth() / 3);
240 165

  
241
//        @Override
242
//	public void getPixExtentPlus(Geometry geom, float[] distances,
243
//			ViewPort viewPort, int dpi) {
244
//		// TODO Implement it
245
//		throw new Error("Not yet implemented!");
246
//
247
//	}
166
            Rectangle rect = new Rectangle(0, 0, (int) myWidth, r.height);
248 167

  
249
//        @Override
250
//	public int getOnePointRgb() {
251
//		// will return a mixture of all symbol's getOnePointRgb() value
252
//
253
//		int rMarker = 0;
254
//		int gMarker = 0;
255
//		int bMarker = 0;
256
//		int aMarker = 0;
257
//
258
//		if (marker!=null && marker.getColor() != null) {
259
//			rMarker = marker.getColor().getRed();
260
//			gMarker = marker.getColor().getGreen();
261
//			bMarker = marker.getColor().getBlue();
262
//			aMarker = marker.getColor().getAlpha();
263
//		}
264
//
265
//		int rLine = 0;
266
//		int gLine = 0;
267
//		int bLine = 0;
268
//		int aLine = 0;
269
//
270
//		if (line != null  && line.getColor() != null) {
271
//			rLine = line.getColor().getRed();
272
//			gLine = line.getColor().getGreen();
273
//			bLine = line.getColor().getBlue();
274
//			aLine = line.getColor().getAlpha();
275
//		}
276
//
277
//		int rFill = 0;
278
//		int gFill = 0;
279
//		int bFill = 0;
280
//		int aFill = 0;
281
//
282
//		if (fill != null ) {
283
//			Color colorOfFill = null;
284
//			if (fill.getOutline()!=null) {
285
//				colorOfFill = fill.getOutline().getColor();
286
//			} else if (fill.getFillColor()!=null) {
287
//				colorOfFill = fill.getFillColor();
288
//			}
289
//			if (colorOfFill != null) {
290
//				rFill = colorOfFill.getRed();
291
//				gFill = colorOfFill.getGreen();
292
//				bFill = colorOfFill.getBlue();
293
//				aFill = colorOfFill.getAlpha();
294
//
295
//			}
296
//		}
297
//
298
//		int red = (rMarker + rLine + rFill) / 3;
299
//		int green = (gMarker + gLine + gFill) / 3;
300
//		int blue = (bMarker + bLine + bFill) / 3;
301
//		int alpha = (aMarker + aLine + aFill) / 3;
302
//
303
//		return (alpha) << 24 + (red << 16) + (green << 8) + blue;
304
//	}
168
            if (marker != null) {
169
                CartographicSupport.copyCartographicContext(this, marker);
170
                g.translate(r.x, r.y);
171
                marker.draw(g, affineTransform, geom, f, cancel, rect);
172
                g.translate(-(r.x), -(r.y));
173
            }
305 174

  
306
        @Override
307
	public boolean isShapeVisible() {
308
		if (marker!=null) {
309
			return marker.isShapeVisible();
310
		}
175
            if (line != null) {
176
                CartographicSupport.copyCartographicContext(this, line);
177
                g.translate(r.x + myWidth, r.y);
178
                line.draw(g, affineTransform, geom, f, cancel, rect);
179
                g.translate(-(r.x + myWidth), -(r.y));
180
            }
311 181

  
312
		if (line != null) {
313
			return line.isShapeVisible();
314
		}
182
            if (fill != null) {
183
                CartographicSupport.copyCartographicContext(this, fill);
184
                g.translate(r.x + myWidth + myWidth, r.y);
185
                fill.draw(g, affineTransform, geom, f, cancel, rect);
186
                g.translate(-(r.x + myWidth + myWidth), -(r.y));
187
            }
188
        } else {
189
            GeometryType geometryType = geom.getGeometryType();
190
            if (geometryType.isTypeOf(Geometry.TYPES.POINT)) {
191
                if (marker != null) {
192
                    CartographicSupport.copyCartographicContext(this, marker);
193
                    marker.draw(g, affineTransform, geom, f, cancel, r);
194
                }
195
            } else if (geometryType.isTypeOf(Geometry.TYPES.CURVE)) {
196
                if (line != null) {
197
                    CartographicSupport.copyCartographicContext(this, line);
198
                    line.draw(g, affineTransform, geom, f, cancel, r);
199
                }
200
            } else if (geometryType.isTypeOf(Geometry.TYPES.SURFACE)) {
201
                if (fill != null) {
202
                    CartographicSupport.copyCartographicContext(this, fill);
203
                    fill.draw(g, affineTransform, geom, f, cancel, r);
204
                }
205
            } else if (geometryType.isTypeOf(Geometry.TYPES.AGGREGATE)) {
206
                Aggregate aggregate = (Aggregate) geom;
207
                for (int i = 0; i < aggregate.getPrimitivesNumber(); i++) {
208
                    draw(g, affineTransform, aggregate.getPrimitiveAt(i), f, cancel, r);
209
                }
210
            }
211
        }
212
    }
315 213

  
316
		if (fill != null) {
317
			fill.isShapeVisible();
318
		}
214
    @Override
215
    public boolean isShapeVisible() {
216
        if (marker != null) {
217
            return marker.isShapeVisible();
218
        }
319 219

  
320
		return false;
321
	}
220
        if (line != null) {
221
            return line.isShapeVisible();
222
        }
322 223

  
323
        @Override
324
	public int getSymbolType() {
325
		return Geometry.TYPES.GEOMETRY;
326
	}
224
        if (fill != null) {
225
            fill.isShapeVisible();
226
        }
327 227

  
328
        @Override
329
	public boolean isSuitableFor(Geometry geom) {
330
		// suitable for everything (why else does it exist?)
331
		return true;
332
	}
228
        return false;
229
    }
333 230

  
334 231
    @Override
335
	public double getRotation() {
336
		if (marker != null) {
337
			return marker.getRotation();
338
		}
339
		return 0;
340
	}
232
    public int getSymbolType() {
233
        return Geometry.TYPES.GEOMETRY;
234
    }
341 235

  
342
        @Override
343
	public void setRotation(double rotation) {
344
		if (marker != null) {
345
			marker.setRotation(rotation);
346
		}
347
	}
236
    @Override
237
    public boolean isSuitableFor(Geometry geom) {
238
        // suitable for everything (why else does it exist?)
239
        return true;
240
    }
348 241

  
349
        @Override
350
	public Point2D getOffset() {
351
		if (marker != null) {
352
			return marker.getOffset();
353
		}
354
		return new Point2D.Double();
355
	}
242
    @Override
243
    public double getRotation() {
244
        if (marker != null) {
245
            return marker.getRotation();
246
        }
247
        return 0;
248
    }
356 249

  
357
        @Override
358
	public void setOffset(Point2D offset) {
359
		if (marker != null) {
360
			marker.setOffset(offset);
361
		}
362
	}
250
    @Override
251
    public void setRotation(double rotation) {
252
        if (marker != null) {
253
            marker.setRotation(rotation);
254
        }
255
    }
363 256

  
364
        @Override
365
	public double getSize() {
366
		if (marker != null) {
367
			return marker.getSize();
368
		}
369
		return 0;
370
	}
257
    @Override
258
    public Point2D getOffset() {
259
        if (marker != null) {
260
            return marker.getOffset();
261
        }
262
        return new Point2D.Double();
263
    }
371 264

  
372
        @Override
373
	public void setSize(double size) {
374
		if (marker != null) {
375
			marker.setSize(size);
376
		}
265
    @Override
266
    public void setOffset(Point2D offset) {
267
        if (marker != null) {
268
            marker.setOffset(offset);
269
        }
270
    }
377 271

  
378
	}
272
    @Override
273
    public double getSize() {
274
        if (marker != null) {
275
            return marker.getSize();
276
        }
277
        return 0;
278
    }
379 279

  
380
        @Override
381
	public Color getColor() {
382
		if (marker != null) {
383
			return marker.getColor();
384
		}
385
		return null;
386
	}
280
    @Override
281
    public void setSize(double size) {
282
        if (marker != null) {
283
            marker.setSize(size);
284
        }
387 285

  
388
        @Override
389
	public void setColor(Color color) {
390
		if (marker != null) {
391
			marker.setColor(color);
392
		}
393
	}
286
    }
394 287

  
395
        @Override
396
	public void setFillColor(Color color) {
397
		if (fill != null) {
398
			fill.setFillColor(color);
399
		}
400
	}
288
    @Override
289
    public Color getColor() {
290
        if (marker != null) {
291
            return marker.getColor();
292
        }
293
        return null;
294
    }
401 295

  
402
        @Override
403
	public void setOutline(ILineSymbol outline) {
404
		if (fill != null) {
405
			fill.setOutline(outline);
406
		}
407
	}
296
    @Override
297
    public void setColor(Color color) {
298
        if (marker != null) {
299
            marker.setColor(color);
300
        }
301
    }
408 302

  
409
        @Override
410
	public Color getFillColor() {
411
		if (fill != null) {
412
			return fill.getFillColor();
413
		}
414
		return null;
415
	}
303
    @Override
304
    public void setFillColor(Color color) {
305
        if (fill != null) {
306
            fill.setFillColor(color);
307
        }
308
    }
416 309

  
417
        @Override
418
	public ILineSymbol getOutline() {
419
		if (fill != null) {
420
			return fill.getOutline();
421
		}
422
		return null;
423
	}
310
    @Override
311
    public void setOutline(ILineSymbol outline) {
312
        if (fill != null) {
313
            fill.setOutline(outline);
314
        }
315
    }
424 316

  
425
        @Override
426
	public int getFillAlpha() {
427
		if (fill != null) {
428
			return fill.getFillAlpha();
429
		}
430
		return 255;
431
	}
317
    @Override
318
    public Color getFillColor() {
319
        if (fill != null) {
320
            return fill.getFillColor();
321
        }
322
        return null;
323
    }
432 324

  
433
        @Override
434
	public IMask getMask() {
435
		return mask;
436
	}
325
    @Override
326
    public ILineSymbol getOutline() {
327
        if (fill != null) {
328
            return fill.getOutline();
329
        }
330
        return null;
331
    }
437 332

  
438
        @Override
439
	public void setUnit(int unitIndex) {
440
		if (marker != null) {
441
			marker.setUnit(unitIndex);
442
		}
443
		if (line != null) {
444
			line.setUnit(unitIndex);
445
		}
446
	}
333
    @Override
334
    public int getFillAlpha() {
335
        if (fill != null) {
336
            return fill.getFillAlpha();
337
        }
338
        return 255;
339
    }
447 340

  
448 341
    @Override
449
	public int getUnit() {
450
		if (marker != null) {
451
			return marker.getUnit();
452
		}
453
		if (line != null) {
454
			return line.getUnit();
455
		}
456
		return -1;
457
	}
342
    public IMask getMask() {
343
        return mask;
344
    }
458 345

  
459 346
    @Override
460
	public void setMask(IMask mask) {
461
		throw new NotYetImplemented();
347
    public void setUnit(int unitIndex) {
348
        if (marker != null) {
349
            marker.setUnit(unitIndex);
350
        }
351
        if (line != null) {
352
            line.setUnit(unitIndex);
353
        }
354
    }
462 355

  
463
	}
356
    @Override
357
    public int getUnit() {
358
        if (marker != null) {
359
            return marker.getUnit();
360
        }
361
        if (line != null) {
362
            return line.getUnit();
363
        }
364
        return -1;
365
    }
464 366

  
465 367
    @Override
466
	public int getReferenceSystem() {
467
		return this.referenceSystem;
468
	}
368
    public void setMask(IMask mask) {
369
        throw new NotYetImplemented();
469 370

  
371
    }
372

  
470 373
    @Override
471
	public void setReferenceSystem(int system) {
472
		this.referenceSystem = system;
374
    public int getReferenceSystem() {
375
        return this.referenceSystem;
376
    }
473 377

  
474
	}
378
    @Override
379
    public void setReferenceSystem(int system) {
380
        this.referenceSystem = system;
475 381

  
382
    }
383

  
476 384
    @Override
477
	public IMarkerSymbol getMarkerSymbol() {
478
		return marker;
479
	}
385
    public IMarkerSymbol getMarkerSymbol() {
386
        return marker;
387
    }
480 388

  
481 389
    @Override
482
	public ILineSymbol getLineSymbol() {
483
		return line;
484
	}
390
    public ILineSymbol getLineSymbol() {
391
        return line;
392
    }
485 393

  
486 394
    @Override
487
	public IFillSymbol getFillSymbol() {
488
		return fill;
489
	}
395
    public IFillSymbol getFillSymbol() {
396
        return fill;
397
    }
490 398

  
491 399
    @Override
492
	public void setMarkerSymbol(IMarkerSymbol markerSymbol) {
493
		this.marker = markerSymbol;
494
	}
400
    public void setMarkerSymbol(IMarkerSymbol markerSymbol) {
401
        this.marker = markerSymbol;
402
    }
495 403

  
496 404
    @Override
497
	public void setLineSymbol(ILineSymbol lineSymbol) {
498
		this.line = lineSymbol;
499
	}
405
    public void setLineSymbol(ILineSymbol lineSymbol) {
406
        this.line = lineSymbol;
407
    }
500 408

  
501 409
    @Override
502
	public void setFillSymbol(IFillSymbol fillFillSymbol) {
503
		this.fill = fillFillSymbol;
504
	}
410
    public void setFillSymbol(IFillSymbol fillFillSymbol) {
411
        this.fill = fillFillSymbol;
412
    }
505 413

  
506 414
    @Override
507
	public boolean hasFill() {
508
	if (fill == null) {
509
		return false;
510
	}
511
	return fill.hasFill();
512
	}
415
    public boolean hasFill() {
416
        if (fill == null) {
417
            return false;
418
        }
419
        return fill.hasFill();
420
    }
513 421

  
514 422
    @Override
515
	public void setHasFill(boolean hasFill) {
516
		if (fill != null) {
517
			fill.setHasFill(hasFill);
518
		}
519
	}
423
    public void setHasFill(boolean hasFill) {
424
        if (fill != null) {
425
            fill.setHasFill(hasFill);
426
        }
427
    }
520 428

  
521 429
    @Override
522
	public boolean hasOutline() {
523
		return false;
524
	}
430
    public boolean hasOutline() {
431
        return false;
432
    }
525 433

  
526 434
    @Override
527
	public void setHasOutline(boolean hasOutline) {
435
    public void setHasOutline(boolean hasOutline) {
528 436

  
529
	}
437
    }
530 438

  
531 439
    @Override
532
	public Object clone() throws CloneNotSupportedException {
533
		MultiShapeSymbol copy = (MultiShapeSymbol) super.clone();
440
    public Object clone() throws CloneNotSupportedException {
441
        MultiShapeSymbol copy = (MultiShapeSymbol) super.clone();
534 442

  
535
		// Clone inner symbols
536
		if (marker != null) {
537
			copy.marker = (IMarkerSymbol) marker.clone();
538
		}
539
		if (line != null) {
540
			copy.line = (ILineSymbol) line.clone();
541
		}
542
		if (fill != null) {
543
			copy.fill = (IFillSymbol) fill.clone();
544
		}
545
		
546
		if (mask != null) {
547
			copy.mask = (IMask) mask.clone();
548
		}
549
		
550
		// Clone selection symbol
551
		if (symSelect != null) {
552
			copy.symSelect = (MultiShapeSymbol) symSelect.clone();
553
		}
554
		
555
		return copy;
556
	}
443
        // Clone inner symbols
444
        if (marker != null) {
445
            copy.marker = (IMarkerSymbol) marker.clone();
446
        }
447
        if (line != null) {
448
            copy.line = (ILineSymbol) line.clone();
449
        }
450
        if (fill != null) {
451
            copy.fill = (IFillSymbol) fill.clone();
452
        }
557 453

  
454
        if (mask != null) {
455
            copy.mask = (IMask) mask.clone();
456
        }
457

  
458
        // Clone selection symbol
459
        if (symSelect != null) {
460
            copy.symSelect = (MultiShapeSymbol) symSelect.clone();
461
        }
462

  
463
        return copy;
464
    }
465

  
558 466
    @Override
559
	public void loadFromState(PersistentState state)
560
			throws PersistenceException {
561
		setDescription(state.getString(FIELD_DESCRIPTION));
562
		setFillSymbol((IFillSymbol) state.get(FIELD_FILL));
563
		setMarkerSymbol((IMarkerSymbol) state.get(FIELD_MARKER));
564
		setLineSymbol((ILineSymbol) state.get(FIELD_LINE));
565
	}
467
    public void loadFromState(PersistentState state)
468
            throws PersistenceException {
469
        setDescription(state.getString(FIELD_DESCRIPTION));
470
        setFillSymbol((IFillSymbol) state.get(FIELD_FILL));
471
        setMarkerSymbol((IMarkerSymbol) state.get(FIELD_MARKER));
472
        setLineSymbol((ILineSymbol) state.get(FIELD_LINE));
473
    }
566 474

  
567 475
    @Override
568
	public void saveToState(PersistentState state) throws PersistenceException {
569
		state.set(FIELD_DESCRIPTION, getDescription());
570
		state.set(FIELD_FILL, getFillSymbol());
571
		state.set(FIELD_MARKER, getMarkerSymbol());
572
		state.set(FIELD_LINE, getLineSymbol());
573
	}
476
    public void saveToState(PersistentState state) throws PersistenceException {
477
        state.set(FIELD_DESCRIPTION, getDescription());
478
        state.set(FIELD_FILL, getFillSymbol());
479
        state.set(FIELD_MARKER, getMarkerSymbol());
480
        state.set(FIELD_LINE, getLineSymbol());
481
    }
574 482

  
575
	public static class RegisterPersistence implements Callable {
483
    public static class RegisterPersistence implements Callable {
576 484

  
577 485
        @Override
578
		public Object call() throws Exception {
579
			PersistenceManager manager = ToolsLocator.getPersistenceManager();
580
			if( manager.getDefinition(MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME)==null ) {
581
				DynStruct definition = manager.addDefinition(
582
						MultiShapeSymbol.class,
583
						MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME,
584
						MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
585
						null, 
586
						null
587
				);
588
				// Description
589
				definition.addDynFieldString(FIELD_DESCRIPTION).setMandatory(false);
590
				// Fill symbol
591
				definition.addDynFieldObject(FIELD_FILL).setClassOfValue(IFillSymbol.class).setMandatory(true);
592
				// Line symbol
593
				definition.addDynFieldObject(FIELD_LINE).setClassOfValue(ILineSymbol.class).setMandatory(true);
594
				// Marker symbol
595
				definition.addDynFieldObject(FIELD_MARKER).setClassOfValue(IMarkerSymbol.class).setMandatory(true);
596
			}
597
			return Boolean.TRUE;
598
		}
599
		
600
	}
486
        public Object call() throws Exception {
487
            PersistenceManager manager = ToolsLocator.getPersistenceManager();
488
            if (manager.getDefinition(MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME) == null) {
489
                DynStruct definition = manager.addDefinition(
490
                        MultiShapeSymbol.class,
491
                        MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME,
492
                        MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME + " Persistence definition",
493
                        null,
494
                        null
495
                );
496
                // Description
497
                definition.addDynFieldString(FIELD_DESCRIPTION).setMandatory(false);
498
                // Fill symbol
499
                definition.addDynFieldObject(FIELD_FILL).setClassOfValue(IFillSymbol.class).setMandatory(true);
500
                // Line symbol
501
                definition.addDynFieldObject(FIELD_LINE).setClassOfValue(ILineSymbol.class).setMandatory(true);
502
                // Marker symbol
503
                definition.addDynFieldObject(FIELD_MARKER).setClassOfValue(IMarkerSymbol.class).setMandatory(true);
504
            }
505
            return Boolean.TRUE;
506
        }
601 507

  
602
	public static class RegisterSymbol implements Callable {
508
    }
603 509

  
510
    public static class RegisterSymbol implements Callable {
511

  
604 512
        @Override
605
		public Object call() throws Exception {
606
	        int[] shapeTypes;
607
	        SymbolManager manager = MapContextLocator.getSymbolManager();
608
	        
609
	        shapeTypes = new int[] { Geometry.TYPES.GEOMETRY };
610
	        manager.registerSymbol(MultiShapeSymbol.SYMBOL_NAME,
611
	            shapeTypes,
612
	            MultiShapeSymbol.class
613
	        );
614
			return Boolean.TRUE;
615
		}
616
	}
617
}
513
        public Object call() throws Exception {
514
            int[] shapeTypes;
515
            SymbolManager manager = MapContextLocator.getSymbolManager();
516

  
517
            shapeTypes = new int[]{Geometry.TYPES.GEOMETRY};
518
            manager.registerSymbol(MultiShapeSymbol.SYMBOL_NAME,
519
                    shapeTypes,
520
                    MultiShapeSymbol.class
521
            );
522
            return Boolean.TRUE;
523
        }
524
    }
525
}

Also available in: Unified diff