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

xworker.javafx.scene.chart.ValueAxisActions Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package xworker.javafx.scene.chart;

import javafx.scene.chart.ValueAxis;
import javafx.util.StringConverter;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;
import xworker.javafx.util.JavaFXUtils;

public class ValueAxisActions {
    static{
        PropertyFactory.regist(ValueAxis.class, "upperBoundProperty", o -> {
            ValueAxis obj = (ValueAxis) o;
            return obj.upperBoundProperty();
        });
        PropertyFactory.regist(ValueAxis.class, "lowerBoundProperty", o -> {
            ValueAxis obj = (ValueAxis) o;
            return obj.lowerBoundProperty();
        });
        PropertyFactory.regist(ValueAxis.class, "minorTickVisibleProperty", o -> {
            ValueAxis obj = (ValueAxis) o;
            return obj.minorTickVisibleProperty();
        });
        PropertyFactory.regist(ValueAxis.class, "tickLabelFormatterProperty", o -> {
            ValueAxis obj = (ValueAxis) o;
            return obj.tickLabelFormatterProperty();
        });
        PropertyFactory.regist(ValueAxis.class, "minorTickLengthProperty", o -> {
            ValueAxis obj = (ValueAxis) o;
            return obj.minorTickLengthProperty();
        });
        PropertyFactory.regist(ValueAxis.class, "minorTickCountProperty", o -> {
            ValueAxis obj = (ValueAxis) o;
            return obj.minorTickCountProperty();
        });
    }

    public static void init(ValueAxis node, Thing thing, ActionContext actionContext){
        AxisActions.init(node, thing, actionContext);

        if(thing.valueExists("lowerBound")){
            node.setLowerBound(thing.getDouble("lowerBound"));
        }
        if(thing.valueExists("minorTickCount")){
            node.setMinorTickCount(thing.getInt("minorTickCount"));
        }
        if(thing.valueExists("minorTickLength")){
            node.setMinorTickLength(thing.getDouble("minorTickLength"));
        }
        if(thing.valueExists("minorTickVisible")){
            node.setMinorTickVisible(thing.getBoolean("minorTickVisible"));
        }
        if(thing.valueExists("tickLabelFormatter")){
            StringConverter tickLabelFormatter = JavaFXUtils.getObject(thing, "tickLabelFormatter", actionContext);
            if(tickLabelFormatter != null) {
                node.setTickLabelFormatter(tickLabelFormatter);
            }
        }
        if(thing.valueExists("upperBound")){
            node.setUpperBound(thing.getDouble("upperBound"));
        }
    }

    public static void createTickLabelFormatter(ActionContext actionContext){
        Thing self = actionContext.getObject("self");
        ValueAxis parent = actionContext.getObject("parent");

        for(Thing child : self.getChilds()){
            Object obj = child.doAction("create", actionContext);
            if(obj instanceof StringConverter){
                parent.setTickLabelFormatter((StringConverter) obj);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy