de.gsi.chart.utils.XYChartUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chartfx-chart Show documentation
Show all versions of chartfx-chart Show documentation
This charting library ${project.artifactId}- is an extension
in the spirit of Oracle's XYChart and performance/time-proven JDataViewer charting functionalities.
Emphasis was put on plotting performance for both large number of data points and real-time displays,
as well as scientific accuracies leading to error bar/surface plots, and other scientific plotting
features (parameter measurements, fitting, multiple axes, zoom, ...).
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package de.gsi.chart.utils;
import java.util.LinkedList;
import java.util.List;
import de.gsi.chart.Chart;
import de.gsi.chart.XYChart;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
/**
* @author braeun
*/
public final class XYChartUtils {
private XYChartUtils() {
}
public static double getLocationX(final Node node) {
return node.getLayoutX() + node.getTranslateX();
}
public static double getLocationY(final Node node) {
return node.getLayoutY() + node.getTranslateY();
}
public static Region getChartContent(final Chart chart) {
return (Region) chart.lookup(".chart-content");
}
public static Node getPlotContent(final XYChart chart) {
return chart.lookup(".plot-content");
}
public static Pane getLegend(final XYChart chart) {
return (Pane) chart.lookup(".chart-legend");
}
public static double getHorizontalInsets(final Insets insets) {
return insets.getLeft() + insets.getRight();
}
public static double getVerticalInsets(final Insets insets) {
return insets.getTop() + insets.getBottom();
}
/**
* Returns Chart instance containing given child node.
*
* @param chartChildNode the node contained within the chart
* @return chart or {@code null} if the node does not belong to chart
*/
public static Chart getChart(final Node chartChildNode) {
Node node = chartChildNode;
while (node != null && !(node instanceof Chart)) {
node = node.getParent();
}
return (Chart) node;
}
public static List