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

xworker.javafx.scene.GroupActions Maven / Gradle / Ivy

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

import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;

public class GroupActions {
	static{
		PropertyFactory.regist(Group.class, "autoSizeChildrenProperty", o -> {
			Group obj = (Group) o;
			return obj.autoSizeChildrenProperty();
		});
	}

	public static void init(Group group, Thing thing, ActionContext actionContext) {
		if(thing.valueExists("autoSizeChildren")) {
			group.setAutoSizeChildren(thing.getBoolean("autoSizeChildren"));
		}
	}
	
	public static Group create(ActionContext actionContext) {
		Thing self = actionContext.getObject("self");
		Object parent = actionContext.getObject("parent");
		
		Group group = new Group();
		init(group, self, actionContext);
		actionContext.g().put(self.getMetadata().getName(), group);
		
		actionContext.peek().put("parent", group);
		for(Thing child : self.getChilds()) {
			Object obj = child.doAction("create", actionContext);
			if(obj instanceof Node) {
				group.getChildren().add((Node) obj);
			}
		}
		
		if(parent instanceof Scene) {
			((Scene) parent).setRoot(group);
		}
		
		return group;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy