Revision 40864

View differences:

branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/legend/IntervalsLegendUtils.java
274 274
			SLDBinaryComparisonOperator resp = new SLDBinaryComparisonOperator();
275 275
			resp.setComparisonOperator(FilterTags.PROPERTYISGREATEROREQUALTHAN);
276 276
			resp.setFirstExpression(new SLDPropertyName(fieldName));
277
			resp.setSecondExpression(new SLDLiteral(Double.toString(min)));
277
			
278
			resp.setSecondExpression(new SLDLiteral(BasicUtils.df.format(min)));
278 279
			return resp;
279 280
			
280 281
		} else {
......
283 284
				SLDBinaryComparisonOperator resp = new SLDBinaryComparisonOperator();
284 285
				resp.setComparisonOperator(FilterTags.PROPERTYISLESSOREQUALTHAN);
285 286
				resp.setFirstExpression(new SLDPropertyName(fieldName));
286
				resp.setSecondExpression(new SLDLiteral(Double.toString(max)));
287
				resp.setSecondExpression(new SLDLiteral(BasicUtils.df.format(max)));
287 288
				return resp;
288 289
				
289 290
			} else {
290 291
				// normal (between)
291 292
				SLDIsBetweenOperator resp = new SLDIsBetweenOperator();
292 293
				resp.setExpression(new SLDPropertyName(fieldName));
293
				resp.setLowerBoundary(new SLDLiteral(Double.toString(min)));
294
				resp.setUpperBoundary(new SLDLiteral(Double.toString(max)));
294
				resp.setLowerBoundary(new SLDLiteral(BasicUtils.df.format(min)));
295
				resp.setUpperBoundary(new SLDLiteral(BasicUtils.df.format(max)));
295 296
				return resp;
296 297
			}
297 298
		}
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/symbol/LineSymbolUtils.java
38 38
		double bw = sym.getLineWidth();
39 39
		
40 40
		SLDStroke stro = new SLDStroke();
41
		String colhex = BasicUtils.toHexadecimal(bcolor, 6, "#");
42
		if (colhex != null) {
43
			stro.setColor(new SLDLiteral(colhex));
44
		}
41
		stro.setColor(bcolor);
45 42
		stro.setWidth(new SLDLiteral(BasicUtils.df.format(bw)));
46 43
		
47 44
		SLDLineSymbol resp = new SLDLineSymbol();
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/symbol/PolygonSymbolUtils.java
79 79
		Color color = sym.getOutline().getColor();
80 80
		double w = sym.getOutline().getLineWidth();
81 81
		SLDStroke stro = new SLDStroke();
82
		String colhex = BasicUtils.toHexadecimal(color, 6, "#");
83
		if (colhex != null) {
84
			stro.setColor(new SLDLiteral(colhex));
82
		if (color != null) {
83
			stro.setColor(color);
85 84
		}
86 85
		stro.setWidth(new SLDLiteral(BasicUtils.df.format(w)));
87 86
		// =================
88 87
		color = sym.getColor();
89
		colhex = BasicUtils.toHexadecimal(color, 6, "#");
90 88
		SLDFill fill = new SLDFill();
91
		if (colhex != null) {
92
			fill.setFillColor(new SLDLiteral(colhex));
89
		if (color != null) {
90
			fill.setFillColor(color);
93 91
		}
94 92
		// =================
95 93
		SLDPolygonSymbol resp = new SLDPolygonSymbol();
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldconverter/org.gvsig.sldconverter.lib/org.gvsig.sldconverter.lib.impl/src/main/java/org/gvsig/sldconverter/impl/symbol/PointSymbolUtils.java
275 275
				rot = -rot * 180.0 / Math.PI;
276 276
				// ===============
277 277
				SLDFill fill = new SLDFill();
278
				String colhex = BasicUtils.toHexadecimal(fillColor, 6, "#");
279
				if (colhex == null) {
280
					colhex = SLDFill.DEFAULT_FILL_COLOR;
278
				if (fillColor == null) {
279
					fillColor = SLDFill.DEFAULT_FILL_COLOR;
281 280
				}
282 281

  
283
				fill.setFillColor(new SLDLiteral(colhex));
282
				fill.setFillColor(fillColor);
284 283
				mark.setFill(fill);
285 284
				// ===
286 285
				SLDStroke stro = new SLDStroke();
287
				colhex = BasicUtils.toHexadecimal(borderColor, 6, "#");
288
				if (colhex != null) {
289
					stro.setColor(new SLDLiteral(colhex));
290
				}
286
				stro.setColor(borderColor);
291 287
				
292 288
				stro.setWidth(new SLDLiteral(BasicUtils.df.format(borderw)));
293 289
				mark.setStroke(stro);
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/sld/symbol/misc/SLDFill.java
1 1
package org.gvsig.sldsupport.sld.symbol.misc;
2 2

  
3
import java.awt.Color;
4

  
3 5
import org.gvsig.sldsupport.sld.filter.expression.SLDExpression;
4 6
import org.gvsig.sldsupport.sld.filter.expression.operator.SLDLiteral;
5 7
import org.gvsig.sldsupport.sld.graphic.SLDGraphic;
6 8

  
7 9
public class SLDFill {
8 10
	
9
	public static String DEFAULT_FILL_COLOR = "#808080";
10
	public static String DEFAULT_OPACITY = "1.0";
11
	public static Color DEFAULT_FILL_COLOR = new Color(128, 128, 128);
12
	public static double DEFAULT_OPACITY = 1.0;
11 13
	
12 14
	protected SLDGraphic fillGraphic = null;
13 15
	
......
21 23
		/*
22 24
		 * Defaults
23 25
		 */
24
		this.setFillColor(new SLDLiteral(DEFAULT_FILL_COLOR));
25
		this.setOpacity(new SLDLiteral(DEFAULT_OPACITY));
26
		this.setFillColor(DEFAULT_FILL_COLOR);
27
		this.setOpacity(DEFAULT_OPACITY);
26 28
	}
27 29
	
28 30
	public SLDGraphic getFillGraphic() {
......
45 47
		this.colorExpression = expr;
46 48
	}
47 49
	
50
	public void setFillColor(Color co) {
51
		if (co != null) {
52
			String strco = SLDStroke.toHexadecimal(co, 6, "#");
53
			setFillColor(new SLDLiteral(strco));
54
		}
55
	}
56

  
57
	
48 58
	public void setOpacity(SLDExpression expr) {
49 59
		this.opacityExpression = expr;
60
	}
61
	
62
	public void setOpacity(double opa) {
63
		if (opa >= 0 && opa <= 1) {
64
			setOpacity(new SLDLiteral(SLDStroke.df.format(opa)));
65
		}
50 66
	}	
51 67

  
52 68
}
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.api/src/main/java/org/gvsig/sldsupport/sld/symbol/misc/SLDStroke.java
1 1
package org.gvsig.sldsupport.sld.symbol.misc;
2 2

  
3
import java.awt.Color;
4
import java.text.DecimalFormat;
5
import java.text.DecimalFormatSymbols;
3 6
import java.util.ArrayList;
4 7
import java.util.List;
5 8

  
......
16 19
	
17 20
	protected int strokeType = STROKE_TYPE_SOLID;
18 21
	
22
	public static DecimalFormat df = null;
23
	static {
24
		DecimalFormatSymbols dformater_rules = new DecimalFormatSymbols();
25
		dformater_rules.setDecimalSeparator ('.');
26
		df = new DecimalFormat("##########.0##########", dformater_rules);
27
	}
28
	
19 29
	protected SLDExpression width = null;
20 30
	protected SLDExpression color = null;
21 31
	
......
54 64
		 * Defaults
55 65
		 */
56 66
		setStrokeType(STROKE_TYPE_SOLID);
57
		this.setColor(new SLDLiteral("#000000"));
58
		this.setOpacity(new SLDLiteral("1.0"));
59
		this.setWidth(new SLDLiteral("1.0"));
67
		this.setColor(Color.BLACK);
68
		this.setOpacity(1);
69
		this.setWidth(1);
60 70
		
61 71
		/*
62 72
		 * These are valid but not standard defaults
......
87 97
	public void setWidth(SLDExpression w) {
88 98
		this.width = w;
89 99
	}
100
	
101
	
102
	public void setWidth(double w) {
103
		if (w >= 0) {
104
			setWidth(new SLDLiteral(df.format(w)));
105
		}
106
	}
107
	
108
	
90 109

  
91 110
	public SLDExpression getColor() {
92 111
		return color;
......
95 114
	public void setColor(SLDExpression c) {
96 115
		this.color = c;
97 116
	}
117
	
118
	public void setColor(Color c) {
119
		
120
		if (c != null) {
121
			String colstr = toHexadecimal(c, 6, "#");
122
			setColor(new SLDLiteral(colstr));
123
		}
124
	}
125
	
98 126

  
99 127
	public SLDExpression getOpacity() {
100 128
		return opacity;
......
103 131
	public void setOpacity(SLDExpression o) {
104 132
		this.opacity = o;
105 133
	}
134
	
106 135

  
136
	public void setOpacity(double opa) {
137
		if (opa >= 0 && opa <= 1) {
138
			setOpacity(new SLDLiteral(df.format(opa)));
139
		}
140
	}
141
	
142

  
107 143
	public SLDExpression getLineJoin() {
108 144
		return lineJoin;
109 145
	}
......
159 195
		this.graphic = g;
160 196
	}
161 197
	
198
	
199
	/**
200
	 * Examples:
201
	 * #ff0000
202
	 * 0x000000cd9983
203
	 * 
204
	 * Returns null is color is null
205
	 * 
206
	 * @param co
207
	 * @param length
208
	 * @param prefix
209
	 * @return
210
	 */
211
	public static String toHexadecimal(Color co, int length, String prefix) {
212
		
213
		if (co == null) {
214
			return null;
215
		}
216
		
217
		int v = (co.getRed() << 16) + (co.getGreen() << 8) + co.getBlue();
218
		String resp = Integer.toHexString(v);
219
		int len = resp.length();
220
		for (int i=0; i<(length-len); i++) {
221
			resp = "0" + resp;
222
		}
223
		resp = resp.substring(resp.length() - length);
224
		if (prefix != null) {
225
			resp = prefix + resp;
226
		}
227
		return resp;
228
	}
229
	
162 230

  
163 231

  
164 232
}
branches/v02_desarrollo/libraries/sld/temp/org.gvsig.sldsupport.lib.impl/src/main/java/org/gvsig/sldsupport/impl/util/SLDUtils.java
162 162
		if (list == null || list.size() == 0) {
163 163
			return "";
164 164
		}
165
		String resp = Float.toString(list.get(0).floatValue());
165
		String resp = df.format(list.get(0).floatValue());
166 166
		for (int i=1; i<list.size(); i++) {
167
			resp = resp + sep + Float.toString(list.get(i).floatValue());
167
			resp = resp + sep + df.format(list.get(i).floatValue());
168 168
		}
169 169
		return resp;
170 170
	}

Also available in: Unified diff