当前位置: 首页>>代码示例>>Java>>正文


Java ScatterChart类代码示例

本文整理汇总了Java中javafx.scene.chart.ScatterChart的典型用法代码示例。如果您正苦于以下问题:Java ScatterChart类的具体用法?Java ScatterChart怎么用?Java ScatterChart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ScatterChart类属于javafx.scene.chart包,在下文中一共展示了ScatterChart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
private void init(Stage primaryStage) {
    VBox root  = new VBox();
    fpsLabel = new Label("FPS:");
    fpsLabel.setStyle("-fx-font-size: 5em;-fx-text-fill: red;");
    fpsLabel.setOnMouseClicked((event) -> {
        tracker.resetAverageFPS();
    });


    FlowPane flow = new FlowPane();
    flow.setCache(true);
    flow.setCacheHint(CacheHint.SPEED);
    root.getChildren().addAll(fpsLabel,flow);
    Scene scene = new Scene(root, 500, 2000);
    createPerformanceTracker(scene);
    primaryStage.setScene(scene);
    List< ScatterChart<Number, Number>> result = new ArrayList<>();
    for(int i =0; i<10;i++) {
        ScatterChart<Number, Number> tmp = createChart();
        result.add(tmp);
    }
    flow.getChildren().setAll(result);
}
 
开发者ID:amoAHCP,项目名称:JavaOne2015JavaFXPitfalls,代码行数:24,代码来源:AdvancedScatterChartSample.java

示例2: createChart

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setSide(Side.TOP);
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setSide(Side.RIGHT);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<5;s++) {
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Data Series "+s);
        for (int i=0; i<30; i++) series.getData().add(new XYChart.Data<Number, Number>(Math.random()*98, Math.random()*98));
        sc.getData().add(series);
    }
    return sc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ChartAdvancedScatter.java

示例3: createChart

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setForceZeroInRange(false);
    final NumberAxis yAxis = new NumberAxis(-100,100,10);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    sc.setId("liveScatterChart");
    sc.setTitle("Animated Sine Wave ScatterChart");
    xAxis.setLabel("X Axis");
    xAxis.setAnimated(false);
    yAxis.setLabel("Y Axis");
    yAxis.setAutoRanging(false);
    // add starting data
    series = new ScatterChart.Series<Number,Number>();
    series.setName("Sine Wave");
    series.getData().add(new ScatterChart.Data<Number, Number>(5d, 5d));
    sc.getData().add(series);
    return sc;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ChartAdvancedScatterLive.java

示例4: ScatterChartSample

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
public ScatterChartSample() {
    NumberAxis xAxis = new NumberAxis("X-Axis", 0d, 8.0d, 1.0d);
    NumberAxis yAxis = new NumberAxis("Y-Axis", 0.0d, 5.0d, 1.0d);
    ObservableList<XYChart.Series> data = FXCollections.observableArrayList(
        new ScatterChart.Series("Series 1", FXCollections.<ScatterChart.Data>observableArrayList(
            new XYChart.Data(0.2, 3.5),
            new XYChart.Data(0.7, 4.6),
            new XYChart.Data(1.8, 1.7),
            new XYChart.Data(2.1, 2.8),
            new XYChart.Data(4.0, 2.2),
            new XYChart.Data(4.1, 2.6),
            new XYChart.Data(4.5, 2.0),
            new XYChart.Data(6.0, 3.0),
            new XYChart.Data(7.0, 2.0),
            new XYChart.Data(7.8, 4.0)
        ))
    );
    ScatterChart chart = new ScatterChart(xAxis, yAxis, data);
    getChildren().add(chart);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:ScatterChartSample.java

示例5: start

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
    
    BorderPane buttonPane = getButtonPane();
    
    borderPane.setTop(buttonPane);
    
    controller = new DataController(x_bounds,y_bounds,initial_k,initial_data_points);
    KMeansGraph kmg = new KMeansGraph(x_bounds,y_bounds);
    ScatterChart sc = kmg.drawGraph(controller.getCentroidToDataPoint(), controller.getCentroids());
    borderPane.setCenter(sc);
    
    StackPane root = new StackPane();

    root.getChildren().add(borderPane);
    Scene scene = new Scene(root, SCREEN_WIDTH, SCREEN_HEIGHT);
    
    primaryStage.setTitle("K Means");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
开发者ID:katharinebeaumont,项目名称:Cluster,代码行数:22,代码来源:Cluster.java

示例6: plotProjections

import javafx.scene.chart.ScatterChart; //导入依赖的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);
}
 
开发者ID:jkunimune15,项目名称:Map-Projections,代码行数:23,代码来源:MapPlotter.java

示例7: drawLabelsAndSave

import javafx.scene.chart.ScatterChart; //导入依赖的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();
			}
		});
}
 
开发者ID:jkunimune15,项目名称:Map-Projections,代码行数:20,代码来源:MapPlotter.java

示例8: createScene

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
private static Scene createScene() {

        javafx.scene.chart.NumberAxis myaxis1 = new javafx.scene.chart.NumberAxis();
        javafx.scene.chart.NumberAxis myaxis2 = new javafx.scene.chart.NumberAxis();

        ScatterChart sc = new ScatterChart(myaxis1, myaxis2);
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName(plotName);
        sc.setTitle(plotTitle);
        int N = pointsX.length;
        for (int k = 0; k < N; k++)
            series.getData().add(new XYChart.Data<Number, Number>(pointsX[k], pointsY[k]));

        sc.getData().add(series);

        BorderPane pane = new BorderPane();

        pane.setCenter(sc);

        Scene myScene = new Scene(pane, Color.ALICEBLUE);

        return myScene;
    }
 
开发者ID:scalalab,项目名称:scalalab,代码行数:24,代码来源:javaFXPlotScatter.java

示例9: createChart

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
protected ScatterChart<Number, Number> createChart() {
    final NumberAxis xAxis = new NumberAxis();
    xAxis.setSide(Side.TOP);
    final NumberAxis yAxis = new NumberAxis();
    yAxis.setSide(Side.RIGHT);
    final ScatterChart<Number,Number> sc = new ScatterChart<Number,Number>(xAxis,yAxis);
    // setup chart
    xAxis.setLabel("X Axis");
    yAxis.setLabel("Y Axis");
    // add starting data
    for (int s=0;s<5;s++) {
        XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
        series.setName("Data Series "+s);
        for (int i=0; i<30; i++) series.getData().add(new XYChart.Data<Number, Number>(Math.random()*98, Math.random()*98));
        sc.getData().add(series);
    }

    return sc;
}
 
开发者ID:amoAHCP,项目名称:JavaOne2015JavaFXPitfalls,代码行数:20,代码来源:AdvancedSimpleScatterChartSample.java

示例10: start

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
@Override
public void start(Stage stage) throws Exception {
    stage.setTitle("Scatter Chart Sample");
    final NumberAxis yAxis = new NumberAxis(1400, 2100, 100);
    final NumberAxis xAxis = new NumberAxis(500000, 90000000, 1000000);
    final ScatterChart<Number, Number> scatterChart = new ScatterChart<>(xAxis, yAxis);
    xAxis.setLabel("Population");
    yAxis.setLabel("Decade");
    scatterChart.setTitle("Population Scatter Graph");

    XYChart.Series series = new XYChart.Series();

    try (CSVReader dataReader = new CSVReader(new FileReader("EuropeanScatterData.csv"), ',')) {
        String[] nextLine;
        while ((nextLine = dataReader.readNext()) != null) {
            int decade = Integer.parseInt(nextLine[0]);
            int population = Integer.parseInt(nextLine[1]);
            series.getData().add(new XYChart.Data(population, decade));
            System.out.println("Decade: " + decade + "  Population: " + population);
        }
    }

    scatterChart.getData().addAll(series);
    Scene scene = new Scene(scatterChart, 500, 400);
    stage.setScene(scene);
    stage.show();
}
 
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:28,代码来源:ScatterChart - MainApp.java

示例11: buildChart

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
private ScatterChart<Number, Number> buildChart(String chartName, List<XYChart.Series<Number, Number>> series) {
	final NumberAxis xAxis = new NumberAxis();
	final NumberAxis yAxis = new NumberAxis();
	final ScatterChart<Number, Number> sc = new ScatterChart<Number, Number>(xAxis, yAxis);
	sc.setTitle(chartName);
	sc.setPrefHeight(450);
	sc.setPrefWidth(600);
	xAxis.getValueForDisplay(1);
	yAxis.getValueForDisplay(2);
	sc.getData().addAll(series);
	return sc;
}
 
开发者ID:jesuino,项目名称:java-ml-projects,代码行数:13,代码来源:Clustering.java

示例12: assignClusters

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
private void assignClusters() {
    Node centre = borderPane.getCenter();
    borderPane.getChildren().remove(centre);
    KMeansGraph kmg = new KMeansGraph(x_bounds,y_bounds);
    controller.assignClusters();
    ScatterChart sc = kmg.drawGraph(controller.getCentroidToDataPoint(), controller.getCentroids());
    borderPane.setCenter(sc);
    updateCost();
}
 
开发者ID:katharinebeaumont,项目名称:Cluster,代码行数:10,代码来源:Cluster.java

示例13: moveCentroid

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
private void moveCentroid() {
    Node centre = borderPane.getCenter();
    borderPane.getChildren().remove(centre);
    KMeansGraph kmg = new KMeansGraph(x_bounds,y_bounds);
    controller.moveCentroids();
    ScatterChart sc = kmg.drawGraph(controller.getCentroidToDataPoint(), controller.getCentroids());
    borderPane.setCenter(sc);
    updateCost();
}
 
开发者ID:katharinebeaumont,项目名称:Cluster,代码行数:10,代码来源:Cluster.java

示例14: reset

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
private void reset() {
    Node centre = borderPane.getCenter();
    borderPane.getChildren().remove(centre);
    int k = (int)centroid_spinner.getValue();
    int data_points = (int)data_slider.getValue();
    controller = new DataController(x_bounds,y_bounds, k, data_points);
    KMeansGraph kmg = new KMeansGraph(x_bounds,y_bounds);
    ScatterChart sc = kmg.drawGraph(controller.getCentroidToDataPoint(), controller.getCentroids());
    borderPane.setCenter(sc);
    cost.setText("");
    btnAC.setDisable(false);
    btnMV.setDisable(true);
    btnShowMe.setDisable(false);
}
 
开发者ID:katharinebeaumont,项目名称:Cluster,代码行数:15,代码来源:Cluster.java

示例15: resetCentroids

import javafx.scene.chart.ScatterChart; //导入依赖的package包/类
private void resetCentroids() {
    Node centre = borderPane.getCenter();
    borderPane.getChildren().remove(centre);
    int k = (int)centroid_spinner.getValue();
    controller.resetCentroids(k);
    KMeansGraph kmg = new KMeansGraph(x_bounds,y_bounds);
    ScatterChart sc = kmg.drawGraph(controller.getCentroidToDataPoint(), controller.getCentroids());
    borderPane.setCenter(sc);
    cost.setText("");
    btnShowMe.setDisable(false);
}
 
开发者ID:katharinebeaumont,项目名称:Cluster,代码行数:12,代码来源:Cluster.java


注:本文中的javafx.scene.chart.ScatterChart类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。