Пример #1
0
  private Scene createScene() {
    lock.lock();
    try {
      final CategoryAxis xAxis = new CategoryAxis();
      final NumberAxis yAxis = new NumberAxis();
      //            yAxis.setUpperBound(500);
      //            yAxis.setAutoRanging(false);
      final BarChart<String, Number> bc = new BarChart<>(xAxis, yAxis);
      bc.setTitle("Communication - " + this.algStr);
      xAxis.setLabel("Time (t)");
      yAxis.setLabel("Messages (m)");

      XYChart.Series series1 = new XYChart.Series();
      series1.setName("Messages sent to UAVs at time t of simulation");

      ChartDatastore chartDatastore = new ChartDatastore();
      Map<Integer, Integer> gData =
          (inforSharingAlg == CC_StaticInitConfig.BROADCAST_INFOSHARE)
              ? chartDatastore.getMessagesPerSecondData_broadcast()
              : chartDatastore.getMessagesPerSecondData_register();
      Map<Integer, Integer> gDataSync = Collections.synchronizedMap(gData);
      for (Integer t : gDataSync.keySet()) {
        series1.getData().add(new XYChart.Data(String.valueOf(t), gData.get(t)));
      }

      bc.getData().addAll(series1);
      bc.setAnimated(false);
      Scene scene = new Scene(bc, 800, 600);
      return scene;
    } finally {
      lock.unlock();
    }
  }
  public LineChart<String, Number> fillChartNacimientos() {
    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    xAxis.setLabel("Mes");
    final LineChart<String, Number> lineChart = new LineChart<>(xAxis, yAxis);

    lineChart.setTitle("Nacimientos de Beceros Por Año");

    //        lineChart.setCreateSymbols(false);
    lineChart.setAlternativeRowFillVisible(false);

    HashMap<Integer, int[]> data = dataForChartNacimientos();
    Set<Integer> keySet = data.keySet();
    for (Integer key : keySet) {
      int[] get = data.get(key);

      XYChart.Series series = new XYChart.Series();
      series.setName("" + key);
      series.getData().add(new XYChart.Data("Ene", get[1]));
      series.getData().add(new XYChart.Data("Feb", get[2]));
      series.getData().add(new XYChart.Data("Mar", get[3]));
      series.getData().add(new XYChart.Data("Abr", get[4]));
      series.getData().add(new XYChart.Data("May", get[5]));
      series.getData().add(new XYChart.Data("Jun", get[6]));
      series.getData().add(new XYChart.Data("Jul", get[7]));
      series.getData().add(new XYChart.Data("Aug", get[8]));
      series.getData().add(new XYChart.Data("Sep", get[9]));
      series.getData().add(new XYChart.Data("Oct", get[10]));
      series.getData().add(new XYChart.Data("Nov", get[11]));
      series.getData().add(new XYChart.Data("Dec", get[12]));

      lineChart.getData().add(series);
    }
    return (lineChart);
  }
  /**
   * Construct a new CandleStickChart with the given axis.
   *
   * @param title The chart title
   * @param xAxis The x axis to use
   * @param yAxis The y axis to use
   * @param bars The bars to display on the chart
   * @param maxBarsToDisplay The maximum number of bars to display on the chart.
   */
  public CandleStickChart(
      String title,
      CategoryAxis xAxis,
      NumberAxis yAxis,
      List<BarData> bars,
      int maxBarsToDisplay) {
    super(xAxis, yAxis);
    this.xAxis = xAxis;
    this.yAxis = yAxis;
    this.maxBarsToDisplay = maxBarsToDisplay;

    yAxis.autoRangingProperty().set(true);
    yAxis.forceZeroInRangeProperty().setValue(Boolean.FALSE);
    setTitle(title);
    setAnimated(true);
    getStylesheets()
        .add(getClass().getResource("/styles/CandleStickChartStyles.css").toExternalForm());
    xAxis.setAnimated(true);
    yAxis.setAnimated(true);
    verticalGridLinesVisibleProperty().set(false);
    XYChart.Series<String, Number> series = new XYChart.Series<>();
    List<BarData> sublist = getSubList(bars, maxBarsToDisplay);
    for (BarData bar : sublist) {
      String label = "";
      label = sdf.format(bar.getDateTime().getTime());
      series.getData().add(new XYChart.Data<>(label, bar.getOpen(), bar));
      logger.log(Level.INFO, "Adding bar with date/time: {0}", bar.getDateTime().getTime());
      logger.log(Level.INFO, "Adding bar with price: {0}", bar.getOpen());
    }

    dataSeries = FXCollections.observableArrayList(series);

    setData(dataSeries);
    lastBar = sublist.get(sublist.size() - 1);
  }
Пример #4
0
  public void play() {
    xAxis = new CategoryAxis();
    yAxis = new NumberAxis();
    xAxis.setLabel("Nombre Agendadores");
    yAxis.setLabel("Solicitudes");
    barChart = new BarChart<String, Number>(xAxis, yAxis);
    barChart.setMinHeight(550);
    barChart.setMinWidth(1000);
    barChart.setTitle("Trafico de agendamiento. Ejecución numero:" + countPlays);
    countPlays++;

    hbxPerExecution = new HBox(10);
    hbxPerExecution.getChildren().addAll(barChart);
    hbxPerExecution.getStyleClass().add("boxChart");
    vbxAllPage.getChildren().add(0, hbxPerExecution);

    serieReqRecieved = new XYChart.Series<String, Number>();
    serieReqRecieved.setName("Recibidas");
    serieNoFreeResouce = new XYChart.Series<String, Number>();
    serieNoFreeResouce.setName("No asignadas");
    serieReqAckSent = new XYChart.Series<String, Number>();
    serieReqAckSent.setName("Asignadas Enviadas");
    serieSendingFailed = new XYChart.Series<String, Number>();
    serieSendingFailed.setName("Asignadas No enviadas");

    barChart
        .getData()
        .addAll(serieReqRecieved, serieNoFreeResouce, serieReqAckSent, serieSendingFailed);
  }
Пример #5
0
  @Override
  public void start(Stage stage) {
    stage.setTitle("Bar Chart Sample");
    final NumberAxis xAxis = new NumberAxis();
    final CategoryAxis yAxis = new CategoryAxis();
    final BarChart<Number, String> bc = new BarChart<Number, String>(xAxis, yAxis);
    bc.setTitle("Country Summary");
    xAxis.setLabel("Value");
    xAxis.setTickLabelRotation(90);
    yAxis.setLabel("Country");

    XYChart.Series series1 = new XYChart.Series();
    series1.setName("2003");
    series1.getData().add(new XYChart.Data(25601.34, austria));
    series1.getData().add(new XYChart.Data(20148.82, brazil));
    series1.getData().add(new XYChart.Data(10000, france));
    series1.getData().add(new XYChart.Data(35407.15, italy));
    series1.getData().add(new XYChart.Data(12000, usa));

    XYChart.Series series2 = new XYChart.Series();
    series2.setName("2004");
    series2.getData().add(new XYChart.Data(57401.85, austria));
    series2.getData().add(new XYChart.Data(41941.19, brazil));
    series2.getData().add(new XYChart.Data(45263.37, france));
    series2.getData().add(new XYChart.Data(117320.16, italy));
    series2.getData().add(new XYChart.Data(14845.27, usa));

    XYChart.Series series3 = new XYChart.Series();
    series3.setName("2005");
    series3.getData().add(new XYChart.Data(45000.65, austria));
    series3.getData().add(new XYChart.Data(44835.76, brazil));
    series3.getData().add(new XYChart.Data(18722.18, france));
    series3.getData().add(new XYChart.Data(17557.31, italy));
    series3.getData().add(new XYChart.Data(92633.68, usa));

    Scene scene = new Scene(bc, 800, 600);
    bc.getData().addAll(series1, series2, series3);
    stage.setScene(scene);
    stage.show();
  }
  public BarChart<Number, String> fillChartBarPopBovinos() {
    final NumberAxis yAxis = new NumberAxis();
    final CategoryAxis xAxis = new CategoryAxis();
    final BarChart<Number, String> chart = new BarChart<>(yAxis, xAxis);
    chart.setTitle("Población de Bovinos");
    xAxis.setLabel("Bovino");
    //        xAxis.setTickLabelRotation(90);
    yAxis.setLabel("Cantidad");

    HashMap<String, Integer> data = dataForChartEdadesySexo();
    Set<String> keySet = data.keySet();
    XYChart.Series series1 = new XYChart.Series();
    ObservableList olist = series1.getData();
    for (String key : keySet) {
      olist.add(new XYChart.Data<>(data.get(key), key));
    }

    chart.getData().addAll(series1);
    chart.setLegendVisible(false);
    // set it to pane
    return (chart);
  }
 public Parent createContent() {
   xAxis = new CategoryAxis();
   yAxis = new NumberAxis();
   chart = new LineChart<>(xAxis, yAxis);
   // setup chart
   chart.setTitle("LineChart with Category Axis");
   xAxis.setLabel("X Axis");
   yAxis.setLabel("Y Axis");
   // add starting data
   XYChart.Series<String, Number> series = new XYChart.Series<>();
   series.setName("Data Series 1");
   series.getData().add(new XYChart.Data<String, Number>(CATEGORIES[0], 50d));
   series.getData().add(new XYChart.Data<String, Number>(CATEGORIES[1], 80d));
   series.getData().add(new XYChart.Data<String, Number>(CATEGORIES[2], 90d));
   series.getData().add(new XYChart.Data<String, Number>(CATEGORIES[3], 30d));
   series.getData().add(new XYChart.Data<String, Number>(CATEGORIES[4], 122d));
   series.getData().add(new XYChart.Data<String, Number>(CATEGORIES[5], 10d));
   chart.getData().add(series);
   return chart;
 }
Пример #8
0
  @Override
  public void start(Stage primaryStage) {
    try {
      BorderPane root =
          (BorderPane) FXMLLoader.load(getClass().getResource("FinanceMainForm.fxml"));
      // ------------------------------------------------------------------------------------
      // MD Alexis code
      // Grid to arrange buttons and text controls
      GridPane grid = new GridPane();
      grid.setAlignment(Pos.TOP_LEFT);
      grid.setPrefWidth(400);
      // TODO: One column may be better, or a multicolumn single row for buttons.
      ColumnConstraints col1 = new ColumnConstraints();
      col1.setPercentWidth(90);
      col1.setMinWidth(200);
      ColumnConstraints col2 = new ColumnConstraints();
      col2.setPercentWidth(10);
      col2.setMinWidth(200);
      grid.getColumnConstraints().addAll(col1, col2);

      grid.setHgap(10);
      grid.setVgap(10);
      // grid.setGridLinesVisible(true);  //Turn this on for debug and layout
      javafx.geometry.Insets ins = new javafx.geometry.Insets(5, 5, 5, 5);
      grid.setPadding(ins);
      // Fill the grid with controls
      Text scenetitle = new Text("Modeler");
      scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
      grid.add(scenetitle, 0, 0, 2, 1);
      // Add Buttons-----------------------------------------
      bthRun.setOnAction(bthHandlerRun);
      grid.add(bthRun, 0, 2);
      // grid.add(child, columnIndex, rowIndex);

      // Add textArea control to show results
      textStatus.setPrefRowCount(10);
      textStatus.setPrefColumnCount(100);
      textStatus.setWrapText(false);
      textStatus.setPrefWidth(300);

      grid.add(textStatus, 0, 3);

      // -------------------Table View - use to display results
      // --------------------------------------------
      // Set up table columns and their data sources
      TableColumn indexCol = new TableColumn("Index");
      TableColumn yearCol = new TableColumn("Year");
      yearCol.setCellValueFactory(new PropertyValueFactory<YearData, String>("year"));
      TableColumn balanceCol = new TableColumn("StartBalance");
      balanceCol.setCellValueFactory(
          new PropertyValueFactory<YearData, String>("startBalanceFormatted"));
      TableColumn mktGainCol = new TableColumn("Gains");
      mktGainCol.setCellValueFactory(
          new PropertyValueFactory<YearData, String>("marketGainsFormatted"));
      TableColumn incGoalCol = new TableColumn("Income Goal");
      incGoalCol.setCellValueFactory(
          new PropertyValueFactory<YearData, String>("incomeGoalWithInflationFormatted"));
      TableColumn totalIncomeCol = new TableColumn("Total Income");
      totalIncomeCol.setCellValueFactory(
          new PropertyValueFactory<YearData, String>("incomeTotalFormatted"));

      tableV
          .getColumns()
          .addAll(indexCol, yearCol, balanceCol, mktGainCol, incGoalCol, totalIncomeCol);

      grid.add(tableV, 0, 4);
      // ------------------------------- Chart ---------------------------------------------
      final CategoryAxis xAxis = new CategoryAxis();
      final NumberAxis yAxis = new NumberAxis();
      // final BarChart barchartResults = new BarChart<>(xAxis,yAxis);
      final AreaChart areachartResults = new AreaChart<>(xAxis, yAxis);

      areachartResults.setTitle("Results Chart");
      xAxis.setLabel("Year");
      yAxis.setLabel("Dollars");
      // Series
      // TODO:  Connect this to an observable list in ModelUtility
      // final XYChart.Series<int[], double[]> seriesBalance = new XYChart.Series();
      final XYChart.Series<String, Double> seriesBalance = new Series<String, Double>();
      seriesBalance.setName("Balance");
      // seriesBalance.setData(MU.balanceDataList);
      areachartResults.setData(MU.balanceDataList);

      // Add the Series to the chart
      areachartResults.getData().addAll(seriesBalance);

      grid.add(areachartResults, 0, 5);
      // ------------------------------------------------------------------------------------
      // Below lines are from initial project setup
      // Scene scene = new Scene(root,600,400);

      Scene scene = new Scene(grid, 1200, 600);
      scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.show();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }