svn-gvsig-desktop / 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 @ 45526
History | View | Annotate | Download (20.3 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl; |
25 |
|
26 |
import java.awt.Color; |
27 |
import java.awt.Graphics2D; |
28 |
import java.awt.Rectangle; |
29 |
import java.awt.geom.AffineTransform; |
30 |
import java.awt.geom.Point2D; |
31 |
import org.gvsig.compat.print.PrintAttributes; |
32 |
import org.gvsig.fmap.dal.feature.Feature; |
33 |
import org.gvsig.fmap.geom.Geometry; |
34 |
import org.gvsig.fmap.geom.aggregate.Aggregate; |
35 |
import org.gvsig.fmap.geom.type.GeometryType; |
36 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
37 |
import org.gvsig.fmap.mapcontext.ViewPort; |
38 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
39 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
40 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager; |
41 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.IMultiShapeSymbol; |
42 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.fill.IFillSymbol; |
43 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
44 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol; |
45 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.ILineStyle; |
46 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.style.IMask; |
47 |
import org.gvsig.tools.ToolsLocator; |
48 |
import org.gvsig.tools.dynobject.DynStruct; |
49 |
import org.gvsig.tools.exception.NotYetImplemented; |
50 |
import org.gvsig.tools.persistence.PersistenceManager; |
51 |
import org.gvsig.tools.persistence.PersistentState; |
52 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
53 |
import org.gvsig.tools.task.Cancellable; |
54 |
import org.gvsig.tools.util.Callable; |
55 |
import org.slf4j.Logger; |
56 |
import org.slf4j.LoggerFactory; |
57 |
|
58 |
/**
|
59 |
* MultiShapeSymbol class allows to create a composition of several symbols with
|
60 |
* different shapes and be treated as a single symbol.These shapes can be
|
61 |
* marker,line or fill.
|
62 |
*
|
63 |
* @author 2005-2008 jaume dominguez faus - jaume.dominguez@iver.es
|
64 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
65 |
*/
|
66 |
public class MultiShapeSymbol implements ILineSymbol, IMarkerSymbol, IFillSymbol, IMultiShapeSymbol { |
67 |
|
68 |
private static final Logger LOG = LoggerFactory.getLogger(MultiShapeSymbol.class); |
69 |
|
70 |
public static final String MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME = "MultiShapeSymbol"; |
71 |
|
72 |
private static final String FIELD_MARKER = "marker"; |
73 |
private static final String FIELD_LINE = "line"; |
74 |
private static final String FIELD_FILL = "fill"; |
75 |
private static final String FIELD_DESCRIPTION = "description"; |
76 |
|
77 |
public static final String SYMBOL_NAME = "multiShape"; |
78 |
|
79 |
private SymbolManager manager = MapContextLocator.getSymbolManager();
|
80 |
|
81 |
private IMarkerSymbol marker;
|
82 |
private ILineSymbol line;
|
83 |
private IFillSymbol fill;
|
84 |
private IMask mask;
|
85 |
private String desc; |
86 |
private int referenceSystem; |
87 |
private MultiShapeSymbol symSelect;
|
88 |
|
89 |
public MultiShapeSymbol() {
|
90 |
super();
|
91 |
marker = (IMarkerSymbol) createSymbol(IMarkerSymbol.SYMBOL_NAME); |
92 |
line = (ILineSymbol) createSymbol(ILineSymbol.SYMBOL_NAME); |
93 |
fill = (IFillSymbol) createSymbol(IFillSymbol.SYMBOL_NAME); |
94 |
} |
95 |
|
96 |
private ISymbol createSymbol(String symbolName) { |
97 |
return manager.createSymbol(symbolName);
|
98 |
} |
99 |
|
100 |
public Color getLineColor() { |
101 |
return line.getColor();
|
102 |
} |
103 |
|
104 |
public void setLineColor(Color color) { |
105 |
line.setLineColor(color); |
106 |
} |
107 |
|
108 |
public ILineStyle getLineStyle() {
|
109 |
return line.getLineStyle();
|
110 |
} |
111 |
|
112 |
public void setLineStyle(ILineStyle lineStyle) { |
113 |
line.setLineStyle(lineStyle); |
114 |
} |
115 |
|
116 |
public void setLineWidth(double width) { |
117 |
line.setLineWidth(width); |
118 |
} |
119 |
|
120 |
public double getLineWidth() { |
121 |
return line.getLineWidth();
|
122 |
} |
123 |
|
124 |
public int getAlpha() { |
125 |
return line.getAlpha();
|
126 |
} |
127 |
|
128 |
public void setAlpha(int outlineAlpha) { |
129 |
line.setAlpha(outlineAlpha); |
130 |
} |
131 |
|
132 |
public ISymbol getSymbolForSelection() {
|
133 |
if (symSelect == null) { |
134 |
symSelect = new MultiShapeSymbol();
|
135 |
} |
136 |
|
137 |
if (marker!=null){ |
138 |
symSelect.setMarkerSymbol((IMarkerSymbol) marker.getSymbolForSelection()); |
139 |
} |
140 |
|
141 |
if (line!=null){ |
142 |
symSelect.setLineSymbol((ILineSymbol) line.getSymbolForSelection()); |
143 |
} |
144 |
|
145 |
if (fill!=null ){ |
146 |
symSelect.setFillSymbol((IFillSymbol) fill.getSymbolForSelection()); |
147 |
} |
148 |
|
149 |
return symSelect;
|
150 |
|
151 |
} |
152 |
|
153 |
public void draw(Graphics2D g, AffineTransform affineTransform, |
154 |
Geometry geom, Feature feature, Cancellable cancel) { |
155 |
GeometryType geometryType = geom.getGeometryType(); |
156 |
if (geometryType.isTypeOf(Geometry.TYPES.POINT)){
|
157 |
if (marker != null) { |
158 |
marker.draw(g, affineTransform, geom, feature, cancel); |
159 |
} |
160 |
}else if (geometryType.isTypeOf(Geometry.TYPES.CURVE)){ |
161 |
if (line != null) { |
162 |
line.draw(g, affineTransform, geom, feature, cancel); |
163 |
} |
164 |
}else if (geometryType.isTypeOf(Geometry.TYPES.SURFACE)){ |
165 |
if (fill != null) { |
166 |
fill.draw(g, affineTransform, geom, feature, cancel); |
167 |
} |
168 |
}else if (geometryType.isTypeOf(Geometry.TYPES.AGGREGATE)){ |
169 |
Aggregate aggregate = (Aggregate)geom; |
170 |
for (int i=0 ; i<aggregate.getPrimitivesNumber() ; i++){ |
171 |
draw(g, affineTransform, aggregate.getPrimitiveAt(i), feature, cancel); |
172 |
} |
173 |
} |
174 |
} |
175 |
|
176 |
@Override
|
177 |
public boolean isOneDotOrPixel(Geometry geom, |
178 |
double[] positionOfDotOrPixel, ViewPort viewPort, int dpi) { |
179 |
|
180 |
GeometryType geomType = geom.getGeometryType(); |
181 |
if( geomType.isSubTypeOf(Geometry.TYPES.POINT) ) {
|
182 |
if (marker != null) { |
183 |
return marker.isOneDotOrPixel(geom, positionOfDotOrPixel, viewPort, dpi);
|
184 |
} |
185 |
|
186 |
} else if( geomType.isSubTypeOf(Geometry.TYPES.CURVE) ) { |
187 |
if (line != null) { |
188 |
return line.isOneDotOrPixel(geom, positionOfDotOrPixel, viewPort, dpi);
|
189 |
} |
190 |
|
191 |
} else if( geomType.isSubTypeOf(Geometry.TYPES.SURFACE) ) { |
192 |
if (fill != null) { |
193 |
return fill.isOneDotOrPixel(geom, positionOfDotOrPixel, viewPort, dpi);
|
194 |
} |
195 |
|
196 |
} |
197 |
if (!geom.isSimple()){
|
198 |
Aggregate aggregate = (Aggregate)geom; |
199 |
for (int i=0 ; i<aggregate.getPrimitivesNumber() ; i++){ |
200 |
if (!isOneDotOrPixel(aggregate.getPrimitiveAt(i), positionOfDotOrPixel, viewPort, dpi)){
|
201 |
return false; |
202 |
} |
203 |
} |
204 |
return true; |
205 |
} |
206 |
return true; |
207 |
} |
208 |
|
209 |
public void getPixExtentPlus(Geometry geom, float[] distances, |
210 |
ViewPort viewPort, int dpi) {
|
211 |
// TODO Implement it
|
212 |
throw new Error("Not yet implemented!"); |
213 |
|
214 |
} |
215 |
|
216 |
public int getOnePointRgb() { |
217 |
// will return a mixture of all symbol's getOnePointRgb() value
|
218 |
|
219 |
int rMarker = 0; |
220 |
int gMarker = 0; |
221 |
int bMarker = 0; |
222 |
int aMarker = 0; |
223 |
|
224 |
if (marker!=null && marker.getColor() != null) { |
225 |
rMarker = marker.getColor().getRed(); |
226 |
gMarker = marker.getColor().getGreen(); |
227 |
bMarker = marker.getColor().getBlue(); |
228 |
aMarker = marker.getColor().getAlpha(); |
229 |
} |
230 |
|
231 |
int rLine = 0; |
232 |
int gLine = 0; |
233 |
int bLine = 0; |
234 |
int aLine = 0; |
235 |
|
236 |
if (line != null && line.getColor() != null) { |
237 |
rLine = line.getColor().getRed(); |
238 |
gLine = line.getColor().getGreen(); |
239 |
bLine = line.getColor().getBlue(); |
240 |
aLine = line.getColor().getAlpha(); |
241 |
} |
242 |
|
243 |
int rFill = 0; |
244 |
int gFill = 0; |
245 |
int bFill = 0; |
246 |
int aFill = 0; |
247 |
|
248 |
if (fill != null ) { |
249 |
Color colorOfFill = null; |
250 |
if (fill.getOutline()!=null) { |
251 |
colorOfFill = fill.getOutline().getColor(); |
252 |
} else if (fill.getFillColor()!=null) { |
253 |
colorOfFill = fill.getFillColor(); |
254 |
} |
255 |
if (colorOfFill != null) { |
256 |
rFill = colorOfFill.getRed(); |
257 |
gFill = colorOfFill.getGreen(); |
258 |
bFill = colorOfFill.getBlue(); |
259 |
aFill = colorOfFill.getAlpha(); |
260 |
|
261 |
} |
262 |
} |
263 |
|
264 |
int red = (rMarker + rLine + rFill) / 3; |
265 |
int green = (gMarker + gLine + gFill) / 3; |
266 |
int blue = (bMarker + bLine + bFill) / 3; |
267 |
int alpha = (aMarker + aLine + aFill) / 3; |
268 |
|
269 |
return (alpha) << 24 + (red << 16) + (green << 8) + blue; |
270 |
} |
271 |
|
272 |
public String getDescription() { |
273 |
return desc;
|
274 |
} |
275 |
|
276 |
public boolean isShapeVisible() { |
277 |
if (marker!=null) { |
278 |
return marker.isShapeVisible();
|
279 |
} |
280 |
|
281 |
if (line != null) { |
282 |
return line.isShapeVisible();
|
283 |
} |
284 |
|
285 |
if (fill != null) { |
286 |
fill.isShapeVisible(); |
287 |
} |
288 |
|
289 |
return false; |
290 |
} |
291 |
|
292 |
public void setDescription(String desc) { |
293 |
this.desc = desc ;
|
294 |
} |
295 |
|
296 |
public int getSymbolType() { |
297 |
return Geometry.TYPES.GEOMETRY;
|
298 |
} |
299 |
|
300 |
public boolean isSuitableFor(Geometry geom) { |
301 |
// suitable for everything (why else does it exist?)
|
302 |
return true; |
303 |
} |
304 |
|
305 |
public void drawInsideRectangle(Graphics2D g, |
306 |
AffineTransform scaleInstance, Rectangle r, PrintAttributes properties) throws SymbolDrawingException { |
307 |
double myWidth = (r.getWidth()/3); |
308 |
|
309 |
Rectangle rect = new Rectangle(0, 0, (int) myWidth, r.height); |
310 |
|
311 |
if (marker != null) { |
312 |
g.translate(r.x, r.y); |
313 |
marker.drawInsideRectangle(g, scaleInstance, rect, properties); |
314 |
g.translate(-(r.x), -(r.y)); |
315 |
} |
316 |
|
317 |
if (line != null) { |
318 |
g.translate(r.x+myWidth, r.y); |
319 |
line.drawInsideRectangle(g, scaleInstance, rect, properties); |
320 |
g.translate(-(r.x+myWidth), -(r.y)); |
321 |
} |
322 |
|
323 |
if (fill != null) { |
324 |
g.translate(r.x+myWidth+myWidth, r.y); |
325 |
fill.drawInsideRectangle(g, scaleInstance, rect, properties); |
326 |
g.translate(-(r.x+myWidth+myWidth), -(r.y)); |
327 |
|
328 |
} |
329 |
} |
330 |
|
331 |
@Override
|
332 |
public void print(Graphics2D g, AffineTransform at, Geometry geom, PrintAttributes properties) { |
333 |
GeometryType geomType = geom.getGeometryType(); |
334 |
if( geomType.isTypeOf(Geometry.TYPES.POINT) ) {
|
335 |
if (marker != null) { |
336 |
marker.print(g, at, geom, properties); |
337 |
} |
338 |
|
339 |
} else if( geomType.isTypeOf(Geometry.TYPES.CURVE) ) { |
340 |
if (line != null) { |
341 |
line.print(g, at, geom, properties); |
342 |
} |
343 |
|
344 |
} else if( geomType.isTypeOf(Geometry.TYPES.SURFACE) ) { |
345 |
if (fill != null) { |
346 |
fill.print(g, at, geom, properties); |
347 |
} |
348 |
|
349 |
} |
350 |
} |
351 |
|
352 |
@Override
|
353 |
public double getRotation() { |
354 |
if (marker != null) { |
355 |
return marker.getRotation();
|
356 |
} |
357 |
return 0; |
358 |
} |
359 |
|
360 |
public void setRotation(double rotation) { |
361 |
if (marker != null) { |
362 |
marker.setRotation(rotation); |
363 |
} |
364 |
} |
365 |
|
366 |
public Point2D getOffset() { |
367 |
if (marker != null) { |
368 |
return marker.getOffset();
|
369 |
} |
370 |
return new Point2D.Double(); |
371 |
} |
372 |
|
373 |
public void setOffset(Point2D offset) { |
374 |
if (marker != null) { |
375 |
marker.setOffset(offset); |
376 |
} |
377 |
} |
378 |
|
379 |
public double getSize() { |
380 |
if (marker != null) { |
381 |
return marker.getSize();
|
382 |
} |
383 |
return 0; |
384 |
} |
385 |
|
386 |
public void setSize(double size) { |
387 |
if (marker != null) { |
388 |
marker.setSize(size); |
389 |
} |
390 |
|
391 |
} |
392 |
|
393 |
public Color getColor() { |
394 |
if (marker != null) { |
395 |
return marker.getColor();
|
396 |
} |
397 |
return null; |
398 |
} |
399 |
|
400 |
public void setColor(Color color) { |
401 |
if (marker != null) { |
402 |
marker.setColor(color); |
403 |
} |
404 |
} |
405 |
|
406 |
public void setFillColor(Color color) { |
407 |
if (fill != null) { |
408 |
fill.setFillColor(color); |
409 |
} |
410 |
} |
411 |
|
412 |
public void setOutline(ILineSymbol outline) { |
413 |
if (fill != null) { |
414 |
fill.setOutline(outline); |
415 |
} |
416 |
} |
417 |
|
418 |
public Color getFillColor() { |
419 |
if (fill != null) { |
420 |
return fill.getFillColor();
|
421 |
} |
422 |
return null; |
423 |
} |
424 |
|
425 |
public ILineSymbol getOutline() {
|
426 |
if (fill != null) { |
427 |
return fill.getOutline();
|
428 |
} |
429 |
return null; |
430 |
} |
431 |
|
432 |
public int getFillAlpha() { |
433 |
if (fill != null) { |
434 |
return fill.getFillAlpha();
|
435 |
} |
436 |
return 255; |
437 |
} |
438 |
|
439 |
public IMask getMask() {
|
440 |
return mask;
|
441 |
} |
442 |
|
443 |
public void setUnit(int unitIndex) { |
444 |
if (marker != null) { |
445 |
marker.setUnit(unitIndex); |
446 |
} |
447 |
if (line != null) { |
448 |
line.setUnit(unitIndex); |
449 |
} |
450 |
} |
451 |
|
452 |
@Override
|
453 |
public int getUnit() { |
454 |
if (marker != null) { |
455 |
return marker.getUnit();
|
456 |
} |
457 |
if (line != null) { |
458 |
return line.getUnit();
|
459 |
} |
460 |
return -1; |
461 |
} |
462 |
|
463 |
@Override
|
464 |
public void setMask(IMask mask) { |
465 |
throw new NotYetImplemented(); |
466 |
|
467 |
} |
468 |
|
469 |
@Override
|
470 |
public int getReferenceSystem() { |
471 |
return this.referenceSystem; |
472 |
} |
473 |
|
474 |
@Override
|
475 |
public void setReferenceSystem(int system) { |
476 |
this.referenceSystem = system;
|
477 |
|
478 |
} |
479 |
|
480 |
@Override
|
481 |
public double toCartographicSize(ViewPort viewPort, double dpi, Geometry geom) { |
482 |
GeometryType geomType = geom.getGeometryType(); |
483 |
if( geomType.isTypeOf(Geometry.TYPES.POINT) ) {
|
484 |
if (marker != null) { |
485 |
return marker.toCartographicSize(viewPort, dpi, geom);
|
486 |
} |
487 |
|
488 |
} else if( geomType.isTypeOf(Geometry.TYPES.CURVE) ) { |
489 |
if (line != null) { |
490 |
return line.toCartographicSize(viewPort, dpi, geom);
|
491 |
} |
492 |
|
493 |
} else if( geomType.isTypeOf(Geometry.TYPES.SURFACE) ) { |
494 |
LOG.warn("Cartographic size does not have any sense for fill symbols");
|
495 |
|
496 |
} |
497 |
return -1; |
498 |
} |
499 |
|
500 |
@Override
|
501 |
public void setCartographicSize(double cartographicSize, Geometry geom) { |
502 |
GeometryType geomType = geom.getGeometryType(); |
503 |
if( geomType.isTypeOf(Geometry.TYPES.POINT) ) {
|
504 |
if (marker != null) { |
505 |
marker.setCartographicSize(cartographicSize, null);
|
506 |
} |
507 |
|
508 |
} else if( geomType.isTypeOf(Geometry.TYPES.CURVE) ) { |
509 |
if (line != null) { |
510 |
line.setCartographicSize(cartographicSize, null);
|
511 |
} |
512 |
|
513 |
} else if( geomType.isTypeOf(Geometry.TYPES.SURFACE) ) { |
514 |
LOG.warn("Cartographic size does not have any sense for fill symbols");
|
515 |
|
516 |
} |
517 |
} |
518 |
|
519 |
|
520 |
@Override
|
521 |
public double getCartographicSize(ViewPort viewPort, double dpi, Geometry geom) { |
522 |
GeometryType geomType = geom.getGeometryType(); |
523 |
if( geomType.isTypeOf(Geometry.TYPES.POINT) ) {
|
524 |
return CartographicSupportToolkit.getCartographicLength(
|
525 |
marker, getSize(), viewPort, dpi |
526 |
); |
527 |
|
528 |
} else if( geomType.isTypeOf(Geometry.TYPES.CURVE) ) { |
529 |
return CartographicSupportToolkit.getCartographicLength(
|
530 |
line, getSize(), viewPort, dpi |
531 |
); |
532 |
|
533 |
} else if( geomType.isTypeOf(Geometry.TYPES.SURFACE) ) { |
534 |
LOG.warn("Cartographic size does not have any sense for fill symbols");
|
535 |
|
536 |
} |
537 |
return -1; |
538 |
} |
539 |
|
540 |
@Override
|
541 |
public IMarkerSymbol getMarkerSymbol() {
|
542 |
return marker;
|
543 |
} |
544 |
|
545 |
@Override
|
546 |
public ILineSymbol getLineSymbol() {
|
547 |
return line;
|
548 |
} |
549 |
|
550 |
@Override
|
551 |
public IFillSymbol getFillSymbol() {
|
552 |
return fill;
|
553 |
} |
554 |
|
555 |
@Override
|
556 |
public void setMarkerSymbol(IMarkerSymbol markerSymbol) { |
557 |
this.marker = markerSymbol;
|
558 |
} |
559 |
|
560 |
@Override
|
561 |
public void setLineSymbol(ILineSymbol lineSymbol) { |
562 |
this.line = lineSymbol;
|
563 |
} |
564 |
|
565 |
@Override
|
566 |
public void setFillSymbol(IFillSymbol fillFillSymbol) { |
567 |
this.fill = fillFillSymbol;
|
568 |
} |
569 |
|
570 |
@Override
|
571 |
public boolean hasFill() { |
572 |
if (fill == null) { |
573 |
return false; |
574 |
} |
575 |
return fill.hasFill();
|
576 |
} |
577 |
|
578 |
@Override
|
579 |
public void setHasFill(boolean hasFill) { |
580 |
if (fill != null) { |
581 |
fill.setHasFill(hasFill); |
582 |
} |
583 |
} |
584 |
|
585 |
@Override
|
586 |
public boolean hasOutline() { |
587 |
return false; |
588 |
} |
589 |
|
590 |
@Override
|
591 |
public void setHasOutline(boolean hasOutline) { |
592 |
|
593 |
} |
594 |
|
595 |
@Override
|
596 |
public Object clone() throws CloneNotSupportedException { |
597 |
MultiShapeSymbol copy = (MultiShapeSymbol) super.clone();
|
598 |
|
599 |
// Clone inner symbols
|
600 |
if (marker != null) { |
601 |
copy.marker = (IMarkerSymbol) marker.clone(); |
602 |
} |
603 |
if (line != null) { |
604 |
copy.line = (ILineSymbol) line.clone(); |
605 |
} |
606 |
if (fill != null) { |
607 |
copy.fill = (IFillSymbol) fill.clone(); |
608 |
} |
609 |
|
610 |
if (mask != null) { |
611 |
copy.mask = (IMask) mask.clone(); |
612 |
} |
613 |
|
614 |
// Clone selection symbol
|
615 |
if (symSelect != null) { |
616 |
copy.symSelect = (MultiShapeSymbol) symSelect.clone(); |
617 |
} |
618 |
|
619 |
return copy;
|
620 |
} |
621 |
|
622 |
@Override
|
623 |
public void loadFromState(PersistentState state) |
624 |
throws PersistenceException {
|
625 |
setDescription(state.getString(FIELD_DESCRIPTION)); |
626 |
setFillSymbol((IFillSymbol) state.get(FIELD_FILL)); |
627 |
setMarkerSymbol((IMarkerSymbol) state.get(FIELD_MARKER)); |
628 |
setLineSymbol((ILineSymbol) state.get(FIELD_LINE)); |
629 |
} |
630 |
|
631 |
@Override
|
632 |
public void saveToState(PersistentState state) throws PersistenceException { |
633 |
state.set(FIELD_DESCRIPTION, getDescription()); |
634 |
state.set(FIELD_FILL, getFillSymbol()); |
635 |
state.set(FIELD_MARKER, getMarkerSymbol()); |
636 |
state.set(FIELD_LINE, getLineSymbol()); |
637 |
} |
638 |
|
639 |
// @Override
|
640 |
// public String getOffsetXExpression() {
|
641 |
// return marker.getOffsetXExpression();
|
642 |
// }
|
643 |
//
|
644 |
// @Override
|
645 |
// public void setOffsetXExpression(String offsetXExpression) {
|
646 |
// marker.setOffsetXExpression(offsetXExpression);
|
647 |
// }
|
648 |
//
|
649 |
// @Override
|
650 |
// public String getOffsetYExpression() {
|
651 |
// return marker.getOffsetYExpression();
|
652 |
// }
|
653 |
//
|
654 |
// @Override
|
655 |
// public void setOffsetYExpression(String offsetYExpression) {
|
656 |
// marker.setOffsetYExpression(offsetYExpression);
|
657 |
// }
|
658 |
//
|
659 |
// @Override
|
660 |
// public String getRotationExpression() {
|
661 |
// return marker.getRotationExpression();
|
662 |
// }
|
663 |
//
|
664 |
// @Override
|
665 |
// public void setRotationExpression(String rotationExpression) {
|
666 |
// marker.setRotationExpression(rotationExpression);
|
667 |
// }
|
668 |
//
|
669 |
// @Override
|
670 |
// public Color getLineToOffsetColor() {
|
671 |
// return marker.getLineToOffsetColor();
|
672 |
// }
|
673 |
//
|
674 |
// @Override
|
675 |
// public Color getLineToOffsetColor(Feature f) {
|
676 |
// return marker.getLineToOffsetColor(f);
|
677 |
// }
|
678 |
//
|
679 |
// @Override
|
680 |
// public String getLineToOffsetColorExpression() {
|
681 |
// return marker.getLineToOffsetColorExpression();
|
682 |
// }
|
683 |
//
|
684 |
// @Override
|
685 |
// public void setLineToOffsetColorExpression(String lineToOffsetColorExpression) {
|
686 |
// marker.setLineToOffsetColorExpression(lineToOffsetColorExpression);
|
687 |
// }
|
688 |
//
|
689 |
// @Override
|
690 |
// public void setLineToOffsetColor(Color lineToOffsetColor) {
|
691 |
// marker.setLineToOffsetColor(lineToOffsetColor);
|
692 |
// }
|
693 |
//
|
694 |
// @Override
|
695 |
// public boolean isDrawLineToOffset() {
|
696 |
// return marker.isDrawLineToOffset();
|
697 |
// }
|
698 |
//
|
699 |
// @Override
|
700 |
// public boolean isDrawLineToOffset(Feature f) {
|
701 |
// return marker.isDrawLineToOffset(f);
|
702 |
// }
|
703 |
//
|
704 |
// @Override
|
705 |
// public void setDrawLineToOffset(boolean drawLineToOffset) {
|
706 |
// marker.setDrawLineToOffset(drawLineToOffset);
|
707 |
// }
|
708 |
|
709 |
public static class RegisterPersistence implements Callable { |
710 |
|
711 |
@Override
|
712 |
public Object call() throws Exception { |
713 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
714 |
if( manager.getDefinition(MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME)==null ) { |
715 |
DynStruct definition = manager.addDefinition( |
716 |
MultiShapeSymbol.class, |
717 |
MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME, |
718 |
MULTI_SHAPE_SYMBOL_PERSISTENCE_DEFINITION_NAME+" Persistence definition",
|
719 |
null,
|
720 |
null
|
721 |
); |
722 |
// Description
|
723 |
definition.addDynFieldString(FIELD_DESCRIPTION).setMandatory(false);
|
724 |
// Fill symbol
|
725 |
definition.addDynFieldObject(FIELD_FILL).setClassOfValue(IFillSymbol.class).setMandatory(true);
|
726 |
// Line symbol
|
727 |
definition.addDynFieldObject(FIELD_LINE).setClassOfValue(ILineSymbol.class).setMandatory(true);
|
728 |
// Marker symbol
|
729 |
definition.addDynFieldObject(FIELD_MARKER).setClassOfValue(IMarkerSymbol.class).setMandatory(true);
|
730 |
} |
731 |
return Boolean.TRUE; |
732 |
} |
733 |
|
734 |
} |
735 |
|
736 |
public static class RegisterSymbol implements Callable { |
737 |
|
738 |
@Override
|
739 |
public Object call() throws Exception { |
740 |
int[] shapeTypes; |
741 |
SymbolManager manager = MapContextLocator.getSymbolManager(); |
742 |
|
743 |
shapeTypes = new int[] { Geometry.TYPES.GEOMETRY }; |
744 |
manager.registerSymbol(MultiShapeSymbol.SYMBOL_NAME, |
745 |
shapeTypes, |
746 |
MultiShapeSymbol.class |
747 |
); |
748 |
return Boolean.TRUE; |
749 |
} |
750 |
|
751 |
} |
752 |
|
753 |
} |