Statistics
| Revision:

root / trunk / extensions / extSymbology / src / org / gvsig / remoteClient / sld / SLDStroke.java @ 20768

History | View | Annotate | Download (6.15 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.remoteClient.sld;
42

    
43
import java.awt.BasicStroke;
44
import java.awt.Color;
45
import java.util.ArrayList;
46

    
47
import org.gvsig.remoteClient.sld.filterEncoding.FExpression;
48

    
49
import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException;
50
/**
51
 * Implements the Stroke element of an SLD specification which
52
 * encapsulates the graphical-symbolization parameters for linear
53
 * geometries
54
 * 
55
 * @see http://portal.opengeospatial.org/files/?artifact_id=1188
56
 * 
57
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
58
 */
59
public abstract class SLDStroke implements ISLDFeatures{
60

    
61
        protected FExpression expressionWidth = new FExpression();
62
        protected FExpression expressionColor = new FExpression();
63
        protected FExpression expressionOpacity = new FExpression();
64
        protected FExpression expressionLineJoin = new FExpression();
65
        protected FExpression expressionLineCap = new FExpression();
66
        protected FExpression expressionDashOffset = new FExpression();
67
        protected SLDGraphic graphic;
68
        protected boolean hasGraphicFill = false;
69
        protected boolean hasGraphicStroke = false;
70
        protected ArrayList<Float> dashArray = new ArrayList<Float>();
71
        
72
        public FExpression getExpressionWidth() {return expressionWidth;}
73
        public void setExpressionWidth(FExpression expressionWidth) {this.expressionWidth = expressionWidth;}
74
        public FExpression getExpressionColor() {return expressionColor;}
75
        public void setExpressionColor(FExpression expressionColor) {this.expressionColor = expressionColor;}
76
        public FExpression getExpressionOpacity() {return expressionOpacity;}
77
        public void setExpressionOpacity(FExpression expressionOpacity) {this.expressionOpacity = expressionOpacity;}
78
        public FExpression getExpressionLineJoin() {return expressionLineJoin;}
79
        public void setExpressionLineJoin(FExpression expressionLineJoin) {this.expressionLineJoin = expressionLineJoin;}
80
        public FExpression getExpressionLineCap() {return expressionLineCap;}
81
        public void setExpressionLineCap(FExpression expressionLineCap) {this.expressionLineCap = expressionLineCap;}
82
        public FExpression getExpressionDashOffset() {return expressionDashOffset;}
83
        public void setExpressionDashOffset(FExpression expressionDashOffset) {this.expressionDashOffset = expressionDashOffset;}
84
        public SLDGraphic getGraphic() {return graphic;}
85
        public void setGraphic(SLDGraphic graphic) {this.graphic = graphic;}
86
        public boolean isHasGraphicFill() {return hasGraphicFill;}
87
        public void setHasGraphicFill(boolean hasGraphicFill) {this.hasGraphicFill = hasGraphicFill;}
88
        public boolean isHasGraphicStroke() {return hasGraphicStroke;}
89
        public void setHasGraphicStroke(boolean hasGraphicStroke) {this.hasGraphicStroke = hasGraphicStroke;}
90
        public ArrayList<Float> getDashArray() {return dashArray;}
91
        public void setDashArray(ArrayList<Float> dashArray) {this.dashArray = dashArray;}
92
        
93
        
94
        public float getStrokeWidth(){return Float.valueOf(expressionWidth.getLiteral());}
95
        public void setExpressionWidth(String width) {this.expressionWidth.setLiteral(width);}
96
        public void setExpressionColor(String color) {this.expressionColor.setLiteral(color);}
97
        public void setExpressionOpacity(String opacity) {this.expressionOpacity.setLiteral(opacity);}
98
        public void setExpressionLineJoin(String lineJoin) {this.expressionLineJoin.setLiteral(lineJoin);}
99
        public void setExpressionLineCap(String lineCap) {this.expressionLineCap.setLiteral(lineCap);}
100
        public void setExpressionDashOffset(String dashOffset) {this.expressionDashOffset.setLiteral(dashOffset);}
101

    
102
        public Color getStrokeColor() throws NumberFormatException, LegendDriverException{
103
                return SLDUtils.convertHexStringToColor(this.expressionColor.getLiteral());
104
        }
105
        
106
        public float[] getMyDashArray() {
107
                float[] myDash = new float[this.dashArray.size()];
108
                for (int i = 0; i < dashArray.size(); i++) {
109
                        myDash[i] = dashArray.get(i);
110
                }
111
                return myDash;
112
        }
113

    
114

    
115
        public void setMyDashArray(float[] dash) {
116
                if(dash != null) {
117
                        dashArray.clear();
118
                        for (int i = 0; i < dash.length; i++) {
119
                                dashArray.add(dash[i]);
120
                        }
121
                }
122
        }
123
        
124
        public int getLineJoin() throws LegendDriverException {
125
                if (expressionLineJoin.getLiteral().compareTo("bevel") == 0)
126
                        return BasicStroke.JOIN_BEVEL;
127
                else if (expressionLineJoin.getLiteral().compareTo("miter") == 0)
128
                        return BasicStroke.JOIN_MITER;
129
                else if (expressionLineJoin.getLiteral().compareTo("round") == 0)
130
                        return BasicStroke.JOIN_ROUND;
131
                else throw new LegendDriverException (LegendDriverException.PARSE_LEGEND_FILE_ERROR);
132

    
133
        }
134

    
135
        public int getLineCap() throws LegendDriverException {
136
                if (expressionLineCap.getLiteral().compareTo("butt") == 0)
137
                        return BasicStroke.CAP_BUTT;
138
                else if (expressionLineCap.getLiteral().compareTo("round") == 0)
139
                        return BasicStroke.CAP_ROUND;
140
                else if (expressionLineCap.getLiteral().compareTo("square") == 0)
141
                        return BasicStroke.CAP_SQUARE;
142
                else throw new LegendDriverException (LegendDriverException.PARSE_LEGEND_FILE_ERROR);
143
        }
144
}