本文整理汇总了Java中javafx.scene.chart.XYChart.Data方法的典型用法代码示例。如果您正苦于以下问题:Java XYChart.Data方法的具体用法?Java XYChart.Data怎么用?Java XYChart.Data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.chart.XYChart
的用法示例。
在下文中一共展示了XYChart.Data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: seriesRemoved
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
@Override protected void seriesRemoved(Series<Number, Number> series) {
// remove all candle nodes
for (XYChart.Data<Number, Number> d : series.getData()) {
final Node candle = d.getNode();
if (shouldAnimate()) {
// fade out old candle
FadeTransition ft = new FadeTransition(Duration.millis(500), candle);
ft.setToValue(0);
ft.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
getPlotChildren().remove(candle);
}
});
ft.play();
} else {
getPlotChildren().remove(candle);
}
}
}
示例2: createChart
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
protected AreaChart<Number,Number> createChart() {
final NumberAxis xAxis = new NumberAxis(0,128,8);
final NumberAxis yAxis = new NumberAxis(0,50,10);
final AreaChart<Number,Number> ac = new AreaChart<Number,Number>(xAxis,yAxis);
// setup chart
ac.setId("audioAreaDemo");
ac.setLegendVisible(false);
ac.setTitle("Live Audio Spectrum Data");
ac.setAnimated(false);
xAxis.setLabel("Frequency Bands");
yAxis.setLabel("Magnitudes");
yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB"));
// add starting data
XYChart.Series<Number,Number> series = new XYChart.Series<Number,Number>();
series.setName("Audio Spectrum");
//noinspection unchecked
series1Data = new XYChart.Data[(int)xAxis.getUpperBound()];
for (int i=0; i<series1Data.length; i++) {
series1Data[i] = new XYChart.Data<Number,Number>(i,50);
series.getData().add(series1Data[i]);
}
ac.getData().add(series);
return ac;
}
示例3: createChart
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
protected BarChart<String, Number> createChart() {
final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis(0,50,10);
final BarChart<String,Number> bc = new BarChart<String,Number>(xAxis,yAxis);
bc.setId("barAudioDemo");
bc.setLegendVisible(false);
bc.setAnimated(false);
bc.setBarGap(0);
bc.setCategoryGap(1);
bc.setVerticalGridLinesVisible(false);
// setup chart
bc.setTitle("Live Audio Spectrum Data");
xAxis.setLabel("Frequency Bands");
yAxis.setLabel("Magnitudes");
yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis,null,"dB"));
// add starting data
XYChart.Series<String,Number> series1 = new XYChart.Series<String,Number>();
series1.setName("Data Series 1");
//noinspection unchecked
series1Data = new XYChart.Data[128];
String[] categories = new String[128];
for (int i=0; i<series1Data.length; i++) {
categories[i] = Integer.toString(i+1);
series1Data[i] = new XYChart.Data<String,Number>(categories[i],50);
series1.getData().add(series1Data[i]);
}
bc.getData().add(series1);
return bc;
}
示例4: updateSeries
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
private void updateSeries(XYChart.Series<Number, Number> series, long now, double newData) {
long elapsed = now - Time.getStartTime();
XYChart.Data<Number, Number> point = new XYChart.Data<>(elapsed, newData);
ObservableList<XYChart.Data<Number, Number>> dataList = series.getData();
if (!dataList.isEmpty()) {
// Make the graph a square wave
// This prevents the graph from appearing to be continuous when the data is discreet
// Note this only affects the chart; the actual data is not changed
double prev = dataList.get(dataList.size() - 1).getYValue().doubleValue();
if (prev != newData) {
dataList.add(new XYChart.Data<>(elapsed - 1, prev));
}
}
dataList.add(point);
realData.computeIfAbsent(series, __ -> FXCollections.observableArrayList()).add(point);
if (!chart.getData().contains(series)
&& Optional.ofNullable(visibleSeries.get(series)).map(Property::getValue).orElse(true)) {
chart.getData().add(series);
}
updateBounds(elapsed);
}
示例5: deepCopySeriesData
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
final Collection<? extends XYChart.Data<X, Y>> data) {
final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
for (final Data<X, Y> i : data) {
result.add(new Data<>(i.getXValue(), i.getYValue()));
}
return result;
}
示例6: deepCopySeriesData
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
static <X, Y> ObservableList<XYChart.Data<X, Y>> deepCopySeriesData(
final Collection<? extends XYChart.Data<X, Y>> data) {
final ObservableList<XYChart.Data<X, Y>> result = FXCollections.observableArrayList();
for (final Data<X, Y> i : data) {
result.add(new Data<>(i.getXValue(), i.getYValue()));
}
return result;
}
示例7: doZoom
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
private void doZoom(final boolean x, final Number n1, final Number n2) {
final double min = Math.min(n1.doubleValue(), n2.doubleValue());
final double max = Math.max(n1.doubleValue(), n2.doubleValue());
if (max - min > 1) {
zoomed = true;
final Iterator<XYChart.Series<X, Y>> it = chart.getData().iterator();
while (it.hasNext()) {
final XYChart.Series<X, Y> s = it.next();
final Iterator<XYChart.Data<X, Y>> it2 = s.getData().iterator();
while (it2.hasNext()) {
final XYChart.Data<X, Y> d = it2.next();
final Object value;
if (x) {
value = d.getXValue();
} else {
value = d.getYValue();
}
if (value instanceof Number) {
final Number n = (Number) value;
final double dd = n.doubleValue();
if (dd < min || dd > max) {
it2.remove();
} else {
}
}
if (s.getData().isEmpty()) {
it.remove();
}
}
}
} else {
// System.out.println("Skip tiny zoom");
}
}
示例8: getSymbolSize
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public Dimension2D getSymbolSize(final Series<X, Y> SERIES) {
if (!getData().contains(SERIES)) { return new Dimension2D(0, 0); }
if (SERIES.getData().isEmpty()) { return new Dimension2D(0, 0); }
for (XYChart.Data<X, Y> data : SERIES.getData()) {
StackPane stackPane = (StackPane) data.getNode();
if (null == stackPane) {
continue;
} else {
return new Dimension2D(stackPane.getLayoutBounds().getWidth(), stackPane.getLayoutBounds().getHeight());
}
}
return new Dimension2D(0, 0);
}
示例9: setSymbolSize
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public void setSymbolSize(final Series<X, Y> SERIES, final double SIZE) {
if (!getData().contains(SERIES)) { return; }
if (SERIES.getData().isEmpty()) { return; }
double symbolSize = Helper.clamp(0, 30, SIZE);
for (XYChart.Data<X, Y> data : SERIES.getData()) {
StackPane stackPane = (StackPane) data.getNode();
if (null == stackPane) { continue; }
stackPane.setPrefSize(symbolSize, symbolSize);
}
}
示例10: setSymbolFill
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public void setSymbolFill(final Series<X, Y> SERIES, final Background SYMBOL_BACKGROUND) {
if (!getData().contains(SERIES)) { return; }
for (XYChart.Data<X, Y> data : SERIES.getData()) {
StackPane stackPane = (StackPane) data.getNode();
if (null == stackPane) { continue; }
stackPane.setBackground(SYMBOL_BACKGROUND);
}
}
示例11: updateSeries
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
/**
* update the given chart Series
* @param series - the series to update
* @param canProperty - the canvalue to take the data from
*/
@SuppressWarnings("rawtypes")
public void updateSeries(XYChart.Series<Number, Number> series, CANProperty canProperty) {
CircularFifoQueue<?> history = canProperty.getCanValue().getHistory();
if (debug)
LOGGER.log(Level.INFO,
"plotting for " + history.size() + " history values of " + canProperty.getCanValue().canInfo.getTitle());
Date first=null;
ObservableList<Data<Number, Number>> dataList = series.getData();
// FIXME - full redraw?
dataList.clear();
for (Object historyValueObject : history) {
ValueItem<?>historyValue = (ValueItem<?>) historyValueObject;
Date timeStamp=historyValue.getTimeStamp();
if (first==null)
first=timeStamp;
Double value;
if (historyValue.getValue() instanceof Integer) {
// http://stackoverflow.com/questions/31860761/maven-compile-error-with-using-java-generics
int intValue=(Integer) historyValue.getValue();
value = new Double(intValue*1.0);
} else {
value = (Double) historyValue.getValue();
}
long minute = getMinute(timeStamp,first);
Data<Number, Number> chartData = new XYChart.Data<Number,Number>(minute,value);
dataList.add(chartData);
}
}
示例12: convertFromXYChartData
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
public static <X, Y extends Number> List<Data> convertFromXYChartData(final List<XYChart.Data<X, Y>> DATA_LIST) {
List<Data> dataList = new ArrayList<>(DATA_LIST.size());
DATA_LIST.forEach(xyChartData -> dataList.add(new Data(xyChartData.getXValue(), xyChartData.getYValue().doubleValue())));
return dataList;
}
示例13: createData
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
private List<XYChart.Data<Number, Number>> createData() {
DoubleStream xValues = DoubleStream.iterate(0, n -> n + 1.0 / NUMBER_OF_X_VALUES).limit(NUMBER_OF_X_VALUES);
return xValues.mapToObj(this::createDataPoint).collect(Collectors.toList());
}
示例14: instancetoChartData
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
private XYChart.Data<Number, Number> instancetoChartData(Instance i) {
return new XYChart.Data<Number, Number>(i.value(0), i.value(1));
}
示例15: createDataPoint
import javafx.scene.chart.XYChart; //导入方法依赖的package包/类
private XYChart.Data<Number, Number> createDataPoint(double x) {
XYChart.Data<Number, Number> dataPoint = new XYChart.Data<>();
dataPoint.setXValue(x);
return dataPoint;
}