gov.nasa.worldwind.util.layertree.KMLContainerTreeNode Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2012 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
package gov.nasa.worldwind.util.layertree;
import gov.nasa.worldwind.ogc.kml.*;
import gov.nasa.worldwind.util.tree.TreeNode;
/**
* A KMLFeatureTreeNode
that represents a KML container defined by a {@link
* gov.nasa.worldwind.ogc.kml.KMLAbstractContainer}
.
*
* @author dcollins
* @version $Id: KMLContainerTreeNode.java 1171 2013-02-11 21:45:02Z dcollins $
*/
public class KMLContainerTreeNode extends KMLFeatureTreeNode
{
/**
* Creates a new KMLContainerTreeNode
from the specified container
. The node's name is set
* to the feature's name, and the node's hierarchy is populated from the container's KML features.
*
* @param container the KML container this node represents.
*
* @throws IllegalArgumentException if the container
is null
.
*/
public KMLContainerTreeNode(KMLAbstractContainer container)
{
super(container);
}
/**
* Indicates the KML container this node represents.
*
* @return this node's KML container.
*/
@Override
public KMLAbstractContainer getFeature()
{
return (KMLAbstractContainer) super.getFeature();
}
/** {@inheritDoc} */
@Override
protected void initialize()
{
super.initialize();
this.refresh();
}
/** Populate this node's hierarchy from the KML features in its KMLAbstractContainer
. */
protected void refresh()
{
this.removeAllChildren();
for (KMLAbstractFeature child : this.getFeature().getFeatures())
{
if (child != null)
this.addFeatureNode(child);
}
}
/**
* Adds the a new KMLFeatureTreeNode
created with the specified feature
to this node.
*
* @param feature the KML feature to add.
*/
protected void addFeatureNode(KMLAbstractFeature feature)
{
TreeNode featureNode = KMLFeatureTreeNode.fromKMLFeature(feature);
if (featureNode != null)
this.addChild(featureNode);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy