Revision 44257
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.symbology/org.gvsig.symbology.lib/org.gvsig.symbology.lib.api/src/main/java/org/gvsig/symbology/fmap/mapcontext/rendering/dynamiclegend/DynamicLabelingStrategy.java | ||
---|---|---|
50 | 50 |
|
51 | 51 |
public abstract void setFontStyle(int style); |
52 | 52 |
|
53 |
public abstract void setFontStyleField(String field);
|
|
53 |
public abstract void setFontStyle(Expression expression);
|
|
54 | 54 |
|
55 |
public abstract void setTextField(String textFieldName);
|
|
55 |
public abstract void setText(Expression expression);
|
|
56 | 56 |
|
57 |
public abstract void setRotationField(String rotationFieldName);
|
|
57 |
public abstract void setRotation(Expression expression);
|
|
58 | 58 |
|
59 |
/** |
|
60 |
* Sets the field that contains the size of the text. The size is computed |
|
61 |
* in meters. To use any other unit, call setUnit(int) with the scale factor |
|
62 |
* from meters (for centimeters, call <b>setUnitFactor(0.01))</b>. |
|
63 |
* |
|
64 |
* @param heightFieldName |
|
65 |
*/ |
|
66 |
public abstract void setHeightField(String heightFieldName); |
|
59 |
public abstract void setHeight(Expression expression); |
|
67 | 60 |
|
68 |
public abstract void setColorField(String colorFieldName);
|
|
61 |
public abstract void setColor(Expression expression);
|
|
69 | 62 |
|
70 | 63 |
public abstract void setUsesFixedSize(boolean b); |
71 | 64 |
|
... | ... | |
95 | 88 |
|
96 | 89 |
public abstract void setFont(Font selFont); |
97 | 90 |
|
98 |
public abstract void setFontField(String fontField); |
|
91 |
public abstract void setFont(Expression expression); |
|
92 |
|
|
93 |
public abstract void setReferenceSystem(Expression expression); |
|
94 |
|
|
95 |
public abstract void setUnit(Expression expression); |
|
99 | 96 |
|
100 | 97 |
} |
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 | ||
---|---|---|
77 | 77 |
@Override |
78 | 78 |
public void setFeature(Feature feat) { |
79 | 79 |
feature = feat; |
80 |
if (featureSymbolTable == null) { |
|
81 |
getFeatureSymbolTable(); |
|
82 |
} |
|
80 | 83 |
featureSymbolTable.setFeature(feat); |
81 | 84 |
} |
82 | 85 |
|
... | ... | |
254 | 257 |
MutableSymbolTable s = ExpressionEvaluatorLocator.getManager().createSymbolTable(); |
255 | 258 |
FeatureSymbolTable fst = DALLocator.getDataManager().createFeatureSymbolTable(); |
256 | 259 |
s.addSymbolTable(fst); |
257 |
fst.setFeature(feature); |
|
260 |
if (feature != null) { |
|
261 |
fst.setFeature(feature); |
|
262 |
} |
|
258 | 263 |
symbolTable = s; |
259 | 264 |
|
260 | 265 |
} |
... | ... | |
425 | 430 |
|
426 | 431 |
} |
427 | 432 |
|
433 |
|
|
428 | 434 |
} |
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/DefaultDynamicLabelingStrategy.java | ||
---|---|---|
5 | 5 |
*/ |
6 | 6 |
package org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend; |
7 | 7 |
|
8 |
|
|
9 | 8 |
import java.awt.Color; |
10 | 9 |
import java.awt.Font; |
11 | 10 |
import java.awt.Graphics2D; |
... | ... | |
61 | 60 |
public class DefaultDynamicLabelingStrategy extends DynamicLabelingStrategy { |
62 | 61 |
|
63 | 62 |
private Feature feature; |
64 |
public String LROTATION = "LROTATION"; |
|
65 |
public String LTEXT = "LTEXT"; |
|
66 |
public String LHEIGHT = "LHEIGHT"; |
|
67 |
public String LCOLOR = "LCOLOR"; |
|
68 |
public String LFONT = "LFONT"; |
|
69 |
public String LFONTSTYLE = "LFONTS"; |
|
63 |
public String LROTATION = "LROTATION"; |
|
64 |
public String LTEXT = "LTEXT"; |
|
65 |
public String LHEIGHT = "LHEIGHT"; |
|
66 |
public String LCOLOR = "LCOLOR"; |
|
67 |
public String LFONT = "LFONT"; |
|
68 |
public String LFONTSTYLE = "LFONTS"; |
|
69 |
|
|
70 |
public static Expression expRotation = null; |
|
71 |
public static Expression expText = null; |
|
72 |
public static Expression expHeight = null; |
|
73 |
public static Expression expColor = null; |
|
74 |
public static Expression expFont = null; |
|
75 |
public static Expression expFontStyle = null; |
|
76 |
public static Expression expUnit; |
|
77 |
public static Expression expReferenceSystem; |
|
78 |
|
|
70 | 79 |
private MutableSymbolTable symbolTable = null; |
80 |
private FeatureSymbolTable featureSymbolTable = null; |
|
71 | 81 |
private FLyrVect layer; |
72 | 82 |
private List<Geometry> drawnGeometryLabels; |
73 | 83 |
private boolean printMode = false; |
... | ... | |
79 | 89 |
public SymbolTable getFeatureSymbolTable() { |
80 | 90 |
if (symbolTable == null) { |
81 | 91 |
MutableSymbolTable s = ExpressionEvaluatorLocator.getManager().createSymbolTable(); |
82 |
FeatureSymbolTable fst = DALLocator.getDataManager().createFeatureSymbolTable(); |
|
83 |
s.addSymbolTable(fst); |
|
84 |
fst.setFeature(feature); |
|
92 |
featureSymbolTable = DALLocator.getDataManager().createFeatureSymbolTable(); |
|
93 |
s.addSymbolTable(featureSymbolTable); |
|
94 |
if (feature!=null) { |
|
95 |
featureSymbolTable.setFeature(feature); |
|
96 |
} |
|
85 | 97 |
symbolTable = s; |
86 | 98 |
} |
87 | 99 |
return symbolTable; |
88 | 100 |
|
89 | 101 |
} |
90 | 102 |
|
91 |
private Expression getExpressionFromString(String value) { |
|
92 |
Expression expression = ExpressionEvaluatorLocator.getManager().createExpression(); |
|
93 |
expression.setPhrase(value); |
|
94 |
return expression; |
|
95 |
} |
|
96 |
|
|
103 |
// private Expression getExpressionFromString(String value) { |
|
104 |
// Expression expression = ExpressionEvaluatorLocator.getManager().createExpression(); |
|
105 |
// expression.setPhrase(value); |
|
106 |
// return expression; |
|
107 |
// } |
|
97 | 108 |
private Object getValueFromExpression(Expression exp) { |
98 | 109 |
if (exp == null) { |
99 | 110 |
return null; |
... | ... | |
111 | 122 |
|
112 | 123 |
@Override |
113 | 124 |
public Expression getRotation() { |
114 |
String value = feature.get(LROTATION).toString(); |
|
115 |
Expression exp = getExpressionFromString(value); |
|
116 |
return exp; |
|
125 |
return expRotation; |
|
117 | 126 |
} |
118 | 127 |
|
119 | 128 |
@Override |
... | ... | |
124 | 133 |
|
125 | 134 |
@Override |
126 | 135 |
public Expression getText() { |
127 |
if (feature == null) { |
|
128 |
return null; |
|
129 |
} |
|
130 |
String value = feature.get(LTEXT).toString(); |
|
131 |
Expression exp = getExpressionFromString(value); |
|
132 |
return exp; |
|
136 |
return expText; |
|
133 | 137 |
} |
134 | 138 |
|
135 | 139 |
@Override |
... | ... | |
140 | 144 |
|
141 | 145 |
@Override |
142 | 146 |
public Expression getHeight() { |
143 |
String value = feature.get(LHEIGHT).toString(); |
|
144 |
Expression exp = getExpressionFromString(value); |
|
145 |
return exp; |
|
147 |
return expHeight; |
|
146 | 148 |
} |
147 | 149 |
|
148 | 150 |
@Override |
... | ... | |
153 | 155 |
|
154 | 156 |
@Override |
155 | 157 |
public Expression getColor() { |
156 |
String value = feature.get(LCOLOR).toString(); |
|
157 |
Expression exp = getExpressionFromString(value); |
|
158 |
return exp; |
|
158 |
return expColor; |
|
159 | 159 |
} |
160 | 160 |
|
161 | 161 |
@Override |
... | ... | |
167 | 167 |
|
168 | 168 |
@Override |
169 | 169 |
public Expression getFixedSize() { |
170 |
String value = feature.get(LHEIGHT).toString(); |
|
171 |
Expression exp = getExpressionFromString(value); |
|
172 |
return exp; |
|
170 |
return expHeight; |
|
173 | 171 |
} |
174 | 172 |
|
175 | 173 |
@Override |
... | ... | |
185 | 183 |
} |
186 | 184 |
|
187 | 185 |
@Override |
188 |
public void setTextField(String textFieldName) {
|
|
189 |
this.LTEXT=textFieldName;
|
|
186 |
public void setText(Expression expression) {
|
|
187 |
expText = expression;
|
|
190 | 188 |
} |
191 | 189 |
|
192 | 190 |
@Override |
193 |
public void setRotationField(String rotationFieldName) {
|
|
194 |
this.LROTATION=rotationFieldName;
|
|
191 |
public void setRotation(Expression expression) {
|
|
192 |
expRotation = expression;
|
|
195 | 193 |
} |
196 | 194 |
|
197 | 195 |
@Override |
198 |
public void setHeightField(String heightFieldName) {
|
|
199 |
this.LHEIGHT=heightFieldName;
|
|
196 |
public void setHeight(Expression expression) {
|
|
197 |
expHeight = expression;
|
|
200 | 198 |
} |
201 | 199 |
|
202 | 200 |
@Override |
203 |
public void setColorField(String colorFieldName) {
|
|
204 |
this.LCOLOR=colorFieldName;
|
|
201 |
public void setColor(Expression expression) {
|
|
202 |
expColor = expression;
|
|
205 | 203 |
} |
206 | 204 |
|
207 | 205 |
@Override |
... | ... | |
231 | 229 |
|
232 | 230 |
@Override |
233 | 231 |
public Expression getFixedColor() { |
234 |
String value = feature.get(LCOLOR).toString(); |
|
235 |
Expression exp = getExpressionFromString(value); |
|
236 |
return exp; |
|
232 |
return expColor; |
|
237 | 233 |
} |
238 | 234 |
|
239 | 235 |
@Override |
... | ... | |
250 | 246 |
|
251 | 247 |
@Override |
252 | 248 |
public Expression getColorFont() { |
253 |
String value = feature.get(LCOLOR).toString(); |
|
254 |
Expression exp = getExpressionFromString(value); |
|
255 |
return exp; |
|
249 |
return expColor; |
|
256 | 250 |
} |
257 | 251 |
|
258 | 252 |
@Override |
... | ... | |
269 | 263 |
|
270 | 264 |
@Override |
271 | 265 |
public Expression getFont() { |
272 |
String value = feature.get(LFONT).toString(); |
|
273 |
Expression exp = getExpressionFromString(value); |
|
274 |
return exp; |
|
266 |
return expFont; |
|
275 | 267 |
} |
276 | 268 |
|
277 | 269 |
@Override |
... | ... | |
288 | 280 |
|
289 | 281 |
@Override |
290 | 282 |
public Expression getFontStyle() { |
291 |
String value = feature.get(LFONTSTYLE).toString(); |
|
292 |
Expression exp = getExpressionFromString(value); |
|
293 |
return exp; |
|
283 |
return expFontStyle; |
|
294 | 284 |
} |
295 | 285 |
|
296 | 286 |
@Override |
... | ... | |
300 | 290 |
} |
301 | 291 |
|
302 | 292 |
@Override |
303 |
public void setFontStyle(int selFont) {
|
|
304 |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
293 |
public void setFontStyle(Expression expression) {
|
|
294 |
expFontStyle = expression;
|
|
305 | 295 |
} |
306 | 296 |
|
307 | 297 |
public void setFeature(Feature f) { |
308 | 298 |
feature = f; |
299 |
if (featureSymbolTable==null) { |
|
300 |
getFeatureSymbolTable(); |
|
301 |
} |
|
302 |
featureSymbolTable.setFeature(f); |
|
309 | 303 |
} |
310 | 304 |
|
311 | 305 |
@Override |
... | ... | |
340 | 334 |
|
341 | 335 |
@Override |
342 | 336 |
public Expression getUnitExp() { |
343 |
String value = "-1"; |
|
344 |
Expression exp = getExpressionFromString(value); |
|
345 |
return exp; |
|
337 |
// String value = "-1"; |
|
338 |
// Expression exp = getExpressionFromString(value); |
|
339 |
// return exp; |
|
340 |
return expUnit; |
|
346 | 341 |
} |
347 | 342 |
|
348 | 343 |
public Expression getReferenceSystemExp() { |
349 |
String value = "0"; |
|
350 |
Expression exp = getExpressionFromString(value); |
|
351 |
return exp; |
|
344 |
// String value = "0";
|
|
345 |
// Expression exp = getExpressionFromString(value);
|
|
346 |
return expReferenceSystem;
|
|
352 | 347 |
} |
353 | 348 |
|
354 | 349 |
private org.gvsig.fmap.geom.primitive.Point createLabelPoint(org.gvsig.fmap.geom.Geometry geom) |
... | ... | |
458 | 453 |
SimpleTextSymbol sym = new SimpleTextSymbol(); |
459 | 454 |
sym.setFont(getComputedFont()); |
460 | 455 |
sym.setUnit(getComputedUnit()); |
461 |
sym.setReferenceSystem(getComputedReferenceSystemExp());
|
|
456 |
sym.setReferenceSystem(getComputedReferenceSystem()); |
|
462 | 457 |
if (this.usesFixedSize()) { //(useFixedSize) { |
463 | 458 |
// uses fixed size |
464 | 459 |
size = getComputedFixedSize();// * fontScaleFactor; |
... | ... | |
590 | 585 |
throw new UnsupportedOperationException("Not supported yet."); |
591 | 586 |
} |
592 | 587 |
|
588 |
public void setUnit(Expression expression) { |
|
589 |
expUnit = expression; |
|
590 |
} |
|
591 |
|
|
593 | 592 |
@Override |
594 | 593 |
public int getUnit() { |
595 | 594 |
return getComputedUnitExp(); |
... | ... | |
600 | 599 |
return value; |
601 | 600 |
} |
602 | 601 |
|
603 |
public int getComputedReferenceSystemExp() { |
|
602 |
|
|
603 |
public int getComputedReferenceSystem() { |
|
604 | 604 |
int value = (int) getValueFromExpression(getReferenceSystemExp()); |
605 | 605 |
return value; |
606 | 606 |
} |
607 |
|
|
607 |
|
|
608 | 608 |
@Override |
609 | 609 |
public int getReferenceSystem() { |
610 |
return 0;
|
|
610 |
return getComputedReferenceSystem();
|
|
611 | 611 |
} |
612 | 612 |
|
613 | 613 |
@Override |
614 | 614 |
public void setReferenceSystem(int referenceSystem) { |
615 |
this.referenceSystem = referenceSystem; |
|
615 |
// this.referenceSystem = referenceSystem;
|
|
616 | 616 |
} |
617 | 617 |
|
618 | 618 |
@Override |
... | ... | |
631 | 631 |
} |
632 | 632 |
|
633 | 633 |
@Override |
634 |
public void setFontField(String fontField) {
|
|
635 |
this.LFONT = fontField;
|
|
634 |
public void setFont(Expression expression) {
|
|
635 |
expFont = expression;
|
|
636 | 636 |
} |
637 | 637 |
|
638 | 638 |
@Override |
639 |
public void setFontStyleField(String field) {
|
|
640 |
this.LFONTSTYLE=field; |
|
639 |
public void setFontStyle(int style) {
|
|
640 |
|
|
641 | 641 |
} |
642 | 642 |
|
643 |
@Override |
|
644 |
public void setReferenceSystem(Expression expression) { |
|
645 |
expReferenceSystem = expression; |
|
646 |
} |
|
647 |
|
|
643 | 648 |
} |
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 | ||
---|---|---|
6 | 6 |
package org.gvsig.symbology.fmap.mapcontext.rendering.dynamiclegend; |
7 | 7 |
|
8 | 8 |
import java.util.ArrayList; |
9 |
import java.util.Arrays; |
|
9 | 10 |
import java.util.List; |
10 | 11 |
import java.util.logging.Level; |
11 | 12 |
import org.gvsig.expressionevaluator.Expression; |
12 | 13 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
13 | 14 |
import org.gvsig.fmap.dal.exception.DataException; |
14 | 15 |
import org.gvsig.fmap.dal.feature.Feature; |
16 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
15 | 17 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
16 | 18 |
import org.gvsig.fmap.geom.Geometry; |
17 | 19 |
import org.gvsig.fmap.geom.GeometryLocator; |
... | ... | |
46 | 48 |
public static final String LEGEND_NAME = "DynamicSymbol"; |
47 | 49 |
private ISymbol defaultSymbol; |
48 | 50 |
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"; |
|
53 | 51 |
|
52 |
public static Expression expOutlineColor = null; |
|
53 |
public static Expression expFillColor = null; |
|
54 |
public static Expression expSize = null; |
|
55 |
public static Expression expRotation = null; |
|
56 |
public static String[] requiredAttributes = null; |
|
57 |
|
|
58 |
// public static final String FIELD_OUTLINECOLOR = "COUTLINE"; |
|
59 |
// public static final String FIELD_FILLCOLOR = "CFILL"; |
|
60 |
// public static final String FIELD_SIZE = "CSIZE"; |
|
61 |
// public static final String FIELD_ROTATION = "CROTATION"; |
|
62 |
|
|
54 | 63 |
/** |
55 | 64 |
* Constructor method, needed by persistence. |
56 | 65 |
*/ |
... | ... | |
112 | 121 |
return expression; |
113 | 122 |
} |
114 | 123 |
|
124 |
public void setOutlineColor(Expression expression) { |
|
125 |
expOutlineColor = expression; |
|
126 |
} |
|
127 |
|
|
128 |
public void setFillColor(Expression expression) { |
|
129 |
expFillColor = expression; |
|
130 |
} |
|
131 |
|
|
132 |
public void setSize(Expression expression) { |
|
133 |
expSize = expression; |
|
134 |
} |
|
135 |
|
|
136 |
public void setRotation(Expression expression) { |
|
137 |
expRotation = expression; |
|
138 |
} |
|
139 |
|
|
115 | 140 |
@Override |
116 | 141 |
public ISymbol getSymbolByFeature(Feature feat) { |
117 | 142 |
DynamicSymbol symbol = (DynamicSymbol) getDefaultSymbol(); |
118 | 143 |
|
119 |
String fillcolor = feat.get(FIELD_FILLCOLOR).toString(); |
|
120 |
Expression expFill = getExpressionFromString(fillcolor); |
|
121 |
symbol.setFillColor(expFill); |
|
144 |
symbol.setFillColor(expFillColor); |
|
122 | 145 |
|
123 |
String outlinecolor = feat.get(FIELD_OUTLINECOLOR).toString(); |
|
124 |
Expression expOutlinecolor = getExpressionFromString(outlinecolor); |
|
125 |
symbol.setOutlineColor(expOutlinecolor); |
|
146 |
symbol.setOutlineColor(expOutlineColor); |
|
126 | 147 |
|
127 |
String size = feat.get(FIELD_SIZE).toString(); |
|
128 |
Expression expSize = getExpressionFromString(size); |
|
129 | 148 |
symbol.setSize(expSize); |
130 |
|
|
131 |
String rotation = feat.get(FIELD_ROTATION).toString(); |
|
132 |
Expression expRotation = getExpressionFromString(rotation); |
|
149 |
|
|
133 | 150 |
symbol.setRotation(expRotation); |
134 |
|
|
151 |
|
|
135 | 152 |
//OFFSET TODO |
136 | 153 |
Point pointOffset = null; |
137 | 154 |
String value = ""; |
... | ... | |
145 | 162 |
Expression offset = getExpressionFromString(value); |
146 | 163 |
symbol.setOffset(offset); |
147 | 164 |
|
165 |
try { |
|
166 |
String[] strList = this.getRequiredFeatureAttributeNames((FeatureStore) feat.getStore()); |
|
167 |
List<String> reqAttr = new ArrayList<>(); |
|
168 |
reqAttr.addAll(Arrays.asList(strList)); |
|
169 |
symbol.setRequiredFeatureAttributesNames(reqAttr); |
|
170 |
} catch (DataException ex) { |
|
171 |
java.util.logging.Logger.getLogger(DefaultDynamicVectorLegend.class.getName()).log(Level.SEVERE, null, ex); |
|
172 |
} |
|
148 | 173 |
|
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 |
|
|
157 | 174 |
symbol.setFeature(feat); |
158 | 175 |
return symbol; |
159 | 176 |
} |
... | ... | |
188 | 205 |
|
189 | 206 |
@Override |
190 | 207 |
protected String[] getRequiredFeatureAttributeNames( |
208 |
//TODO: Optimizar por obtener solo los campos que usan las expresiones |
|
191 | 209 |
FeatureStore featureStore) throws DataException { |
192 |
// We only need the default Geometry to draw |
|
193 |
return new String[]{featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()}; |
|
210 |
if (requiredAttributes == null) { |
|
211 |
requiredAttributes = new String[]{}; |
|
212 |
for (int i = 0; i < featureStore.getDefaultFeatureType().size(); i++) { |
|
213 |
FeatureAttributeDescriptor att = featureStore.getDefaultFeatureType().get(i); |
|
214 |
requiredAttributes[i] = att.getName(); |
|
215 |
} |
|
216 |
} |
|
217 |
return requiredAttributes; |
|
194 | 218 |
} |
195 | 219 |
|
196 | 220 |
@Override |
Also available in: Unified diff