Esempio n. 1
0
  public void open() throws IOException {

    paneCenter.getChildren().clear();

    String station = (String) cbStations.getValue();

    File f = new File("database\\" + station + "\\status.txt");
    FileReader fr1 = new FileReader(f);
    LineNumberReader ln = new LineNumberReader(fr1);
    int count = 0;
    while (ln.readLine() != null) {
      count++;
    }
    ln.close();
    fr1.close();

    FileReader fr2 = new FileReader(f);
    BufferedReader br = new BufferedReader(fr2);

    paneCenter.add(new Label("Last seen : " + (br.readLine())), 0, 0);

    for (int i = 1; i < count; i++) {
      paneCenter.add(new Label(br.readLine()), 0, i);
    }
    br.close();
    fr2.close();

    addQuantityToCB();
  }
Esempio n. 2
0
  public void addStationsToCB() throws IOException {
    File f = new File("config");

    FileReader fr1 = new FileReader(f);
    LineNumberReader ln = new LineNumberReader(fr1);
    int count = 0;
    while (ln.readLine() != null) {
      count++;
    }
    ln.close();
    fr1.close();

    FileReader fr2 = new FileReader(f);
    BufferedReader br = new BufferedReader(fr2);
    for (int i = 0; i < count; i++) {
      cbStations.getItems().add(br.readLine());
    }
    br.close();
    fr2.close();
  }
Esempio n. 3
0
  public void showGraph() {
    Stage secondaryStage = new Stage();

    String quantity = (String) cbQuantity.getValue().toString();
    secondaryStage.setTitle(quantity);

    LineChart<Long, Number> lc = null;

    switch (quantity) {
      case "Wind Speed":
        windSerie.add(new XYChart.Series<>("Wind Speed", windData));
        lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 130, 10), windSerie);
        break;

      case "Temperature":
        temperatureSerie.add(new XYChart.Series<>("Temperature", temperatureData));
        lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 50, 10), temperatureSerie);
        break;

      case "Rainfall Rate":
        rainfallSerie.add(new XYChart.Series<>("Rainfall Rate", rainfallData));
        lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 100, 10), rainfallSerie);
        break;

      case "Humidity":
        humiditySerie.add(new XYChart.Series<>("Humidity", humidityData));
        lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 100, 10), humiditySerie);
        break;

      case "Pressure":
        pressureSerie.add(new XYChart.Series<>("Pressure", pressureData));
        lc = new LineChart<>(new DateAxis(), new NumberAxis("Value", 0, 20, 10), pressureSerie);
        break;
    }

    graphic = new Scene(lc, 500, 250);

    secondaryStage.setScene(graphic);
    secondaryStage.show();
  }
Esempio n. 4
0
  public void addQuantityToCB() throws IOException {

    temperatureSerie.removeAll();
    pressureSerie.removeAll();
    windSerie.removeAll();
    rainfallSerie.removeAll();
    humiditySerie.removeAll();

    cbQuantity.getItems().clear();

    String station = (String) cbStations.getValue();
    File f = new File("database\\" + station + "\\data.txt");

    FileReader fr1 = new FileReader(f);
    LineNumberReader ln = new LineNumberReader(fr1);
    int count = 0;
    while (ln.readLine() != null) {
      count++;
    }
    ln.close();
    fr1.close();

    FileReader fr2 = new FileReader(f);
    BufferedReader br = new BufferedReader(fr2);

    boolean wsFlag = false;
    boolean prFlag = false;
    boolean teFlag = false;
    boolean huFlag = false;
    boolean rrFlag = false;

    for (int i = 0; i < count; i++) {

      String line = br.readLine();
      String[] words = line.split(" ");

      for (int j = 0; j < words.length; j++) {

        if (words[0].equals("") == false) {

          long timeValue = Long.parseLong(words[0]);

          if (words[j].equals("WS")) {
            windData.add(new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2])));
            if (wsFlag == false) {
              cbQuantity.getItems().add("Wind Speed");

              wsFlag = true;
            }
          } else if (words[j].equals("PR")) {
            pressureData.add(
                new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2])));
            if (prFlag == false) {
              cbQuantity.getItems().add("Pressure");
              prFlag = true;
            }
          } else if (words[j].equals("TE")) {
            temperatureData.add(
                new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2])));
            if (teFlag == false) {
              cbQuantity.getItems().add("Temperature");
              teFlag = true;
            }
          } else if (words[j].equals("HU")) {
            humidityData.add(
                new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2])));
            if (huFlag == false) {
              cbQuantity.getItems().add("Humidity");
              huFlag = true;
            }
          } else if (words[j].equals("RR")) {
            rainfallData.add(
                new XYChart.Data<Long, Number>(timeValue, Integer.parseInt(words[j + 2])));
            if (rrFlag == false) {
              cbQuantity.getItems().add("Rainfall Rate");
              rrFlag = true;
            }
          }
        }
      }
    }
    br.close();
    fr2.close();
  }