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

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

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

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

public class ArcActions {
    static{
        PropertyFactory.regist(Arc.class, "centerYProperty", o -> {
            Arc obj = (Arc) o;
            return obj.centerYProperty();
        });
        PropertyFactory.regist(Arc.class, "centerXProperty", o -> {
            Arc obj = (Arc) o;
            return obj.centerXProperty();
        });
        PropertyFactory.regist(Arc.class, "radiusYProperty", o -> {
            Arc obj = (Arc) o;
            return obj.radiusYProperty();
        });
        PropertyFactory.regist(Arc.class, "radiusXProperty", o -> {
            Arc obj = (Arc) o;
            return obj.radiusXProperty();
        });
        PropertyFactory.regist(Arc.class, "typeProperty", o -> {
            Arc obj = (Arc) o;
            return obj.typeProperty();
        });
        PropertyFactory.regist(Arc.class, "lengthProperty", o -> {
            Arc obj = (Arc) o;
            return obj.lengthProperty();
        });
        PropertyFactory.regist(Arc.class, "startAngleProperty", o -> {
            Arc obj = (Arc) o;
            return obj.startAngleProperty();
        });
    }

    public static void init(Arc 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("length")){
            node.setLength(thing.getDouble("length"));
        }
        if(thing.valueExists("radiusX")){
            node.setRadiusX(thing.getDouble("radiusX"));
        }
        if(thing.valueExists("radiusY")){
            node.setRadiusY(thing.getDouble("radiusY"));
        }
        if(thing.valueExists("startAngle")){
            node.setStartAngle(thing.getDouble("startAngle"));
        }
        if(thing.valueExists("type")){
            node.setType(ArcType.valueOf(thing.getString("type")));
        }
    }

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

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