Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.wmts / org.gvsig.wmts.provider / src / main / java / org / gvsig / wmts / provider / tree / DefaultWMTSThemeNode.java @ 8700

History | View | Annotate | Download (3.11 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2018 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.wmts.provider.tree;
24

    
25
import java.net.URL;
26
import java.util.ArrayList;
27
import java.util.Collections;
28
import java.util.Enumeration;
29
import java.util.List;
30

    
31
import javax.swing.tree.TreeNode;
32

    
33
import org.gvsig.fmap.dal.OpenDataStoreParameters;
34
import org.gvsig.raster.wmts.ogc.struct.WMTSTheme;
35

    
36

    
37
/**
38
 * @author fdiaz
39
 *
40
 */
41
public class DefaultWMTSThemeNode extends AbstractWMTSNode implements WMTSThemeNode {
42

    
43
    private WMTSTheme source;
44
    private List<WMTSNode> children;
45
    private WMTSLayerNode layer;
46
    private URL service;
47

    
48
    /**
49
     * @param source
50
     * @param parent
51
     * @param service
52
     *
53
     */
54
    public DefaultWMTSThemeNode(WMTSTheme source, WMTSNode parent, URL service) {
55
        super(parent);
56
        this.source = source;
57
        this.parent = parent;
58
        this.service = service;
59
        if(source.getLayer()!=null) {
60
            layer = new DefaultWMTSLayerNode(source.getLayer(), this, service);
61
        }
62
    }
63

    
64
    @Override
65
    public TreeNode getChildAt(int childIndex) {
66
        return children.get(childIndex);
67
    }
68

    
69
    @Override
70
    public int getChildCount() {
71
        return children.size();
72
    }
73

    
74
    @Override
75
    public int getIndex(TreeNode node) {
76
        return this.children.indexOf(node);
77
    }
78

    
79
    @Override
80
    public boolean getAllowsChildren() {
81
        return true;
82
    }
83

    
84
    @Override
85
    public boolean isLeaf() {
86
        return (this.children.size()<=0);
87
    }
88

    
89
    @Override
90
    public Enumeration children() {
91
        return Collections.enumeration(getChildren());
92
    }
93

    
94
    /**
95
     * @return the children
96
     */
97
    public List<WMTSNode> getChildren() {
98
        if (this.children == null) {
99
            this.children = new ArrayList<WMTSNode>();
100
            if(this.layer!=null){
101
                children.add(this.layer);
102
            }
103
            for(int i = 0; i<this.source.getChildCount(); i++){
104
                children.add(new DefaultWMTSThemeNode(this.source.getChildren(i), this, this.service));
105
            }
106
        }
107
        return this.children;
108
    }
109

    
110
    /* (non-Javadoc)
111
     * @see org.gvsig.wmts.provider.WMTSThemeNode#getLayer()
112
     */
113
    @Override
114
    public WMTSLayerNode getLayer() {
115
        return layer;
116
    }
117

    
118
}