Revision 44256 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/dynamiclegend/DefaultDynamicSymbol.java
DefaultDynamicSymbol.java | ||
---|---|---|
27 | 27 |
import org.gvsig.fmap.geom.Geometry; |
28 | 28 |
import org.gvsig.fmap.geom.GeometryLocator; |
29 | 29 |
import org.gvsig.fmap.geom.GeometryManager; |
30 |
import org.gvsig.fmap.geom.GeometryUtils; |
|
30 | 31 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
31 | 32 |
import org.gvsig.fmap.geom.primitive.Envelope; |
32 | 33 |
import org.gvsig.fmap.geom.primitive.Point; |
... | ... | |
87 | 88 |
@Override |
88 | 89 |
public ISymbol getSymbolForSelection() { |
89 | 90 |
int typeGeom = feature.getDefaultGeometry().getGeometryType().getType(); |
90 |
switch (typeGeom) { |
|
91 |
case Geometry.TYPES.POINT: |
|
92 |
case Geometry.TYPES.MULTIPOINT: |
|
93 |
setPointSymbolValues(); |
|
94 |
pointSymbol.setColor(MapContext.getSelectionColor()); |
|
95 |
pointSymbol.setOutlineColor(MapContext.getSelectionColor()); |
|
96 |
return pointSymbol; |
|
97 |
case Geometry.TYPES.LINE: |
|
98 |
case Geometry.TYPES.MULTILINE: |
|
99 |
setLineSymbolValues(); |
|
100 |
lineSymbol.setColor(MapContext.getSelectionColor()); |
|
101 |
return lineSymbol; |
|
102 |
case Geometry.TYPES.POLYGON: |
|
103 |
case Geometry.TYPES.ELLIPSE: |
|
104 |
case Geometry.TYPES.CIRCLE: |
|
105 |
case Geometry.TYPES.MULTIPOLYGON: |
|
106 |
setPolygonSymbolValues(); |
|
107 |
polygonSymbol.setFillColor(MapContext.getSelectionColor()); |
|
108 |
return polygonSymbol; |
|
109 |
default: |
|
110 |
break; |
|
91 |
|
|
92 |
if (GeometryUtils.isSubtype(Geometry.TYPES.POINT, typeGeom) |
|
93 |
|| GeometryUtils.isSubtype(Geometry.TYPES.MULTIPOINT, typeGeom)) { |
|
94 |
setPointSymbolValues(); |
|
95 |
pointSymbol.setColor(MapContext.getSelectionColor()); |
|
96 |
pointSymbol.setOutlineColor(MapContext.getSelectionColor()); |
|
97 |
return pointSymbol; |
|
98 |
} else if (GeometryUtils.isSubtype(Geometry.TYPES.CURVE, typeGeom) |
|
99 |
|| GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, typeGeom)) { |
|
100 |
setLineSymbolValues(); |
|
101 |
lineSymbol.setColor(MapContext.getSelectionColor()); |
|
102 |
return lineSymbol; |
|
103 |
} else if (GeometryUtils.isSubtype(Geometry.TYPES.SURFACE, typeGeom) |
|
104 |
|| GeometryUtils.isSubtype(Geometry.TYPES.MULTISURFACE, typeGeom)) { |
|
105 |
setPolygonSymbolValues(); |
|
106 |
polygonSymbol.setFillColor(MapContext.getSelectionColor()); |
|
107 |
return polygonSymbol; |
|
108 |
|
|
109 |
} else { |
|
110 |
return null; |
|
111 | 111 |
} |
112 |
return null; |
|
112 |
|
|
113 | 113 |
} |
114 | 114 |
|
115 | 115 |
@Override |
116 | 116 |
public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cancel) { |
117 | 117 |
Color c = getColor(); //TODO |
118 | 118 |
int typeGeom = geom.getGeometryType().getType(); |
119 |
switch (typeGeom) { |
|
120 |
case Geometry.TYPES.POINT: |
|
121 |
case Geometry.TYPES.MULTIPOINT: |
|
122 |
drawPoint(g, affineTransform, geom, f, cancel); |
|
123 |
break; |
|
124 |
case Geometry.TYPES.LINE: |
|
125 |
case Geometry.TYPES.MULTILINE: |
|
126 |
drawLine(g, affineTransform, geom, f, cancel); |
|
127 |
break; |
|
128 |
case Geometry.TYPES.POLYGON: |
|
129 |
case Geometry.TYPES.ELLIPSE: |
|
130 |
case Geometry.TYPES.CIRCLE: |
|
131 |
case Geometry.TYPES.MULTIPOLYGON: |
|
132 |
drawPolygon(g, affineTransform, geom, f, cancel); |
|
133 |
break; |
|
134 |
default: |
|
135 |
// Optimiza el pintado de geometrias grandes. |
|
136 |
try { |
|
137 |
Geometry env = geom.getEnvelope().getGeometry(); |
|
138 |
env.transform(affineTransform); |
|
139 |
Envelope env2 = env.getEnvelope(); |
|
140 |
if (env2.getLength(0) < 1.5 && env2.getLength(1) < 1.5) { |
|
141 |
geom = env2.getUpperCorner(); |
|
142 |
} |
|
143 |
} catch (Exception ex) { |
|
144 |
LOG.warn("Error optimizing the drawing of the geometry. Continues with normal drawing.", ex); |
|
145 |
// Do nothing, continue with the draw of the original geometry |
|
119 |
if (GeometryUtils.isSubtype(Geometry.TYPES.POINT, typeGeom) |
|
120 |
|| GeometryUtils.isSubtype(Geometry.TYPES.MULTIPOINT, typeGeom)) { |
|
121 |
drawPoint(g, affineTransform, geom, f, cancel); |
|
122 |
} else if (GeometryUtils.isSubtype(Geometry.TYPES.CURVE, typeGeom) |
|
123 |
|| GeometryUtils.isSubtype(Geometry.TYPES.MULTICURVE, typeGeom)) { |
|
124 |
drawLine(g, affineTransform, geom, f, cancel); |
|
125 |
} else if (GeometryUtils.isSubtype(Geometry.TYPES.SURFACE, typeGeom) |
|
126 |
|| GeometryUtils.isSubtype(Geometry.TYPES.MULTISURFACE, typeGeom)) { |
|
127 |
drawPolygon(g, affineTransform, geom, f, cancel); |
|
128 |
|
|
129 |
} else { |
|
130 |
// Optimiza el pintado de geometrias grandes. |
|
131 |
try { |
|
132 |
Geometry env = geom.getEnvelope().getGeometry(); |
|
133 |
env.transform(affineTransform); |
|
134 |
Envelope env2 = env.getEnvelope(); |
|
135 |
if (env2.getLength(0) < 1.5 && env2.getLength(1) < 1.5) { |
|
136 |
geom = env2.getUpperCorner(); |
|
146 | 137 |
} |
147 |
g.setColor(c); |
|
148 |
g.fill(geom.getShape(affineTransform)); |
|
149 |
g.draw(geom.getShape(affineTransform)); |
|
150 |
break; |
|
138 |
} catch (Exception ex) { |
|
139 |
LOG.warn("Error optimizing the drawing of the geometry. Continues with normal drawing.", ex); |
|
140 |
// Do nothing, continue with the draw of the original geometry |
|
141 |
} |
|
142 |
g.setColor(c); |
|
143 |
g.fill(geom.getShape(affineTransform)); |
|
144 |
g.draw(geom.getShape(affineTransform)); |
|
145 |
|
|
151 | 146 |
} |
152 | 147 |
} |
153 | 148 |
|
... | ... | |
319 | 314 |
public Expression getOffset() { |
320 | 315 |
return eOffset; |
321 | 316 |
} |
322 |
|
|
317 |
|
|
323 | 318 |
public void setOffset(Expression offset) { |
324 | 319 |
eOffset = offset; |
325 | 320 |
} |
... | ... | |
336 | 331 |
return pointOffset; |
337 | 332 |
} |
338 | 333 |
|
339 |
|
|
340 | 334 |
public Expression getRotation() { |
341 | 335 |
return eRotation; |
342 | 336 |
} |
... | ... | |
351 | 345 |
eRotation = exp; |
352 | 346 |
} |
353 | 347 |
|
354 |
|
|
355 |
|
|
356 | 348 |
private Color getColorFromExpression(Expression exp) { |
357 | 349 |
Integer rgbcolor = (Integer) exp.execute(getFeatureSymbolTable()); |
358 | 350 |
Color color = new Color(rgbcolor, true); |
... | ... | |
427 | 419 |
return this.listRequiredAttributeNames; |
428 | 420 |
|
429 | 421 |
} |
430 |
|
|
422 |
|
|
431 | 423 |
public void setRequiredFeatureAttributesNames(List<String> listRequiredAttributeNames) { |
432 | 424 |
this.listRequiredAttributeNames = listRequiredAttributeNames; |
433 |
|
|
425 |
|
|
434 | 426 |
} |
435 |
|
|
436 | 427 |
|
437 | 428 |
} |
Also available in: Unified diff