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

📄 jiggle.java~2~

📁 一个用java写的地震分析软件(无源码)-used to write a seismic analysis software (without source)
💻 JAVA~2~
📖 第 1 页 / 共 5 页
字号:
package org.trinet.jiggle;

import java.applet.*;
import java.awt.*;
import java.util.*;
import java.io.*;
import java.awt.event.*;

import javax.swing.*;      // JFC "swing" library
import javax.swing.event.*;

import org.trinet.jasi.*;
import org.trinet.util.BenchMark;
import org.trinet.util.EpochTime;

import org.trinet.util.gazetteer.*;
import org.trinet.util.graphics.PrintUtilities;
import org.trinet.util.graphics.HTMLHelp;
import org.trinet.util.graphics.table.CatalogPanel;

/**
   The main Jiggle application. Jiggle is a graphical earthquake analysis tool.
   Because it is written in Java, Jiggle is platform independent.
   It has been run on Solaris, Window NT v4.0, Windows 98, Windows2000, and FreeBSD.

    Its basic functions are:
<pre>
          Read/write of seismic data from/to any data source in any format.
          (Requires appropriate "jasi" implementation)
          Display user defined catalog list
          Display waveforms, phase picks, amplitudes, etc.
          Manipulation of waveforms (scaling, zooming, filtering, etc.)
          Editing and creation of phase picks, amplitudes, etc.
          Location calculation (using a remote location server)
          Magnitude calculation
</pre>
*/
public class Jiggle extends JFrame {

    static final String versionNumber  = "2002.10.28 - EW-v62-030704";
    static final String authorName = "Doug Given";
    static final String webSite =
           "http://iron.gps.caltech.edu/trinet_tpp_doc/v1.5/Jiggle.html";

    /** Main Jiggle properties list */
    public static JiggleProperties props;

    /** Name of the properties file. Path is assumed to be <user-home-dir>/.jiggle
        @see: PropertyList  */
    public static String propertyFileName = "properties";

    /** Event properties */
    static EventSelectionProperties eventProps;
    public static String eventPropertyFileName = "eventProperties";

    /** The master view (note its static so there will only be one, ever.) */
    // Create an empty one to avoid null pointer exceptions before a valid one
    // is loaded with real data
    static MasterView mv = new MasterView();

    /** The list of solutions displayed in the Catalog Panel */
    SolutionList catSolList;

// GUI components

    /** Mainframe title */
    static final String DEFAULT_FRAME_TITLE = "Jiggle  v" + versionNumber;

    /** The main menu bar */
    private JMenuBar menuBar;  // main menu bar

    /** Where status of loads is shown */
    MainStatusBar statusBar = new MainStatusBar();

    /** The status panel in the MainStatusBar. */
    public static StatusPanel statusPanel;

    // status popup
    public static StatusFrame statusFrame = new StatusFrame();

    private Object menuObject;  // action object passed from the Frame menu
    // this menu is global so it can be disabled if no event is loaded.
    public JMenu menuEvent;

    public JSplitPane   mainSplit;		     // big splitpane
    public JSplitPane   wfSplit;			// waveform splitpane
    public PickingPanel pickPanel;			// zoom pane

    public WFScroller   wfScroller;

    //* The panel containg the catalog table */
    CatPane catPanel = new CatPane();

    /** Main tool bar */
    public MainToolBar toolBar;

// Text panels for the tabPane
    public JTabbedPane tabPane;

// Define all the tabs
    static final int TAB_LOCATION = 0;
    static final int TAB_MAGNITUDE= 1;
    static final int TAB_WHERE    = 2;
    static final int TAB_MESSAGE  = 3;
    static final int TAB_CATALOG  = 4;
    static final int TAB_WAVEFORM = 5;

    // Define tab titles
    static final String tabTitle[] = {
                 "LOCATION", "MAGNITUDE", "WHERE", "MESSAGES",
                 "CATALOG", "WAVEFORMS"};
    // Define tab tooltips
    static final String tabTip[] = {
                 "Location Output", "Magnitude Info", "Where Info", "Text Messages",
                 "Earthquake List", "Seismogram View"};

    /** The panel containing all the tab panes*/
   JPanel tabPanel[] = new JPanel[tabTitle.length];

   /** The WHERE engine, returns info about close landmarks, etc.*/
   WhereIsEngine whereEngine;


// create a connection to the location server (solserver process)
    LocationEngine locEng;

    // Mca engine
//    MagnitudeEngine mcaMagEng;
    org.trinet.util.magnitudeengines.JiggleMCA   mcaMagEng;

    // Mag classes
    String DefaultMagMethodClass = "org.trinet.util.magnitudeengines.SoCalML";
    String MLmagMethodClass = DefaultMagMethodClass;
    String DefaultMagnitudeEngineClass = "org.trinet.util.magnitudeengines.LocalMagnitudeEngine";
    String magEngineClass = DefaultMagnitudeEngineClass;


  //    JiggleFileChooser fileChooser = new JiggleFileChooser(this);

  // put these here so I'd remember how to do it, for later use.
    int screenRes = getToolkit().getScreenResolution();
    Dimension screenSize = getToolkit().getScreenSize();

    /** Time benchmark class */

    static BenchMark bench1;  // must be static to use in Main

    // Set True to see lots of status & startup messages
    boolean verbose = true;

    /** If true plot WFSegment boundaries in PickingPanel. Specified in
        properties */
    boolean showSegments = false;

    /** A solutionlock object that matches the current DataSource. Some data sources
     * may not support event locking. This can be checked with boolean result of
     * solLock.isSupported()  */
    SolutionLock solLock;

    /** Keeps track of when a lock warning has been issued so we only do it
    * the first time. */
//    boolean lockWarningIssued = false;

    /** True if we can write back to the dbase. */
//    boolean writeBackEnabled;

    /** Set true if waveform view is in a tab, else its in a split pane */
//    boolean waveformInTab;

    SelectableReadingList selMagList;

    // debugging flag
    static boolean debug = true;

    // Need non-static instance to do some things
    static Jiggle jiggle;

// ------ MAIN -------

    public static void main(String args[]) {

	// Need non-static instance to do some things
	// This reference to jiggle is NOT preserved in instance scope!
     System.out.println ("Starting Jiggle v"+versionNumber);

	jiggle = new Jiggle();
	jiggle.setup();
    }

    /** Were the GUI and components are set up */
    public void setup () {

// Handle frame close using native close widget. Don't call 'shutDown()' here
// because I can't get [No] option in shutDown dialog to work when the native
// frame widget is used to close the framer.
     addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) { stop(); }
     });

     if (verbose) bench1 = new BenchMark (" * Elapse since program start: ");

     if (verbose) System.out.println (DEFAULT_FRAME_TITLE + " starting");

     // Read and setup properties
     setProperties(new JiggleProperties(propertyFileName));
     whereEngine = WhereIsEngine.CreateWhereIsEngine(props.getProperty("WhereIsEngine"));
     locEng =      LocationEngine.CreateLocationEngine(props.getProperty("LocationEngine"));
//     mcaMagEng =   MagnitudeEngine.CreateMagnitudeEngine(props.getProperty("MCAMagnitudeEngine"));


     setEventProperties(new EventSelectionProperties(eventPropertyFileName));

     EnvironmentInfo.setApplicationName("Jiggle");

     makeGUI();

     // check version while were waiting for everything else to finish
		 // DK Code Change 121802
		 // Don't Check version if 	doNotCheckJiggleVersion is true
		 if(!props.getBoolean("disableJiggleVersionCheck"))
       checkVersion();
		 // END DK Code Change 121802


     if (makeDataSourceConnection()) {
	makeCatPanel();
     } else {
        System.out.println("Could not connect to data source.");
     }
	if (!loadChannelList()) System.out.println("Could not load Channel list.");

	if (verbose) bench1.print();      // timestamp
    }

    /** Set the Jiggle properties. */
    public static void setProperties (JiggleProperties properties) {
      props = properties;
      mv.setChannelTimeWindowModel(props.getCurrentChannelTimeWindowModelInstance());

      // Set the jasi object type to be used for the run
      if (!JasiObject.setDefault(props.getProperty("jasiObjectType"))) {
           int yn = JOptionPane.showConfirmDialog(
                   null, "WARNING: Default jasi object type undefined or invalid.\n"+
		         "Click [YES] to set it in preferences",
                   "Bad Jasi Type", JOptionPane.YES_NO_OPTION);
	   if (yn == JOptionPane.YES_OPTION) jiggle.doPreferencesDialog(PreferencesDialog.TAB_MISC );
      }

      jiggle.checkProperties();
    }
    /** Set the Jiggle properties. */
    public static void setEventProperties (EventSelectionProperties properties) {
      eventProps = properties;
    }

    /** Sanity and completeness check of properties. */
    // Note: this can't be done in the JiggleProperties class because it may have
    // no graphics context.
    void checkProperties() {

    // Net code
      if (props.getProperty("localNetCode").equals("??")) {
        // changed by kenny : 2004-12-28
        System.out.println("WARNING: Network code is undefined.");
        /*
           int yn = JOptionPane.showConfirmDialog(
                   null, "WARNING: Network code is undefined.\n"+
		         "Click [YES] to set it in preferences",
                   "No Net Code", JOptionPane.YES_NO_OPTION);
	   if (yn == JOptionPane.YES_OPTION) doPreferencesDialog(PreferencesDialog.TAB_MISC );*/
      }

    }

    /** Checks this code's version against highest available back at the home
    * web site. Pops a warning dialog if we are out of rev. */
    void checkVersion() {

      System.getProperties();

         if (!VersionChecker.isCurrent(versionNumber)) {

            String msg = "<html><h2>WARNING:</h2><b>Your version of Jiggle is out-of-date.<p>"+
            "Download latest version "+VersionChecker.getVersion()+ " from:<br><it>"+
	     VersionChecker.getDownloadAddress() +"</it></b> </html>";

	    Object[] options = {"Dismiss" , "Open Browser"};
            String title = "Jiggle Out of Date "+versionNumber;

	    int rtn = JOptionPane.showOptionDialog(null, msg, title,
	      JOptionPane.YES_NO_CANCEL_OPTION,
	      JOptionPane.QUESTION_MESSAGE,
	      null,
	      options,
	      options[0]);  // default

	      if (rtn == 1) {
		  try {
		    Process pBrowser = Runtime.getRuntime().exec(
		      "cmd /c start "+VersionChecker.getDownloadAddress());
		  } catch (Exception ex) {
		    ex.printStackTrace();
		  }
	      }

         }
    }

    /*
     * Load the Channel list. This is done one time at program startup.
     * The list is used to lookup lat/lon for new data as it is read in.
     */

    public boolean loadChannelList() {

      boolean status = true;

      if (props.getBoolean("cacheChannelList")) {

        String str = "Reading Channel data from cache.";
        if (verbose) System.out.println (str);
        statusPanel.setProgressBarValue(0, str);
        statusFrame.set ("Channel Data", str);
        statusFrame.setVisible(true);

        // read Channel list from cache using the filename in properties
        MasterChannelList.set(
	  ChannelList.readFromCache(
	    props.getProperty("channelCacheFilename")
	));

        // cache read failed, read from dbase and write to cache for future use
        if (MasterChannelList.get().isEmpty()) {
	   str = "Read of Channel cache failed\nread from data source.";
	   str += "\n" + MasterChannelList.get().getCacheFilename();

           statusFrame.setText(str);

           if (verbose) System.out.println (str);
           statusPanel.setProgressBarValue(0, str);

           MasterChannelList.set(ChannelList.readCurrentList());
	   // create Cache file
//           status = MasterChannelList.get().writeToCache();
           status = MasterChannelList.get().writeToCacheInBackground();

        // cache read succeeded, refresh the cache
        } else {
	  // cache read succeeded -- refresh in background to keep current
	   if (props.getBoolean("autoRefreshChannelList"))
		        MasterChannelList.get().refreshCache();
        }

     // don't use the cache (but refresh it)
     } else {
        String str = "Reading Channel data from data source.";
        statusFrame.setText(str);
        if (verbose) System.out.println (str);
        statusPanel.setProgressBarValue(0, str);
        MasterChannelList.set(ChannelList.readCurrentList());
	MasterChannelList.get().writeToCacheInBackground();
     }

     statusPanel.setProgressBarValue(0, "");
     statusFrame.setVisible(false);

     return status;

    }

    /** Clear the Catalog Panel. Generally done when the datasource changes.*/
    public void clearCatPanel() {
      catPanel = new CatPane();
    }
    /** Make the catalogPanel for browsing the catalog */
    public void makeCatPanel () {

	/* The List of Solutions in the catalog panel */
	catSolList = loadCatalogList();

	boolean updateable = false;
	//	boolean editable   = false;
	JTextArea catTextArea = null;

	if (verbose) System.out.println
			 ("Creating catalog table. "+catSolList.size());

	statusPanel.setProgressBarValue(0, "Creating catalog table. ");

	// strange way to pass connection to CatalogPanel
	catSolList.setConnection(DataSource.getConnection());
	// set/reset selected to currently selected event
	// must do it by ID because refreshing the list creates new Solution
	// instances in the SolutionList.

⌨️ 快捷键说明

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