Revision 10293
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.legend.picturemarkersymboltable.lib.impl.PictureMarkerSymbolTableLibraryImpl |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.impl/src/main/resources/org/gvsig/legend/picturemarkersymboltable/lib/impl/PictureMarkerSymbolTablePersistence.xml | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<definitions> |
|
3 |
<version>1.0.0</version> |
|
4 |
<classes> |
|
5 |
<class name="DefaultPictureMarkerSymbolTableLegend"> |
|
6 |
<extends> |
|
7 |
<class name="VectorialLegend" namespace="persistence"/> |
|
8 |
</extends> |
|
9 |
<fields> |
|
10 |
<field name="scale" type="Double" defaultValue="1" mandatory="false"> |
|
11 |
<description></description> |
|
12 |
</field> |
|
13 |
<field name="size" type="Double" defaultValue="15" mandatory="false"> |
|
14 |
<description></description> |
|
15 |
</field> |
|
16 |
<field name="units" type="Integer" defaultValue="-1" mandatory="false"> |
|
17 |
<description></description> |
|
18 |
</field> |
|
19 |
<field name="lineToOffsetColor" type="Object" ClassOfValue="java.awt.Color" defaultValue="darkgrey" mandatory="false"> |
|
20 |
<description></description> |
|
21 |
</field> |
|
22 |
<field name="drawLineToOffset" type="Boolean" defaultValue="true" mandatory="false"> |
|
23 |
<description></description> |
|
24 |
</field> |
|
25 |
<field name="reverseDirectionOfAngle" type="Boolean" defaultValue="false" mandatory="false"> |
|
26 |
<description></description> |
|
27 |
</field> |
|
28 |
<field name="classifyingFieldName" type="String" defaultValue="" mandatory="true"> |
|
29 |
<description></description> |
|
30 |
</field> |
|
31 |
<field name="offsetXFieldName" type="String" defaultValue="" mandatory="false"> |
|
32 |
<description></description> |
|
33 |
</field> |
|
34 |
<field name="offsetYFieldName" type="String" defaultValue="" mandatory="false"> |
|
35 |
<description></description> |
|
36 |
</field> |
|
37 |
<field name="rotationFieldName" type="String" defaultValue="" mandatory="false"> |
|
38 |
<description></description> |
|
39 |
</field> |
|
40 |
<field name="lineToOffsetColorFieldlName" type="String" defaultValue="" mandatory="false"> |
|
41 |
<description></description> |
|
42 |
</field> |
|
43 |
<field name="imagesTableName" type="String" defaultValue="" mandatory="true"> |
|
44 |
<description></description> |
|
45 |
</field> |
|
46 |
<field name="imagesTableClassifyingFieldName" type="String" defaultValue="" mandatory="true"> |
|
47 |
<description></description> |
|
48 |
</field> |
|
49 |
<field name="imageFieldName" type="String" defaultValue="" mandatory="true"> |
|
50 |
<description></description> |
|
51 |
</field> |
|
52 |
<field name="imageSelectedFieldName" type="String" defaultValue="" mandatory="false"> |
|
53 |
<description></description> |
|
54 |
</field> |
|
55 |
</fields> |
|
56 |
</class> |
|
57 |
|
|
58 |
</classes> |
|
59 |
</definitions> |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.impl/src/main/java/org/gvsig/legend/picturemarkersymboltable/lib/impl/ImageMarkerSymbol.java | ||
---|---|---|
1 |
package org.gvsig.legend.picturemarkersymboltable.lib.impl; |
|
2 |
|
|
3 |
import java.awt.Graphics2D; |
|
4 |
import java.awt.Rectangle; |
|
5 |
import java.awt.geom.AffineTransform; |
|
6 |
import java.awt.geom.Point2D; |
|
7 |
import java.awt.image.BufferedImage; |
|
8 |
import org.gvsig.fmap.dal.feature.Feature; |
|
9 |
import org.gvsig.fmap.geom.Geometry; |
|
10 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
11 |
import org.gvsig.fmap.geom.GeometryManager; |
|
12 |
import org.gvsig.fmap.geom.aggregate.Aggregate; |
|
13 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
14 |
import org.gvsig.fmap.geom.primitive.Point; |
|
15 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
16 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
|
17 |
import org.gvsig.fmap.mapcontext.rendering.symbols.IMultiLayerSymbol; |
|
18 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
19 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol_v2; |
|
20 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.ILineSymbol; |
|
21 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.line.impl.AbstractLineSymbol; |
|
22 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.IMarkerSymbol; |
|
23 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.impl.AbstractMarkerSymbol; |
|
24 |
import org.gvsig.tools.swing.api.TransparencySupport; |
|
25 |
import org.gvsig.tools.task.Cancellable; |
|
26 |
import org.slf4j.Logger; |
|
27 |
import org.slf4j.LoggerFactory; |
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @author gvSIG Team |
|
32 |
*/ |
|
33 |
@SuppressWarnings("UseSpecificCatch") |
|
34 |
public class ImageMarkerSymbol extends AbstractMarkerSymbol implements IMarkerSymbol, IMultiLayerSymbol, TransparencySupport { |
|
35 |
|
|
36 |
private static final Logger LOGGER = LoggerFactory.getLogger(ImageMarkerSymbol.class); |
|
37 |
|
|
38 |
private ImageMarkerSymbol selectionSym; |
|
39 |
private boolean selected; |
|
40 |
private BufferedImage image; |
|
41 |
private BufferedImage imagesel; |
|
42 |
private ISymbol[] layers; |
|
43 |
|
|
44 |
private static class ImageSymbol extends AbstractMarkerSymbol implements IMarkerSymbol { |
|
45 |
|
|
46 |
private final ImageMarkerSymbol parent; |
|
47 |
|
|
48 |
public ImageSymbol(ImageMarkerSymbol parent) { |
|
49 |
this.parent = parent; |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
public ISymbol getSymbolForSelection() { |
|
54 |
return ((ImageMarkerSymbol)(this.parent.getSymbolForSelection())).getLayer(1); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cnclbl, Rectangle r) { |
|
59 |
Point p; |
|
60 |
if(r != null){ |
|
61 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
62 |
try { |
|
63 |
p = (Point) geometryManager.createPoint(r.getCenterX(), r.getCenterY(), Geometry.SUBTYPES.GEOM2D); |
|
64 |
} catch (CreateGeometryException ex) { |
|
65 |
return; |
|
66 |
} |
|
67 |
} else { |
|
68 |
try { |
|
69 |
p = geom.centroid(); |
|
70 |
} catch (Exception ex) { |
|
71 |
return; |
|
72 |
} |
|
73 |
try { |
|
74 |
if( geom.getType()==Geometry.TYPES.LINE ) { |
|
75 |
// Si es una linea, intenta coger un punto aproximadamente |
|
76 |
// sobre el centro de la linea. |
|
77 |
p = (Point) geom.closestPoints(p)[0]; |
|
78 |
} else if( geom.getType()==Geometry.TYPES.MULTILINE && ((Aggregate)geom).getPrimitivesNumber()==1 ) { |
|
79 |
// Si es una multilinea compuesta por solo una linea, intenta |
|
80 |
// coger un punto aproximadamene sobre el centro de esa linea |
|
81 |
p = (Point) ((Aggregate)geom).getPrimitiveAt(0).closestPoints(p)[0]; |
|
82 |
} |
|
83 |
} catch(Throwable th) { |
|
84 |
// Do nothing, ignore error and use centroid |
|
85 |
LOGGER.debug("Problems calculating the center of geometry",th); |
|
86 |
} |
|
87 |
|
|
88 |
if (affineTransform != null) { |
|
89 |
p.transform(affineTransform); |
|
90 |
} |
|
91 |
} |
|
92 |
double x, y; |
|
93 |
int size = (int) Math.round(this.parent.getEfectiveSize(f)); |
|
94 |
double halfSize = this.parent.getEfectiveSize(f) / 2; |
|
95 |
x = p.getX() - halfSize; |
|
96 |
y = p.getY() - halfSize; |
|
97 |
Point2D theOffset = this.parent.getEfectiveOffset(f); |
|
98 |
int xOffset = (int) theOffset.getX(); |
|
99 |
int yOffset = (int) theOffset.getY(); |
|
100 |
|
|
101 |
if (size > 0) { |
|
102 |
Rectangle rect = new Rectangle(size, size); |
|
103 |
g.translate(x + xOffset, y + yOffset); |
|
104 |
double auxRotation = this.parent.getEfectiveRotationInRadians(f); |
|
105 |
g.rotate(auxRotation, halfSize, halfSize); |
|
106 |
|
|
107 |
this.parent.drawInsideRectangle(g, rect, true); |
|
108 |
|
|
109 |
g.rotate(-auxRotation, halfSize, halfSize); |
|
110 |
g.translate(-(x + xOffset), -(y + yOffset)); |
|
111 |
|
|
112 |
} |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public void setCartographicContext(CartographicContext ctx) { |
|
117 |
super.setCartographicContext(ctx); |
|
118 |
this.parent.setCartographicContext(ctx); |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
122 |
public int getUnit() { |
|
123 |
return this.parent.getUnit(); |
|
124 |
} |
|
125 |
|
|
126 |
} |
|
127 |
|
|
128 |
private static class LineSymbol extends AbstractLineSymbol implements ILineSymbol { |
|
129 |
|
|
130 |
private final ImageMarkerSymbol parent; |
|
131 |
|
|
132 |
public LineSymbol(ImageMarkerSymbol parent) { |
|
133 |
this.parent = parent; |
|
134 |
} |
|
135 |
|
|
136 |
@Override |
|
137 |
public ISymbol getSymbolForSelection() { |
|
138 |
return ((ImageMarkerSymbol)(this.parent.getSymbolForSelection())).getLayer(0); |
|
139 |
} |
|
140 |
|
|
141 |
@Override |
|
142 |
public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cnclbl, Rectangle rect) { |
|
143 |
Point p; |
|
144 |
try { |
|
145 |
p = geom.centroid(); |
|
146 |
} catch (Exception ex) { |
|
147 |
return; |
|
148 |
} |
|
149 |
if (affineTransform != null) { |
|
150 |
p.transform(affineTransform); |
|
151 |
} |
|
152 |
int size = (int) Math.round(this.parent.getEfectiveSize(f)); |
|
153 |
Point2D theOffset = this.parent.getEfectiveOffset(f); |
|
154 |
int xOffset = (int) theOffset.getX(); |
|
155 |
int yOffset = (int) theOffset.getY(); |
|
156 |
|
|
157 |
if (size > 0) { |
|
158 |
if (this.parent.isDrawLineToOffset()) { |
|
159 |
g.setColor(this.parent.getEfectiveLineToOffsetColor(f)); |
|
160 |
g.drawLine((int) p.getX(), (int) p.getY(), (int) p.getX() + xOffset, (int) p.getY() + yOffset); |
|
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
public void setLineWidth(double d) { |
|
167 |
} |
|
168 |
|
|
169 |
@Override |
|
170 |
public double getLineWidth() { |
|
171 |
return 1; |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
public void setCartographicContext(CartographicContext ctx) { |
|
176 |
super.setCartographicContext(ctx); |
|
177 |
this.parent.setCartographicContext(ctx); |
|
178 |
} |
|
179 |
|
|
180 |
@Override |
|
181 |
public int getUnit() { |
|
182 |
return this.parent.getUnit(); |
|
183 |
} |
|
184 |
|
|
185 |
} |
|
186 |
|
|
187 |
public ImageMarkerSymbol() { |
|
188 |
this.layers = new ISymbol[] {new LineSymbol(this), new ImageSymbol(this)}; |
|
189 |
} |
|
190 |
|
|
191 |
void setImage(BufferedImage img) { |
|
192 |
this.image = img; |
|
193 |
} |
|
194 |
|
|
195 |
void setImageSel(BufferedImage img) { |
|
196 |
this.imagesel = img; |
|
197 |
} |
|
198 |
|
|
199 |
@Override |
|
200 |
public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cancel, Rectangle r) { |
|
201 |
for (int i = 0; (cancel == null || !cancel.isCanceled()) |
|
202 |
&& layers != null && i < layers.length; i++) { |
|
203 |
ISymbol layer = layers[i]; |
|
204 |
if (layer == null) { |
|
205 |
continue; |
|
206 |
} |
|
207 |
if(layer instanceof CartographicSupport){ |
|
208 |
((CartographicSupport)layer).setCartographicContext(this.getCartographicContext()); |
|
209 |
} |
|
210 |
if(layer instanceof ISymbol_v2){ |
|
211 |
((ISymbol_v2)layer).draw(g, affineTransform, geom, f, cancel, r); |
|
212 |
} else { |
|
213 |
layer.draw(g, affineTransform, geom, f, cancel); |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
private void drawInsideRectangle(Graphics2D g, Rectangle r, boolean keepAspectRatio) { |
|
219 |
BufferedImage theImage = (!selected) ? this.image : this.imagesel; |
|
220 |
if (theImage != null) { |
|
221 |
|
|
222 |
double xOffset = 0; |
|
223 |
double yOffset = 0; |
|
224 |
@SuppressWarnings("UnusedAssignment") |
|
225 |
double xScale = 1; |
|
226 |
@SuppressWarnings("UnusedAssignment") |
|
227 |
double yScale = 1; |
|
228 |
if (keepAspectRatio) { |
|
229 |
double scale; |
|
230 |
if (theImage.getWidth() > theImage.getHeight()) { |
|
231 |
scale = r.getWidth() / theImage.getWidth(); |
|
232 |
yOffset = 0.5 * (r.getHeight() - theImage.getHeight() * scale); |
|
233 |
} else { |
|
234 |
scale = r.getHeight() / theImage.getHeight(); |
|
235 |
xOffset = 0.5 * (r.getWidth() - theImage.getWidth() * scale); |
|
236 |
} |
|
237 |
xScale = yScale = scale; |
|
238 |
|
|
239 |
} else { |
|
240 |
xScale = r.getWidth() / theImage.getWidth(); |
|
241 |
yScale = r.getHeight() / theImage.getHeight(); |
|
242 |
yOffset = theImage.getHeight() * 0.5 * yScale; |
|
243 |
|
|
244 |
} |
|
245 |
|
|
246 |
AffineTransform at = AffineTransform.getTranslateInstance(xOffset, yOffset); |
|
247 |
at.concatenate(AffineTransform.getScaleInstance(xScale, yScale)); |
|
248 |
g.drawRenderedImage(theImage, at); |
|
249 |
} |
|
250 |
|
|
251 |
} |
|
252 |
|
|
253 |
|
|
254 |
@Override |
|
255 |
public ISymbol getSymbolForSelection() { |
|
256 |
if (selectionSym == null) { |
|
257 |
try { |
|
258 |
selectionSym = (ImageMarkerSymbol) this.clone(); |
|
259 |
} catch (CloneNotSupportedException e) { |
|
260 |
// LOG.warn("Error creating the selection symbol for the symbol "+ this, e); |
|
261 |
} |
|
262 |
selectionSym.selected = true; |
|
263 |
selectionSym.selectionSym = selectionSym; // avoid too much lazy creations |
|
264 |
} else { |
|
265 |
selectionSym.setColor(MapContext.getSelectionColor()); |
|
266 |
} |
|
267 |
return selectionSym; |
|
268 |
} |
|
269 |
|
|
270 |
@Override |
|
271 |
public Object clone() throws CloneNotSupportedException { |
|
272 |
ImageMarkerSymbol copy = (ImageMarkerSymbol) super.clone(); |
|
273 |
copy.layers = new ISymbol[] {new LineSymbol(copy), new ImageSymbol(copy)}; |
|
274 |
|
|
275 |
return copy; |
|
276 |
} |
|
277 |
|
|
278 |
@Override |
|
279 |
public void setTransparency(double d) { |
|
280 |
} |
|
281 |
|
|
282 |
@Override |
|
283 |
public double getTransparency() { |
|
284 |
return 0; |
|
285 |
} |
|
286 |
|
|
287 |
@Override |
|
288 |
public void setLayer(int i, ISymbol is) throws IndexOutOfBoundsException { |
|
289 |
} |
|
290 |
|
|
291 |
@Override |
|
292 |
public void swapLayers(int i, int i1) { |
|
293 |
} |
|
294 |
|
|
295 |
@Override |
|
296 |
public ISymbol getLayer(int i) { |
|
297 |
return getLayers()[i]; |
|
298 |
} |
|
299 |
|
|
300 |
@Override |
|
301 |
public int getLayerCount() { |
|
302 |
return 2; |
|
303 |
} |
|
304 |
|
|
305 |
@Override |
|
306 |
public void addLayer(ISymbol is) { |
|
307 |
} |
|
308 |
|
|
309 |
@Override |
|
310 |
public void addLayer(ISymbol is, int i) throws IndexOutOfBoundsException { |
|
311 |
} |
|
312 |
|
|
313 |
@Override |
|
314 |
public boolean removeLayer(ISymbol is) { |
|
315 |
return false; |
|
316 |
} |
|
317 |
|
|
318 |
public ISymbol[] getLayers() { |
|
319 |
return layers; |
|
320 |
} |
|
321 |
|
|
322 |
@Override |
|
323 |
public void setCartographicContext(CartographicContext ctx) { |
|
324 |
super.setCartographicContext(ctx); |
|
325 |
// ((CartographicSupport)this.layers[0]).setCartographicContext(ctx); |
|
326 |
// ((CartographicSupport)this.layers[1]).setCartographicContext(ctx); |
|
327 |
} |
|
328 |
} |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.impl/src/main/java/org/gvsig/legend/picturemarkersymboltable/lib/impl/DefaultPictureMarkerSymbolTableManager.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2015 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.legend.picturemarkersymboltable.lib.impl; |
|
24 |
|
|
25 |
import org.gvsig.legend.picturemarkersymboltable.lib.api.PictureMarkerSymbolTableLegend; |
|
26 |
import org.gvsig.legend.picturemarkersymboltable.lib.api.PictureMarkerSymbolTableManager; |
|
27 |
import org.slf4j.Logger; |
|
28 |
import org.slf4j.LoggerFactory; |
|
29 |
|
|
30 |
@SuppressWarnings("UseSpecificCatch") |
|
31 |
public class DefaultPictureMarkerSymbolTableManager implements PictureMarkerSymbolTableManager { |
|
32 |
|
|
33 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPictureMarkerSymbolTableManager.class); |
|
34 |
|
|
35 |
@Override |
|
36 |
public PictureMarkerSymbolTableLegend createPictureMarkerSymbolTableLegend() { |
|
37 |
return new DefaultPictureMarkerSymbolTableLegend(); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public Class<? extends PictureMarkerSymbolTableLegend> getPictureMarkerSymbolTableLegendClass() { |
|
42 |
return DefaultPictureMarkerSymbolTableLegend.class; |
|
43 |
} |
|
44 |
|
|
45 |
|
|
46 |
} |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.impl/src/main/java/org/gvsig/legend/picturemarkersymboltable/lib/impl/DefaultPictureMarkerSymbolTableLegend.java | ||
---|---|---|
1 |
package org.gvsig.legend.picturemarkersymboltable.lib.impl; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import java.awt.geom.Point2D; |
|
5 |
import java.awt.image.BufferedImage; |
|
6 |
import java.net.URL; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.List; |
|
9 |
import javax.annotation.processing.SupportedSourceVersion; |
|
10 |
import javax.lang.model.SourceVersion; |
|
11 |
import org.apache.commons.collections4.map.LRUMap; |
|
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
14 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
15 |
import org.gvsig.fmap.dal.DALLocator; |
|
16 |
import org.gvsig.fmap.dal.DataTypes; |
|
17 |
import org.gvsig.fmap.dal.StoresRepository; |
|
18 |
import org.gvsig.fmap.dal.exception.DataException; |
|
19 |
import org.gvsig.fmap.dal.feature.Feature; |
|
20 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
21 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
22 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
23 |
import org.gvsig.fmap.geom.Geometry; |
|
24 |
import org.gvsig.fmap.geom.GeometryUtils; |
|
25 |
import org.gvsig.fmap.mapcontext.MapContextException; |
|
26 |
import org.gvsig.fmap.mapcontext.rendering.legend.ZSort; |
|
27 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.IntervalLegendEvent; |
|
28 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LabelLegendEvent; |
|
29 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendChangedEvent; |
|
30 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendClearEvent; |
|
31 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent; |
|
32 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.ValueLegendEvent; |
|
33 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
34 |
import org.gvsig.legend.picturemarkersymboltable.lib.api.PictureMarkerSymbolTableLegend; |
|
35 |
import org.gvsig.symbology.SymbologyLocator; |
|
36 |
import org.gvsig.symbology.SymbologyManager; |
|
37 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractVectorialLegend; |
|
38 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.marker.ISimpleMarkerSymbol; |
|
39 |
import org.gvsig.tools.ToolsLocator; |
|
40 |
import org.gvsig.tools.dataTypes.Coercion; |
|
41 |
import org.gvsig.tools.persistence.PersistentState; |
|
42 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
43 |
import org.gvsig.tools.swing.api.SimpleImage; |
|
44 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
45 |
import org.slf4j.Logger; |
|
46 |
import org.slf4j.LoggerFactory; |
|
47 |
|
|
48 |
@SupportedSourceVersion(SourceVersion.RELEASE_8) |
|
49 |
@SuppressWarnings("UseSpecificCatch") |
|
50 |
public class DefaultPictureMarkerSymbolTableLegend |
|
51 |
extends AbstractVectorialLegend |
|
52 |
implements PictureMarkerSymbolTableLegend |
|
53 |
{ |
|
54 |
|
|
55 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPictureMarkerSymbolTableLegend.class); |
|
56 |
|
|
57 |
private static final int IMAGESCACHE_SIZE = 100; |
|
58 |
|
|
59 |
/** |
|
60 |
* defaultSimbol no se usa para nada. |
|
61 |
* Lo inicializamos en el constructor a SimpleMarkerSymbol por si a caso |
|
62 |
* alguien lo consulta, por ejemplo al persistir el ImageMarkerSimbol. |
|
63 |
*/ |
|
64 |
transient private final ISimpleMarkerSymbol defaultSymbol; |
|
65 |
|
|
66 |
transient private final Coercion toColor; |
|
67 |
transient private FeatureStore imagesStore; |
|
68 |
transient private ExpressionBuilder expressionBuilder; |
|
69 |
transient private final LRUMap<Object, BufferedImage[]> imagesCache; |
|
70 |
|
|
71 |
private double size; |
|
72 |
private int units; |
|
73 |
private Color lineToOffsetColor; |
|
74 |
private boolean drawLineToOffset; |
|
75 |
|
|
76 |
private String classifyingFieldName; |
|
77 |
private String offsetXFieldName; |
|
78 |
private String offsetYFieldName; |
|
79 |
private String rotationFieldName; |
|
80 |
private String lineToOffsetColorFieldlName; |
|
81 |
|
|
82 |
private String imagesTableName; |
|
83 |
private String imagesTableClassifyingFieldName; |
|
84 |
private String imageFieldName; |
|
85 |
private String imageSelectedFieldName; |
|
86 |
private SimpleImage imageNotFound; |
|
87 |
|
|
88 |
private double scale; |
|
89 |
private boolean reverseDirectionOfAngle; |
|
90 |
|
|
91 |
private class MyZSort extends ZSort { |
|
92 |
|
|
93 |
public MyZSort() { |
|
94 |
super(); |
|
95 |
} |
|
96 |
|
|
97 |
@Override |
|
98 |
public void legendChanged(LegendChangedEvent e) throws MapContextException { |
|
99 |
// symbols.clear(); |
|
100 |
// usingZSort = false; |
|
101 |
// initialize(e.getNewLegend()); |
|
102 |
|
|
103 |
} |
|
104 |
|
|
105 |
@Override |
|
106 |
public String getClassName() { |
|
107 |
return getClass().getName(); |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public int getLevelCount() { |
|
112 |
return 2; |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public void setUsingZSort(boolean usingZSort) { |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public void setLevels(ISymbol sym, int[] values) { |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void setLevels(int row, int[] values) { |
|
125 |
} |
|
126 |
|
|
127 |
@Override |
|
128 |
public int[] getLevels(ISymbol sym) { |
|
129 |
return new int[]{0,1}; |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public int[] getLevels(int row) { |
|
134 |
return null; |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public boolean isUsingZSort() { |
|
139 |
return true; |
|
140 |
} |
|
141 |
|
|
142 |
@Override |
|
143 |
public ISymbol[] getSymbols() { |
|
144 |
return null; |
|
145 |
} |
|
146 |
|
|
147 |
@Override |
|
148 |
public String[] getDescriptions() { |
|
149 |
return new String[] {"line", "Image"}; |
|
150 |
} |
|
151 |
|
|
152 |
@Override |
|
153 |
public int getTopLevelIndexAllowed() { |
|
154 |
return 0; |
|
155 |
} |
|
156 |
|
|
157 |
@Override |
|
158 |
public String toString() { |
|
159 |
return "Line, Image"; |
|
160 |
} |
|
161 |
|
|
162 |
@Override |
|
163 |
public boolean symbolChanged(SymbolLegendEvent e) { |
|
164 |
return true; |
|
165 |
} |
|
166 |
|
|
167 |
@Override |
|
168 |
public boolean classifiedSymbolChange(SymbolLegendEvent e) { |
|
169 |
return true; |
|
170 |
} |
|
171 |
|
|
172 |
@Override |
|
173 |
public boolean intervalChange(IntervalLegendEvent e) { |
|
174 |
return false; |
|
175 |
} |
|
176 |
|
|
177 |
@Override |
|
178 |
public boolean valueChange(ValueLegendEvent e) { |
|
179 |
return false; |
|
180 |
} |
|
181 |
|
|
182 |
// TODO should not exist here |
|
183 |
@Override |
|
184 |
public boolean labelFieldChange(LabelLegendEvent e) { |
|
185 |
return false; |
|
186 |
} |
|
187 |
|
|
188 |
@Override |
|
189 |
public void legendCleared(LegendClearEvent event) { |
|
190 |
} |
|
191 |
|
|
192 |
} |
|
193 |
|
|
194 |
public DefaultPictureMarkerSymbolTableLegend() { |
|
195 |
|
|
196 |
SymbologyManager symbologyManager = SymbologyLocator.getSymbologyManager(); |
|
197 |
this.scale = 1; |
|
198 |
this.defaultSymbol = symbologyManager.createSimpleMarkerSymbol(); |
|
199 |
this.toColor = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.COLOR); |
|
200 |
this.size = DEFAULT_IMAGE_SIZE; |
|
201 |
this.drawLineToOffset = true; |
|
202 |
this.lineToOffsetColor = Color.DARK_GRAY; |
|
203 |
this.imagesCache = new LRUMap<>(IMAGESCACHE_SIZE); |
|
204 |
this.reverseDirectionOfAngle = false; |
|
205 |
this.setZSort(new MyZSort()); |
|
206 |
} |
|
207 |
|
|
208 |
@Override |
|
209 |
public ISymbol getDefaultSymbol() { |
|
210 |
return this.defaultSymbol; |
|
211 |
} |
|
212 |
|
|
213 |
@Override |
|
214 |
public void setDefaultSymbol(ISymbol is) { |
|
215 |
//DO NOTHING |
|
216 |
} |
|
217 |
|
|
218 |
private Color getColor(Feature feature, String attrname, Color defaultValue) { |
|
219 |
if( StringUtils.isBlank(attrname) ) { |
|
220 |
return defaultValue; |
|
221 |
} |
|
222 |
try { |
|
223 |
return (Color) toColor.coerce(feature.get(attrname)); |
|
224 |
} catch(Exception ex) { |
|
225 |
return defaultValue; |
|
226 |
} |
|
227 |
} |
|
228 |
|
|
229 |
@Override |
|
230 |
public ISymbol getSymbolByFeature(Feature feature) throws MapContextException { |
|
231 |
ImageMarkerSymbol symbol = new ImageMarkerSymbol(); |
|
232 |
|
|
233 |
Point2D.Double offset = new Point2D.Double(0,0); |
|
234 |
if( StringUtils.isNotBlank(this.offsetXFieldName)) { |
|
235 |
offset.x = feature.getDouble(this.offsetXFieldName)*this.scale; |
|
236 |
} |
|
237 |
if( StringUtils.isNotBlank(this.offsetYFieldName)) { |
|
238 |
offset.y = feature.getDouble(this.offsetYFieldName)*this.scale; |
|
239 |
} |
|
240 |
symbol.setOffset(offset); |
|
241 |
|
|
242 |
if( StringUtils.isNotBlank(this.rotationFieldName)) { |
|
243 |
if( this.isReverseDirectionOfAngle() ) { |
|
244 |
symbol.setRotation(360 - feature.getDouble(this.rotationFieldName)); |
|
245 |
} else { |
|
246 |
symbol.setRotation(feature.getDouble(this.rotationFieldName)); |
|
247 |
} |
|
248 |
} else { |
|
249 |
symbol.setRotation(0); |
|
250 |
} |
|
251 |
|
|
252 |
if( drawLineToOffset && (offset.x!=0 || offset.y!=0)) { |
|
253 |
symbol.setDrawLineToOffset(true); |
|
254 |
symbol.setLineToOffsetColor( |
|
255 |
getColor( |
|
256 |
feature, |
|
257 |
this.lineToOffsetColorFieldlName, |
|
258 |
this.lineToOffsetColor |
|
259 |
) |
|
260 |
); |
|
261 |
} else { |
|
262 |
symbol.setDrawLineToOffset(false); |
|
263 |
symbol.setLineToOffsetColor(Color.DARK_GRAY); |
|
264 |
} |
|
265 |
symbol.setSize(this.size*this.scale); |
|
266 |
symbol.setUnit(this.units); |
|
267 |
|
|
268 |
Object classifyingValue = feature.get(this.classifyingFieldName); |
|
269 |
BufferedImage[] images = this.getImages(classifyingValue); |
|
270 |
symbol.setImage(images[0]); |
|
271 |
symbol.setImageSel(images[1]); |
|
272 |
return symbol; |
|
273 |
} |
|
274 |
|
|
275 |
@Override |
|
276 |
public int getShapeType() { |
|
277 |
return Geometry.TYPES.POINT; |
|
278 |
} |
|
279 |
|
|
280 |
private BufferedImage[] getImages(Object classifyingValue) { |
|
281 |
|
|
282 |
BufferedImage[] images; |
|
283 |
images = this.imagesCache.get(classifyingValue); |
|
284 |
if( images!=null ) { |
|
285 |
return images; |
|
286 |
} |
|
287 |
|
|
288 |
images = new BufferedImage[] { null, null }; |
|
289 |
try { |
|
290 |
FeatureStore store = this.getImagesStore(); |
|
291 |
FeatureType featureType = store.getDefaultFeatureTypeQuietly(); |
|
292 |
FeatureAttributeDescriptor attr = featureType.getAttributeDescriptor(this.imagesTableClassifyingFieldName); |
|
293 |
Object value = attr.coerce(classifyingValue); |
|
294 |
ExpressionBuilder builder = this.getExpressionBuilder(); |
|
295 |
String filter = builder.eq( |
|
296 |
builder.column(this.imagesTableClassifyingFieldName), |
|
297 |
builder.constant(value) |
|
298 |
).toString(); |
|
299 |
Feature f = store.findFirst(filter); |
|
300 |
if( f==null ) { |
|
301 |
SimpleImage image = getImageNotFound(); |
|
302 |
images[0] = image.getBufferedImage(); |
|
303 |
images[1] = images[0]; |
|
304 |
} else { |
|
305 |
SimpleImage image = (SimpleImage) f.getFromProfile(this.imageFieldName); |
|
306 |
if( image != null ) { |
|
307 |
images[0] = image.getBufferedImage(); |
|
308 |
images[1] = images[0]; |
|
309 |
} |
|
310 |
image = (SimpleImage) f.getFromProfile(this.imageSelectedFieldName); |
|
311 |
if( image != null && !image.isEmpty() ) { |
|
312 |
images[1] = image.getBufferedImage(); |
|
313 |
} |
|
314 |
} |
|
315 |
} catch(Exception ex) { |
|
316 |
LOGGER.debug("Can't retrieve images from table '"+this.imagesTableName+"'", ex); |
|
317 |
} |
|
318 |
this.imagesCache.put(classifyingValue, images); |
|
319 |
return images; |
|
320 |
} |
|
321 |
|
|
322 |
private SimpleImage getImageNotFound() { |
|
323 |
if(this.imageNotFound == null){ |
|
324 |
URL url = this.getClass().getResource("/images/picturemarkersymboltablelegend/image-not-found.png"); |
|
325 |
this.imageNotFound = ToolsSwingLocator.getToolsSwingManager().createSimpleImage(url); |
|
326 |
} |
|
327 |
return this.imageNotFound; |
|
328 |
} |
|
329 |
|
|
330 |
private ExpressionBuilder getExpressionBuilder() { |
|
331 |
if( this.expressionBuilder == null ) { |
|
332 |
this.expressionBuilder = ExpressionUtils.createExpressionBuilder(); |
|
333 |
} |
|
334 |
return this.expressionBuilder; |
|
335 |
} |
|
336 |
|
|
337 |
private FeatureStore getImagesStore() { |
|
338 |
if( this.imagesStore == null ) { |
|
339 |
StoresRepository repository = DALLocator.getDataManager().getStoresRepository(); |
|
340 |
this.imagesStore = (FeatureStore) repository.getStore(this.imagesTableName); |
|
341 |
} |
|
342 |
return this.imagesStore; |
|
343 |
} |
|
344 |
|
|
345 |
@Override |
|
346 |
public void setShapeType(int i) { |
|
347 |
} |
|
348 |
|
|
349 |
@Override |
|
350 |
public boolean isUseDefaultSymbol() { |
|
351 |
return true; |
|
352 |
} |
|
353 |
|
|
354 |
@Override |
|
355 |
public void useDefaultSymbol(boolean bln) { |
|
356 |
} |
|
357 |
|
|
358 |
@Override |
|
359 |
public boolean isSuitableForShapeType(int shapeType) { |
|
360 |
return GeometryUtils.isSubtype(Geometry.TYPES.POINT, shapeType); |
|
361 |
} |
|
362 |
|
|
363 |
@Override |
|
364 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
365 |
super.loadFromState(state); |
|
366 |
|
|
367 |
this.scale = state.getDouble("scale",1.0); |
|
368 |
this.size = state.getDouble("size",DEFAULT_IMAGE_SIZE); |
|
369 |
this.units = state.getInt("units",-1); |
|
370 |
this.lineToOffsetColor = (Color) state.get("lineToOffsetColor"); |
|
371 |
this.drawLineToOffset = state.getBoolean("drawLineToOffset",true); |
|
372 |
this.reverseDirectionOfAngle = state.getBoolean("reverseDirectionOfAngle",false); |
|
373 |
this.classifyingFieldName = state.getString("classifyingFieldName"); |
|
374 |
|
|
375 |
this.offsetXFieldName = state.getString("offsetXFieldName"); |
|
376 |
this.offsetYFieldName = state.getString("offsetYFieldName"); |
|
377 |
this.rotationFieldName = state.getString("rotationFieldName"); |
|
378 |
this.lineToOffsetColorFieldlName = state.getString("lineToOffsetColorFieldlName"); |
|
379 |
|
|
380 |
this.imagesTableName = state.getString("imagesTableName"); |
|
381 |
this.imagesTableClassifyingFieldName = state.getString("imagesTableClassifyingFieldName"); |
|
382 |
this.imageFieldName = state.getString("imageFieldName"); |
|
383 |
this.imageSelectedFieldName = state.getString("imageSelectedFieldName"); |
|
384 |
|
|
385 |
setZSort(new MyZSort()); |
|
386 |
|
|
387 |
|
|
388 |
} |
|
389 |
|
|
390 |
@Override |
|
391 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
392 |
super.saveToState(state); |
|
393 |
|
|
394 |
state.set("scale", this.scale); |
|
395 |
state.set("size", this.size); |
|
396 |
state.set("units", this.units); |
|
397 |
state.set("lineToOffsetColor", this.lineToOffsetColor); |
|
398 |
state.set("drawLineToOffset", this.drawLineToOffset); |
|
399 |
state.set("reverseDirectionOfAngle", this.reverseDirectionOfAngle); |
|
400 |
state.set("classifyingFieldName", this.classifyingFieldName); |
|
401 |
|
|
402 |
state.set("offsetXFieldName", this.offsetXFieldName); |
|
403 |
state.set("offsetYFieldName", this.offsetYFieldName); |
|
404 |
state.set("rotationFieldName", this.rotationFieldName); |
|
405 |
state.set("lineToOffsetColorFieldlName", this.lineToOffsetColorFieldlName); |
|
406 |
|
|
407 |
state.set("imagesTableName", this.imagesTableName); |
|
408 |
state.set("imagesTableClassifyingFieldName", this.imagesTableClassifyingFieldName); |
|
409 |
state.set("imageFieldName", this.imageFieldName); |
|
410 |
state.set("imageSelectedFieldName", this.imageSelectedFieldName); |
|
411 |
|
|
412 |
} |
|
413 |
|
|
414 |
@Override |
|
415 |
protected String[] getRequiredFeatureAttributeNames(FeatureStore fs) throws DataException { |
|
416 |
List<String> attributes = new ArrayList<>(); |
|
417 |
if( StringUtils.isNotBlank(this.classifyingFieldName)) { |
|
418 |
attributes.add(this.classifyingFieldName); |
|
419 |
} |
|
420 |
if( StringUtils.isNotBlank(this.offsetXFieldName)) { |
|
421 |
attributes.add(this.offsetXFieldName); |
|
422 |
} |
|
423 |
if( StringUtils.isNotBlank(this.offsetYFieldName)) { |
|
424 |
attributes.add(this.offsetYFieldName); |
|
425 |
} |
|
426 |
if( StringUtils.isNotBlank(this.rotationFieldName)) { |
|
427 |
attributes.add(this.rotationFieldName); |
|
428 |
} |
|
429 |
if( StringUtils.isNotBlank(this.lineToOffsetColorFieldlName)) { |
|
430 |
attributes.add(this.lineToOffsetColorFieldlName); |
|
431 |
} |
|
432 |
attributes.add( fs.getDefaultFeatureType().getDefaultGeometryAttributeName() ); |
|
433 |
return attributes.toArray(new String[attributes.size()]); |
|
434 |
} |
|
435 |
|
|
436 |
@Override |
|
437 |
public Color getDefaultLineToOffsetColor() { |
|
438 |
return this.lineToOffsetColor; |
|
439 |
} |
|
440 |
|
|
441 |
@Override |
|
442 |
public void setDefaultLineToOffsetColor(Color color) { |
|
443 |
this.lineToOffsetColor = color; |
|
444 |
} |
|
445 |
|
|
446 |
@Override |
|
447 |
public boolean isDrawLineToOffset() { |
|
448 |
return this.drawLineToOffset; |
|
449 |
} |
|
450 |
|
|
451 |
@Override |
|
452 |
public void setDrawLineToOffset(boolean drawLineToOffset) { |
|
453 |
this.drawLineToOffset = drawLineToOffset; |
|
454 |
} |
|
455 |
|
|
456 |
@Override |
|
457 |
public double getImageSize() { |
|
458 |
return this.size; |
|
459 |
} |
|
460 |
|
|
461 |
@Override |
|
462 |
public void setImageSize(double size) { |
|
463 |
this.size = size; |
|
464 |
} |
|
465 |
|
|
466 |
@Override |
|
467 |
public String getLineToOffsetColorFieldName() { |
|
468 |
return this.lineToOffsetColorFieldlName; |
|
469 |
} |
|
470 |
|
|
471 |
@Override |
|
472 |
public void setLineToOffsetColorFieldName(String fieldName) { |
|
473 |
this.lineToOffsetColorFieldlName = fieldName; |
|
474 |
} |
|
475 |
|
|
476 |
@Override |
|
477 |
public String getOffsetXFieldName() { |
|
478 |
return this.offsetXFieldName; |
|
479 |
} |
|
480 |
|
|
481 |
@Override |
|
482 |
public void setOffsetXFieldName(String fieldName) { |
|
483 |
this.offsetXFieldName = fieldName; |
|
484 |
} |
|
485 |
|
|
486 |
@Override |
|
487 |
public String getOffsetYFieldName() { |
|
488 |
return this.offsetYFieldName; |
|
489 |
} |
|
490 |
|
|
491 |
@Override |
|
492 |
public void setOffsetYFieldName(String fieldName) { |
|
493 |
this.offsetYFieldName = fieldName; |
|
494 |
} |
|
495 |
|
|
496 |
@Override |
|
497 |
public String getRotationFieldName() { |
|
498 |
return this.rotationFieldName; |
|
499 |
} |
|
500 |
|
|
501 |
@Override |
|
502 |
public void setRotationFieldName(String fieldName) { |
|
503 |
this.rotationFieldName = fieldName; |
|
504 |
} |
|
505 |
|
|
506 |
@Override |
|
507 |
public String getImagesTableName() { |
|
508 |
return imagesTableName; |
|
509 |
} |
|
510 |
|
|
511 |
@Override |
|
512 |
public void setImagesTableName(String imagesTableName) { |
|
513 |
this.imagesTableName = imagesTableName; |
|
514 |
this.imagesCache.clear(); |
|
515 |
} |
|
516 |
|
|
517 |
@Override |
|
518 |
public String getImageFieldName() { |
|
519 |
return imageFieldName; |
|
520 |
} |
|
521 |
|
|
522 |
@Override |
|
523 |
public void setImageFieldName(String imageFieldName) { |
|
524 |
this.imageFieldName = imageFieldName; |
|
525 |
this.imagesCache.clear(); |
|
526 |
} |
|
527 |
|
|
528 |
@Override |
|
529 |
public String getClassifyingFieldName() { |
|
530 |
return classifyingFieldName; |
|
531 |
} |
|
532 |
|
|
533 |
@Override |
|
534 |
public void setClassifyingFieldName(String classifyingFieldName) { |
|
535 |
this.classifyingFieldName = classifyingFieldName; |
|
536 |
this.imagesCache.clear(); |
|
537 |
} |
|
538 |
|
|
539 |
@Override |
|
540 |
public String getImageSelectedFieldName() { |
|
541 |
return imageSelectedFieldName; |
|
542 |
} |
|
543 |
|
|
544 |
@Override |
|
545 |
public void setImageSelectedFieldName(String imageSelectedFieldName) { |
|
546 |
this.imageSelectedFieldName = imageSelectedFieldName; |
|
547 |
this.imagesCache.clear(); |
|
548 |
} |
|
549 |
|
|
550 |
@Override |
|
551 |
public String getImagesTableClassifyingFieldName() { |
|
552 |
return imagesTableClassifyingFieldName; |
|
553 |
} |
|
554 |
|
|
555 |
@Override |
|
556 |
public void setImagesTableClassifyingFieldName(String imagesTableClassifyingFieldName) { |
|
557 |
this.imagesTableClassifyingFieldName = imagesTableClassifyingFieldName; |
|
558 |
this.imagesCache.clear(); |
|
559 |
} |
|
560 |
|
|
561 |
@Override |
|
562 |
public String[] getDescriptions() { |
|
563 |
return new String[] { this.imagesTableName + ", "+ this.classifyingFieldName}; |
|
564 |
} |
|
565 |
|
|
566 |
@Override |
|
567 |
public ISymbol[] getSymbols() { |
|
568 |
return new ISymbol[] { this.defaultSymbol }; |
|
569 |
} |
|
570 |
|
|
571 |
@Override |
|
572 |
public Object[] getValues() { |
|
573 |
return new Object[] { "" } ; |
|
574 |
} |
|
575 |
|
|
576 |
@Override |
|
577 |
public int getUnits() { |
|
578 |
return units; |
|
579 |
} |
|
580 |
|
|
581 |
@Override |
|
582 |
public void setUnits(int units) { |
|
583 |
this.units = units; |
|
584 |
} |
|
585 |
|
|
586 |
@Override |
|
587 |
public double getScale() { |
|
588 |
return scale; |
|
589 |
} |
|
590 |
|
|
591 |
@Override |
|
592 |
public void setScale(double scale) { |
|
593 |
this.scale = scale; |
|
594 |
} |
|
595 |
|
|
596 |
|
|
597 |
@Override |
|
598 |
public void setReverseDirectionOfAngle(boolean reverse) { |
|
599 |
this.reverseDirectionOfAngle = reverse; |
|
600 |
} |
|
601 |
|
|
602 |
@Override |
|
603 |
public boolean isReverseDirectionOfAngle() { |
|
604 |
return this.reverseDirectionOfAngle; |
|
605 |
} |
|
606 |
|
|
607 |
} |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.impl/src/main/java/org/gvsig/legend/picturemarkersymboltable/lib/impl/PictureMarkerSymbolTableLibraryImpl.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright ? 2007-2015 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 2 |
|
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 |
|
|
25 |
package org.gvsig.legend.picturemarkersymboltable.lib.impl; |
|
26 |
|
|
27 |
import java.io.InputStream; |
|
28 |
import java.util.Map; |
|
29 |
import org.gvsig.fmap.mapcontext.MapContextLibrary; |
|
30 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
31 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
32 |
import org.gvsig.legend.picturemarkersymboltable.lib.api.PictureMarkerSymbolTableLibrary; |
|
33 |
import org.gvsig.legend.picturemarkersymboltable.lib.api.PictureMarkerSymbolTableLocator; |
|
34 |
import org.gvsig.symbology.impl.SymbologyDefaultImplLibrary; |
|
35 |
import org.gvsig.tools.ToolsLocator; |
|
36 |
import org.gvsig.tools.dynobject.DynStruct; |
|
37 |
import org.gvsig.tools.library.AbstractLibrary; |
|
38 |
import org.gvsig.tools.library.LibraryException; |
|
39 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
40 |
|
|
41 |
public class PictureMarkerSymbolTableLibraryImpl extends AbstractLibrary { |
|
42 |
|
|
43 |
@Override |
|
44 |
public void doRegistration() { |
|
45 |
registerAsImplementationOf(PictureMarkerSymbolTableLibrary.class); |
|
46 |
this.require(MapContextLibrary.class); |
|
47 |
this.require(SymbologyDefaultImplLibrary.class); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
protected void doInitialize() throws LibraryException { |
|
52 |
PictureMarkerSymbolTableLocator.registerPictureMarkerSymbolTableManager(DefaultPictureMarkerSymbolTableManager.class); |
|
53 |
MapContextManager mapContextManager = MapContextLocator.getMapContextManager(); |
|
54 |
mapContextManager.registerLegend("PictureMarkerSymbolTableLegend", DefaultPictureMarkerSymbolTableLegend.class); |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
protected void doPostInitialize() throws LibraryException { |
|
59 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
|
60 |
InputStream is = this.getClass().getResourceAsStream("PictureMarkerSymbolTablePersistence.xml"); |
|
61 |
Map<String,DynStruct> definitions; |
|
62 |
try { |
|
63 |
definitions = ToolsLocator.getDynObjectManager().importDynClassDefinitions(is, this.getClass().getClassLoader()); |
|
64 |
} catch (Exception ex) { |
|
65 |
throw new LibraryException(this.getClass(), ex); |
|
66 |
} |
|
67 |
|
|
68 |
persistenceManager.addDefinition( |
|
69 |
DefaultPictureMarkerSymbolTableLegend.class, |
|
70 |
"DefaultPictureMarkerSymbolTableLegend", |
|
71 |
definitions, |
|
72 |
null, |
|
73 |
null |
|
74 |
); |
|
75 |
} |
|
76 |
|
|
77 |
} |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.impl/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<artifactId>org.gvsig.legend.picturemarkersymboltable.lib.impl</artifactId> |
|
4 |
<name>org.gvsig.legend.picturemarkersymboltable.lib.impl</name> |
|
5 |
<parent> |
|
6 |
<groupId>org.gvsig</groupId> |
|
7 |
<artifactId>org.gvsig.legend.picturemarkersymboltable.lib</artifactId> |
|
8 |
<version>1.0.57</version> |
|
9 |
</parent> |
|
10 |
<groupId>org.gvsig</groupId> |
|
11 |
<dependencies> |
|
12 |
<dependency> |
|
13 |
<groupId>org.gvsig</groupId> |
|
14 |
<artifactId>org.gvsig.legend.picturemarkersymboltable.lib.api</artifactId> |
|
15 |
<scope>compile</scope> |
|
16 |
</dependency> |
|
17 |
<dependency> |
|
18 |
<groupId>org.gvsig</groupId> |
|
19 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
20 |
<scope>compile</scope> |
|
21 |
</dependency> |
|
22 |
<dependency> |
|
23 |
<groupId>org.gvsig</groupId> |
|
24 |
<artifactId>org.gvsig.symbology.lib.impl</artifactId> |
|
25 |
<scope>compile</scope> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.gvsig</groupId> |
|
29 |
<artifactId>org.gvsig.ui</artifactId> |
|
30 |
<scope>compile</scope> |
|
31 |
</dependency> |
|
32 |
|
|
33 |
<dependency> |
|
34 |
<groupId>org.gvsig</groupId> |
|
35 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
36 |
<scope>test</scope> |
|
37 |
</dependency> |
|
38 |
<dependency> |
|
39 |
<groupId>org.gvsig</groupId> |
|
40 |
<!-- |
|
41 |
<artifactId>${org.gvsig.h2spatial.provider}</artifactId> |
|
42 |
--> |
|
43 |
<artifactId>org.gvsig.h2spatial.h2gis132.provider</artifactId> |
|
44 |
|
|
45 |
<scope>test</scope> |
|
46 |
</dependency> |
|
47 |
<dependency> |
|
48 |
<groupId>org.gvsig</groupId> |
|
49 |
<artifactId>${org.gvsig.fmap.geometry.impl}</artifactId> |
|
50 |
<scope>test</scope> |
|
51 |
</dependency> |
|
52 |
<dependency> |
|
53 |
<groupId>org.gvsig</groupId> |
|
54 |
<artifactId>org.gvsig.expressionevaluator.lib.impl</artifactId> |
|
55 |
<scope>test</scope> |
|
56 |
</dependency> |
|
57 |
<dependency> |
|
58 |
<groupId>org.gvsig</groupId> |
|
59 |
<artifactId>org.gvsig.expressionevaluator.geometry.lib.impl</artifactId> |
|
60 |
<scope>test</scope> |
|
61 |
</dependency> |
|
62 |
<dependency> |
|
63 |
<groupId>org.gvsig</groupId> |
|
64 |
<artifactId>${org.gvsig.proj.lib.impl}</artifactId> |
|
65 |
<scope>test</scope> |
|
66 |
</dependency> |
|
67 |
<dependency> |
|
68 |
<groupId>org.gvsig</groupId> |
|
69 |
<artifactId>org.gvsig.compat.se</artifactId> |
|
70 |
<scope>test</scope> |
|
71 |
</dependency> |
|
72 |
<dependency> |
|
73 |
<groupId>org.gvsig</groupId> |
|
74 |
<artifactId>org.gvsig.metadata.lib.basic.impl</artifactId> |
|
75 |
<scope>test</scope> |
|
76 |
</dependency> |
|
77 |
<dependency> |
|
78 |
<groupId>org.gvsig</groupId> |
|
79 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId> |
|
80 |
<scope>test</scope> |
|
81 |
</dependency> |
|
82 |
<dependency> |
|
83 |
<groupId>org.gvsig</groupId> |
|
84 |
<artifactId>org.gvsig.fmap.dal.file.csv</artifactId> |
|
85 |
<scope>test</scope> |
|
86 |
</dependency> |
|
87 |
<dependency> |
|
88 |
<groupId>org.gvsig</groupId> |
|
89 |
<artifactId>org.gvsig.tools.util.impl</artifactId> |
|
90 |
<scope>test</scope> |
|
91 |
</dependency> |
|
92 |
<dependency> |
|
93 |
<groupId>org.gvsig</groupId> |
|
94 |
<artifactId>org.gvsig.tools.swing.impl</artifactId> |
|
95 |
<scope>test</scope> |
|
96 |
</dependency> |
|
97 |
<dependency> |
|
98 |
<groupId>org.gvsig</groupId> |
|
99 |
<artifactId>org.gvsig.fmap.dal.db.jdbc</artifactId> |
|
100 |
<scope>compile</scope> |
|
101 |
</dependency> |
|
102 |
</dependencies> |
|
103 |
</project> |
|
0 | 104 |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.api/src/main/java/org/gvsig/legend/picturemarkersymboltable/lib/api/PictureMarkerSymbolTableManager.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2015 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 3 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.legend.picturemarkersymboltable.lib.api; |
|
24 |
|
|
25 |
|
|
26 |
public interface PictureMarkerSymbolTableManager { |
|
27 |
|
|
28 |
public PictureMarkerSymbolTableLegend createPictureMarkerSymbolTableLegend(); |
|
29 |
|
|
30 |
public Class<? extends PictureMarkerSymbolTableLegend> getPictureMarkerSymbolTableLegendClass(); |
|
31 |
|
|
32 |
} |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.api/src/main/java/org/gvsig/legend/picturemarkersymboltable/lib/api/PictureMarkerSymbolTableLegend.java | ||
---|---|---|
1 |
package org.gvsig.legend.picturemarkersymboltable.lib.api; |
|
2 |
|
|
3 |
import java.awt.Color; |
|
4 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend; |
|
5 |
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend; |
|
6 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
7 |
|
|
8 |
public interface PictureMarkerSymbolTableLegend |
|
9 |
extends IVectorLegend, IClassifiedLegend |
|
10 |
{ |
|
11 |
|
|
12 |
public static final int DEFAULT_IMAGE_SIZE = 15; |
|
13 |
|
|
14 |
public double getImageSize(); |
|
15 |
|
|
16 |
public int getUnits(); |
|
17 |
|
|
18 |
public boolean isDrawLineToOffset(); |
|
19 |
|
|
20 |
public Color getDefaultLineToOffsetColor(); |
|
21 |
|
|
22 |
|
|
23 |
public String getClassifyingFieldName(); |
|
24 |
|
|
25 |
public String getOffsetXFieldName(); |
|
26 |
|
|
27 |
public String getOffsetYFieldName(); |
|
28 |
|
|
29 |
public String getRotationFieldName(); |
|
30 |
|
|
31 |
public String getLineToOffsetColorFieldName(); |
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
public String getImagesTableName(); |
|
36 |
|
|
37 |
public String getImageFieldName(); |
|
38 |
|
|
39 |
public String getImageSelectedFieldName(); |
|
40 |
|
|
41 |
public String getImagesTableClassifyingFieldName(); |
|
42 |
|
|
43 |
public double getScale(); |
|
44 |
|
|
45 |
|
|
46 |
public void setImageSize(double size); |
|
47 |
|
|
48 |
public void setUnits(int unit); |
|
49 |
|
|
50 |
public void setDefaultLineToOffsetColor(Color color); |
|
51 |
|
|
52 |
public void setDrawLineToOffset(boolean drawLineToOffset); |
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
public void setLineToOffsetColorFieldName(String fieldName); |
|
57 |
|
|
58 |
public void setOffsetXFieldName(String fieldName); |
|
59 |
|
|
60 |
public void setOffsetYFieldName(String fieldName); |
|
61 |
|
|
62 |
public void setRotationFieldName(String fieldName); |
|
63 |
|
|
64 |
public void setClassifyingFieldName(String classifyingFieldName); |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
public void setImagesTableName(String imagesTableName); |
|
69 |
|
|
70 |
public void setImageFieldName(String imageFieldName); |
|
71 |
|
|
72 |
public void setImageSelectedFieldName(String imageSelectedFieldName); |
|
73 |
|
|
74 |
public void setImagesTableClassifyingFieldName(String imagesTableClassifyingFieldName); |
|
75 |
|
|
76 |
public void setScale(double scale); |
|
77 |
|
|
78 |
public void setReverseDirectionOfAngle(boolean reverse); |
|
79 |
|
|
80 |
public boolean isReverseDirectionOfAngle(); |
|
81 |
} |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.api/src/main/java/org/gvsig/legend/picturemarkersymboltable/lib/api/PictureMarkerSymbolTableLocator.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2015 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.legend.picturemarkersymboltable.lib.api; |
|
24 |
|
|
25 |
import org.gvsig.tools.locator.AbstractLocator; |
|
26 |
import org.gvsig.tools.locator.Locator; |
|
27 |
import org.gvsig.tools.locator.LocatorException; |
|
28 |
|
|
29 |
|
|
30 |
public class PictureMarkerSymbolTableLocator extends AbstractLocator { |
|
31 |
|
|
32 |
/** |
|
33 |
* HeatmapLegend locator name |
|
34 |
*/ |
|
35 |
private static final String LOCATOR_NAME = "PictureMarkerSymbolTableLocator"; |
|
36 |
|
|
37 |
/** |
|
38 |
* HeatmapLegend manager name |
|
39 |
*/ |
|
40 |
public static final String MANAGER_NAME = "PictureMarkerSymbolTableManager"; |
|
41 |
|
|
42 |
/** |
|
43 |
* HeatmapLegend manager description |
|
44 |
*/ |
|
45 |
private static final String MANAGER_DESCRIPTION = |
|
46 |
"PictureMarkerSymbolTable Manager of gvSIG"; |
|
47 |
|
|
48 |
|
|
49 |
/** |
|
50 |
* Unique instance |
|
51 |
*/ |
|
52 |
private static final PictureMarkerSymbolTableLocator instance = new PictureMarkerSymbolTableLocator(); |
|
53 |
|
|
54 |
@Override |
|
55 |
public String getLocatorName() { |
|
56 |
return LOCATOR_NAME; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Registers the Class implementing the UrbanHorizontalSignageManager interface. |
|
61 |
* |
|
62 |
* @param clazz |
|
63 |
* implementing the UrbanHorizontalSignageManager interface |
|
64 |
*/ |
|
65 |
public static void registerPictureMarkerSymbolTableManager(Class clazz){ |
|
66 |
getInstance().register(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
67 |
} |
|
68 |
|
|
69 |
public static void registerDefaultPictureMarkerSymbolTableManager(Class clazz){ |
|
70 |
getInstance().registerDefault(MANAGER_NAME, MANAGER_DESCRIPTION, clazz); |
|
71 |
} |
|
72 |
|
|
73 |
public static PictureMarkerSymbolTableManager getPictureMarkerSymbolTableManager() throws LocatorException { |
|
74 |
return (PictureMarkerSymbolTableManager) getInstance().get(MANAGER_NAME); |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* @return |
|
79 |
*/ |
|
80 |
public static Locator getInstance() { |
|
81 |
return instance; |
|
82 |
} |
|
83 |
|
|
84 |
} |
org.gvsig.legend.picturemarkersymboltable/tags/org.gvsig.legend.picturemarkersymboltable-1.0.57/org.gvsig.legend.picturemarkersymboltable.lib/org.gvsig.legend.picturemarkersymboltable.lib.api/src/main/java/org/gvsig/legend/picturemarkersymboltable/lib/api/PictureMarkerSymbolTableLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2015 gvSIG Association |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
Also available in: Unified diff