package org.genericsystem.cv.params;

import java.util.HashMap;
import java.util.Map;

import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

public class ParamsPanel extends VBox {

	private Map<String, SimpleDoubleProperty> model = new HashMap<>();

	public DoubleProperty addProperty(String name, double value) {
		DoubleProperty property = new SimpleDoubleProperty(value);
		model.put(name, new SimpleDoubleProperty(value));
		return property;
	}

	public DoubleProperty addSliderProperty(String propertyName, double value, double min, double max) {
		DoubleProperty property = addProperty(propertyName, value);
		property.addListener((ov, oldV, newV) -> System.out.println(propertyName + " " + newV));
		HBox hbox = new HBox();
		Label label = new Label(propertyName);
		Slider slider = new Slider(min, max, value);
		slider.setShowTickLabels(true);
		slider.setShowTickMarks(true);
		// slider.setMajorTickUnit(50);
		// slider.setMinorTickCount(5);
		// slider.setBlockIncrement(10);
		slider.valueProperty().addListener((ov, oldValue, newValue) -> {
			if (!slider.isValueChanging())
				property.setValue(newValue);
		});
		slider.valueChangingProperty().addListener((ov, oldValue, newValue) -> {
			if (!newValue)
				property.setValue(slider.getValue());
		});
		hbox.getChildren().add(label);
		hbox.getChildren().add(slider);
		getChildren().add(hbox);
		return property;
	}

	// public DoubleProperty getProperty(String propertyName) {
	// return model.get(propertyName);
	// }

	// public DoubleProperty getSliderProperty(String propertyName) {
	// return getProperty(propertyName);
	// }

}
@@ -78,16 +78,42 @@
 til.Map;
+%0Aimport java.util.Objects;
 %0A%0Aimport
@@ -818,99 +818,8 @@
 e);%0A
-%09%09property.addListener((ov, oldV, newV) -%3E System.out.println(propertyName + %22 %22 + newV));%0A
 %09%09HB
@@ -924,24 +924,229 @@
 ax, value);%0A
+%09%09Label valueLabel = new Label(Objects.toString(value));%0A%09%09property.addListener((ov, oldV, newV) -%3E %7B%0A%09%09%09valueLabel.setText(Objects.toString(newV));%0A%09%09%09System.out.println(propertyName + %22 %22 + newV);%0A%09%09%7D);%0A
 %09%09slider.set
@@ -1617,16 +1617,16 @@
 label);%0A
-
 %09%09hbox.g
@@ -1651,16 +1651,54 @@
 lider);%0A
+%09%09hbox.getChildren().add(valueLabel);%0A
 %09%09getChi

Add value of sliders