Пример #1
0
  private void importProjectAndData() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setApproveButtonText("Importa");
    fileChooser.setDialogTitle("Importa progetto e  dati");
    fileChooser.addChoosableFileFilter(new GenericFileFilter(".atd", "Arduino Trend Data"));
    int n = fileChooser.showOpenDialog(view);

    if (n == JFileChooser.APPROVE_OPTION) {

      try {
        project.importProjectAndData(fileChooser.getSelectedFile());
        file = null;
        inizializePens(project.getPenModels());
        modelListPens.update(null, null);
        view.setTitle(project.getTitle());
        view.trend.setModel(project.getTrendModel());
        view.trend.setMillsAtFirstRecord();
      } catch (IOException e) {
        view.popupErrorMessage(e.getMessage());
        e.printStackTrace();
      } catch (ClassNotFoundException e) {
        view.popupErrorMessage("File non trovato");
        e.printStackTrace();
      }
    }
  }
Пример #2
0
 private void removeAllPen() {
   for (int i = 0; i < pens.length; i++) {
     pens[i] = null;
   }
   modelListPens.update(null, null);
   view.setEnabledAddPen(true);
 }
Пример #3
0
 private void newProject() {
   project = new Project("Senza Titolo");
   file = null;
   view.setTitle(project.getTitle());
   inizializePens(project.getPenModels());
   modelListPens.update(null, null);
   view.setTitle(project.getTitle());
   view.trend.setModel(project.getTrendModel());
 }
Пример #4
0
  private void removePen(int index) {

    for (int i = index; i < pens.length; i++) {

      if (i < pens.length - 1) {
        pens[i] = pens[i + 1];
      } else {
        pens[i] = null;
      }
    }
    modelListPens.update(null, null);

    view.setEnabledAddPen(true);

    fileEdited = true;
  }
Пример #5
0
  private void addNewPen(Pen pen) {
    for (int i = 0; i < pens.length; i++) {
      if (pens[i] == null) {
        pens[i] = pen;
        if (view.trend.isPlay()) {
          pens[i].startReg();
        }
        if (i == 0 && view.trend.getTypeScaleAxisY() == TrendModel.TYPE_SCALE_AXIS_Y.PENS) {
          view.trend.setScaleAxisY(pen.getMin(), pen.getMax());
        }
        if (i == pens.length - 1) view.setEnabledAddPen(false);
        break;
      }
    }
    modelListPens.update(null, null);

    fileEdited = true;
  }
Пример #6
0
  private void openProject() {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.addChoosableFileFilter(new GenericFileFilter(".atp", "Arduino Trend Progetto"));
    int n = fileChooser.showOpenDialog(view);

    if (n == JFileChooser.APPROVE_OPTION) {

      try {
        project.load(fileChooser.getSelectedFile());
        file = fileChooser.getSelectedFile();
        inizializePens(project.getPenModels());
        modelListPens.update(null, null);
        view.setTitle(project.getTitle());
        view.trend.setModel(project.getTrendModel());
      } catch (IOException e) {
        view.popupErrorMessage(e.getMessage());
        e.printStackTrace();
      } catch (ClassNotFoundException e) {
        view.popupErrorMessage("File non trovato");
        e.printStackTrace();
      }
    }
  }