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

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

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

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

public class RectangleActions {
    static{
        PropertyFactory.regist(Rectangle.class, "arcWidthProperty", o -> {
            Rectangle obj = (Rectangle) o;
            return obj.arcWidthProperty();
        });
        PropertyFactory.regist(Rectangle.class, "arcHeightProperty", o -> {
            Rectangle obj = (Rectangle) o;
            return obj.arcHeightProperty();
        });
        PropertyFactory.regist(Rectangle.class, "widthProperty", o -> {
            Rectangle obj = (Rectangle) o;
            return obj.widthProperty();
        });
        PropertyFactory.regist(Rectangle.class, "xProperty", o -> {
            Rectangle obj = (Rectangle) o;
            return obj.xProperty();
        });
        PropertyFactory.regist(Rectangle.class, "heightProperty", o -> {
            Rectangle obj = (Rectangle) o;
            return obj.heightProperty();
        });
        PropertyFactory.regist(Rectangle.class, "yProperty", o -> {
            Rectangle obj = (Rectangle) o;
            return obj.yProperty();
        });
    }

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

        if(thing.valueExists("arcHeight")){
            node.setArcHeight(thing.getDouble("arcHeight"));
        }
        if(thing.valueExists("arcWidth")){
            node.setArcWidth(thing.getDouble("arcWidth"));
        }
        if(thing.valueExists("height")){
            node.setHeight(thing.getDouble("height"));
        }
        if(thing.valueExists("width")){
            node.setWidth(thing.getDouble("width"));
        }
        if(thing.valueExists("x")){
            node.setX(thing.getDouble("x"));
        }
        if(thing.valueExists("y")){
            node.setY(thing.getDouble("y"));
        }
    }

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

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