Search in sources :

Example 1 with Legend

use of com.sun.javafx.charts.Legend in project Gargoyle by callakrsos.

the class AttachedTextValuePieChart method layoutChartChildren.

/* (non-Javadoc)
	 * @see javafx.scene.chart.PieChart#layoutChartChildren(double, double, double, double)
	 */
@Override
protected void layoutChartChildren(double top, double left, double contentWidth, double contentHeight) {
    if (getLabelsVisible()) {
        getData().forEach(d -> {
            if (tooltipConverter != null || customAction != null) {
                d.getNode().lookupAll(".chart-pie").stream().forEach(v -> {
                    if (tooltipConverter != null)
                        FxUtil.installTooltip(v, tooltipConverter.toString(d));
                    if (customAction != null) {
                        customAction.accept(d, v);
                    }
                });
            }
            if (labelConverter != null) {
                Optional<Node> opTextNode = this.lookupAll(".chart-pie-label").stream().filter(n -> n instanceof Text && ((Text) n).getText().contains(d.getName())).findAny();
                if (opTextNode.isPresent()) {
                    Text text = (Text) opTextNode.get();
                    text.setText(labelConverter.toString(d));
                }
            }
        });
    //			Legend legend = (Legend) getLegend();
    //			legend.getItems().forEach(item->{
    //				
    //				item.
    //				
    //			});
    //			if (isLegendVisible() && seriesLegendLabelCustomAction != null) {
    //				this.lookupAll(".chart-legend-item").stream().forEach(v -> {
    //					System.out.println(v);
    //				});
    //			}
    }
    super.layoutChartChildren(top, left, contentWidth, contentHeight);
}
Also used : Text(javafx.scene.text.Text) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) PieChart(javafx.scene.chart.PieChart) Legend(com.sun.javafx.charts.Legend) Node(javafx.scene.Node) BiConsumer(java.util.function.BiConsumer) Optional(java.util.Optional) StringConverter(javafx.util.StringConverter) Node(javafx.scene.Node) Text(javafx.scene.text.Text)

Aggregations

FxUtil (com.kyj.fx.voeditor.visual.util.FxUtil)1 Legend (com.sun.javafx.charts.Legend)1 Optional (java.util.Optional)1 BiConsumer (java.util.function.BiConsumer)1 Node (javafx.scene.Node)1 PieChart (javafx.scene.chart.PieChart)1 Text (javafx.scene.text.Text)1 StringConverter (javafx.util.StringConverter)1