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

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

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

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

public class EllipseActions {
    static{
        PropertyFactory.regist(Ellipse.class, "centerYProperty", o -> {
            Ellipse obj = (Ellipse) o;
            return obj.centerYProperty();
        });
        PropertyFactory.regist(Ellipse.class, "centerXProperty", o -> {
            Ellipse obj = (Ellipse) o;
            return obj.centerXProperty();
        });
        PropertyFactory.regist(Ellipse.class, "radiusYProperty", o -> {
            Ellipse obj = (Ellipse) o;
            return obj.radiusYProperty();
        });
        PropertyFactory.regist(Ellipse.class, "radiusXProperty", o -> {
            Ellipse obj = (Ellipse) o;
            return obj.radiusXProperty();
        });
    }

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

        if(thing.valueExists("centerX")){
            node.setCenterX(thing.getDouble("centerX"));
        }
        if(thing.valueExists("centerY")){
            node.setCenterY(thing.getDouble("centerY"));
        }
        if(thing.valueExists("radiusX")){
            node.setRadiusX(thing.getDouble("radiusX"));
        }
        if(thing.valueExists("radiusY")){
            node.setRadiusY(thing.getDouble("radiusY"));
        }
    }

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

        Ellipse node = new Ellipse();
        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