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

xworker.javafx.scene.shape.QuadCurveActions Maven / Gradle / Ivy

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

import javafx.scene.shape.QuadCurve;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;

public class QuadCurveActions {
    static{
        PropertyFactory.regist(QuadCurve.class, "startXProperty", o -> {
            QuadCurve obj = (QuadCurve) o;
            return obj.startXProperty();
        });
        PropertyFactory.regist(QuadCurve.class, "endXProperty", o -> {
            QuadCurve obj = (QuadCurve) o;
            return obj.endXProperty();
        });
        PropertyFactory.regist(QuadCurve.class, "endYProperty", o -> {
            QuadCurve obj = (QuadCurve) o;
            return obj.endYProperty();
        });
        PropertyFactory.regist(QuadCurve.class, "startYProperty", o -> {
            QuadCurve obj = (QuadCurve) o;
            return obj.startYProperty();
        });
        PropertyFactory.regist(QuadCurve.class, "controlYProperty", o -> {
            QuadCurve obj = (QuadCurve) o;
            return obj.controlYProperty();
        });
        PropertyFactory.regist(QuadCurve.class, "controlXProperty", o -> {
            QuadCurve obj = (QuadCurve) o;
            return obj.controlXProperty();
        });
    }

    public static void init(QuadCurve node, Thing thing, ActionContext actionContext){
        ShapeActions.init(node, thing, actionContext);

        if(thing.valueExists("controlX")){
            node.setControlX(thing.getDouble("controlX"));
        }
        if(thing.valueExists("controlY")){
            node.setControlY(thing.getDouble("controlY"));
        }
        if(thing.valueExists("endX")){
            node.setEndX(thing.getDouble("endX"));
        }
        if(thing.valueExists("endY")){
            node.setEndY(thing.getDouble("endY"));
        }
        if(thing.valueExists("startX")){
            node.setStartX(thing.getDouble("startX"));
        }
        if(thing.valueExists("startY")){
            node.setStartY(thing.getDouble("startY"));
        }
    }

    public static QuadCurve create(ActionContext actionContext){
        Thing self = actionContext.getObject("self");

        QuadCurve node = new QuadCurve();
        init(node, self, actionContext);
        actionContext.g().put(self.getMetadata().getName(), node);

        actionContext.peek().put("parent", node);
        for(Thing child : self.getChilds()){
            child.doAction("create", actionContext);
        }

        return node;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy