private void updateDistanceDistributionChart() {

    double[][] transformedTrajectory = getTransformedTrajectory();
    if (transformedTrajectory == null) return;

    double approxDiameter =
        PhaseSpaceDistribution.maxPhaseSpaceDiameterApproximate(transformedTrajectory);

    long[] histo;
    // subsequent distance distribution
    if (distanceDistributionSelector.getSelectionModel().getSelectedIndex() == 0) {
      histo =
          PhaseSpaceDistribution.approximateSubsequentDistanceDistribution(
              transformedTrajectory, 1500, approxDiameter);
    } else {
      histo =
          PhaseSpaceDistribution.approximateDistanceDistribution(
              transformedTrajectory, 1500, approxDiameter);
    }

    subsequentDistanceDistributionChart.getData().clear();
    XYChart.Series series = new XYChart.Series();
    for (int i = 0; i < histo.length; i++) {
      series.getData().add(new XYChart.Data(i, histo[i]));
    }
    subsequentDistanceDistributionChart.getData().add(series);
  }
  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);
  }
  /**
   * Método para pintar la gráfica
   *
   * @param min
   * @param max
   * @param grado
   */
  private void pintarGrafica(int min, int max, int grado) {

    // Creamos un ObservableList para guardar los puntos que pintaremos en la gráfica
    ObservableList<XYChart.Series<Double, Double>> lineChartData =
        FXCollections.observableArrayList();

    // Instanciamos un punto a pintar
    LineChart.Series<Double, Double> series = new LineChart.Series<Double, Double>();

    // Imprimimos la función que vamos a pintar como etiqueta
    series.setName("f(x^" + grado + ")");

    // obtenemos los puntos a pintar. Daros cuenta que los puntos a pintar estan definidos
    // por el valor de 'x' y el resultado de 'f(x)', siendo f(x)=Math.pow(x, grado) = x^grado
    for (double i = min; i < max; i = i + 0.1) {
      series.getData().add(new XYChart.Data<Double, Double>(i, Math.pow(i, grado)));
    }

    // Guardamos todos los puntos de la función que hemos obtenido
    lineChartData.add(series);

    // Si No quereis que se pinten los puntos, poner a false
    graph.setCreateSymbols(true);

    // Ponemos los puntos en la gráfica
    graph.setData(lineChartData);
    graph.createSymbolsProperty();
  }
  private void updateTimeSeriesChart() {
    // clear time series chart
    timeSeriesChart.getData().clear();

    // fill time series chart
    double[][] transformedTrajectory = getTransformedTrajectory();
    for (int i = 0; i < transformedTrajectory.length; i++) {
      XYChart.Series series = new XYChart.Series();
      series.setName("Dimension " + (i + 1));
      for (int j = 0; j < transformedTrajectory[i].length; j++) {
        series.getData().add(new XYChart.Data(j, transformedTrajectory[i][j]));
      }
      timeSeriesChart.getData().add(series);
    }
  }
  /**
   * Handle user actions on the toggle group to switch between weekly bar chart and monthly line
   * chart
   */
  @FXML
  private void handleChartRadioActions() {
    if (weekRadio.isSelected()) {
      // remove month line chart from view
      monthLineChart.setVisible(false);
      // set week bar chart visible
      weekBarChart.setVisible(true);
    }

    if (monthRadio.isSelected()) {
      // remove month line chart from view
      weekBarChart.setVisible(false);
      // set week bar chart visible
      monthLineChart.setVisible(true);
    }
  }
 private void setUpLineChart() {
   NumberAxis xAxis = new NumberAxis();
   NumberAxis yAxis = new NumberAxis();
   xAxis.setLabel("Czas (s)");
   yAxis.setLabel("Temperatura (C)");
   lineChart = new LineChart<Number, Number>(xAxis, yAxis);
   lineChart.setPrefSize(1000, 760);
 }
Пример #7
0
  public void drawTrack() {
    int offset = Math.round(longestTrackFrameLength / GRAPH_POINT_COUNT);
    offset = (int) (offset * (track.getSampleRate() / 44100));

    XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();

    float[] tempData = track.getAudioData();

    int audioFileLength = track.getLength();
    int x = 0;

    /**
     * TODO momentan ist die Zeichnung auf 2000 Werte begrenzt, bei längeren Files kommt dadurch
     * kein schönes Bild zustande, müssen wir uns noch anschauen
     */
    for (int i = 0; i < audioFileLength * track.getNumberOfChannels(); i += offset) {
      float mean = 0;
      float leftChannel = tempData[i];

      if (track.getNumberOfChannels() == 2) {
        float rightChannel = tempData[i + 1];
        mean = (leftChannel + rightChannel) / 2;
      } else {
        mean = leftChannel;
      }
      series.getData().add(new XYChart.Data<Number, Number>(x, mean));
      x++;
    }

    // Fill rest with zeroes
    // TODO: it seems like we're actually drawing 2 x 2000 points??
    for (; x < GRAPH_POINT_COUNT * track.getNumberOfChannels(); x++) {
      series.getData().add(new XYChart.Data<Number, Number>(x, 0));
    }

    lineChartWaveform.getData().clear();
    lineChartWaveform.getData().add(series);

    NumberAxis xAxis = (NumberAxis) lineChartWaveform.getXAxis();
    xAxis.setAutoRanging(false);
    xAxis.setUpperBound(x - 1);
    NumberAxis yAxis = (NumberAxis) lineChartWaveform.getYAxis();
    yAxis.setAutoRanging(false);
    yAxis.setLowerBound(-1.0);
    yAxis.setUpperBound(1.0);
  }
 protected LineChart<Number, Number> createChart() {
   final NumberAxis xAxis = new NumberAxis();
   final NumberAxis yAxis = new NumberAxis();
   final LineChart<Number, Number> lc = new LineChart<Number, Number>(xAxis, yAxis);
   // setup chart
   lc.setTitle("Basic LineChart");
   xAxis.setLabel("X Axis");
   yAxis.setLabel("Y Axis");
   // add starting data
   Series<Number, Number> series = new Series<Number, Number>();
   series.setName("Data Series 1");
   series.getData().add(new XYChart.Data<Number, Number>(20d, 50d));
   series.getData().add(new XYChart.Data<Number, Number>(40d, 80d));
   series.getData().add(new XYChart.Data<Number, Number>(50d, 90d));
   series.getData().add(new XYChart.Data<Number, Number>(70d, 30d));
   series.getData().add(new XYChart.Data<Number, Number>(170d, 122d));
   lc.getData().add(series);
   return lc;
 }
 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;
 }
  @Override
  public void start(Stage stage) {

    Parameters parameters = getParameters();
    List<String> rawArguments = parameters.getRaw();

    List<String> file_paths = new LinkedList<String>();

    int size = rawArguments.size(); // un solo file / argomento in realtà

    for (int i = 0; i < size; i++) {
      String path_data_file = rawArguments.get(i);
      System.out.println(" * data file n." + (i + 1) + " : " + path_data_file);
      file_paths.add(path_data_file);
    }

    stage.setTitle("Cpu during joining");

    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();

    xAxis.setLabel("time");
    // xAxis.setTickUnit(10);

    yAxis.setLabel("CPU %");
    yAxis.setTickUnit(2);

    final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);

    lineChart.setTitle("CPU during Joining and Cleanups");
    lineChart.setCreateSymbols(false);

    // add_line_to_chart(lineChart, file_paths.get(0), "from 3 to 4 nodes", 3, 80000);
    // add_line_to_chart(lineChart, file_paths.get(0), "from 4 to 5 nodes", 4, 95000);
    add_line_to_chart(lineChart, file_paths.get(0), "from 5 to 6 nodes", 5, 112000);

    Scene scene = new Scene(lineChart, 800, 600);

    stage.setScene(scene);
    stage.show();
  }
Пример #11
0
 private void enableStereoSettings(SidTune tune) {
   EmulationSection emulationSection = util.getConfig().getEmulationSection();
   boolean second = SidTune.isSIDUsed(emulationSection, tune, 1);
   boolean third = SidTune.isSIDUsed(emulationSection, tune, 2);
   int sidBase = SidTune.getSIDAddress(emulationSection, tune, 0);
   int dualSidBase = SidTune.getSIDAddress(emulationSection, tune, 1);
   boolean isForcedStereo = second && emulationSection.isForceStereoTune();
   boolean isFakeStereo = isForcedStereo && dualSidBase == sidBase;
   boolean isForced3Sid = third && emulationSection.isForce3SIDTune();
   if (isFakeStereo) {
     stereoMode.getSelectionModel().select(StereoMode.FAKE_STEREO);
   } else if (isForced3Sid) {
     stereoMode.getSelectionModel().select(StereoMode.THREE_SID);
   } else if (isForcedStereo) {
     stereoMode.getSelectionModel().select(StereoMode.STEREO);
   } else {
     stereoMode.getSelectionModel().select(StereoMode.AUTO);
   }
   // stereo, only:
   mainBalance.setDisable(!second);
   secondVolume.setDisable(!second);
   secondBalance.setDisable(!second);
   sid2Emulation.setDisable(!second);
   sid2Model.setDisable(!second);
   secondFilter.setDisable(!second);
   secondFilterCurve.setDisable(!second);
   // 3-SID, only:
   thirdVolume.setDisable(!third);
   thirdBalance.setDisable(!third);
   sid3Emulation.setDisable(!third);
   sid3Model.setDisable(!third);
   thirdFilter.setDisable(!third);
   thirdFilterCurve.setDisable(!third);
   // fake stereo, only:
   sidToRead.setDisable(!(isFakeStereo));
   // forced stereo or forced 3-SID, only:
   baseAddress.setDisable(!(isForcedStereo || isForced3Sid));
   // forced 3-SID, only:
   thirdAddress.setDisable(!isForced3Sid);
 }
  /**
   * Called after @FXML annotated fields are injected and so is used to update the view with the
   * data built in the constructor.
   *
   * <p>Retrieves history and achievement information from the account to build the charts and set
   * the text for attribute and username labels.
   *
   * <p>First displays the user's workout activity in the last seven days but the user is allowed to
   * switch between last 30 days/ last 7 days charts
   */
  @FXML
  private void initialize() {

    // build the series from the workout history information
    workoutHistoryLog = HistoryAnalyser.getDailyWorkoutHistoryFromCurrentAccount();
    makeWeekSeriesFromAccountHistory();
    makeMonthSeriesFromAccountHistory();

    // ----------------------------------------------------------//
    // Character attributes and avatar
    // Get the authenticated and up to date account and get its attributes
    Account account = Main.account;
    attributes = account.getCharacterAttributes();

    // ----------------------------------------------------------//
    // Progress charts

    // immediately remove the line chart that displays the last 30 days of workout activity from
    // view
    monthLineChart.setVisible(false);

    // add the series to their charts
    weekBarChart.getData().add(seriesW);
    monthLineChart.getData().add(seriesM);

    // manage the toggling feature between month and weekRadios
    radioGroup = new ToggleGroup();
    monthRadio.setToggleGroup(radioGroup);
    weekRadio.setToggleGroup(radioGroup);
    // Initially set week radio to selected
    weekRadio.setSelected(true);

    showAccountAttributes();

    showAvatarInStackPane();

    showAchievementsInListView();
  }
  private void updateLineLengthHistogram(ObservableValue obs, Number oldValue, Number newValue) {
    if (drqa == null) return;

    long[][] histos;
    if (useDRQA.isSelected())
      histos = new long[][] {drqa.l_hist, drqa.v_hist, drqa.w_hist, drqa.r_hist};
    else {
      // add indefinite and definite histograms
      histos =
          new long[][] {
            Arrays.copyOf(drqa.l_hist, drqa.l_hist.length),
            Arrays.copyOf(drqa.v_hist, drqa.v_hist.length),
            Arrays.copyOf(drqa.w_hist, drqa.w_hist.length),
            Arrays.copyOf(drqa.r_hist, drqa.r_hist.length),
          };
      long[][] indefiniteHistos =
          new long[][] {
            drqa.l_hist_indefinite,
            drqa.v_hist_indefinite,
            drqa.w_hist_indefinite,
            drqa.r_hist_indefinite
          };
      // add the indefinite histos to the definite histos to gain traditional rqa
      for (int i = 0; i < histos.length; i++) {
        for (int j = 0; j < indefiniteHistos[i].length; j++) histos[i][j] += indefiniteHistos[i][j];
      }
    }

    lineLengthHistogram.getData().clear();
    long[] histogram = histos[newValue.intValue()];

    // fill time series chart
    XYChart.Series series = new XYChart.Series();
    for (int i = 0; i < histogram.length; i++) {
      series.getData().add(new XYChart.Data(i, histogram[i]));
    }
    lineLengthHistogram.getData().add(series);
  }
Пример #14
0
  /**
   * Draw filter curve of the specified SID number and filter name
   *
   * @param filterBox filter combo box
   * @param num SID chip number
   */
  private void drawFilterCurve(
      final ComboBox<String> filterBox, LineChart<Number, Number> filterCurve) {
    EmulationSection emulationSection = util.getConfig().getEmulationSection();
    XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
    series.setName(util.getBundle().getString("FILTERCURVE_TITLE"));
    filterCurve.getData().clear();

    SidTune tune = util.getPlayer().getTune();

    boolean second = SidTune.isSIDUsed(emulationSection, tune, 1);
    boolean third = SidTune.isSIDUsed(emulationSection, tune, 2);

    Optional<FilterSection> optFilter =
        util.getConfig()
            .getFilterSection()
            .stream()
            .filter(f -> f.getName().equals(filterBox.getSelectionModel().getSelectedItem()))
            .findFirst();
    if (optFilter.isPresent()) {
      FilterSection filter = optFilter.get();
      // stereo curve or 3-SID curve currently not used?
      if (!((filterCurve == secondFilterCurve && !second)
          || (filterCurve == thirdFilterCurve && !third))) {
        for (int fc = 0; fc < SIDChip.FC_MAX; fc += STEP) {
          if (filter.isReSIDFilter6581() || filter.isReSIDFilter8580()) {
            double data = resid_builder.resid.FilterModelConfig.estimateFrequency(filter, fc);
            series.getData().add(new XYChart.Data<Number, Number>(fc, (int) data));
          } else if (filter.isReSIDfpFilter6581() || filter.isReSIDfpFilter8580()) {
            double data = resid_builder.residfp.FilterModelConfig.estimateFrequency(filter, fc);
            series.getData().add(new XYChart.Data<Number, Number>(fc, (int) data));
          }
        }
      }
    }
    filterCurve.getData().add(series);
  }
  @Override
  public void initialize(URL arg0, ResourceBundle arg1) {
    days.bind(viewModel.daysProperty());
    targetLineSeries.dataProperty().bind(viewModel.targetLineDataProperty());
    loggedHoursSeries.dataProperty().bind(viewModel.loggedHoursDataProperty());
    burndownSeries.dataProperty().bind(viewModel.burndownDataProperty());

    burndownChart.getData().addAll(targetLineSeries, loggedHoursSeries, burndownSeries);
    burndownChart.getXAxis().setAutoRanging(true);

    // style
    burndownChart.setLegendVisible(false);
    burndownChart.setAnimated(false);

    yAxis.setMinorTickVisible(false);

    exportHyperlink.setOnAction(
        event -> {
          burndownChart.snapshot(
              snapshotResult -> {
                WritableImage image = snapshotResult.getImage();
                // https://community.oracle.com/thread/2450090?tstart=0
                final FileChooser fileChooser = new FileChooser();
                fileChooser
                    .getExtensionFilters()
                    .addAll(
                        new FileChooser.ExtensionFilter("PNG Files", "*.png"),
                        new FileChooser.ExtensionFilter("All Files", "*"));
                String organisationFilename =
                    viewModel.organisationProperty().get().getSaveLocation().getName();
                fileChooser.setInitialFileName(
                    organisationFilename.substring(0, organisationFilename.lastIndexOf('.'))
                        + ".png");
                File file = fileChooser.showSaveDialog(burndownChart.getScene().getWindow());
                try {
                  if (file != null) {
                    ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
                  }
                } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                return null;
              },
              null,
              null);
        });
  }
Пример #16
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    try {
      screenSize = Screen.getPrimary().getVisualBounds();
      width = screenSize.getWidth(); // gd.getDisplayMode().getWidth();
      height = screenSize.getHeight(); // gd.getDisplayMode().getHeight();
    } catch (Exception excep) {
      System.out.println("<----- Exception in  Get Screen Size ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    try {
      dbCon =
          DriverManager.getConnection(
              "jdbc:mysql://192.168.1.6:3306/ale", "Root", "oqu#$XQgHFzDj@1MGg1G8");
      estCon = true;
    } catch (SQLException sqlExcep) {
      System.out.println("<----- SQL Exception in Establishing Database Connection ----->");
      sqlExcep.printStackTrace();
      System.out.println("<---------->\n");
    }

    xmlParser.generateUserInfo();
    superUser = xmlParser.getSuperUser();

    // ----------------------------------------------------------------------------------------------------> Top Panel Start

    closeBtn = new Button("");
    closeBtn.getStyleClass().add("systemBtn");
    closeBtn.setOnAction(
        e -> {
          systemClose();
        });

    minimizeBtn = new Button("");
    minimizeBtn.getStyleClass().add("systemBtn");
    minimizeBtn.setOnAction(
        e -> {
          primaryStage.setIconified(true);
        });

    miscContainer = new HBox();

    calcBtn = new Button();
    calcBtn.getStyleClass().addAll("calcBtn");
    calcBtn.setOnAction(
        e -> {
          calculator calculator = new calculator();
          scientificCalculator scientificCalculator = new scientificCalculator();
          calculator.start(calculatorName);
        });

    miscContainer.getChildren().add(calcBtn);

    topPanel = new HBox(1);
    topPanel.getStyleClass().add("topPanel");
    topPanel.setPrefWidth(width);
    topPanel.setAlignment(Pos.CENTER_RIGHT);
    topPanel.setPadding(new Insets(0, 0, 0, 0));
    topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn);

    // ------------------------------------------------------------------------------------------------------> Top Panel End

    // ----------------------------------------------------------------------------------------------> Navigation Panel Start

    Line initDivider = new Line();
    initDivider.setStartX(0.0f);
    initDivider.setEndX(205.0f);
    initDivider.setStroke(Color.GRAY);

    // <----- Dashboard ----->
    dashboardToolTip = new Tooltip("Dashboard");

    dashboardBtn = new Button("");
    dashboardBtn.getStyleClass().add("dashboardBtn");
    dashboardBtn.setTooltip(dashboardToolTip);
    dashboardBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(dashBoardBase);
        });

    // <----- Profile ----->
    profileToolTip = new Tooltip("Profile");

    profileBtn = new Button();
    profileBtn.getStyleClass().add("profileBtn");
    profileBtn.setTooltip(profileToolTip);
    profileBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(profilePanel);
        });

    // <----- Courses ----->
    courseToolTip = new Tooltip("Courses");

    coursesBtn = new Button("");
    coursesBtn.getStyleClass().add("coursesBtn");
    coursesBtn.setTooltip(courseToolTip);
    coursesBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(coursesPanel);
          // miscContainer.getChildren().addAll(watchVidBtn);
          coursesPanel.setContent(coursesGridPanel);
        });

    Line mainDivider = new Line();
    mainDivider.setStartX(0.0f);
    mainDivider.setEndX(205.0f);
    mainDivider.setStroke(Color.GRAY);

    // <----- Simulations ----->
    simsToolTip = new Tooltip("Simulations");

    simsBtn = new Button();
    simsBtn.getStyleClass().add("simsBtn");
    simsBtn.setTooltip(simsToolTip);
    simsBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(simsPanel);
          simsPanel.setContent(simsGridPanel);
        });

    // <----- Text Editor ----->
    textEditorToolTip = new Tooltip("Text Editor");

    textEditorBtn = new Button();
    textEditorBtn.getStyleClass().add("textEditorBtn");
    textEditorBtn.setTooltip(textEditorToolTip);
    textEditorBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(textEditorPanel);
          miscContainer.getChildren().addAll(saveDocBtn);
        });

    Line toolsDivider = new Line();
    toolsDivider.setStartX(0.0f);
    toolsDivider.setEndX(205.0f);
    toolsDivider.setStroke(Color.GRAY);

    // <----- Wolfram Alpha ----->
    wolframToolTip = new Tooltip("Wolfram Alpha");

    wolframBtn = new Button();
    wolframBtn.getStyleClass().add("wolframBtn");
    wolframBtn.setTooltip(wolframToolTip);
    wolframBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(wolframPanel);
        });

    // <----- Wikipedia ----->
    wikipediaToolTip = new Tooltip();

    wikipediaBtn = new Button();
    wikipediaBtn.getStyleClass().add("wikipediaBtn");
    wikipediaBtn.setTooltip(wikipediaToolTip);
    wikipediaBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(wikipediaPanel);
        });

    Line sitesDivider = new Line();
    sitesDivider.setStartX(0.0f);
    sitesDivider.setEndX(205.0f);
    sitesDivider.setStroke(Color.GRAY);

    // <----- Settings ----->
    settingsToolTip = new Tooltip("Settings");

    settingsBtn = new Button();
    settingsBtn.getStyleClass().add("settingsBtn");
    settingsBtn.setTooltip(settingsToolTip);
    settingsBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(settingsPanel);
        });

    leftPanel = new VBox(0);
    // leftPanel.setPrefWidth(1);
    leftPanel.getStyleClass().add("leftPane");
    leftPanel
        .getChildren()
        .addAll(
            initDivider,
            dashboardBtn,
            profileBtn,
            coursesBtn,
            mainDivider,
            simsBtn,
            textEditorBtn,
            toolsDivider,
            wolframBtn,
            wikipediaBtn,
            sitesDivider,
            settingsBtn);

    topPanel = new HBox(1);
    topPanel.getStyleClass().add("topPanel");
    topPanel.setPrefWidth(width);
    topPanel.setAlignment(Pos.CENTER_RIGHT);
    topPanel.setPadding(new Insets(0, 0, 0, 0));
    topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn);

    // ------------------------------------------------------------------------------------------------> Navigation Panel End

    // -----------------------------------------------------------------------------------------------> Dashboard Pane Start

    final WebView webVid = new WebView();
    final WebEngine webVidEngine = webVid.getEngine();
    webVid.setPrefHeight(860);
    webVid.setPrefWidth(width - 118);
    webVidEngine.loadContent("");

    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    xAxis.setLabel("Day");
    yAxis.setLabel("Score");
    final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);

    lineChart.setTitle("Line Chart");
    XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
    series.setName("My Data");

    // populating the series with data
    series.getData().add(new XYChart.Data<Number, Number>(0.25, 36));
    series.getData().add(new XYChart.Data<Number, Number>(1, 23));
    series.getData().add(new XYChart.Data<Number, Number>(2, 114));
    series.getData().add(new XYChart.Data<Number, Number>(3, 15));
    series.getData().add(new XYChart.Data<Number, Number>(4, 124));
    lineChart.getData().add(series);
    lineChart.setPrefWidth(400);
    lineChart.setPrefHeight(300);
    lineChart.setLegendVisible(false);

    chatRoomField = new TextField();
    chatRoomField.getStyleClass().add("textField");
    chatRoomField.setPromptText("Enter Chat Room");
    chatRoomField.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              chatRoom = chatRoomField.getText();
              client.connect(messageArea, messageInputArea, superUser, chatRoom);
            }
          }
        });

    messageArea = new TextArea();
    messageArea.getStyleClass().add("textArea");
    messageArea.setWrapText(true);
    messageArea.setPrefHeight(740);
    messageArea.setEditable(false);

    messageInputArea = new TextArea();
    messageInputArea.getStyleClass().add("textArea");
    messageInputArea.setWrapText(true);
    messageInputArea.setPrefHeight(100);
    messageInputArea.setPromptText("Enter Message");
    messageInputArea.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              client.send(messageArea, messageInputArea, superUser, chatRoom);
              event.consume();
            }
          }
        });

    chatBox = new VBox();
    chatBox.setPrefWidth(250);
    chatBox.setMaxWidth(250);
    chatBox.getStyleClass().add("chatBox");
    chatBox.getChildren().addAll(chatRoomField, messageArea, messageInputArea);

    // client.test(messageArea, messageInputArea);

    dashboardGridPanel = new GridPane();
    dashboardGridPanel.getStyleClass().add("gridPane");
    dashboardGridPanel.setVgap(5);
    dashboardGridPanel.setHgap(5);
    dashboardGridPanel.setGridLinesVisible(false);
    dashboardGridPanel.setPrefWidth(width - 430);
    dashboardGridPanel.setPrefHeight(860);

    dashboardGridPanel.setColumnIndex(lineChart, 0);
    dashboardGridPanel.setRowIndex(lineChart, 0);
    dashboardGridPanel.getChildren().addAll(lineChart);

    dashboardPanel = new ScrollPane();
    dashboardPanel.getStyleClass().add("scrollPane");
    dashboardPanel.setPrefWidth(width - 400);
    dashboardPanel.setPrefHeight(860);
    dashboardPanel.setContent(dashboardGridPanel);

    dashBoardBase = new HBox();
    dashBoardBase.setPrefWidth(width - (leftPanel.getWidth() + chatBox.getWidth()));
    dashBoardBase.setPrefHeight(860);
    dashBoardBase.getChildren().addAll(dashboardPanel, chatBox);

    // -------------------------------------------------------------------------------------------------> Dashboard Pane End

    // -------------------------------------------------------------------------------------------------> Profile Pane Start

    profilePictureBtn = new Button();
    profilePictureBtn.getStyleClass().addAll("profilePictureBtn");

    String profileUserName = xmlParser.getSuperUser();

    String profileEmail = xmlParser.getEmail();
    String profileAge = xmlParser.getAge();
    String profileSchool = xmlParser.getSchool();
    String profileCountry = "";
    String profileCity = "";

    userNameLbl = new Label(profileUserName);
    userNameLbl.getStyleClass().add("profileLbl");
    userNameLbl.setAlignment(Pos.CENTER);

    emailLbl = new Label(profileEmail);
    emailLbl.getStyleClass().add("profileLbl");

    ageLbl = new Label(profileAge);
    ageLbl.getStyleClass().add("profileLbl");

    schoolLbl = new Label(profileSchool);
    schoolLbl.getStyleClass().add("profileLbl");

    profileGridPanel = new GridPane();
    profileGridPanel.getStyleClass().add("gridPane");
    profileGridPanel.setVgap(5);
    profileGridPanel.setHgap(5);
    profileGridPanel.setGridLinesVisible(false);
    profileGridPanel.setPrefWidth(width - 208);
    profileGridPanel.setPrefHeight(860);
    profileGridPanel.setAlignment(Pos.TOP_CENTER);

    profileGridPanel.setRowIndex(profilePictureBtn, 0);
    profileGridPanel.setColumnIndex(profilePictureBtn, 0);
    profileGridPanel.setRowIndex(userNameLbl, 1);
    profileGridPanel.setColumnIndex(userNameLbl, 0);
    profileGridPanel.setRowIndex(emailLbl, 2);
    profileGridPanel.setColumnIndex(emailLbl, 0);
    profileGridPanel.setRowIndex(ageLbl, 3);
    profileGridPanel.setColumnIndex(ageLbl, 0);
    profileGridPanel.setRowIndex(schoolLbl, 4);
    profileGridPanel.setColumnIndex(schoolLbl, 0);
    profileGridPanel
        .getChildren()
        .addAll(profilePictureBtn, userNameLbl, emailLbl, ageLbl, schoolLbl);

    profilePanel = new ScrollPane();
    profilePanel.getStyleClass().add("scrollPane");
    profilePanel.setContent(profileGridPanel);

    // ---------------------------------------------------------------------------------------------------> Profile Pane End

    // -------------------------------------------------------------------------------------------------> Courses Pane Start

    String course = "";

    // Media media = new Media("media.mp4");

    // mediaPlayer = new MediaPlayer(media);
    // mediaPlayer.setAutoPlay(true);

    // mediaView = new MediaView(mediaPlayer);

    watchVidBtn = new Button("Watch Video");
    watchVidBtn.getStyleClass().add("btn");
    watchVidBtn.setOnAction(
        e -> {

          // coursesPanel.setContent(mediaView);
        });

    chemistryBtn = new Button();
    chemistryBtn.getStyleClass().add("chemistryBtn");
    chemistryBtn.setOnAction(
        e -> {
          displayCourse("chemistry");
        });

    physicsBtn = new Button();
    physicsBtn.getStyleClass().add("physicsBtn");
    physicsBtn.setOnAction(
        e -> {
          displayCourse("physics");
        });

    mathsBtn = new Button();
    mathsBtn.getStyleClass().add("mathsBtn");

    bioBtn = new Button();
    bioBtn.getStyleClass().add("bioBtn");
    bioBtn.setOnAction(
        e -> {
          rootPane.setCenter(biologyCourse.biologyPane());
        });

    // Course Web View
    try {
      courseView = new WebView();
      courseWebEngine = courseView.getEngine();
      courseView.setPrefHeight(860);
      courseView.setPrefWidth(width - 208);
    } catch (Exception excep) {
      System.out.println("<----- Exception in Course Web ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    coursesGridPanel = new GridPane();
    coursesGridPanel.getStyleClass().add("gridPane");
    coursesGridPanel.setVgap(5);
    coursesGridPanel.setHgap(5);
    coursesGridPanel.setGridLinesVisible(false);
    coursesGridPanel.setPrefWidth(width - 208);
    coursesGridPanel.setPrefHeight(860);

    coursesGridPanel.setRowIndex(chemistryBtn, 1);
    coursesGridPanel.setColumnIndex(chemistryBtn, 1);
    coursesGridPanel.setRowIndex(physicsBtn, 1);
    coursesGridPanel.setColumnIndex(physicsBtn, 2);
    coursesGridPanel.setRowIndex(mathsBtn, 1);
    coursesGridPanel.setColumnIndex(mathsBtn, 3);
    coursesGridPanel.setRowIndex(bioBtn, 1);
    coursesGridPanel.setColumnIndex(bioBtn, 4);
    coursesGridPanel.getChildren().addAll(chemistryBtn, physicsBtn, mathsBtn, bioBtn);

    coursesPanel = new ScrollPane();
    coursesPanel.getStyleClass().add("scrollPane");
    coursesPanel.setPrefWidth(width - 118);
    coursesPanel.setPrefHeight(860);
    coursesPanel.setContent(coursesGridPanel);

    // ---------------------------------------------------------------------------------------------------> Courses Pane End

    // ---------------------------------------------------------------------------------------------> Simulations Pane Start
    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();
    browser.setPrefHeight(860);
    browser.setPrefWidth(width - 208);

    /*
    File phetImageFile = new File("img/styleDark/poweredByPHET.png");
    String phetImageURL = phetImageFile.toURI().toURL().toString();
    Image phetImage = new Image(phetImageURL, false);
    */

    final ImageView phetImageView = new ImageView();
    final Image phetImage =
        new Image(Main.class.getResourceAsStream("img/styleDark/poweredByPHET.png"));
    phetImageView.setImage(phetImage);

    Label motionLbl = new Label("Motion");
    motionLbl.getStyleClass().add("lbl");

    forcesAndMotionBtn = new Button();
    forcesAndMotionBtn.getStyleClass().add("forcesAndMotionBtn");
    forcesAndMotionBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html");
          simsPanel.setContent(browser);
        });

    balancingActBtn = new Button();
    balancingActBtn.getStyleClass().add("balancingActBtn");
    balancingActBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html");
          simsPanel.setContent(browser);
        });

    energySkateParkBtn = new Button();
    energySkateParkBtn.getStyleClass().add("energySkateParkBtn");
    energySkateParkBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/energy-skate-park-basics/latest/"
                  + "energy-skate-park-basics_en.html");
          simsPanel.setContent(browser);
        });

    balloonsAndStaticElectricityBtn = new Button();
    balloonsAndStaticElectricityBtn.getStyleClass().add("balloonsAndStaticElectricityBtn");
    balloonsAndStaticElectricityBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/"
                  + "balloons-and-static-electricity_en.html");
          simsPanel.setContent(browser);
        });

    buildAnAtomBtn = new Button();
    buildAnAtomBtn.getStyleClass().add("buildAnAtomBtn");
    buildAnAtomBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/build-an-atom/latest/build-an-atom_en.html");
          simsPanel.setContent(browser);
        });

    colorVisionBtn = new Button();
    colorVisionBtn.getStyleClass().add("colorVisionBtn");
    colorVisionBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/color-vision/latest/color-vision_en.html");
          simsPanel.setContent(browser);
        });

    Label soundAndWavesLbl = new Label("Sound and Waves");
    soundAndWavesLbl.getStyleClass().add("lbl");

    wavesOnAStringBtn = new Button();
    wavesOnAStringBtn.getStyleClass().add("wavesOnAStringBtn");
    wavesOnAStringBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/wave-on-a-string/latest/wave-on-a-string_en.html");
          simsPanel.setContent(browser);
        });

    /*
    motionSimsFlowPane = new FlowPane();
    motionSimsFlowPane.getStyleClass().add("flowPane");
    motionSimsFlowPane.setVgap(5);
    motionSimsFlowPane.setHgap(5);
    motionSimsFlowPane.setAlignment(Pos.TOP_LEFT);
    motionSimsFlowPane.getChildren().addAll(forcesAndMotionBtn, balancingActBtn, energySkateParkBtn,
            buildAnAtomBtn, colorVisionBtn, wavesOnAStringBtn);


    soundAndWavesFlowPane = new FlowPane();
    soundAndWavesFlowPane.getStyleClass().add("flowPane");
    soundAndWavesFlowPane.setVgap(5);
    soundAndWavesFlowPane.setHgap(5);
    soundAndWavesFlowPane.setAlignment(Pos.TOP_LEFT);
    soundAndWavesFlowPane.getChildren().addAll(wavesOnAStringBtn);


    simsBox = new VBox();
    simsBox.getStyleClass().add("vbox");
    simsBox.setPrefHeight(height);
    simsBox.setPrefWidth(width);
    simsBox.getChildren().addAll(motionLbl, motionSimsFlowPane, soundAndWavesLbl, soundAndWavesFlowPane);
    */

    simsGridPanel = new GridPane();
    simsGridPanel.getStyleClass().add("gridPane");
    simsGridPanel.setVgap(5);
    simsGridPanel.setHgap(5);
    simsGridPanel.setGridLinesVisible(false);
    simsGridPanel.setPrefWidth(width - 208);
    simsGridPanel.setPrefHeight(860);

    simsGridPanel.setRowIndex(phetImageView, 0);
    simsGridPanel.setColumnIndex(phetImageView, 4);

    simsGridPanel.setRowIndex(motionLbl, 0);
    simsGridPanel.setColumnIndex(motionLbl, 0);
    simsGridPanel.setRowIndex(forcesAndMotionBtn, 1);
    simsGridPanel.setColumnIndex(forcesAndMotionBtn, 0);
    simsGridPanel.setRowIndex(balancingActBtn, 1);
    simsGridPanel.setColumnIndex(balancingActBtn, 1);
    simsGridPanel.setRowIndex(energySkateParkBtn, 1);
    simsGridPanel.setColumnIndex(energySkateParkBtn, 2);
    simsGridPanel.setRowIndex(buildAnAtomBtn, 1);
    simsGridPanel.setColumnIndex(buildAnAtomBtn, 3);
    simsGridPanel.setRowIndex(colorVisionBtn, 1);
    simsGridPanel.setColumnIndex(colorVisionBtn, 4);

    simsGridPanel.setRowIndex(soundAndWavesLbl, 2);
    simsGridPanel.setColumnIndex(soundAndWavesLbl, 0);
    simsGridPanel.setColumnSpan(soundAndWavesLbl, 4);
    simsGridPanel.setRowIndex(wavesOnAStringBtn, 3);
    simsGridPanel.setColumnIndex(wavesOnAStringBtn, 0);

    simsGridPanel
        .getChildren()
        .addAll(
            phetImageView,
            motionLbl,
            forcesAndMotionBtn,
            balancingActBtn,
            energySkateParkBtn,
            buildAnAtomBtn,
            colorVisionBtn,
            soundAndWavesLbl,
            wavesOnAStringBtn);

    simsPanel = new ScrollPane();
    simsPanel.getStyleClass().add("scrollPane");
    simsPanel.setContent(simsGridPanel);

    // -----------------------------------------------------------------------------------------------> Simulations Pane End

    // ---------------------------------------------------------------------------------------------> Text Editor Pane Start

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefHeight(860);
    htmlEditor.setPrefWidth(width - 208);

    // Prevents Scroll on Space Pressed
    htmlEditor.addEventFilter(
        KeyEvent.KEY_PRESSED,
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getEventType() == KeyEvent.KEY_PRESSED) {
              if (event.getCode() == KeyCode.SPACE) {
                event.consume();
              }
            }
          }
        });

    XWPFDocument document = new XWPFDocument();
    XWPFParagraph tmpParagraph = document.createParagraph();
    XWPFRun tmpRun = tmpParagraph.createRun();

    saveDocBtn = new Button();
    saveDocBtn.getStyleClass().add("btn");
    saveDocBtn.setText("Save");
    saveDocBtn.setOnAction(
        e -> {
          tmpRun.setText(tools.stripHTMLTags(htmlEditor.getHtmlText()));
          tmpRun.setFontSize(12);
          saveDocument(document, primaryStage);
        });

    textEditorPanel = new ScrollPane();
    textEditorPanel.getStyleClass().add("scrollPane");
    textEditorPanel.setContent(htmlEditor);

    // -----------------------------------------------------------------------------------------------> Text Editor Pane End

    // -------------------------------------------------------------------------------------------------> Wolfram Pane Start

    Boolean wolframActive = false;
    try {
      final WebView wolframWeb = new WebView();
      wolframWeb.getStyleClass().add("webView");
      final WebEngine wolframWebEngine = wolframWeb.getEngine();
      wolframWeb.setPrefHeight(860);
      wolframWeb.setPrefWidth(width - 208);
      if (wolframActive == false) {
        wolframWebEngine.load("http://www.wolframalpha.com/");
        wolframActive = true;
      }
      wolframPanel = new ScrollPane();
      wolframPanel.setContent(wolframWeb);
    } catch (Exception excep) {
      System.out.println("<----- Exception in Wolfram Alpha Web ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    // ---------------------------------------------------------------------------------------------------> Wolfram Pane End

    // ------------------------------------------------------------------------------------------------> Wikipedia Pane Start

    Boolean wikipediaActive = false;
    try {
      final WebView wikipediaWeb = new WebView();
      wikipediaWeb.getStyleClass().add("scrollPane");
      wikipediaWebEngine = wikipediaWeb.getEngine();
      wikipediaWeb.setPrefHeight(860);
      wikipediaWeb.setPrefWidth(width - 208);
      if (wikipediaActive == false) {
        wikipediaWebEngine.load("https://en.wikipedia.org/wiki/Main_Page");
        wikipediaActive = true;
      }
      wikipediaPanel = new ScrollPane();
      wikipediaPanel.setContent(wikipediaWeb);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // --------------------------------------------------------------------------------------------------> Wikipedia Pane End

    // -------------------------------------------------------------------------------------------------> Settings Pane Start

    settingsGridPanel = new GridPane();
    settingsGridPanel.getStyleClass().add("gridPane");
    settingsGridPanel.setPrefWidth(width - 208);
    settingsGridPanel.setPrefHeight(height);
    settingsGridPanel.setVgap(5);
    settingsGridPanel.setHgap(5);

    settingsPanel = new ScrollPane();
    settingsPanel.getStyleClass().add("scrollPane");
    settingsPanel.setContent(settingsGridPanel);

    // ---------------------------------------------------------------------------------------------------> Settings Pane End
    rootPane = new BorderPane();
    rootPane.setLeft(leftPanel);
    rootPane.setTop(topPanel);
    rootPane.setCenter(dashBoardBase);
    rootPane.getStyleClass().add("rootPane");
    rootPane.getStylesheets().add(Main.class.getResource("css/styleDark.css").toExternalForm());

    programWidth = primaryStage.getWidth();
    programHeight = primaryStage.getHeight();

    primaryStage.setTitle("ALE");
    primaryStage.initStyle(StageStyle.UNDECORATED);
    primaryStage
        .getIcons()
        .add(new javafx.scene.image.Image(Main.class.getResourceAsStream("img/aleIcon.png")));
    primaryStage.setScene(new Scene(rootPane, width, height));
    primaryStage.show();
  }
Пример #17
0
  private Pane createChartsPane(double spacing) {
    final DateFormat dateFormat =
        DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);

    final XYChart.Series<String, Number> mpsSeries = new XYChart.Series<>();
    mpsSeries.setName("Flow Speed");
    final XYChart.Series<String, Number> rpsSeries = new XYChart.Series<>();
    rpsSeries.setName("Sensor Speed");

    KeyFrame chartUpdateFrame =
        new KeyFrame(
            Duration.seconds(5),
            new EventHandler<ActionEvent>() {
              @Override
              public void handle(ActionEvent t) {
                if (orca.isRunning()) {
                  ORCABuffer.Capture rpsCapture =
                      buffer
                          .getRotationsPerSecondBuffer()
                          .get(buffer.getRotationsPerSecondBuffer().size() - 1);
                  rpsSeries
                      .getData()
                      .add(
                          new XYChart.Data<String, Number>(
                              dateFormat.format(rpsCapture.getCaptureDate().getTime()),
                              rpsCapture.getData()));
                  ORCABuffer.Capture mpsCapture =
                      buffer
                          .getMetersPerSecondBuffer()
                          .get(buffer.getMetersPerSecondBuffer().size() - 1);
                  mpsSeries
                      .getData()
                      .add(
                          new XYChart.Data<String, Number>(
                              dateFormat.format(mpsCapture.getCaptureDate().getTime()),
                              mpsCapture.getData()));
                }
              }
            });

    Timeline chartUpdate = new Timeline(chartUpdateFrame);
    chartUpdate.setCycleCount(Timeline.INDEFINITE);
    chartUpdate.play();

    LineChart<String, Number> mpsChart =
        new LineChart(
            CategoryAxisBuilder.create().label("Date").build(),
            NumberAxisBuilder.create().label("Meters Per Second").build());

    mpsChart.setTitle("Flow Speed");
    mpsChart.getData().add(mpsSeries);

    LineChart<String, Number> rpsChart =
        new LineChart(
            CategoryAxisBuilder.create().label("Date").build(),
            NumberAxisBuilder.create().label("Rotations Per Sectond").build());

    rpsChart.setTitle("Sensor Speed");
    rpsChart.getData().add(rpsSeries);

    VBox charts = new VBox(spacing);
    charts.getChildren().addAll(mpsChart, rpsChart);

    return charts;
  }
Пример #18
0
 public void addToChart(LineChart<Number, Number> chart) {
   chart.getData().add(getSerie());
 }
  private void add_line_to_chart(
      LineChart<Number, Number> lineChart, String file_path, String name, int num, int ir) {
    XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
    series.setName(name);

    try {
      BufferedReader reader = new BufferedReader(new FileReader(file_path));
      System.out.println("\n * parsing input file");
      //                 nodi, IR,    CPU,    THR       mRT  p95RT
      // line format :    3; 80000; 91.701;  79753.125; 5.8; 16.0;
      //     n token :    0     1      2        3       4     5
      int time = 0;
      String line = reader.readLine();
      while (line != null) {
        StringTokenizer st = new StringTokenizer(line, ";");
        st.nextToken();
        int inputrate = Integer.parseInt(st.nextToken());
        if (inputrate == ir) {
          double cpu = Double.parseDouble(st.nextToken());

          series.getData().add(new XYChart.Data<Number, Number>(time, cpu));
          time = time + 15;
        }
        line = reader.readLine();
      }
      reader.close();

      lineChart.getData().add(series);
      System.out.println(" * new line inserted");

    } catch (IOException e) {
      System.err.println("Error in opening|writing|closing the file: " + file_path);
      e.printStackTrace();
    }

    XYChart.Series<Number, Number> seriesnodi = new XYChart.Series<Number, Number>();
    seriesnodi.setName("number of nodes");

    try {
      BufferedReader reader = new BufferedReader(new FileReader(file_path));
      System.out.println("\n * parsing input file");
      //                 nodi, IR,    CPU,    THR       mRT  p95RT
      // line format :    3; 80000; 91.701;  79753.125; 5.8; 16.0;
      //     n token :    0     1      2        3       4     5
      int time = 0;
      String line = reader.readLine();
      while (line != null) {
        StringTokenizer st = new StringTokenizer(line, ";");
        int nodi = Integer.parseInt(st.nextToken());
        int inputrate = Integer.parseInt(st.nextToken());
        if (inputrate == ir) {

          seriesnodi.getData().add(new XYChart.Data<Number, Number>(time, nodi * 8));
          time = time + 15;
        }
        line = reader.readLine();
      }
      reader.close();

      lineChart.getData().add(seriesnodi);
      System.out.println(" * new line inserted");

    } catch (IOException e) {
      System.err.println("Error in opening|writing|closing the file: " + file_path);
      e.printStackTrace();
    }
  }
Пример #20
0
  static LineChart<String, Number> initializeChart(
      String title, boolean showPercentages, VBox container) {

    final CategoryAxis xAxis = new CategoryAxis();
    final NumberAxis yAxis = new NumberAxis();
    if (showPercentages) {
      yAxis.setLabel("%");
    } else {
      yAxis.setLabel("€");
    }
    yAxis.setForceZeroInRange(false);
    yAxis.setSide(Side.RIGHT);

    final LineChart<String, Number> lineChart = new LineChart<>(xAxis, yAxis);
    lineChart.setPrefHeight(700);
    lineChart.setTitle(title);
    lineChart.setTitleSide(Side.LEFT);
    lineChart.setCreateSymbols(false);
    lineChart.setVerticalGridLinesVisible(false);
    lineChart.setHorizontalGridLinesVisible(true);

    XYChart.Series seriesMax = new XYChart.Series();
    XYChart.Series seriesMin = new XYChart.Series();
    XYChart.Series seriesAverage = new XYChart.Series();
    lineChart.getData().addAll(seriesMax, seriesMin, seriesAverage);

    lineChart.setLegendVisible(true);
    lineChart.setLegendSide(Side.RIGHT);

    container.getChildren().add(lineChart);

    lineChart.getStylesheets().add("charts.css");

    return lineChart;
  }
Пример #21
0
  protected TabbedInspector buildInspector() {

    // create the network
    network = new ExchangeNetwork(getGoodType());

    // if there is no GUI, forget about it
    Preconditions.checkState(MacroII.hasGUI()); // can't be called otherwise!

    TabbedInspector toReturn = new TabbedInspector(true);
    toReturn.setName(toString() + " inspector");

    /**
     * ******************************************* Prices ******************************************
     */

    // switching to JavaFX for fun and profit
    // set up the chart
    panel = new JFXPanel();

    NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();
    xAxis.setLabel("Day");
    yAxis.setLabel("Price");
    final LineChart<Number, Number> priceChart = new LineChart<>(xAxis, yAxis);
    priceChart.setAnimated(true);

    // set up the series
    priceSeries = new XYChart.Series<>();
    priceSeries.setName("LastClosingPrice");
    // now make the price update whenever data updates!
    // use steppable to update

    priceChart.getData().add(priceSeries);

    Platform.runLater(
        new Runnable() {
          @Override
          public void run() {
            panel.setScene(new Scene(priceChart));
          }
        });
    // we are going to add the new JPanel IN the new inspector
    closingPriceInspector =
        new Inspector() {
          @Override
          public void updateInspector() {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    repaint();
                  }
                });
          }
        };
    closingPriceInspector.setVolatile(true);
    closingPriceInspector.setLayout(new BorderLayout()); // this centers it
    closingPriceInspector.add(panel);

    toReturn.addInspector(closingPriceInspector, "Closing price");

    /**
     * ******************************************* VOLUME ******************************************
     */

    // switching to JavaFX for fun and profit
    // set up the chart
    final JFXPanel panel2 = new JFXPanel();

    xAxis = new NumberAxis();
    yAxis = new NumberAxis();
    xAxis.setLabel("Day");
    yAxis.setLabel("Volume");
    final LineChart<Number, Number> volumeChart = new LineChart<>(xAxis, yAxis);
    volumeChart.setAnimated(true);
    volumeChart.setCreateSymbols(false);
    // set up the series
    volumeSeries = new XYChart.Series<Number, Number>();
    volumeSeries.setName("Daily Volume Traded");

    volumeChart.getData().add(volumeSeries);
    Platform.runLater(
        new Runnable() {
          @Override
          public void run() {
            panel2.setScene(new Scene(volumeChart));
          }
        });
    // we are going to add the new JPanel IN the new inspector
    Inspector closingVolumeInspector =
        new Inspector() {
          @Override
          public void updateInspector() {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    repaint();
                  }
                });
          }
        };
    closingVolumeInspector.setVolatile(true);
    closingVolumeInspector.setLayout(new BorderLayout()); // this centers it
    closingVolumeInspector.add(panel2);

    toReturn.addInspector(closingVolumeInspector, "Volume");

    /**
     * ******************************************* TIMELINE
     * ******************************************
     */
    // todo logtodo

    /**
     * ************************************************* Network
     * *************************************************
     */
    Inspector networkInspector =
        new Inspector() {
          @Override
          public void updateInspector() {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    repaint();
                  }
                });
          }
        };
    networkInspector.setLayout(new BorderLayout());
    // add the visualization
    networkInspector.add(network.getVisualization());
    toReturn.addInspector(networkInspector, "Network");

    return toReturn;
  }
Пример #22
0
  protected PropertySheet createPropertySheet() {
    final LineChart<Number, Number> lc = (LineChart<Number, Number>) getChildren().get(0);
    final NumberAxis xAxis = (NumberAxis) lc.getXAxis();
    final NumberAxis yAxis = (NumberAxis) lc.getYAxis();
    // create actions
    EventHandler<ActionEvent> addDataItem =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (lc.getData() == null) {
              lc.setData(
                  FXCollections.observableArrayList(
                      new Series<Number, Number>(
                          FXCollections.observableArrayList(
                              new XYChart.Data<Number, Number>(
                                  Math.random() * 1000, Math.random() * 1000)))));
            } else if (lc.getData().isEmpty()) {
              lc.getData()
                  .add(
                      new Series<Number, Number>(
                          FXCollections.observableArrayList(
                              new XYChart.Data<Number, Number>(
                                  Math.random() * 1000, Math.random() * 1000))));
            } else {
              Series<Number, Number> s =
                  lc.getData().get((int) (Math.random() * lc.getData().size()));
              if (s != null)
                s.getData()
                    .add(
                        new LineChart.Data<Number, Number>(
                            Math.random() * 1000, Math.random() * 1000));
            }
          }
        };
    EventHandler<ActionEvent> insertDataItem =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (lc.getData() != null && !lc.getData().isEmpty()) {
              Series<Number, Number> s =
                  lc.getData().get((int) (Math.random() * lc.getData().size()));
              if (s != null)
                s.getData()
                    .add(
                        (int) (s.getData().size() * Math.random()),
                        new LineChart.Data<Number, Number>(
                            Math.random() * 1000, Math.random() * 1000));
            }
          }
        };
    EventHandler<ActionEvent> addDataItemNegative =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (lc.getData() == null) {
              lc.setData(
                  FXCollections.observableArrayList(
                      new Series<Number, Number>(
                          FXCollections.observableArrayList(
                              new XYChart.Data<Number, Number>(
                                  Math.random() * -200, Math.random() * -200)))));
            } else if (lc.getData().isEmpty()) {
              lc.getData()
                  .add(
                      new Series<Number, Number>(
                          FXCollections.observableArrayList(
                              new XYChart.Data<Number, Number>(
                                  Math.random() * -200, Math.random() * -200))));
            } else {
              Series<Number, Number> s =
                  lc.getData().get((int) (Math.random() * lc.getData().size()));
              if (s != null)
                s.getData()
                    .add(
                        new LineChart.Data<Number, Number>(
                            Math.random() * -200, Math.random() * -200));
            }
          }
        };
    EventHandler<ActionEvent> deleteDataItem =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            ChartActions.deleteDataItem(lc);
          }
        };
    EventHandler<ActionEvent> changeDataItem =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (lc.getData() != null && !lc.getData().isEmpty()) {
              Series<Number, Number> s =
                  lc.getData().get((int) (Math.random() * (lc.getData().size())));
              if (s != null && !s.getData().isEmpty()) {
                XYChart.Data<Number, Number> d =
                    s.getData().get((int) (Math.random() * (s.getData().size())));
                if (d != null) {
                  d.setXValue(d.getXValue().doubleValue() + (Math.random() * 50) - 25);
                  d.setYValue(Math.random() * 1000);
                }
              }
            }
          }
        };
    EventHandler<ActionEvent> addSeries =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (lc.getData() == null) {
              lc.setData(FXCollections.<Series<Number, Number>>observableArrayList());
            }
            Series<Number, Number> series = new Series<Number, Number>();
            series.setName("Data Series 1");
            double x = 0;
            for (int i = 0; i < 10; i++) {
              x += Math.random() * 100;
              series.getData().add(new LineChart.Data<Number, Number>(x, Math.random() * 800));
            }
            if (lc.getData() == null)
              lc.setData(FXCollections.<Series<Number, Number>>observableArrayList());
            lc.getData().add(series);
          }
        };
    EventHandler<ActionEvent> deleteSeries =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (lc.getData() != null && !lc.getData().isEmpty()) {
              lc.getData().remove((int) (Math.random() * lc.getData().size()));
            }
          }
        };
    EventHandler<ActionEvent> animateData =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (lc.getData() == null) {
              return;
            }
            Timeline tl = new Timeline();
            tl.getKeyFrames()
                .add(
                    new KeyFrame(
                        Duration.millis(500),
                        new EventHandler<ActionEvent>() {
                          @Override
                          public void handle(ActionEvent actionEvent) {
                            for (Series<Number, Number> series : lc.getData()) {
                              for (XYChart.Data<Number, Number> data : series.getData()) {
                                data.setXValue(Math.random() * 1000);
                                data.setYValue(Math.random() * 1000);
                              }
                            }
                          }
                        }));
            tl.setCycleCount(30);
            tl.play();
          }
        };
    EventHandler<ActionEvent> animateDataFast =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            if (lc.getData() == null) {
              return;
            }
            lc.setAnimated(false);
            Timeline tl = new Timeline();
            tl.getKeyFrames()
                .add(
                    new KeyFrame(
                        Duration.millis(50),
                        new EventHandler<ActionEvent>() {
                          @Override
                          public void handle(ActionEvent actionEvent) {
                            for (Series<Number, Number> series : lc.getData()) {
                              for (XYChart.Data<Number, Number> data : series.getData()) {
                                data.setXValue(-500 + Math.random() * 1000);
                                data.setYValue(-500 + Math.random() * 1000);
                              }
                            }
                          }
                        }));
            tl.setOnFinished(
                new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                    lc.setAnimated(true);
                  }
                });
            tl.setCycleCount(100);
            tl.play();
          }
        };
    EventHandler<ActionEvent> removeAllData =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            lc.setData(null);
          }
        };
    EventHandler<ActionEvent> setNewData =
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent actionEvent) {
            ObservableList<Series<Number, Number>> data = FXCollections.observableArrayList();
            for (int j = 0; j < 5; j++) {
              Series<Number, Number> series = new Series<Number, Number>();
              series.setName("Data Series " + j);
              double x = 0;
              for (int i = 0; i < 10; i++) {
                x += Math.random() * 100;
                series.getData().add(new LineChart.Data<Number, Number>(x, Math.random() * 800));
              }
              data.add(series);
            }
            lc.setData(data);
          }
        };

    // Create X/Y side overriding values to filter out unhelpful values
    List<Enum> xValidSides = new ArrayList();
    xValidSides.add(Side.BOTTOM);
    xValidSides.add(Side.TOP);

    List<Enum> yValidSides = new ArrayList();
    yValidSides.add(Side.LEFT);
    yValidSides.add(Side.RIGHT);

    // create property editor
    return new PropertySheet(
        new PropertySheet.PropertyGroup(
            "Actions",
            PropertySheet.createProperty("Add Data Item", addDataItem),
            PropertySheet.createProperty("Insert Data Item", insertDataItem),
            PropertySheet.createProperty("Add Data Item Negative", addDataItemNegative),
            PropertySheet.createProperty("Delete Data Item", deleteDataItem),
            PropertySheet.createProperty("Change Data Item", changeDataItem),
            PropertySheet.createProperty("Add Series", addSeries),
            PropertySheet.createProperty("Delete Series", deleteSeries),
            PropertySheet.createProperty("Remove All Data", removeAllData),
            PropertySheet.createProperty("Set New Data", setNewData)),
        new PropertySheet.PropertyGroup(
            "Chart Properties",
            PropertySheet.createProperty("Title", lc.titleProperty()),
            PropertySheet.createProperty("Title Side", lc.titleSideProperty()),
            PropertySheet.createProperty("Legend Side", lc.legendSideProperty())),
        new PropertySheet.PropertyGroup(
            "XY Chart Properties",
            PropertySheet.createProperty(
                "Vertical Grid Line Visible", lc.verticalGridLinesVisibleProperty()),
            PropertySheet.createProperty(
                "Horizontal Grid Line Visible", lc.horizontalGridLinesVisibleProperty()),
            PropertySheet.createProperty(
                "Alternative Column Fill Visible", lc.alternativeColumnFillVisibleProperty()),
            PropertySheet.createProperty(
                "Alternative Row Fill Visible", lc.alternativeRowFillVisibleProperty()),
            PropertySheet.createProperty(
                "Vertical Zero Line Visible", lc.verticalZeroLineVisibleProperty()),
            PropertySheet.createProperty(
                "Horizontal Zero Line Visible", lc.horizontalZeroLineVisibleProperty()),
            PropertySheet.createProperty("Animated", lc.animatedProperty())),
        new PropertySheet.PropertyGroup(
            "Line Chart Properties",
            PropertySheet.createProperty("Create Symbols", lc.createSymbolsProperty())),
        new PropertySheet.PropertyGroup(
            "X Axis Properties",
            PropertySheet.createProperty("Side", xAxis.sideProperty(), xValidSides),
            PropertySheet.createProperty("Label", xAxis.labelProperty()),
            PropertySheet.createProperty("Tick Mark Length", xAxis.tickLengthProperty()),
            PropertySheet.createProperty("Auto Ranging", xAxis.autoRangingProperty()),
            PropertySheet.createProperty("Tick Label Font", xAxis.tickLabelFontProperty()),
            PropertySheet.createProperty("Tick Label Fill", xAxis.tickLabelFillProperty()),
            PropertySheet.createProperty("Tick Label Gap", xAxis.tickLabelGapProperty()),
            // Value Axis Props
            // PropertySheet.createProperty("Scale",xAxis.scaleProperty(), true),
            PropertySheet.createProperty("Lower Bound", xAxis.lowerBoundProperty(), true),
            PropertySheet.createProperty("Upper Bound", xAxis.upperBoundProperty(), true),
            PropertySheet.createProperty(
                "Tick Label Formatter", xAxis.tickLabelFormatterProperty()),
            PropertySheet.createProperty("Minor Tick Length", xAxis.minorTickLengthProperty()),
            PropertySheet.createProperty("Minor Tick Count", xAxis.minorTickCountProperty()),
            // Number Axis Properties
            PropertySheet.createProperty("Force Zero In Range", xAxis.forceZeroInRangeProperty()),
            PropertySheet.createProperty("Tick Unit", xAxis.tickUnitProperty())),
        new PropertySheet.PropertyGroup(
            "Y Axis Properties",
            PropertySheet.createProperty("Side", yAxis.sideProperty(), yValidSides),
            PropertySheet.createProperty("Label", yAxis.labelProperty()),
            PropertySheet.createProperty("Tick Mark Length", yAxis.tickLengthProperty()),
            PropertySheet.createProperty("Auto Ranging", yAxis.autoRangingProperty()),
            PropertySheet.createProperty("Tick Label Font", yAxis.tickLabelFontProperty()),
            PropertySheet.createProperty("Tick Label Fill", yAxis.tickLabelFillProperty()),
            PropertySheet.createProperty("Tick Label Gap", yAxis.tickLabelGapProperty()),
            // Value Axis Props
            // PropertySheet.createProperty("Scale",yAxis.scaleProperty(), true),
            PropertySheet.createProperty("Lower Bound", yAxis.lowerBoundProperty(), true),
            PropertySheet.createProperty("Upper Bound", yAxis.upperBoundProperty(), true),
            PropertySheet.createProperty(
                "Tick Label Formatter", yAxis.tickLabelFormatterProperty()),
            PropertySheet.createProperty("Minor Tick Length", yAxis.minorTickLengthProperty()),
            PropertySheet.createProperty("Minor Tick Count", yAxis.minorTickCountProperty()),
            // Number Axis Properties
            PropertySheet.createProperty("Force Zero In Range", yAxis.forceZeroInRangeProperty()),
            PropertySheet.createProperty("Tick Unit", yAxis.tickUnitProperty())));
  }
 @SuppressWarnings("unchecked")
 private void removeSeries(XYChart.Series<Number, Number> series) {
   lineChart.getData().removeAll(series);
 }