Example #1
0
  private void createChart() {
    xAxis = new NumberAxis();
    xAxis.setForceZeroInRange(false);
    xAxis.setAutoRanging(true);
    xAxis.setLabel(priceColumnLabel.get());

    yAxis = new NumberAxis();
    yAxis.setForceZeroInRange(false);
    yAxis.setAutoRanging(true);
    yAxis.setLabel("Amount in BTC");
    yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis, "", ""));

    seriesBuy = new XYChart.Series();
    seriesBuy.setName("Offers for  buy bitcoin  ");

    seriesSell = new XYChart.Series();
    seriesSell.setName("Offers for sell bitcoin");

    areaChart = new AreaChart<>(xAxis, yAxis);
    areaChart.setAnimated(false);
    areaChart.setId("charts");
    areaChart.setMinHeight(300);
    areaChart.setPadding(new Insets(0, 30, 10, 0));
    areaChart.getData().addAll(seriesBuy, seriesSell);
  }
  @Override
  public void showFilteredResult(
      List<WorkflowStateSummary> filteredlist, EngineLoadFilterModel usedFilter) {

    WorkflowStateSummary copperLoadInfo = filteredlist.get(0);
    Date date = new Date();
    // new SimpleDateFormat("HH:mm:ss").format(new Date());

    for (Entry<WorkflowInstanceState, Integer> entry :
        copperLoadInfo.getNumberOfWorkflowInstancesWithState().entrySet()) {
      Series<Number, Number> axis = stateToAxis.get(entry.getKey());
      ObservableList<Data<Number, Number>> data = axis.getData();
      data.add(new XYChart.Data<Number, Number>(date.getTime(), entry.getValue()));
      if (data.size() > MAX_DATA_POINTS) {
        data.remove(0);
      }

      if (usedFilter.stateFilters.get(entry.getKey()).getValue()) {
        if (!areaChart.getData().contains(axis)) {
          areaChart.getData().add(axis);
        }
      } else {
        areaChart.getData().remove(axis);
      }
    }

    ComponentUtil.setupXAxis((NumberAxis) areaChart.getXAxis(), areaChart.getData());
  }
Example #3
0
  @Override
  protected void activate() {
    currencyComboBox.setItems(model.getTradeCurrencies());
    currencyComboBox.getSelectionModel().select(model.getTradeCurrency());
    currencyComboBox.setVisibleRowCount(Math.min(currencyComboBox.getItems().size(), 25));
    currencyComboBox.setOnAction(
        e -> {
          model.onSetTradeCurrency(currencyComboBox.getSelectionModel().getSelectedItem());
          updateChartData();
        });

    model.getOfferBookListItems().addListener(changeListener);
    tradeCurrencySubscriber =
        EasyBind.subscribe(
            model.tradeCurrency,
            newValue -> {
              String code = newValue.getCode();
              areaChart.setTitle("Offer book for " + newValue.getName());
              priceColumnLabel.set("Price (" + code + "/BTC)");
              volumeColumnLabel.set("Volume (" + code + ")");
              xAxis.setLabel(priceColumnLabel.get());
              xAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(xAxis, "", ""));
            });

    buyOfferTableView.setItems(model.getBuyOfferList());
    sellOfferTableView.setItems(model.getSellOfferList());

    updateChartData();
  }
 private void initChart() {
   stateToAxis.clear();
   for (WorkflowInstanceState workflowInstanceState : WorkflowInstanceState.values()) {
     XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
     series.setName(workflowInstanceState.toString());
     stateToAxis.put(workflowInstanceState, series);
     areaChart.getData().add(series);
   }
   // areaChart.getXAxis().setAnimated(false);
 }
  @Override
  public void initialize(URL url, ResourceBundle rb) {
    temperatureChart.getXAxis().setLabel("Seconds");
    temperatureChart.getYAxis().setLabel("Temperature");
    _seriesTemperature.setName("Temperatures by Second");
    temperatureChart.getData().add(_seriesTemperature);

    dateTimeCol.setCellValueFactory(new PropertyValueFactory<>("dateTimeFormatted"));

    latitudeCol.setCellValueFactory(new PropertyValueFactory<>("latitude"));

    longitudeCol.setCellValueFactory(new PropertyValueFactory<>("longitude"));

    altitudeCol.setCellValueFactory(new PropertyValueFactory<>("altitude"));

    positionTable.setItems(_positionReadings);

    setStatus("Not connected to server", true, false, false);
  }
 protected AreaChart<Number, Number> createChart() {
   final NumberAxis xAxis = new NumberAxis(0, 128, 8);
   final NumberAxis yAxis = new NumberAxis(0, 50, 10);
   final AreaChart<Number, Number> ac = new AreaChart<Number, Number>(xAxis, yAxis);
   // setup chart
   ac.setId("audioAreaDemo");
   ac.setLegendVisible(false);
   ac.setTitle("Live Audio Spectrum Data");
   ac.setAnimated(false);
   xAxis.setLabel("Frequency Bands");
   yAxis.setLabel("Magnitudes");
   yAxis.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis, null, "dB"));
   // add starting data
   XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
   series.setName("Audio Spectrum");
   //noinspection unchecked
   series1Data = new XYChart.Data[(int) xAxis.getUpperBound()];
   for (int i = 0; i < series1Data.length; i++) {
     series1Data[i] = new XYChart.Data<Number, Number>(i, 50);
     series.getData().add(series1Data[i]);
   }
   ac.getData().add(series);
   return ac;
 }
Example #7
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();
    }
  }
 @Override
 public void clear() {
   areaChart.getData().clear();
   initChart();
 }