All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.rpgframework.jfx.NumericalValueField Maven / Gradle / Ivy

package de.rpgframework.jfx;

import java.lang.System.Logger;
import java.util.function.Supplier;

import org.prelle.javafx.skin.AcrylicPaneSkin;

import de.rpgframework.genericrpg.NumericalValue;
import de.rpgframework.genericrpg.NumericalValueController;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
import javafx.util.Callback;

public class NumericalValueField> extends Control {

	private final static Logger logger = System.getLogger("prelle.jfx");
	public static final String REFRESH = "refreshKey";

	private ObjectProperty> supplier   = new SimpleObjectProperty<>();
	private ObjectProperty> control = new SimpleObjectProperty<>();
	private ObjectProperty> converter = new SimpleObjectProperty<>();
//	private int minWidthEm;
//	private boolean useLabel = true;
//	private Integer overrideValue;

	private ObjectProperty> onAction = new SimpleObjectProperty<>();

	//--------------------------------------------------------------------
	public NumericalValueField() {
	}

	//--------------------------------------------------------------------
	public NumericalValueField(Supplier valueProvider) {
		this.supplier.set(valueProvider);
	}

	//--------------------------------------------------------------------
	public NumericalValueField(Supplier valueProvider, NumericalValueController ctrl) {
		if (valueProvider==null) throw new NullPointerException("valueProvider");
		this.supplier.set(valueProvider);
		this.control.set(ctrl);
	}

	//--------------------------------------------------------------------
	public Skin createDefaultSkin() {
		return new NumericalValueFieldSkin<>(this);
	}

	//--------------------------------------------------------------------
	public ObjectProperty> valueFactoryProperty() { return supplier; }
	public Supplier getValueFactory() { return supplier.get(); }
	public NumericalValueField setValueFactory(Supplier value) { supplier.set(value); return this; }

	//--------------------------------------------------------------------
	public ObjectProperty> controllerProperty() { return control; }
	public NumericalValueController getController() { return control.get(); }
	public NumericalValueField setController(NumericalValueController value) { control.set(value); return this; }

	//--------------------------------------------------------------------
	public ObjectProperty> converterProperty() { return converter; }
	public Callback getConverter() { return converter.get(); }
	public NumericalValueField setConverter(Callback value) { converter.set(value); return this; }

	//--------------------------------------------------------------------
	public void refresh() {
        getProperties().put(AcrylicPaneSkin.REFRESH, Boolean.TRUE);
	}

	//--------------------------------------------------------------------
	public ObjectProperty > onActionProperty() { return onAction; }
	public EventHandler  getOnAction() { return onAction.get(); }
	public void setOnAction(EventHandler handler) {
		this.onAction.set(handler);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy