nl.cloudfarming.client.geoviewer.layers.LayerNode Maven / Gradle / Ivy
The newest version!
/**
* Copyright (C) 2010 Cloudfarming
*
* Licensed under the Eclipse Public License - v 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.cloudfarming.client.geoviewer.layers;
import javax.swing.Action;
import nl.cloudfarming.client.geoviewer.Layer;
import nl.cloudfarming.client.geoviewer.LayerInfo;
import nl.cloudfarming.client.geoviewer.MapController;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.util.lookup.Lookups;
/**
* A node which indicates a layer (image or items).
*
* @author Timon Veenstra
*/
public class LayerNode extends AbstractNode implements Comparable {
private Layer layer;
private MapController mapApi;
public LayerNode(MapController mapApi, Layer layer) {
// only display children of interactive layers
super((layer.isInterActive())? new LayerObjectChildren(mapApi,layer):Children.LEAF, Lookups.fixed(layer, mapApi));
this.layer = layer;
this.mapApi = mapApi;
}
/**
* Returns the HTML display name based on the visibility of the layer.
*
* @return The HTML display name of the node (layer)
*/
@Override
public String getHtmlDisplayName() {
LayerInfo layerInfo = mapApi.getLayerInfo(layer);
String displayName = layer.getName();
if (displayName == null) {
displayName = layer.getName();
}
if (layerInfo.isVisible()) {
return "" + displayName + "";
} else {
return "" + displayName + "";
}
}
/**
* Returns the actions for a node (layer).
*
* @param popup
* @return
*/
@Override
public Action[] getActions(boolean popup) {
return new Action[]{new VisibilityLayerAction(mapApi.getLayerInfo(layer)), new SortLayerAction(), new SettingsForLayerAction()};
}
/**
* Required for the sortedArray interface for the parentNode.children
* Dummy function. Only needed for the encapsulating Children.sortedArray class.
* @param arg0
* @return
*/
@Override
public int compareTo(Object arg0) {
return 0; // no need to change.. it doesn't do anything for us
}
/**
* Add support for copying this node
*/
@Override
public boolean canCopy() {
return true;
}
/**
* Add support for cutting (moving) this node
*/
@Override
public boolean canCut() {
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy