Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wms / WMSStyle.java @ 38579

History | View | Annotate | Download (5.14 KB)

1 3323 ldiaz
2 29658 jpiera
package org.gvsig.remoteclient.wms;
3 3323 ldiaz
4
import java.io.IOException;
5
6
import org.kxml2.io.KXmlParser;
7
import org.xmlpull.v1.XmlPullParserException;
8
9 33738 jpiera
import org.gvsig.remoteclient.utils.CapabilitiesTags;
10
11 3323 ldiaz
/**
12
 * <p>Defines a OGC style. Theme that describes the appeareance of certain layer.</p>
13 9003 jaume
 *
14 3323 ldiaz
 */
15
public abstract class WMSStyle {
16
17
        //style name, defined in the WMS capabilities
18
        private String name;
19
        //style title, defined in the WMS capabilities
20
        private String title;
21
        // style abstract, defined in the WMS capabilities
22
    private String styleAbstract;
23
24 29658 jpiera
    private org.gvsig.remoteclient.wms.WMSStyle.LegendURL legendURL;
25 9003 jaume
26 4924 jaume
    /**
27
     * <p>Parses the STYLE tag in the WMS capabilities, filling the WMSStyle object
28
     * loading the data in memory to be easily accesed</p>
29 9003 jaume
     *
30 4924 jaume
     */
31 3323 ldiaz
    public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException;
32 9003 jaume
33 3750 ldiaz
    /**
34
     * Parses the legendURL tag.
35
     * @param parser
36
     * @throws IOException
37
     * @throws XmlPullParserException
38
     */
39
    protected void parseLegendURL(KXmlParser parser) throws IOException, XmlPullParserException
40 9003 jaume
    {
41 3750 ldiaz
            int currentTag;
42
            boolean end = false;
43 9003 jaume
44 3750 ldiaz
            parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.LEGENDURL);
45 9003 jaume
46 3750 ldiaz
            String value = new String();
47 9003 jaume
            legendURL = new LegendURL();
48
49 4924 jaume
            //First of all set whether the layer is Queryable reading the attribute.
50
            value = parser.getAttributeValue("", CapabilitiesTags.WIDTH);
51
            if (value != null)
52 3750 ldiaz
            {
53 9003 jaume
                    legendURL.width = Integer.parseInt( value );
54 3750 ldiaz
            }
55 4924 jaume
            value = parser.getAttributeValue("", CapabilitiesTags.HEIGHT);
56
            if (value != null)
57
            {
58 9003 jaume
                    legendURL.height = Integer.parseInt( value );
59 4924 jaume
            }
60 9003 jaume
            currentTag = parser.nextTag();
61
62
            while (!end)
63 4924 jaume
            {
64
                    switch(currentTag)
65
                    {
66
                    case KXmlParser.START_TAG:
67
                            if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0)
68 9003 jaume
                            {
69
                                    legendURL.format = parser.nextText();
70
                            }
71 4924 jaume
                            else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0)
72
                            {
73
                                    value = parser.getAttributeValue("", CapabilitiesTags.XLINK_TYPE);
74
                                    if (value != null)
75 9003 jaume
                                            legendURL.onlineResource_type = value;
76 4924 jaume
                                    value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF);
77
                                    if (value != null)
78 9003 jaume
                                            legendURL.onlineResource_href = value;
79 4924 jaume
                            }
80
                            break;
81
                    case KXmlParser.END_TAG:
82
                            if (parser.getName().compareTo(CapabilitiesTags.LEGENDURL) == 0)
83
                                    end = true;
84
                            break;
85 9003 jaume
                    case KXmlParser.TEXT:
86 4924 jaume
                            break;
87
                    }
88
                    if (!end)
89
                    {
90
                            currentTag = parser.next();
91
                    }
92
            }
93 3750 ldiaz
            parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LEGENDURL);
94 9003 jaume
    }
95
96 3750 ldiaz
    /**
97
     * gets the LegendURL OnlineResource type
98
     */
99
    public String getLegendURLOnlineResourceType()
100
    {
101
            if (legendURL != null)
102
            {
103
                    return legendURL.onlineResource_type;
104
            }
105
            else
106
            {
107
                    return null;
108
            }
109
    }
110 9003 jaume
111 3750 ldiaz
    /**
112
     * gets the LegendURL OnlineResource href
113
     */
114
    public String getLegendURLOnlineResourceHRef()
115
    {
116
            if (legendURL != null)
117
            {
118
                    return legendURL.onlineResource_href;
119
            }
120
            else
121
            {
122
                    return null;
123
            }
124 9003 jaume
    }
125 3750 ldiaz
    public String getLegendURLFormat()
126
    {
127
            if (legendURL != null)
128
            {
129
                    return legendURL.format;
130
            }
131
            else
132
            {
133
                    return null;
134
            }
135
    }
136
    public int getLegendURLWidth()
137
    {
138
            if (legendURL != null)
139
            {
140
                    return legendURL.width;
141
            }
142
            return 0;
143 9003 jaume
    }
144 3750 ldiaz
    public int getLegendURLHeight()
145
    {
146
            if (legendURL != null)
147
            {
148
                    return legendURL.height;
149
            }
150
            return 0;
151 9003 jaume
    }
152
153 3750 ldiaz
    /**
154
     * sets LegendURL
155
     */
156
    protected void setLegendURL(LegendURL legendURL)
157
    {
158
            this.legendURL = legendURL;
159
    }
160 9003 jaume
161 4924 jaume
    /**
162
     * <p>gets the style name</p>
163 9003 jaume
     *
164 4924 jaume
     * @return style name
165
     */
166 9003 jaume
    public String getName() {
167 3323 ldiaz
            return name;
168 9003 jaume
    }
169
170 4924 jaume
    /**
171
     * <p>sets the style name.</p>
172 9003 jaume
     *
173
     * @param _name
174 4924 jaume
     */
175 9003 jaume
    public void setName(String _name) {
176 4924 jaume
            name = _name;
177 9003 jaume
    }
178
179 4924 jaume
    /**
180
     * <p>gets the style title</p>
181 9003 jaume
     *
182
     *
183 4924 jaume
     * @return style title
184
     */
185 9003 jaume
    public String getTitle() {
186 4924 jaume
            return title;
187 9003 jaume
    }
188
189 4924 jaume
    /**
190
     * <p>Sets style title</p>
191 9003 jaume
     *
192
     *
193
     * @param _title
194 4924 jaume
     */
195 9003 jaume
    public void setTitle(String _title) {
196 4924 jaume
            title = _title.trim();
197 9003 jaume
    }
198
199 4924 jaume
    /**
200
     * <p>gets style abstract</p>
201 9003 jaume
     *
202
     *
203 4924 jaume
     * @return style abstract
204
     */
205 9003 jaume
    public String getAbstract() {
206 4924 jaume
            return styleAbstract;
207 9003 jaume
    }
208
209 4924 jaume
    /**
210
     * <p>sets style abstract</p>
211 9003 jaume
     *
212
     *
213
     * @param _abstract, style abstract
214 4924 jaume
     */
215 9003 jaume
    public void setAbstract(String _abstract) {
216 4924 jaume
            styleAbstract = _abstract;
217 3665 ldiaz
    }
218 9003 jaume
219 3665 ldiaz
    /**
220
     * <p>Inner class describing the Legend URL defined for styles in the OGC specifications in WMS</p>
221 9003 jaume
     *
222 3665 ldiaz
     */
223 3750 ldiaz
    protected class LegendURL
224 9003 jaume
    {
225 3750 ldiaz
            public LegendURL()
226
            {
227
                    width = 0;
228
                    height= 0;
229
                    format = new String();
230
                    onlineResource_type = new String();
231
                    onlineResource_href = new String();
232
            }
233 9003 jaume
234 4924 jaume
            public int width;
235
            public int height;
236
            public String format;
237
            public String onlineResource_type;
238
            public String onlineResource_href;
239 9003 jaume
    }
240 4924 jaume
}