将散点图保存为图像

时间:2016-04-18 13:48:07

标签: java image

我想从我的阵列中保存一个点图作为图像(PNG),使用这个Java程序我可以显示我的Schatter图,但我不知道如何保存它。也许用ImageIO.write,怎么样?

public class Graph extends Application {

public void start(Stage primaryStage) {
    Pane root = new Pane();
    int[] mydata = {
            12, 9, 0, 1, 38, 19, 21, 72, 33, 83, 14, 10, 65, 46, 10, 17, 27, 38, 65, 98, 8, 58, 38, 79, 37, 69, 26, 15};

            NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();
    ScatterChart scatterChart=new ScatterChart(xAxis,yAxis);


    XYChart.Series data=new XYChart.Series();
    for (int i=0; i< mydata.length; i++) {
        data.getData().add(new XYChart.Data(i,mydata[i]));
    }       
     scatterChart.getData().addAll(data);


root.getChildren().add(scatterChart);
Scene scene = new Scene(root, 600, 400);

primaryStage.setScene(scene);
primaryStage.show();

File file = new File("c:\\Images\\Image.png");

}
public static void main(String[] args) {
    launch(args);
}
}

任何人都可以给我一些建议来解决这个问题。谢谢

0 个答案:

没有答案