Beispiel #1
0
  public void displayLocation() {
    pokupiPodatke();
    dateModel = new LineChartModel();

    dateModel.setExtender("chartExtender");
    dateModel.setZoom(true);
    dateModel.getAxis(AxisType.Y).setLabel("Values");

    for (ProgramMjerenja pm : selektiraniPodaci.keySet()) {
      List<Podatak> podaci = selektiraniPodaci.get(pm);

      LineChartSeries series1 = new LineChartSeries();
      series1.setLabel(pm.getKomponentaId().getNaziv());
      for (Podatak p : podaci) {
        if (p.getObuhvat() > 74) {
          series1.set(sdf.format(p.getVrijeme()), p.getVrijednost());
        }
      }
      //            series1.setMarkerStyle("circle");
      dateModel.addSeries(series1);
    }
    DateAxis axis = new DateAxis("Dates");
    axis.setTickAngle(-50);
    axis.setMin(sdf.format(d1));
    axis.setMax(sdf.format(d2));
    axis.setTickFormat("%m. %d. %H:%M");
    dateModel.getAxes().put(AxisType.X, axis);
    dateModel.setLegendPosition("ne");
  }
Beispiel #2
0
  private void pisiCsv(CsvWriter csvWriter) {
    try {
      SortedMap<Date, Integer> vremena = new TreeMap<>();
      Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+1"));
      cal.setTime(d1);
      int nrow = 0;
      while (!cal.getTime().after(d2)) {
        vremena.put(cal.getTime(), nrow);
        cal.add(Calendar.HOUR, 1);
        nrow++;
      }
      int size = selektiraniPodaci.keySet().size();

      csvWriter.write("Vrijeme");
      HashMap<ProgramMjerenja, Integer> komponente = new HashMap<>();
      Integer ncol = 0;
      for (ProgramMjerenja pm : selektiraniPodaci.keySet()) {
        try {
          komponente.put(pm, ncol);
          csvWriter.write(pm.getKomponentaId().getFormula());
          csvWriter.write("obuhvat");
          csvWriter.write("status");

          ncol++;
        } catch (IOException ex) {
          Logger.getLogger(PfTest.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
      csvWriter.endRecord();
      Podatak[][] tablica = new Podatak[nrow][size];
      for (ProgramMjerenja pm : selektiraniPodaci.keySet()) {
        List<Podatak> podatak = podatakFacade.getPodatak(pm, d1, d2, true, true);
        for (Podatak p : podatak) {
          Integer i = komponente.get(pm);
          Integer j = vremena.get(p.getVrijeme());
          tablica[j][i] = p;
        }
      }
      for (Date d : vremena.keySet()) {
        try {

          csvWriter.write(sdf.format(d));
          for (int i = 0; i < ncol; i++) {
            Podatak p = tablica[vremena.get(d)][i];
            if (p != null) {
              csvWriter.write(p.getVrijednost().toString());
              csvWriter.write(p.getObuhvat().toString());
              csvWriter.write(Integer.toString(p.getStatus()));
            } else {

            }
          }
          csvWriter.endRecord();
        } catch (IOException ex) {
          Logger.getLogger(PfTest.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
      csvWriter.flush();
    } catch (IOException ex) {
      Logger.getLogger(PfTest.class.getName()).log(Level.SEVERE, null, ex);
    }
  }