Revision 44249 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/DefaultDynamicVectorLegend.java

View differences:

DefaultDynamicVectorLegend.java
5 5
 */
6 6
package org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend;
7 7

  
8
import java.util.ArrayList;
9
import java.util.List;
10
import java.util.logging.Level;
11
import org.gvsig.expressionevaluator.Expression;
12
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator;
8 13
import org.gvsig.fmap.dal.exception.DataException;
9 14
import org.gvsig.fmap.dal.feature.Feature;
10 15
import org.gvsig.fmap.dal.feature.FeatureStore;
11 16
import org.gvsig.fmap.geom.Geometry;
12
import org.gvsig.fmap.geom.type.GeometryType;
13
import org.gvsig.fmap.mapcontext.MapContextException;
17
import org.gvsig.fmap.geom.GeometryLocator;
18
import org.gvsig.fmap.geom.primitive.Point;
14 19
import org.gvsig.fmap.mapcontext.MapContextLocator;
15 20
import org.gvsig.fmap.mapcontext.MapContextManager;
16
import org.gvsig.fmap.mapcontext.rendering.legend.ISingleSymbolLegend;
17
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent;
18 21
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol;
19
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolManager;
20 22
import org.gvsig.symbology.SymbologyLocator;
21 23
import org.gvsig.symbology.SymbologyManager;
22 24
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.AbstractVectorialLegend;
......
44 46
    public static final String LEGEND_NAME = "DynamicSymbol";
45 47
    private ISymbol defaultSymbol;
46 48
    private int shapeType = Geometry.TYPES.SURFACE; // Por defecto, tipo pol?gono
49
    public static final String FIELD_OUTLINECOLOR = "COUTLINE";
50
    public static final String FIELD_FILLCOLOR = "CFILL";
51
    public static final String FIELD_SIZE = "CSIZE";
52
    public static final String FIELD_ROTATION = "CROTATION";
47 53

  
48 54
    /**
49 55
     * Constructor method, needed by persistence.
50 56
     */
51 57
    public DefaultDynamicVectorLegend() {
52
       
58

  
53 59
    }
54 60

  
55 61
    /**
......
58 64
     * @param style S?mbolo.
59 65
     */
60 66
    public DefaultDynamicVectorLegend(ISymbol style) {
61
        
67

  
62 68
        setDefaultSymbol(style);
63 69
    }
64 70

  
......
100 106
        }
101 107
    }
102 108

  
109
    private Expression getExpressionFromString(String value) {
110
        Expression expression = ExpressionEvaluatorLocator.getManager().createExpression();
111
        expression.setPhrase(value);
112
        return expression;
113
    }
114

  
103 115
    @Override
104 116
    public ISymbol getSymbolByFeature(Feature feat) {
105 117
        DynamicSymbol symbol = (DynamicSymbol) getDefaultSymbol();
118

  
119
        String fillcolor = feat.get(FIELD_FILLCOLOR).toString();
120
        Expression expFill = getExpressionFromString(fillcolor);
121
        symbol.setFillColor(expFill);
122

  
123
        String outlinecolor = feat.get(FIELD_OUTLINECOLOR).toString();
124
        Expression expOutlinecolor = getExpressionFromString(outlinecolor);
125
        symbol.setOutlineColor(expOutlinecolor);
126

  
127
        String size = feat.get(FIELD_SIZE).toString();
128
        Expression expSize = getExpressionFromString(size);
129
        symbol.setSize(expSize);
130
        
131
        String rotation = feat.get(FIELD_ROTATION).toString();
132
        Expression expRotation = getExpressionFromString(rotation);
133
        symbol.setRotation(expRotation);
134
        
135
        //OFFSET TODO
136
        Point pointOffset = null;
137
        String value = "";
138
        try {
139
            pointOffset = GeometryLocator.getGeometryManager().createPoint(0, 0, Geometry.SUBTYPES.GEOM2D);
140
            value = pointOffset.convertToWKT();
141
        } catch (Exception ex) {
142
            java.util.logging.Logger.getLogger(DefaultDynamicSymbol.class.getName()).log(Level.SEVERE, null, ex);
143
        }
144

  
145
        Expression offset = getExpressionFromString(value);
146
        symbol.setOffset(offset);
147

  
148

  
149

  
150
        List<String> requiredAttributes = new ArrayList<>();
151
        requiredAttributes.add(FIELD_OUTLINECOLOR);
152
        requiredAttributes.add(FIELD_FILLCOLOR);
153
        requiredAttributes.add(FIELD_ROTATION);
154
        requiredAttributes.add(FIELD_SIZE);
155
        symbol.setRequiredFeatureAttributesNames(requiredAttributes);
156

  
106 157
        symbol.setFeature(feat);
107 158
        return symbol;
108

  
109 159
    }
110 160

  
111 161
    @Override
112 162
    public void useDefaultSymbol(boolean b) {
113
        LOG.warn("TODO: SingleSymbolLegend.useDefaultSymbol");
163
        LOG.warn("TODO: DefaultDynamicVectorLegend.useDefaultSymbol");
114 164
    }
115 165

  
116 166
    public String[] getUsedFields() {
......
133 183
    }
134 184

  
135 185
    public void setFeatureStore(FeatureStore fs) throws DataException {
136
        LOG.warn("TODO: SingleSymbolLegend.useDefaultSymbol");
186
        LOG.warn("TODO: DefaultDynamicVectorLegend.useDefaultSymbol");
137 187
    }
138 188

  
139 189
    @Override
......
151 201
//        if (defaultSymbol != null) {
152 202
//            clone.defaultSymbol = (ISymbol) defaultSymbol.clone();
153 203
//        }
154

  
155 204
        return clone;
156 205
    }
157 206

  

Also available in: Unified diff