Example #1
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();
  }
Example #2
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();
  }