Created
March 15, 2022 21:34
-
-
Save PragmaticCoding/f0e42ebf77f2e73ea4677374f77b037e to your computer and use it in GitHub Desktop.
Demo Showing Custom Node for Z-Graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AreaChartDemo extends Application { | |
public static void main(String[] args) { | |
launch(args); | |
} | |
private Point2D firstClick = null; | |
private float SND(double x) { | |
return (float) ((1 / Math.sqrt(2 * Math.PI)) * Math.pow(Math.E, -Math.pow(x, 2) / 2)); | |
} | |
public XYChart.Series<Number, Number> create_z_chart(Float segments) { | |
XYChart.Series<Number, Number> series = new XYChart.Series<>(); | |
for (float i = -4; i < 4; i += 4 / segments) { | |
XYChart.Data<Number, Number> value = new XYChart.Data<>(i, SND(i)); | |
System.out.println(i); | |
if ((i > 0.96) && (i < 1.03)) { | |
value.setNode(new Label("Right Here")); | |
} else { | |
value.setNode(new Circle(.0)); | |
} | |
series.getData().add(value); | |
System.out.println(value.getNode()); | |
} | |
return series; | |
} | |
@Override | |
public void start(Stage stage) throws Exception { | |
NumberAxis x = new NumberAxis(-4, 4, 1); | |
x.setLabel("Z"); | |
NumberAxis y = new NumberAxis(); | |
y.setLabel("Probability Density"); | |
AreaChart<Number, Number> areaChart = new AreaChart<>(x, y); | |
XYChart.Series<Number, Number> z_series = create_z_chart(100.0F); | |
areaChart.getData().add(z_series); | |
z_series.setName("Z chart"); | |
areaChart.setCreateSymbols(true); | |
Scene scene = new Scene(areaChart, 420, 420); | |
stage.setScene(scene); | |
stage.show(); | |
stage.setTitle("Z table"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment