本文整理汇总了Java中javafx.scene.chart.XYChart.Data类的典型用法代码示例。如果您正苦于以下问题:Java Data类的具体用法?Java Data怎么用?Java Data使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Data类属于javafx.scene.chart.XYChart包,在下文中一共展示了Data类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDataItemStrNum
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
public static void addDataItemStrNum(final XYChart<String, Number> chart) {
if (chart.getData() == null) {
chart.setData(FXCollections.<XYChart.Series<String, Number>>observableArrayList());
}
if (chart.getData().isEmpty()) {
chart.getData().add(new XYChart.Series<String, Number>());
}
int sIndex = (int) (Math.random() * chart.getData().size());
XYChart.Series<String, Number> series = chart.getData().get(sIndex);
Set<String> existingYears = new HashSet<String>();
for (Data<String, Number> data : series.getData()) {
existingYears.add(data.getXValue());
}
int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
while (existingYears.contains(Integer.toString(randomYear))) {
randomYear++;
}
series.getData().add(new XYChart.Data<String, Number>(Integer.toString(randomYear), 10 + (Math.random() * 3800)));
}
示例2: addDataItemNumStr
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
public static void addDataItemNumStr(final XYChart<Number, String> chart) {
if (chart.getData() == null) {
chart.setData(FXCollections.<XYChart.Series<Number, String>>observableArrayList());
}
if (chart.getData().isEmpty()) {
chart.getData().add(new XYChart.Series<Number, String>());
}
int sIndex = (int) (Math.random() * chart.getData().size());
XYChart.Series<Number, String> series = chart.getData().get(sIndex);
Set<String> existingYears = new HashSet<String>();
for (Data<Number, String> data : series.getData()) {
existingYears.add(data.getYValue());
}
int randomYear = 1900 + (int) (Math.round(12 * Math.random()) * 10);
while (existingYears.contains(Integer.toString(randomYear))) {
randomYear++;
}
series.getData().add(new XYChart.Data<Number, String>(10 + (Math.random() * 3800), Integer.toString(randomYear)));
}
示例3: swapClusteredChartSeriesColors
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
private void swapClusteredChartSeriesColors() {
List<Series<Number, Number>> clusteredSeries = new ArrayList<>();
// we have to copy the original data to swap the series
clusteredChart.getData().forEach(serie -> {
Series<Number, Number> series = new Series<>();
series.setName(serie.getName());
serie.getData().stream().map(d -> new Data<Number, Number>(d.getXValue(), d.getYValue()))
.forEach(series.getData()::add);
clusteredSeries.add(series);
});
int i = swapColorsCombinations[swapIndex][0];
int j = swapColorsCombinations[swapIndex][1];
Collections.swap(clusteredSeries, i, j);
clusteredChart.getData().clear();
clusteredChart.getData().addAll(clusteredSeries);
swapIndex = swapIndex == NUMBER_OF_CLASSES - 1 ? 0 : swapIndex + 1;
}
示例4: newData
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
@Override
public void newData(byte[] data) {
if(data[0] == FlashboardXYChart.VALUE_UPDATE){
synchronized (dataCollection) {
double x = FlashUtil.toDouble(data, 1);
double y = FlashUtil.toDouble(data, 9);
dataCollection.add(new Data<Number, Number>(x, y));
}
}
if(data[0] == FlashboardXYChart.CONFIG_UPDATE){
synchronized (configMutex) {
minX = FlashUtil.toDouble(data, 1);
maxX = FlashUtil.toDouble(data, 9);
minY = FlashUtil.toDouble(data, 17);
maxY = FlashUtil.toDouble(data, 25);
configUpdate = true;
}
}
}
示例5: update
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
@Override
protected void update() {
synchronized (configMutex) {
if(configUpdate){
configUpdate = false;
axisY.setUpperBound(maxY);
axisY.setLowerBound(minY);
}
}
Enumeration<BarChartSeriesControl> controlEnum = controls.elements();
while(controlEnum.hasMoreElements()){
BarChartSeriesControl control = controlEnum.nextElement();
if(control.hasData()){
double dataY = Mathf.roundDecimal(control.getData());
Data<String, Number> data = new Data<String, Number>(control.getName(), dataY);
//chart.setTitle(getName()+": "+dataY);
chartSeries.getData().add(data);
((StackPane)data.getNode()).getChildren().add(new Label(String.valueOf(dataY)));
}
}
}
示例6: deepCopySeriesData
import javafx.scene.chart.XYChart.Data; //导入依赖的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: deepCopySeriesData
import javafx.scene.chart.XYChart.Data; //导入依赖的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;
}
示例8: getValue
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
@Override
public Data<String, Number> getValue(int columnIndex, String columnName, int row) {
Map<String, List<Map<String, String>>> map = this.rows.get().get(row);
List<Map<String, String>> list = map.get("c");
Map<String, String> dateInfo = list.get(0);
Map<String, String> query = list.get(columnIndex + 1);
if (query == null)
return null;
String colName = dateInfo.get("f");
String value = query.get("f");
if (colName == null || value == null)
return null;
Integer valueOf = Integer.valueOf(value, 10);
return new Data<>(colName, valueOf);
}
示例9: initialize
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
@FXML
public void initialize() {
items.addListener(this);
// chart.getData().add(chartSeries);
slider.setMin(0D);
slider.setMax(displaySize.get());
this.displaySize.bind(slider.maxProperty());
slider.valueProperty().addListener((oba, oldval, newval) -> {
int start = newval.intValue();
int end = (int) (start + displaySize.get());
if (end > items.size())
end = items.size();
ObservableList<Data<String, Number>> subList = items.stream().skip(start).limit(5).map(v -> converter.apply(v))
.collect(FxCollectors.toObservableList());
Series<String, Number> chartSeries = new Series<>("", subList);
chart.getData().remove(0);
chart.getData().add(chartSeries);
});
}
示例10: setDataNode
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
private void setDataNode(SVNLogEntry entry, Data<String, String> data) {
Group group = new Group();
group.setManaged(false);
Text value = new Text(entry.getRevision() + "");
value.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
value.translateYProperty().set(-15);
Circle circle = new Circle(4, Color.WHITE);
circle.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
circle.setStroke(Color.web("#f3622d"));
StackPane stackPane = new StackPane(value, circle);
stackPane.setPrefSize(30, 60);
group.getChildren().add(stackPane);
data.setNode(group);
}
示例11: seriesLegendLabelCustomAction
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
@Override
public void seriesLegendLabelCustomAction(Data t, Node u) {
// u.setOnMouseEntered(ev -> {
// u.setCursor(Cursor.HAND);
// });
//
// u.setOnMouseExited(ev -> {
// u.setCursor(Cursor.DEFAULT);
// });
//
// u.setOnMouseClicked(ev -> {
//
// ListView<RuleViolation> lvViolation = this.checkedListComposite.getLvViolation();
// ObservableList<RuleViolation> items = lvViolation.getItems();
// ObservableList<RuleViolation> violationList = this.checkedListComposite.getViolationList();
// List<RuleViolation> collect = violationList.stream().filter(ruleViolationFilter())
// .filter(v -> ValueUtil.equals(t.getName(), ValueUtil.getSimpleFileName(v.getFilename()))).collect(Collectors.toList());
// items.setAll(collect);
//
// });
}
示例12: getChartData
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
public static ObservableList<XYChart.Series<String, Number>> getChartData()
{
Debugger.out("Diagramm getChartData says : Hello ! ");
if (Data != null || Data.get(0).equals(null))
{
resetData();
} else
{
Logger.out("ObservableList Data in Diagramm is already empty");
}
getKarteien();
getPunkte();
for (int i = 0; i < Stacks.size(); i++)
{
Series<String, Number> thisSerie = new Series<String, Number>();
thisSerie.setName(Stacks.get(i));
Number forChart = (Number) Punkte.get(i);
thisSerie.getData().add(new Data<String, Number>(Stacks.get(i), forChart));
Data.add(thisSerie);
}
return Data;
}
示例13: plotProjections
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
private static void plotProjections(ScatterChart<Number, Number> chart,
AnchorPane overlay, List<Label> labels, List<Data<Number,Number>> data,
Projection[] projections, String name, double[][][] points) {
final Series<Number, Number> series = new Series<Number, Number>();
series.setName(name);
for (Projection projection: projections) {
System.out.print(projection+": ");
final double[] params = projection.getDefaultParameters();
final double distortion[] = projection.avgDistortion(points, params);
final Data<Number, Number> datum = new Data<Number, Number>(
distortion[0]/DECIBEL, distortion[1]/DECIBEL);
series.getData().add(datum);
final Label lbl = new Label(projection.getName());
overlay.getChildren().add(lbl);
labels.add(lbl);
data.add(datum);
System.out.println(distortion[0]+", "+distortion[1]);
}
chart.getData().add(series);
}
示例14: drawLabelsAndSave
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
private void drawLabelsAndSave(ScatterChart<Number,Number> chart,
List<Label> labels, List<Data<Number,Number>> data) {
for (int i = 0; i < labels.size(); i ++) {
AnchorPane.setLeftAnchor(labels.get(i),
chart.getXAxis().localToParent(chart.getXAxis().getDisplayPosition(data.get(i).getXValue()), 0).getX() + chart.getPadding().getLeft() + 3);
AnchorPane.setTopAnchor(labels.get(i),
chart.getYAxis().localToParent(0, chart.getYAxis().getDisplayPosition(data.get(i).getYValue())).getY() + chart.getPadding().getTop() - labels.get(i).getHeight()
);
}
Platform.runLater(() -> {
try {
ImageIO.write(
SwingFXUtils.fromFXImage(stack.snapshot(null, null), null),
"png", new File("output/graph - plotter.png"));
} catch (IOException e) {
e.printStackTrace();
}
});
}
示例15: updateExpectedPulse
import javafx.scene.chart.XYChart.Data; //导入依赖的package包/类
public void updateExpectedPulse(){
chart.getData().remove(expectedPulseSeries);
if(showExpectedIncidentPulseCheckBox.isSelected() && getActivatedData() instanceof IncidentPulse && strikerBar.isValid() && barSetup != null){
IncidentPulse pulse = (IncidentPulse)getActivatedData();
expectedPulseSeries = new XYChart.Series<Number, Number>();
expectedPulseSeries.setName("Expected Incident Pulse");
ArrayList<Data<Number, Number>> expectedPulseDataPoints = new ArrayList<Data<Number, Number>>();
int begin = getChartBeginIndex();
int end = getChartEndIndex();
int totalDataPoints = end - begin;
double[] xData = getActivatedData().Data.timeData;
xData = Arrays.stream(xData).map(x -> x * timeUnits.getMultiplier()).toArray();
for (int i = begin; i <= end; i++) {
int sign = isCompressionSample ? -1 : 1;
if (i >= getActivatedData().getBegin() && i <= getActivatedData().getEnd()) {
expectedPulseDataPoints
.add(new Data<Number, Number>(xData[i], sign * barSetup.IncidentBar.getExpectedPulse(strikerBar,pulse.strainGauge)) );
}
i += totalDataPoints / dataPointsToShow;
}
expectedPulseSeries.getData().addAll(expectedPulseDataPoints);
chart.getData().add(expectedPulseSeries);
}
}