svn-gvsig-desktop / tags / v1_0_2_Build_896 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / SLDUtils.java @ 10391
History | View | Annotate | Download (2.48 KB)
1 | 4111 | ldiaz | package com.iver.cit.gvsig.fmap.core; |
---|---|---|---|
2 | |||
3 | import org.geotools.styling.Fill; |
||
4 | import org.geotools.styling.GraphicImpl; |
||
5 | import org.geotools.styling.LineSymbolizer; |
||
6 | import org.geotools.styling.Mark; |
||
7 | import org.geotools.styling.PointSymbolizer; |
||
8 | import org.geotools.styling.PolygonSymbolizer; |
||
9 | import org.geotools.styling.StrokeImpl; |
||
10 | import org.geotools.styling.StyleBuilder; |
||
11 | import org.geotools.styling.StyleFactory; |
||
12 | import org.geotools.styling.Symbolizer; |
||
13 | |||
14 | import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
||
15 | import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
||
16 | |||
17 | 4130 | ldiaz | /**
|
18 | * utility class for SLD functionality
|
||
19 | * @author laura
|
||
20 | */
|
||
21 | 4111 | ldiaz | public class SLDUtils { |
22 | |||
23 | public static String convertColorToHexString(java.awt.Color c) |
||
24 | { |
||
25 | String str = Integer.toHexString( c.getRGB() & 0xFFFFFF ); |
||
26 | return ( "#" + "000000".substring( str.length() ) + str.toUpperCase() ); |
||
27 | } |
||
28 | public String getWellKnownName(int symbolType) |
||
29 | { |
||
30 | return ""; |
||
31 | } |
||
32 | |||
33 | 8765 | jjdelcerro | public static Symbolizer toGeotoolsSymbol(ISymbol sym) |
34 | 4111 | ldiaz | { |
35 | 8765 | jjdelcerro | FSymbol symbol = (FSymbol) sym; |
36 | 4111 | ldiaz | StyleFactory styleFactory = StyleFactory.createStyleFactory(); |
37 | StyleBuilder styleBuilder = new StyleBuilder();
|
||
38 | StrokeImpl theStroke = (StrokeImpl)styleBuilder.createStroke(); |
||
39 | GraphicImpl graphic = (GraphicImpl)styleBuilder.createGraphic(); |
||
40 | try
|
||
41 | { |
||
42 | switch (symbol.getSymbolType())
|
||
43 | { |
||
44 | case FConstant.SYMBOL_TYPE_POINT:
|
||
45 | PointSymbolizer point = styleFactory.createPointSymbolizer(); |
||
46 | graphic.setSize(symbol.getSize()); |
||
47 | Mark[] mark = new Mark[1]; |
||
48 | mark[0] = styleFactory.createMark();
|
||
49 | //
|
||
50 | //mark[0].setWellKnownName( getWellKnownName(symbol.getStyle()));
|
||
51 | graphic.setMarks(mark); |
||
52 | |||
53 | // add, color, graphic, size, ...
|
||
54 | return point;
|
||
55 | case FConstant.SYMBOL_TYPE_LINE:
|
||
56 | LineSymbolizer line = styleFactory.createLineSymbolizer(); |
||
57 | theStroke.setColor(convertColorToHexString(symbol.getColor())); |
||
58 | line.setStroke(theStroke); |
||
59 | return line;
|
||
60 | case FConstant.SYMBOL_TYPE_FILL:
|
||
61 | PolygonSymbolizer polygon = styleFactory.createPolygonSymbolizer(); |
||
62 | Fill theFill = styleBuilder.createFill(symbol.getColor()); |
||
63 | //theFill.setOpacity();
|
||
64 | polygon.setFill( theFill ); |
||
65 | //theStroke.setColor(symbol.getOutlineColor());
|
||
66 | return polygon;
|
||
67 | case FShape.MULTI:
|
||
68 | // To implement: ver que clase de simbolo corresponde
|
||
69 | return null; |
||
70 | } |
||
71 | return null; |
||
72 | } |
||
73 | catch(Exception e) |
||
74 | { |
||
75 | e.printStackTrace(); |
||
76 | return null; |
||
77 | } |
||
78 | } |
||
79 | } |