Styl legendy JavaFX LineChart

Chcę zaktualizować styl legendy LineChart i używając setStyle na węzłach z klasą serii correspoding.

String color = ....
XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
_chart.getData().add(series);

String seriesClass = null;
for(String styleClass : series.getNode().getStyleClass())
{
    if(styleClass.startsWith("series"))
    {
        seriesClass = styleClass;
        break;
    }
}
if(seriesClass != null)
{
    //
    // Customize the style.
    //
    StringBuilder sb = new StringBuilder();
    sb.append("-fx-stroke: ");
    sb.append(color);
    sb.append("; ");
    sb.append("-fx-background-color: ");
    sb.append(color);
    sb.append(", white;");
    if(doted)
    {
        sb.append("-fx-stroke-dash-array: 10 10");
    }
    _styles.put(seriesClass, sb.toString()); 
}

java.util.Set<javafx.scene.Node> nodes = _chart.lookupAll("." + seriesClass);
for(javafx.scene.Node n : nodes)
{
    n.setStyle(style);
}

Rzecz w tym, że wpływa to tylko na styl ścieżki, styl legendy się nie zmienia. Wydrukowałem dzieci z węzła wykresu i widzę, że legendy nie są w pełni tworzone po dodaniu zwrotów wywołania serii:

Legend@18e8627[styleClass=chart-legend]
    Label@1689c98[styleClass=label chart-legend-item]
    Label@100e4ce[styleClass=label chart-legend-item]
    Label@1adcb5e[styleClass=label chart-legend-item]
    Label@102a8fb[styleClass=label chart-legend-item]

Nieco później, gdy ponownie wydrukuję dzieci:

Legend@9a095[styleClass=chart-legend]
    Label[id=null, styleClass=label chart-legend-item]
        LabelSkin[id=null, styleClass=label chart-legend-item]
            Region@12acafc[styleClass=chart-legend-item-symbol chart-line-symbol series0 default-color0]
            LabeledText@749a47[styleClass=text]
    Label[id=null, styleClass=label chart-legend-item]
        LabelSkin[id=null, styleClass=label chart-legend-item]
            Region@3ca3a4[styleClass=chart-legend-item-symbol chart-line-symbol series1 default-color1]
            LabeledText@11b9972[styleClass=text]
    Label[id=null, styleClass=label chart-legend-item]
        LabelSkin[id=null, styleClass=label chart-legend-item]
            Region@57f433[styleClass=chart-legend-item-symbol chart-line-symbol series2 default-color2]
            LabeledText@6172b5[styleClass=text]
    Label[id=null, styleClass=label chart-legend-item]
        LabelSkin[id=null, styleClass=label chart-legend-item]
            Region@16458ed[styleClass=chart-legend-item-symbol chart-line-symbol series3 default-color3]
            LabeledText@10a68bd[styleClass=text]

Jeśli teraz zaktualizuję styl, styl legendy zostanie zaktualizowany poprawnie.

Skąd mogę wiedzieć, kiedy dodano dziecko Regionu z klasami potrzebnymi do ustawienia stylu, więc mogę ustawićStyle na tych węzłach?

wszelkie inne pomysły na aktualizację stylu legendy po dodaniu nowej serii?

questionAnswers(3)

yourAnswerToTheQuestion