xworker.javafx.scene.chart.PieChartActions Maven / Gradle / Ivy
package xworker.javafx.scene.chart;
import javafx.collections.ObservableList;
import javafx.scene.chart.PieChart;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import xworker.javafx.beans.property.PropertyFactory;
import xworker.javafx.util.JavaFXUtils;
public class PieChartActions {
static{
PropertyFactory.regist(PieChart.class, "dataProperty", o -> {
PieChart obj = (PieChart) o;
return obj.dataProperty();
});
PropertyFactory.regist(PieChart.class, "startAngleProperty", o -> {
PieChart obj = (PieChart) o;
return obj.startAngleProperty();
});
PropertyFactory.regist(PieChart.class, "clockwiseProperty", o -> {
PieChart obj = (PieChart) o;
return obj.clockwiseProperty();
});
PropertyFactory.regist(PieChart.class, "labelLineLengthProperty", o -> {
PieChart obj = (PieChart) o;
return obj.labelLineLengthProperty();
});
PropertyFactory.regist(PieChart.class, "labelsVisibleProperty", o -> {
PieChart obj = (PieChart) o;
return obj.labelsVisibleProperty();
});
}
public static void init(PieChart node, Thing thing, ActionContext actionContext){
ChartActions.init(node, thing, actionContext);
if(thing.valueExists("clockwise")){
node.setClockwise(thing.getBoolean("clockwise"));
}
if(thing.valueExists("data")){
ObservableList data = JavaFXUtils.getObject(thing, "data", actionContext);
if(data != null) {
node.setData(data);
}
}
if(thing.valueExists("labelLineLength")){
node.setLabelLineLength(thing.getDouble("labelLineLength"));
}
if(thing.valueExists("labelsVisible")){
node.setLabelsVisible(thing.getBoolean("labelsVisible"));
}
if(thing.valueExists("startAngle")){
node.setStartAngle(thing.getDouble("startAngle"));
}
}
public static PieChart create(ActionContext actionContext){
Thing self = actionContext.getObject("self");
PieChart node = new PieChart();
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;
}
}