Revision 458 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/LegendFactory.java

View differences:

LegendFactory.java
8 8
import org.geotools.renderer.style.LineStyle2D;
9 9
import org.geotools.renderer.style.MarkStyle2D;
10 10
import org.geotools.renderer.style.PolygonStyle2D;
11
import org.geotools.renderer.style.Style2D;
12 11

  
12
import com.iver.cit.gvsig.fmap.core.FShape;
13
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
14
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
13 15
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D;
14 16
import com.iver.utiles.XMLEntity;
15 17

  
......
20 22
 * @author Fernando Gonz?lez Cort?s
21 23
 */
22 24
public class LegendFactory {
23
    public static FStyle2D DEFAULT_SYMBOL;
24
    private static MarkStyle2D DEFAULT_POINT_SYMBOL = new MarkStyle2D();
25
    private static LineStyle2D DEFAULT_LINE_SYMBOL = new LineStyle2D();    
26
    private static PolygonStyle2D DEFAULT_POLYGON_SYMBOL = new PolygonStyle2D();
27
    static {
28
    	
29
    	DEFAULT_POLYGON_SYMBOL = new PolygonStyle2D();
30
    	DEFAULT_POLYGON_SYMBOL.setContour(Color.DARK_GRAY);
31
    	DEFAULT_POLYGON_SYMBOL.setStroke(new BasicStroke(3));
32
    	DEFAULT_POLYGON_SYMBOL.setFill(Color.LIGHT_GRAY);
25
    public static FSymbol DEFAULT_POINT_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_POINT);
26
    public static FSymbol DEFAULT_LINE_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_LINE);;    
27
    public static FSymbol DEFAULT_POLYGON_SYMBOL = new FSymbol(FConstant.SYMBOL_TYPE_FILL);
33 28

  
34
        DEFAULT_POINT_SYMBOL = new MarkStyle2D();
35

  
36
        DEFAULT_POINT_SYMBOL.setShape(Java2DMark.getWellKnownMark(""));
37
        DEFAULT_POINT_SYMBOL.setFill(Color.RED);
38
        DEFAULT_POINT_SYMBOL.setSize(5);
39
    	
40
        DEFAULT_LINE_SYMBOL.setContour(Color.BLUE);
41
        DEFAULT_LINE_SYMBOL.setContourComposite(null);
42

  
43
        BasicStroke stroke = new BasicStroke(1);
44
        DEFAULT_LINE_SYMBOL.setStroke(stroke);
45

  
46
        /*
47
         * TODO Falta definir los Style2D's de punto, de pol?gono 
48
         * y de texto por defecto
49
         */ 
50
        
51
        DEFAULT_SYMBOL = new FStyle2D();
52
        DEFAULT_SYMBOL.setPointStyle2D(DEFAULT_POINT_SYMBOL);
53
        DEFAULT_SYMBOL.setLineStyle2D(DEFAULT_LINE_SYMBOL);
54
        DEFAULT_SYMBOL.setPolygonStyle2D(DEFAULT_POLYGON_SYMBOL);
55
    }
56

  
57 29
    // TODO Descomentar esto cuando se tenga la interfaz de datos
58 30

  
59 31
    /*
......
72 44
     * Crea un objeto renderer de s?mbolo ?nico con las caracter?sticas que se
73 45
     * pasan como par?metro
74 46
     *
75
     * @param pointStyle DOCUMENT ME!
76
     * @param lineStyle DOCUMENT ME!
77
     * @param polygonStyle DOCUMENT ME!
78
     * @param textStyle DOCUMENT ME!
79
     *
80 47
     * @return DOCUMENT ME!
81 48
     */
82
    public static VectorialLegend createUniqueSymbolLegend(Style2D pointStyle,
83
        LineStyle2D lineStyle, PolygonStyle2D polygonStyle, Style2D textStyle) {
84
        FStyle2D style = new FStyle2D();
85

  
86
        if (pointStyle != null) {
87
            style.setPointStyle2D(pointStyle);
88
        }
89

  
90
        if (lineStyle != null) {
91
            style.setLineStyle2D(lineStyle);
92
        }
93

  
94
        if (polygonStyle != null) {
95
            style.setPolygonStyle2D(polygonStyle);
96
        }
97

  
98
        if (textStyle != null) {
99
            style.setTextStyle2D(textStyle);
100
        }
101

  
102
        return new SingleSymbolLegend(style);
49
    public static VectorialLegend createSingleSymbolLegend(int shapeType) {
50
    	switch (shapeType)
51
		{
52
    		case FShape.POINT:
53
    			return new SingleSymbolLegend(new FSymbol(FConstant.SYMBOL_TYPE_POINT));
54
    		case FShape.LINE:
55
    			return new SingleSymbolLegend(new FSymbol(FConstant.SYMBOL_TYPE_LINE));
56
    		case FShape.POLYGON:
57
    			return new SingleSymbolLegend(new FSymbol(FConstant.SYMBOL_TYPE_FILL));
58
    		
59
		}
60
    	return null;
61
        
103 62
    }
104 63

  
105 64
    /**
106
     * Crea un objeto renderer de s?mbolo ?nico con las caracter?sticas que se
107
     * pasan como par?metro
108
     *
109
     * @return DOCUMENT ME!
110
     */
111
    public static VectorialLegend createSingleSymbolLegend() {
112
        return new SingleSymbolLegend(DEFAULT_SYMBOL);
113
    }
114

  
115
    /**
116 65
     * Obtiene un objeto con las propiedades del renderer. Este m?todo se
117 66
     * invocar? con el fin de guardar el s?mbolo en disco.
118 67
     *

Also available in: Unified diff