svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / temp / org.gvsig.sldsupport.lib.api / oldcode / graphic / SLDStroke.java @ 40781
History | View | Annotate | Download (6.27 KB)
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib��ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.sldsupport.graphic; |
42 |
|
43 |
import java.awt.BasicStroke; |
44 |
import java.awt.Color; |
45 |
import java.util.ArrayList; |
46 |
|
47 |
import org.gvsig.sldsupport.exception.SLDReadException; |
48 |
import org.gvsig.sldsupport.feature.ISLDFeatures; |
49 |
import org.gvsig.sldsupport.filterencoding.FExpression; |
50 |
import org.gvsig.sldsupport.util.SLDUtils; |
51 |
|
52 |
/**
|
53 |
* Implements the Stroke element of an SLD specification which
|
54 |
* encapsulates the graphical-symbolization parameters for linear
|
55 |
* geometries
|
56 |
*
|
57 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188
|
58 |
*
|
59 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
60 |
*/
|
61 |
public abstract class SLDStroke implements ISLDFeatures{ |
62 |
|
63 |
protected FExpression expressionWidth = new FExpression(); |
64 |
protected FExpression expressionColor = new FExpression(); |
65 |
protected FExpression expressionOpacity = new FExpression(); |
66 |
protected FExpression expressionLineJoin = new FExpression(); |
67 |
protected FExpression expressionLineCap = new FExpression(); |
68 |
protected FExpression expressionDashOffset = new FExpression(); |
69 |
protected SLDGraphic graphic;
|
70 |
protected boolean hasGraphicFill = false; |
71 |
protected boolean hasGraphicStroke = false; |
72 |
protected ArrayList<Float> dashArray = new ArrayList<Float>(); |
73 |
|
74 |
public FExpression getExpressionWidth() {return expressionWidth;} |
75 |
public void setExpressionWidth(FExpression expressionWidth) {this.expressionWidth = expressionWidth;} |
76 |
public FExpression getExpressionColor() {return expressionColor;} |
77 |
public void setExpressionColor(FExpression expressionColor) {this.expressionColor = expressionColor;} |
78 |
public FExpression getExpressionOpacity() {return expressionOpacity;} |
79 |
public void setExpressionOpacity(FExpression expressionOpacity) {this.expressionOpacity = expressionOpacity;} |
80 |
public FExpression getExpressionLineJoin() {return expressionLineJoin;} |
81 |
public void setExpressionLineJoin(FExpression expressionLineJoin) {this.expressionLineJoin = expressionLineJoin;} |
82 |
public FExpression getExpressionLineCap() {return expressionLineCap;} |
83 |
public void setExpressionLineCap(FExpression expressionLineCap) {this.expressionLineCap = expressionLineCap;} |
84 |
public FExpression getExpressionDashOffset() {return expressionDashOffset;} |
85 |
public void setExpressionDashOffset(FExpression expressionDashOffset) {this.expressionDashOffset = expressionDashOffset;} |
86 |
public SLDGraphic getGraphic() {return graphic;} |
87 |
public void setGraphic(SLDGraphic graphic) {this.graphic = graphic;} |
88 |
public boolean isHasGraphicFill() {return hasGraphicFill;} |
89 |
public void setHasGraphicFill(boolean hasGraphicFill) {this.hasGraphicFill = hasGraphicFill;} |
90 |
public boolean isHasGraphicStroke() {return hasGraphicStroke;} |
91 |
public void setHasGraphicStroke(boolean hasGraphicStroke) {this.hasGraphicStroke = hasGraphicStroke;} |
92 |
public ArrayList<Float> getDashArray() {return dashArray;} |
93 |
public void setDashArray(ArrayList<Float> dashArray) {this.dashArray = dashArray;} |
94 |
|
95 |
|
96 |
public float getStrokeWidth(){return Float.valueOf(expressionWidth.getLiteral());} |
97 |
public void setExpressionWidth(String width) {this.expressionWidth.setLiteral(width);} |
98 |
public void setExpressionColor(String color) {this.expressionColor.setLiteral(color);} |
99 |
public void setExpressionOpacity(String opacity) {this.expressionOpacity.setLiteral(opacity);} |
100 |
public void setExpressionLineJoin(String lineJoin) {this.expressionLineJoin.setLiteral(lineJoin);} |
101 |
public void setExpressionLineCap(String lineCap) {this.expressionLineCap.setLiteral(lineCap);} |
102 |
public void setExpressionDashOffset(String dashOffset) {this.expressionDashOffset.setLiteral(dashOffset);} |
103 |
|
104 |
public Color getStrokeColor() throws NumberFormatException, SLDReadException { |
105 |
return SLDUtils.convertHexStringToColor(this.expressionColor.getLiteral()); |
106 |
} |
107 |
|
108 |
public float[] getFloatDashArray() { |
109 |
float[] myDash = new float[this.dashArray.size()]; |
110 |
for (int i = 0; i < dashArray.size(); i++) { |
111 |
myDash[i] = dashArray.get(i); |
112 |
} |
113 |
return myDash;
|
114 |
} |
115 |
|
116 |
|
117 |
public void setFloatDashArray(float[] dash) { |
118 |
if(dash != null) { |
119 |
dashArray.clear(); |
120 |
for (int i = 0; i < dash.length; i++) { |
121 |
dashArray.add(dash[i]); |
122 |
} |
123 |
} |
124 |
} |
125 |
|
126 |
public int getLineJoin() throws SLDReadException { |
127 |
if (expressionLineJoin.getLiteral().compareTo("bevel") == 0) |
128 |
return BasicStroke.JOIN_BEVEL; |
129 |
else if (expressionLineJoin.getLiteral().compareTo("miter") == 0) |
130 |
return BasicStroke.JOIN_MITER; |
131 |
else if (expressionLineJoin.getLiteral().compareTo("round") == 0) |
132 |
return BasicStroke.JOIN_ROUND; |
133 |
else throw new SLDReadException(new Exception( |
134 |
"Unknown line join type: " + expressionLineJoin.getLiteral()));
|
135 |
|
136 |
} |
137 |
|
138 |
public int getLineCap() throws SLDReadException { |
139 |
if (expressionLineCap.getLiteral().compareTo("butt") == 0) |
140 |
return BasicStroke.CAP_BUTT; |
141 |
else if (expressionLineCap.getLiteral().compareTo("round") == 0) |
142 |
return BasicStroke.CAP_ROUND; |
143 |
else if (expressionLineCap.getLiteral().compareTo("square") == 0) |
144 |
return BasicStroke.CAP_SQUARE; |
145 |
else throw new SLDReadException(new Exception( |
146 |
"Unknown line cap type: " + expressionLineCap.getLiteral()));
|
147 |
} |
148 |
} |