/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 01/05/2015 : SCA : V2.1
 * ----------------------------------------
 */
package fr.tlse.irap.pt.client.controller.tools.common;

import java.util.List;

import javafx.scene.Node;
import javafx.scene.layout.VBox;

public class MapLegend extends VBox {

	private static final Double lowOpacity = 0.3;

	public MapLegend() {
	}

	/**
	 * Create a Map Legend from a list of nodes
	 */
	public MapLegend(List<Node> nodes) {
		getChildren().addAll(nodes);
	}

	/**
	 * Refresh nodes of the Map Legend 
	 * @param nodes
	 */
	public void setNodes(List<Node> nodes) {
		getChildren().clear();
		getChildren().addAll(nodes);
	}
	
	public void toggleNodeOpacity(Node node) {
		node.setOpacity((node.getOpacity() == lowOpacity) ? 1.0 : lowOpacity);
	}

	public void setNodeOpacity(Node node, boolean pVisibility) {
		node.setOpacity(pVisibility ? 1.0 : lowOpacity);
	}

	public boolean isVisibleNode(Node node) {
		return (node.getOpacity() == 1.0);
	}

}
