本文整理汇总了Java中com.sun.javafx.charts.Legend.LegendItem类的典型用法代码示例。如果您正苦于以下问题:Java LegendItem类的具体用法?Java LegendItem怎么用?Java LegendItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LegendItem类属于com.sun.javafx.charts.Legend包,在下文中一共展示了LegendItem类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLegendTextFill
import com.sun.javafx.charts.Legend.LegendItem; //导入依赖的package包/类
public void setLegendTextFill(final Series<X, Y> SERIES, final Paint FILL) {
if (getData().isEmpty()) { return; }
if (!getData().contains(SERIES)) { return; }
int seriesIndex = getData().indexOf(SERIES);
if (seriesIndex == -1) { return; }
Legend legend = (Legend) getLegend();
if (null == legend) { return; }
LegendItem item = legend.getItems().get(seriesIndex);
if (null == item) { return; }
String itemText = item.getText();
for (Node node : legend.lookupAll(".chart-legend-item")) {
if (node instanceof Label) {
Label label = (Label) node;
if (label.getText().equals(itemText)) { label.setTextFill(FILL); }
}
}
}
示例2: setLegendSymbolFill
import com.sun.javafx.charts.Legend.LegendItem; //导入依赖的package包/类
public void setLegendSymbolFill(final Series<X, Y> SERIES, final Paint LEGEND_SYMBOL_FILL) {
if (getData().isEmpty()) { return; }
if (!getData().contains(SERIES)) { return; }
int seriesIndex = getData().indexOf(SERIES);
if (seriesIndex == -1) { return; }
Legend legend = (Legend) getLegend();
if (null == legend) { return; }
LegendItem item = legend.getItems().get(seriesIndex);
if (null == item) { return; }
Region symbol = (Region) item.getSymbol();
if (null == symbol) { return; }
symbol.setBackground(new Background(new BackgroundFill(LEGEND_SYMBOL_FILL, new CornerRadii(6), Insets.EMPTY)));
}
示例3: updateLegend
import com.sun.javafx.charts.Legend.LegendItem; //导入依赖的package包/类
/**
* This is called whenever a series is added or removed and the legend needs to
* be updated
*/
@Override
protected void updateLegend() {
legend.getItems().clear();
if (getData() != null) {
for (int seriesIndex = 0; seriesIndex < getData().size(); seriesIndex++) {
MultiAxisChart.Series<X, Y> series = getData().get(seriesIndex);
LegendItem legenditem = new LegendItem(series.getName());
legenditem.getSymbol().getStyleClass().addAll("chart-area-symbol", "series" + seriesIndex,
"area-legend-symbol", series.defaultColorStyleClass);
legend.getItems().add(legenditem);
}
}
if (legend.getItems().size() > 0) {
if (getLegend() == null) {
setLegend(legend);
}
} else {
setLegend(null);
}
}
示例4: updateLegend
import com.sun.javafx.charts.Legend.LegendItem; //导入依赖的package包/类
/**
* This is called whenever a series is added or removed and the legend needs to
* be updated
*/
@Override
protected void updateLegend() {
legend.getItems().clear();
if (getData() != null) {
for (int seriesIndex = 0; seriesIndex < getData().size(); seriesIndex++) {
Series<X, Y> series = getData().get(seriesIndex);
LegendItem legenditem = new LegendItem(series.getName());
legenditem.getSymbol().getStyleClass().addAll("chart-line-symbol", "series" + seriesIndex,
series.defaultColorStyleClass);
legend.getItems().add(legenditem);
}
}
if (legend.getItems().size() > 0) {
if (getLegend() == null) {
setLegend(legend);
}
} else {
setLegend(null);
}
}
示例5: updateLegend
import com.sun.javafx.charts.Legend.LegendItem; //导入依赖的package包/类
/**
* This is called whenever a series is added or removed and the legend needs to
* be updated
*/
@Override
protected void updateLegend() {
legend.getItems().clear();
if (getData() != null) {
for (int seriesIndex = 0; seriesIndex < getData().size(); seriesIndex++) {
Series<X, Y> series = getData().get(seriesIndex);
LegendItem legenditem = new LegendItem(series.getName());
legenditem.getSymbol().getStyleClass().addAll("chart-bar", "series" + seriesIndex, "bar-legend-symbol",
series.defaultColorStyleClass);
legend.getItems().add(legenditem);
}
}
if (legend.getItems().size() > 0) {
if (getLegend() == null) {
setLegend(legend);
}
} else {
setLegend(null);
}
}
示例6: updateLegend
import com.sun.javafx.charts.Legend.LegendItem; //导入依赖的package包/类
/**
* This is called whenever a series is added or removed and the legend needs to
* be updated
*/
@Override
protected void updateLegend() {
legend.getItems().clear();
if (getData() != null) {
for (int seriesIndex = 0; seriesIndex < getData().size(); seriesIndex++) {
MultiAxisChart.Series<X, Y> series = getData().get(seriesIndex);
LegendItem legenditem = new LegendItem(series.getName());
if (!series.getData().isEmpty() && series.getData().get(0).getNode() != null) {
legenditem.getSymbol().getStyleClass().addAll(series.getData().get(0).getNode().getStyleClass());
}
legend.getItems().add(legenditem);
}
}
if (legend.getItems().size() > 0) {
if (getLegend() == null) {
setLegend(legend);
}
} else {
setLegend(null);
}
}
示例7: getLegends
import com.sun.javafx.charts.Legend.LegendItem; //导入依赖的package包/类
protected ArrayList<NamedLegend> getLegends() {
ArrayList<NamedLegend> legends = new ArrayList<NamedLegend>();
Boolean vertical[] = {false, true};
int items_num[] = {0, 1, 5, 100};
for (int i = 0; i < vertical.length; i++) {
for (int j = 0; j < items_num.length; j++) {
NamedLegend legend = new NamedLegend(vertical[i] ? "vert" : "false" + " " + items_num[j]);
for (int k = 0; k < items_num[j]; k++) {
legend.getItems().add(new LegendItem("Item " + k));
}
legends.add(legend);
}
}
return legends;
}