示例#1
0
  private void inititateSarType() {
    int selectedIndex = typeSelectionComboBox.getSelectedIndex();
    // 0 Simple SAR
    // 1 Rapid Response
    // 2 Datum Point
    // 3 Datum Line
    // 4 Back track

    switch (selectedIndex) {
      case 0:
        voctManager.setSarType(SAR_TYPE.SIMPLE_SAR);
        // rapidResponseDatumPointInputPanel
        // .setSARType(SAR_TYPE.RAPID_RESPONSE);

        currentCard = SIMPLESAR;
        break;
      case 1:
        voctManager.setSarType(SAR_TYPE.RAPID_RESPONSE);
        rapidResponseDatumPointInputPanel.setSARType(SAR_TYPE.RAPID_RESPONSE);
        currentCard = INPUTSARRAPIDRESPONSEDATUM;
        break;
      case 2:
        voctManager.setSarType(SAR_TYPE.DATUM_POINT);
        rapidResponseDatumPointInputPanel.setSARType(SAR_TYPE.DATUM_POINT);
        currentCard = INPUTSARRAPIDRESPONSEDATUM;
        break;
      case 3:
        voctManager.setSarType(SAR_TYPE.DATUM_LINE);
        currentCard = INPUTPANELDATUMLINE;
        break;
        // case 3:
        // voctManager.setSarType(SAR_TYPE.BACKTRACK);
        // // currentCard = INPUTSARRAPIDRESPONSEDATUM;
        // break;
    }
  }
示例#2
0
  private boolean validateInputAndInititate() {
    SAR_TYPE type = voctManager.getSarType();

    switch (type) {
      case RAPID_RESPONSE:
        return validateRapidResponse();
      case DATUM_POINT:
        return validateRapidResponse();
      case DATUM_LINE:
        return validateDatumLine();
      case BACKTRACK:
        return false;
      case NONE:
        return false;
      case SIMPLE_SAR:
        return validateSimpleSar();
      default:
        return false;
    }
  }
示例#3
0
  /**
   * Create the dialog.
   *
   * @param voctManager
   */
  public SARInputCommon(VOCTManagerCommon voctManager) {
    this.voctManager = voctManager;

    voctManager.addListener(this);

    setTitle("SAR Operation");
    this.setModal(true);
    this.setResizable(false);

    // setBounds(100, 100, 559, 733);
    setBounds(100, 100, 559, 500);

    masterPanel = new JPanel();

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(masterPanel, BorderLayout.CENTER);

    buttomBar();

    // We initialize it with the init pane, this is where you select the
    // type of operation

    masterPanel.setLayout(new CardLayout());

    initPanel();
    inputPanel();
    calculationsPanel();

    // CardLayout cl = (CardLayout) (masterPanel.getLayout());
    // backButton.setEnabled(true);
    //
    // inititateSarType();
    //
    // System.out.println("Setting panel to " + currentCard);
    //
    // // The type select determines which panel we show
    // cl.show(masterPanel, currentCard);
  }
示例#4
0
  private boolean validateRapidResponse() {

    // System.out.println("Validating Rapid Response");

    // Get LKP values
    double rapidResponseLKPLat = rapidResponseDatumPointInputPanel.getRapidResponseDatumLKPLat();

    if (rapidResponseLKPLat == -9999) {
      return false;
    }

    double rapidResponseLKPLon = rapidResponseDatumPointInputPanel.getRapidResponseDatumLKPLon();

    Position rapidResponsePosition;

    if (rapidResponseLKPLat != -9999 && rapidResponseLKPLon != -9999) {
      rapidResponsePosition = Position.create(rapidResponseLKPLat, rapidResponseLKPLon);
    } else {
      // msgbox
      // System.out.println("Failed lat");
      return false;
    }

    // System.out.println("All validated correctly, we got positions");

    // System.out.println("LKP Date is "
    // + rapidResponseDatumPointInputPanel.getLKPDate());
    // System.out.println("CSS Date is "
    // + rapidResponseDatumPointInputPanel.getCSSDate());

    // Time and date will be automatically sorted

    List<SurfaceDriftPanel> weatherList =
        rapidResponseDatumPointInputPanel.getSurfaceDriftPanelList();

    List<SARWeatherData> sarWeatherDataPoints = new ArrayList<SARWeatherData>();

    for (int i = 0; i < weatherList.size(); i++) {
      // Get weather
      SurfaceDriftPanel weatherPanel = weatherList.get(i);

      double TWCKnots = weatherPanel.getTWCKnots();

      if (TWCKnots == -9999) {
        // Error message is handled within function
        return false;
      }

      double leewayKnots = weatherPanel.getLeeway();

      if (leewayKnots == -9999) {
        // Error message is handled within function
        return false;
      }

      double twcHeading = weatherPanel.getTWCHeading();

      if (twcHeading == -9999) {
        // Error message is handled within function
        return false;
      }

      double leewayHeading = weatherPanel.getLeewayHeading();

      if (leewayHeading == -9999) {
        // Error message is handled within function
        return false;
      }

      DateTime dateTime = new DateTime(weatherPanel.getDateTime().getTime());

      SARWeatherData sarWeatherData =
          new SARWeatherData(twcHeading, TWCKnots, leewayKnots, leewayHeading, dateTime);

      sarWeatherDataPoints.add(sarWeatherData);
    }

    double xError = rapidResponseDatumPointInputPanel.getInitialPositionError();

    if (xError == -9999) {
      // Error message is handled within function
      return false;
    }

    double yError = rapidResponseDatumPointInputPanel.getNavError();

    if (yError == -9999) {
      // Error message is handled within function
      return false;
    }

    double safetyFactor = rapidResponseDatumPointInputPanel.getSafetyFactor();

    if (safetyFactor == -9999) {
      // Error message is handled within function
      return false;
    }

    int searchObject = rapidResponseDatumPointInputPanel.getSearchItemID();

    // Only valid search objects is value 0 to 19
    if (searchObject < 0 || searchObject > 20) {
      // Error message is handled within function
      // System.out.println("failed search object with id " +
      // searchObject);
      return false;
    }

    // rapidResponsePosition
    // commenceStartPosition
    // TWCKnots
    // twcHeading
    // leewayKnots
    // leewayHeading
    // xError
    // yError
    // safetyFactor
    // searchObject

    if (!rapidResponseDatumPointInputPanel.checkTime()) {
      return false;
    }

    if (!rapidResponseDatumPointInputPanel.checkMetocTime()) {
      return false;
    }

    voctManager.inputRapidResponseDatumData(
        rapidResponseDatumPointInputPanel.getSARID(),
        rapidResponseDatumPointInputPanel.getLKPDate(),
        rapidResponseDatumPointInputPanel.getCSSDate(),
        rapidResponsePosition,
        xError,
        yError,
        safetyFactor,
        searchObject,
        sarWeatherDataPoints);

    return true;
  }
示例#5
0
  private boolean validateSimpleSar() {

    // Datum
    if (simpleSarInputPanel.getDatumLat() == -9999) {
      return false;
    }

    if (simpleSarInputPanel.getDatumLon() == -9999) {
      return false;
    }

    Position datum =
        Position.create(simpleSarInputPanel.getDatumLat(), simpleSarInputPanel.getDatumLon());

    // A position
    if (simpleSarInputPanel.getALat() == -9999) {
      return false;
    }

    if (simpleSarInputPanel.getALon() == -9999) {
      return false;
    }

    Position aPos = Position.create(simpleSarInputPanel.getALat(), simpleSarInputPanel.getALon());

    // B Position
    if (simpleSarInputPanel.getBLat() == -9999) {
      return false;
    }

    if (simpleSarInputPanel.getBLon() == -9999) {
      return false;
    }

    Position bPos = Position.create(simpleSarInputPanel.getBLat(), simpleSarInputPanel.getBLon());

    // C Position
    if (simpleSarInputPanel.getCLat() == -9999) {
      return false;
    }

    if (simpleSarInputPanel.getCLon() == -9999) {
      return false;
    }

    Position cPos = Position.create(simpleSarInputPanel.getCLat(), simpleSarInputPanel.getCLon());

    // D Position
    if (simpleSarInputPanel.getDLat() == -9999) {
      return false;
    }

    if (simpleSarInputPanel.getDLon() == -9999) {
      return false;
    }

    Position dPos = Position.create(simpleSarInputPanel.getDLat(), simpleSarInputPanel.getDLon());

    if (!simpleSarInputPanel.checkTime()) {
      return false;
    }

    double xError = simpleSarInputPanel.getInitialPositionError();

    if (xError == -9999) {
      // Error message is handled within function
      return false;
    }

    double yError = simpleSarInputPanel.getNavError();

    if (yError == -9999) {
      // Error message is handled within function
      return false;
    }

    double safetyFactor = simpleSarInputPanel.getSafetyFactor();

    if (safetyFactor == -9999) {
      // Error message is handled within function
      return false;
    }

    int searchObject = simpleSarInputPanel.getSearchItemID();

    // Only valid search objects is value 0 to 19
    if (searchObject < 0 || searchObject > 20) {
      // Error message is handled within function
      // System.out.println("failed search object with id " +
      // searchObject);
      return false;
    }

    voctManager.inputSimpleSarData(
        simpleSarInputPanel.getSARID(),
        simpleSarInputPanel.getLKPDate(),
        simpleSarInputPanel.getCSSDate(),
        xError,
        yError,
        safetyFactor,
        searchObject,
        aPos,
        bPos,
        cPos,
        dPos,
        datum);

    return true;
  }
示例#6
0
  @Override
  public void actionPerformed(ActionEvent arg0) {

    if (arg0.getSource() == typeSelectionComboBox) {
      int selectedIndex = typeSelectionComboBox.getSelectedIndex();
      // 0 Simple SAR
      // 1 Rapid Response
      // 2 Datum Point
      // 3 Datum Line
      // 4 Back track

      switch (selectedIndex) {
        case 0:
          descriptiveImage.setIcon(simpleSarIcon);
          descriptiveText.setText(simpleSarTxt);
          nextButton.setEnabled(true);
          break;
        case 1:
          descriptiveImage.setIcon(rapidResponseIcon);
          descriptiveText.setText(rapidresponseTxt);
          nextButton.setEnabled(true);
          break;
        case 2:
          descriptiveImage.setIcon(datumPointIcon);
          descriptiveText.setText(datumPointTxt);
          nextButton.setEnabled(true);
          break;
        case 3:
          descriptiveImage.setIcon(datumLineIcon);
          descriptiveText.setText(datumLineTxt);
          nextButton.setEnabled(true);
          break;
          // case 4:
          // descriptiveImage.setIcon(backtrackIcon);
          // descriptiveText.setText(backtrackTxt);
          // nextButton.setEnabled(false);
          // break;
      }
    }

    if (arg0.getSource() == btnImport) {
      // Import started

      // Open a file menu select for xml files

      // Create SARIS parser for returned object

      JFileChooser fileChooser = new JFileChooser(new File("."));
      fileChooser.addChoosableFileFilter(new XmlFilter());
      fileChooser.setAcceptAllFileFilterUsed(true);
      fileChooser.showOpenDialog(null);

      if (fileChooser.getSelectedFile() != null) {

        String fileChoosen = fileChooser.getSelectedFile().getAbsolutePath();

        try {

          // if (fileChoosen.contains(".sar")) {
          // SARFileParser parser = new SARFileParser(fileChoosen);
          //
          // // voctManager.setSarType(SAR_TYPE.SARIS_DATUM_POINT);
          // // voctManager.setSarData(parser.getSarData());
          // // calculationsText.setText("SARIS PARSE SUCCESSFULL");
          // // backButton.setEnabled(true);
          // // nextButton.setText("Finish");
          // // nextButton.setEnabled(true);
          //
          // } else {
          SARISXMLParser parser = new SARISXMLParser(fileChoosen);

          voctManager.setSarType(SAR_TYPE.SARIS_DATUM_POINT);
          voctManager.setSarData(parser.getSarData());
          calculationsText.setText("SARIS PARSE SUCCESSFULL");
          backButton.setEnabled(true);
          nextButton.setText("Finish");
          nextButton.setEnabled(true);

          // }

          CardLayout cl = (CardLayout) (masterPanel.getLayout());
          cl.show(masterPanel, CALCULATIONSPANEL);
          currentCard = CALCULATIONSPANEL;

          // Move to final page where we show the info
        } catch (Exception e) {
          calculationsText.setText("SARIS Parse failed on file " + fileChoosen);
          backButton.setEnabled(true);
          nextButton.setEnabled(false);
          voctManager.setSarType(SAR_TYPE.SARIS_DATUM_POINT);
          CardLayout cl = (CardLayout) (masterPanel.getLayout());
          cl.show(masterPanel, CALCULATIONSPANEL);
          currentCard = CALCULATIONSPANEL;
        }
      }
    }

    if (arg0.getSource() == nextButton) {
      // Get the current card and action depends on that

      // System.out.println("Next button pressed, currently at :"
      // + currentCard);

      // We're at SAR selection screen
      if (currentCard == SELECTSARTYPE) {
        CardLayout cl = (CardLayout) (masterPanel.getLayout());
        backButton.setEnabled(true);

        inititateSarType();

        // System.out.println("Setting panel to " + currentCard);

        // The type select determines which panel we show
        cl.show(masterPanel, currentCard);

        return;
      }

      // We're at input screen
      if (currentCard == INPUTSARRAPIDRESPONSEDATUM
          || currentCard == INPUTPANELDATUMLINE
          || currentCard == SIMPLESAR) {
        CardLayout cl = (CardLayout) (masterPanel.getLayout());

        if (validateInputAndInititate()) {
          // System.out.println("Validated");
          calculationsText.setText(voctManager.getSarData().generateHTML());
          backButton.setEnabled(true);
          nextButton.setText("Finish");

          cl.show(masterPanel, CALCULATIONSPANEL);
          currentCard = CALCULATIONSPANEL;
        } else {
          // do nothing, missing data, internally sorted
        }

        return;
      }

      // We're at confirmation screen
      if (currentCard == CALCULATIONSPANEL) {
        // System.out.println(currentCard);
        CardLayout cl = (CardLayout) (masterPanel.getLayout());
        backButton.setEnabled(true);
        nextButton.setText("Next");
        nextButton.setEnabled(true);

        SAR_TYPE type = voctManager.getSarType();

        if (type == SAR_TYPE.RAPID_RESPONSE) {
          currentCard = INPUTSARRAPIDRESPONSEDATUM;
        }

        if (type == SAR_TYPE.DATUM_POINT) {
          currentCard = INPUTSARRAPIDRESPONSEDATUM;
        }

        if (type == SAR_TYPE.DATUM_LINE) {
          currentCard = INPUTPANELDATUMLINE;
        }

        if (type == SAR_TYPE.BACKTRACK) {
          // To be implemented
        }

        if (type == SAR_TYPE.SARIS_DATUM_POINT) {
          // To be implemented
          currentCard = SELECTSARTYPE;
        }

        if (type == SAR_TYPE.SIMPLE_SAR) {
          currentCard = SIMPLESAR;
        }

        if (sarReady) {

          this.setVisible(false);

          // Set the dialog back to input screen for reentering
          cl.show(masterPanel, currentCard);

          // System.out.println("Hiding");

          // Display SAR command
          voctManager.setLoadSarFromSerialize(false);
          voctManager.displaySar();
          sarReady = false;
        }

        return;
      }
    }

    if (arg0.getSource() == backButton) {

      // If we're at Rapid Response or Datum or Back back go back to
      // init
      if (currentCard == INPUTSARRAPIDRESPONSEDATUM
          || currentCard == INPUTPANELDATUMLINE
          || currentCard == SIMPLESAR) {
        CardLayout cl = (CardLayout) (masterPanel.getLayout());
        cl.show(masterPanel, SELECTSARTYPE);
        backButton.setEnabled(false);
        currentCard = SELECTSARTYPE;
        return;
      }

      // We're at confirmation
      if (currentCard == CALCULATIONSPANEL) {
        CardLayout cl = (CardLayout) (masterPanel.getLayout());

        SAR_TYPE type = voctManager.getSarType();

        if (type == SAR_TYPE.RAPID_RESPONSE) {
          currentCard = INPUTSARRAPIDRESPONSEDATUM;
        }

        if (type == SAR_TYPE.DATUM_POINT) {
          currentCard = INPUTSARRAPIDRESPONSEDATUM;
        }

        if (type == SAR_TYPE.DATUM_LINE) {
          currentCard = INPUTPANELDATUMLINE;
        }

        if (type == SAR_TYPE.SARIS_DATUM_POINT) {
          // To be implemented
          currentCard = SELECTSARTYPE;
        }

        if (type == SAR_TYPE.SIMPLE_SAR) {
          currentCard = SIMPLESAR;
        }

        cl.show(masterPanel, currentCard);
        backButton.setEnabled(true);
        nextButton.setText("Next");
        return;
      }
    }

    if (arg0.getSource() == cancelButton) {
      this.setVisible(false);
      // voctManager.cancelSarOperation();
      return;
    }
  }