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

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

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

import javafx.scene.paint.Material;
import javafx.scene.shape.CullFace;
import javafx.scene.shape.DrawMode;
import javafx.scene.shape.Shape3D;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;
import xworker.javafx.scene.NodeActions;
import xworker.javafx.util.JavaFXUtils;

public class Shape3DActions {
    static{
        PropertyFactory.regist(Shape3D.class, "materialProperty", o -> {
            Shape3D obj = (Shape3D) o;
            return obj.materialProperty();
        });
        PropertyFactory.regist(Shape3D.class, "cullFaceProperty", o -> {
            Shape3D obj = (Shape3D) o;
            return obj.cullFaceProperty();
        });
        PropertyFactory.regist(Shape3D.class, "drawModeProperty", o -> {
            Shape3D obj = (Shape3D) o;
            return obj.drawModeProperty();
        });
    }

    public static void init(Shape3D node, Thing thing, ActionContext actionContext){
        NodeActions.init(node, thing, actionContext);

        if(thing.valueExists("cullFace")){
            node.setCullFace(CullFace.valueOf(thing.getString("cullFace")));
        }
        if(thing.valueExists("drawMode")){
            node.setDrawMode(DrawMode.valueOf(thing.getString("drawMode")));
        }
        if(thing.valueExists("material")){
            Material material = JavaFXUtils.getObject(thing, "material", actionContext);
            if(material != null) {
                node.setMaterial(material);
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy