⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jiggle.java

📁 一个用java写的地震分析软件(无源码)-used to write a seismic analysis software (without source)
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    addToMenu("Properties", menuInfo);
    addToMenu("Event Locks", menuInfo);
    menuInfo.addSeparator();

    // dump sub menues
    JMenu dumpMenu = new JMenu("Dump");
    addSubMenu("Connection Info", dumpMenu);
    addSubMenu("Origin Info", dumpMenu);
    addSubMenu("Phase Info", dumpMenu);
    addSubMenu("Mag Info", dumpMenu);
    addSubMenu("Amp Info", dumpMenu);
    addSubMenu("Channel Info", dumpMenu);
    addSubMenu("WFSelected Info", dumpMenu);
    addSubMenu("MasterView Info", dumpMenu);
//        addSubMenu("", dumpMenu);

    menuInfo.add(dumpMenu);

    menuBar.add(menuInfo);

    // [Help] menu
    JMenu menuHelp = new JMenu("Help", true);

    addToMenu("Help Browser", menuHelp).setEnabled(false); ;

    addToMenu("About", menuHelp);

    menuBar.add(menuHelp);

// add menubar to Frame
    setJMenuBar(menuBar);

  } // end of createMenu constructor

// -----------------------------------------------------------
  /**
   * Add an item to the main menu. Note: using this method adds items
   * anonymously :. cannot enable/disable later.
   */
  JMenuItem addToMenu(String item, JMenu menu)
  // Streamline adding  a menu item to 'menu'
  {
    JMenuItem m = new JMenuItem(item); // instantiate the item
    m.addActionListener(new MenuHandler()); // register with handler
    menu.add(m); // add to main menu

    return m;
  }

  /** Add a submenu to an menu item. */
  JMenuItem addSubMenu(String item, JMenu main) {
    JMenuItem sub = main.add(new JMenuItem(item));
    sub.addActionListener(new MenuHandler());
    return sub;
  }

  /**
   * Make the actual connection to the data source. Returns 'true' on success.
   */
  public boolean makeDataSourceConnection() {

    // get current data source description from properties
    DbaseConnectionDescription dbDesc = props.getDbaseDescription();
    String statusString = "Connecting to : " + dbDesc.getDbasename() +
        " on " + dbDesc.getHost();

// New connection OK?
    if (!DataSource.set(dbDesc)) {
      String err = DataSource.getStatus();
      String str = "WARNING: DataSource could not be opened.\n" +
          err + "\n" +
          "Check parameters.\n" +
          "\n" +
          "URL = " + DataSource.getHostName() + "\n" +
          "Dbase = " + DataSource.getDbaseName() + "\n" +
          "Username = " + DataSource.getUsername() + "\n" +
          "Port #: " + DataSource.getPort();
      JOptionPane.showMessageDialog(null,
                                    str, "Bad DataSource",
                                    JOptionPane.INFORMATION_MESSAGE);
      if (statusPanel != null) {
        statusPanel.setText("Connection failed.");
      }
      updateDataSourceLabels();
      return false;
    }

    if (debug) {
      System.out.println(statusString);
    }
    System.out.println(DataSource.toDumpString());

    // Tell user what happened via the status panel if there is on
    /*	if (DataSource.getConnection() == null) {
         if (statusPanel != null) statusPanel.setText("Connection failed.");
         return false;      // no connection
     }
     */
    if (statusPanel != null) {
      statusPanel.clear();

      // tell the waveform class about the new data source
    }
    if (props.getInt("waveformReadMode") == Waveform.LoadFromDataSource) {
      props.setWaveSource(props.getInt("waveformReadMode"),
                          DataSource.getDbaseConnectionDescription());
    }

    updateDataSourceLabels();
// Check if locking works for new data source
    solLock = SolutionLock.create();
    if (!solLock.checkLockingWorks()) {
      String str =
          "WARNING: Event locking is not supported by this data source.\n" +
          " You can procede with the possiblity of collisions with other users.";
      JOptionPane.showMessageDialog(null,
                                    str, "Event Lock Warning",
                                    JOptionPane.INFORMATION_MESSAGE);
//	   lockWarningIssued = true;
    }

// Check if dbase os readonly
//    if (DataSource.getConnection() != null && DataSource.isReadOnly()) {
    if (DataSource.isReadOnly()) {
      String str = "WARNING: You have READ-ONLY access to this database.\n" +
          " You will not be able to save any of the work you do.";
      str += "\n" +
          "URL = " + DataSource.getHostName() + "\n" +
          "Dbase = " + DataSource.getDbaseName() + "\n" +
          "Username = " + DataSource.getUsername() + "\n" +
          "Port #: " + DataSource.getPort();
      JOptionPane.showMessageDialog(null,
                                    str, "Read-only Access",
                                    JOptionPane.INFORMATION_MESSAGE);
    }

    return true;

  }

  /** Switch to a newly defined data source. Clear the GUI because you don't
   *  want to write old, previously loaded, data to a new data source. */
  private boolean switchDataSource() {
    clearCatPanel();
    clearGUI();
    if (makeDataSourceConnection()) {
      updateDataSourceLabels();
      makeCatPanel(); // refresh the catalog view
      return true;
    }
    return false;
  }

  /**
   * Load the catalog list from the data source using parameters in
   * eventSelectionProperties for start and end times, etc. */
  public SolutionList loadCatalogList() {

    if (debug) {
      System.out.println("loadCatalogList ......\n" + eventProps.listToString());

    }
    return new SolutionList(eventProps);
  }

  /**
       * Load the EventTable from the remote Oracle dbase starting at 'hoursBack' and
   * reading forward to now. Sets eventSelectionProperties for start and end times */
  /*    public SolutionList loadCatalogList(double hoursBack)
      {
       setCatalogTimeWindow (hoursBack) ;
   eventProps.setProperty("validFlag", "TRUE");
   System.out.println ("Fetching: "+eventProps.getTimeSpan().toString());
   statusPanel.setProgressBarValue(0, "Fetching catalog data. ");
   return new SolutionList(eventProps);
      }
   */

  /**
   * Save the current selected solution to the dbase.
   */
// TODO: add progress bars

  public boolean saveToDb() {

    return saveToDb(mv.getSelectedSolution());

  }

  /**
   * Save the given solution to the dbase.
   */
// TODO: add progress bars

  public boolean saveToDb(Solution sol) {

    if (sol == null) {
      return false;
    }

    long evid = sol.id.longValue();
    //debug
    System.out.println("Saving event: " + evid);

    // Warn if solution is stale but allow saving of stale sol if asked.
    if (hasGoodLocation(sol)) {
      // save Solution
      try {
        boolean status = sol.commit();
        System.out.println(sol.getCommitStatus());

        SolutionList solList = this.catPanel.catPanel.getSolutionList();
        Solution[] solArray = (Solution[]) solList.toArray(new Solution[solList.
            size()]);
        for (int i = 0; i < solArray.length; i++) {
          if (solArray[i].equals(sol)) {
            solArray[i] = sol;
            this.catPanel.catPanel.setSolutionList(solList);
            break;
          }
        }

        return status;
      }
      catch (JasiCommitException ex) {

        // bad save
        String msg = "WARNING: Error during save of event " + evid + ". \n" +
            ex.toString() +
            "\n" + sol.getCommitStatus();
        String title = "Save Error " + evid;
        JOptionPane.showMessageDialog(null,
                                      msg, title,
                                      JOptionPane.INFORMATION_MESSAGE);
        return false;
      }
    }

    return false;
  }

  /**
   * Save the current selected solution to the dbase and take site-specific finalization action.
   */
  public boolean finalToDb() {

    return finalToDb(mv.getSelectedSolution());

  }

  /**
   * Save the given solution to the dbase and take site-specific finalization action
   */
  public boolean finalToDb(Solution sol) {

    if (sol == null) {
      return false;
    }

    long evid = sol.id.longValue();
    //debug
    System.out.println("Finalizing event: " + evid);

    // Warn if solution is stale but allow saving of stale sol if asked.
    if (hasGoodLocation(sol)) {
      // save Solution
      try {
        boolean status = sol.finalCommit();
        System.out.println(sol.getCommitStatus());
        return status;
      }
      catch (JasiCommitException ex) {

        // bad save
        String msg = "WARNING: Error during finalize of event " + evid + ". \n" +
            ex.toString() +
            "\n" + sol.getCommitStatus();
        String title = "Finalize Error " + evid;
        JOptionPane.showMessageDialog(null,
                                      msg, title,
                                      JOptionPane.INFORMATION_MESSAGE);
        return false;
      }
    }

    return false;
  }

      /** Checks two things: 1) if event needs to be relocated and 2) if the solution
   * is good. Return true if there's a good, "fresh" (not stale)  location OR
   * if the operator chose not to relocate. Warn user with
   * dialog, if event is stale or location is null (lat, lon and z are 0.0) */
  public boolean hasGoodLocation(Solution sol) {

    // give option of relocating stale event, proceed regardless of outcome
    if (hasStaleLocation(sol)) {
      return false;
    }

    // not stale, now check that its non-zero
    if (sol == null || sol.getLatLonZ() == null || sol.getLatLonZ().isNull()) {

      int ync = JOptionPane.showConfirmDialog(
          null, "WARNING: Solution has no location.\n" +
          "Proceed anyway?",
          "No Location: ID = " + sol.id.toString(),
          JOptionPane.YES_NO_OPTION);

      // [YES] return true to proceed
      if (ync == JOptionPane.YES_OPTION) {
        return true;
      }

      // [NO]
      return false; // no solution
    }
    else {
      return true;
    }
  }

  /**
     Check for stale solution. Warn user with dialog if stale and give option
       of locating the event. Return true is event is still stale, false if its OK.
   */
  public boolean hasStaleLocation(Solution sol) {
    if (sol.hasStaleLocation()) {

      //pop-up confirming  yes/no dialog:
      int ync = JOptionPane.showConfirmDialog(
          null, "WARNING: This solution is stale and should be relocated.\n" +
          "[YES] will relocate then continue.\n" +
          "[NO] will continue without relocating.\n" +
          "[CANCEL] will cancel this operation.\n" +
          "Relocate now?",
          "Stale Solution: ID = " + sol.id.toString(),
          JOptionPane.YES_NO_CANCEL_OPTION);

      // [CANCEL] bail out, report as stale
      if (ync == JOptionPane.CANCEL_OPTION) {
        return true;
      }

      // [YES] Re-locate, return result
      if (ync == JOptionPane.YES_OPTION) {
        return!locate();
      }

      // [NO]
      if (ync == JOptionPane.NO_OPTION) {
        return false;
      }
    }
    return false;

  }

  /**
   * Save all currently loaded solutions to the dbase.
   */
// TODO: add progress bars

  public void saveAllToDb() {

    Solution sol[] = mv.solList.getArray();

    for (int i = 0; i < sol.length; i++) {

      saveToDb(sol[i]);

    }
  }

  /**
   * Toggle unpick mode on/off.
   */
  public void setUnpickMode(boolean tf) {

    UnpickMode.set(tf);

    Cursor cursor;

    if (debug) {
      System.out.println("unpick mode = " + tf);

// this doesn't seem to work
    }
    if (tf) {
      cursor = new Cursor(Cursor.HAND_CURSOR);
    }
    else {
      cursor = new Cursor(Cursor.DEFAULT_CURSOR);
    }
    wfScroller.setCursor(cursor);
    pickPanel.setCursor(cursor);
  }

  /**
   * Locate the current event, re-sort waveform views
   */

  public void relocate() {

    if (locate()) {

      // resort views
      reSortWFViews();

      tabPane.setSelectedIndex(TAB_LOCATION);
    }

  }

  /**
   * Locate the current event.
   */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -