root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wmts / struct / WMTSThemes.java @ 38531
History | View | Annotate | Download (3.32 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.remoteclient.wmts.struct; |
23 |
|
24 |
import java.io.IOException; |
25 |
import java.util.ArrayList; |
26 |
|
27 |
import org.gvsig.remoteclient.wmts.WMTSServerDescription; |
28 |
import org.kxml2.io.KXmlParser; |
29 |
import org.xmlpull.v1.XmlPullParserException; |
30 |
|
31 |
/**
|
32 |
* Layer hierarchy
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
34 |
*/
|
35 |
public abstract class WMTSThemes extends ArrayList { |
36 |
private static final long serialVersionUID = 1L; |
37 |
|
38 |
/**
|
39 |
* Parses this service ID
|
40 |
* @param parser
|
41 |
* @param content
|
42 |
* @throws IOException
|
43 |
* @throws XmlPullParserException
|
44 |
*/
|
45 |
public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException; |
46 |
|
47 |
/**
|
48 |
* Assign the layer associated
|
49 |
* @param layers
|
50 |
*/
|
51 |
public void calculateLayers(ArrayList layers) { |
52 |
for (int i = 0; i < size(); i++) { |
53 |
((WMTSTheme)get(i)).calculateLayers(layers); |
54 |
} |
55 |
} |
56 |
|
57 |
/**
|
58 |
* Loads this list of themes with the layer information
|
59 |
* @param layers
|
60 |
*/
|
61 |
public void loadThemesWithLayerInfo(ArrayList layers, WMTSServerDescription status) { |
62 |
if(size() == 0) { |
63 |
for (int i = 0; i < layers.size(); i++) { |
64 |
WMTSTheme theme = (WMTSTheme)status.createVersionObject("WMTSTheme");
|
65 |
WMTSLayer layer = (WMTSLayer)layers.get(i); |
66 |
theme.setTitle(layer.getTitle()); |
67 |
theme.setLayer(layer); |
68 |
theme.setAbstract(layer.getAbstract()); |
69 |
add(theme); |
70 |
} |
71 |
} |
72 |
} |
73 |
|
74 |
/**
|
75 |
* Gets a node by its name
|
76 |
* @param name
|
77 |
* @return
|
78 |
*/
|
79 |
public WMTSTheme getNodeByName(String name) { |
80 |
WMTSTheme result = null;
|
81 |
|
82 |
for (int i = 0; i < size(); i++) { |
83 |
WMTSTheme theme = ((WMTSTheme)get(i)); |
84 |
String title = theme.getTitle();
|
85 |
if(title.compareTo(name) == 0) |
86 |
result = ((WMTSTheme)get(i)); |
87 |
else
|
88 |
result = theme.getNodeByName(name); |
89 |
if(result != null) |
90 |
return result;
|
91 |
} |
92 |
return null; |
93 |
} |
94 |
|
95 |
/**
|
96 |
* Gets the number of nodes
|
97 |
* @param parent
|
98 |
* @return
|
99 |
*/
|
100 |
public int getChildCount() { |
101 |
int acum = 0; |
102 |
for (int i = 0; i < size(); i++) { |
103 |
acum += 1 + ((WMTSTheme)get(i)).getChildCount();
|
104 |
} |
105 |
return acum;
|
106 |
} |
107 |
|
108 |
/**
|
109 |
* Gets the children of the index position
|
110 |
* @param index
|
111 |
* @return
|
112 |
*/
|
113 |
public WMTSTheme getChildren(int index) { |
114 |
return (WMTSTheme)get(index);
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* Gets the index of a children
|
119 |
* @param parent
|
120 |
* @param child
|
121 |
* @return
|
122 |
*/
|
123 |
public int getIndexOfChild(WMTSTheme child) { |
124 |
for (int i = 0; i < size(); i++) |
125 |
if (child == getChildren(i))
|
126 |
return i;
|
127 |
return -1; |
128 |
} |
129 |
|
130 |
public String toString() { |
131 |
return "Base"; |
132 |
} |
133 |
} |