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

📄 masterview.java

📁 一个用java写的地震分析软件(无源码)
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package org.trinet.jiggle;

import java.util.*;
import java.awt.event.*;
//import java.sql.*;

import org.trinet.util.*;
import org.trinet.jdbc.*;
import org.trinet.jasi.*;
import org.trinet.jasi.coda.*;
import org.trinet.util.gazetteer.LatLonZ;

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

/**
 * This class is the Big Data View.
 * It is primarily a list of WFViews that define a
 * "view" of network data. Note that this is a REQUESTED view;
 * some requested channels or time windows may contain no data.
 * This also contains a list of Solutions that are associated with phases
 * that appear in the view.
 * The MasterView timeSpan will be expanded to include any added objects.<p>
 *                                     6
 * The WFViews that make up the MasterView are determined by the ChannelTimeWindowModel.
 * The default model is DataSourceChannelTimeModel which gets its list of channels
 * and time windows from those associated with the event at the DataSource.
 *
 *  @see: ChannelTimeWindowModel()
 *  @see: DataSourceChannelTimeModel()
 *
 * @author Doug Given
 */
/*
    Removed all notions of what's "selected" from this class to keep it pure. What
    Solution, WFView, Phase, etc. is currently selected is meaningless for many
    uses of MasterView and, when needed, is maintained by SelectionModel classes.
 */

public class MasterView {

    /** The model for which WFPanel and :. which channel is selected. */
    public SelectedWFViewModel  masterWFViewModel = new SelectedWFViewModel();
    /** The model for the zoomed waveform window that is selected. */
    public SelectedWFWindowModel masterWFWindowModel = new SelectedWFWindowModel();
    /** The model for the scrolling window that is selected. */
//    public SelectedWFWindowModel masterWFScrollModel = new SelectedWFWindowModel();

    /** The total time span bounding this view */
    public TimeSpan timeSpan = new TimeSpan();

    /** List of solution in this view */
    //    public SolutionList solList = new SolutionList();

    /** MVC model for list and selected solution */
//    public ActiveSolutionList solList = new ActiveSolutionList();
    public SolutionList solList = new SolutionList();

    /** Phase list. Includes ALL phases from all solutions in the MasterView,
    * both associated and unassociated. */
//x//    public PhaseList phaseList = new PhaseList();

    /** Set true if you want to retreive all phases */
    boolean phaseRetrieveFlag = true;

    /** Default value for stripping residuals. */
    double residualStripValue = 1.0;

    /** Paint WFPanel time scale red if clock quality is worse than this value,
     *  0.0 -> 1.0 */
    double clockQualityThreshold = 0.5;

    /** Amplitudes list. Includes ALL amplitudes in the MasterView. */
//x//    public AmpList ampList = new AmpList();

    /** Set true if you want to retreive all amplitudes */
    boolean ampRetrieveFlag = true;

    /** Coda list. Includes ALL codas in the MasterView. */
//x//    public CodaList codaList = new CodaList();

    /** Set true if you want to retreive all amplitudes */
    boolean codaRetrieveFlag = true;

    /** List of WFViews */
    public WFViewList wfvList = new WFViewList();

    protected ChannelTimeWindowModel defaultChannelTimeWindowModel =
					  new DataSourceChannelTimeModel();

    /** Keep individual WFView lists in synch with the master lists. */
    JasiReadingListModel jasiReadingListModel = new JasiReadingListModel(wfvList);

    static final int NULL = (int) Math.pow(2.0, 31.0);

/** Set true if you want to retreive all waveforms */
    boolean wfRetrieveFlag = true;

/** If true, load Channel data (lat/lon) for each WFView */
    boolean loadChannelData = true;

    /* Enumerate load mode options */
    public static final int LoadAllInForeground = 0;
    public static final int LoadAllInBackground = 1;
    public static final int LoadNone = 2;
    public static final int Cache = 3;
    public static final int LimitNumber = 4;
    public static final int ModeCount = 4;

    /** Set waveform default load mode */
    int waveformLoadMode = LoadAllInBackground;

/** Set true if you want to line up the waveforms by time. If true the viewBox of
 *  all the WFView's will be set to the max/min times of the whole data set */
//    boolean timeAlign = true;

    public static final int AlignOnTime = 0;
//    public static final int AlignOnP    = 1;
//    public static final int AlignOnS    = 2;
    int alignmentMode = AlignOnTime;
    int AlignmentModeCount = 1;

    /** Include only WFViews that have phase picks */
    boolean includeOnlyWithPhases = false;

/** */
    StatusPanel statusPanel = null;

    /** Set max. waveforms to load */
    int waveformLoadLimit = Integer.MAX_VALUE;

    // output verbosity flag
       static boolean debug = true;
   // static boolean debug = false;

    // access runtime information
    //    Runtime runtime = Runtime.getRuntime();

/**
 * Default constructor
 */
  public MasterView() {

      // give all WFViews a reference to the MasterView via a static member
      WFView.setMasterView(this);

  }

 /**
 * Default constructor with statusPanel reference.
 *
 * @param ts - a StatusPanel where status updates will go
 * @see StatusPanel()
 */
  public MasterView(StatusPanel sp) {

      this();

      setStatusPanel(sp);

  }

/**
 * Constructor sets initial size of timeSpan
 *
 * @param ts - a TimeSpan object
 * @see TimeSpan
 */
  public MasterView(TimeSpan ts ) {

      this();

      timeSpan = ts;

  }

/**
 * Build a master view for this 'evid'. In other words, the view is based on one
 * event as found in the dbase.  The view's timeSpan will be defined to include
 * all the waveforms and phases associated with this evid.  Other phases in the
 * time span associated with another evid (or no evid) will not be included.  */
  public MasterView(long id) {

      this();

      defineByDataSource(id);
  }

/**
 * Build a master view for this Solution based on this event as found in the
 * DataSource.  The view's timeSpan will be defined to include all the waveforms
 * and phases associated with this evid.  Other phases in the time span
 * associated with another evid (or no evid) will not be included.  */
  public MasterView(Solution sol) {

      this();

      defineByDataSource(sol);
  }

    /**
     * Build a MasterView based on this solution containing stations within the
     * parameter bounds and with waveforms with the given timespan. The view is
     * NOT based on waveforms saved in the DataSource. Rather Waveform objects
     * are created based on the TimeSpan given. These are effectively 'requests'
     * that may or may not be successfully fulfilled when a call to
     * loadWaveforms() is made. The DataSource will be searced for the TimeSpan
     * specified to find phases, amps, etc.  <p>
     *
     * The list will end at either the  distance cutoff or the station count,
     * whichever comes first. For example, assume there are 50 channels within
     * 100 km of the epicenter; if distCutoff=100 & maxCount=20, only the
     * nearest 20 channels will be included. If distCutoff=100 & maxCount=200,
     * only the 50 stations within 100 km will be include. The station list
     * comes from the channel list in * the Channel class.
     *
     * @see: defineByParameters()*/

    public MasterView (Solution sol, double distCutoff, int maxCount, TimeSpan ts) {

      this();

      defineByParameters(sol, distCutoff,maxCount, ts);
    }

    /**
     * Build a MasterView based on this solution ID containing stations within the
     * parameter bounds and with waveforms with the given timespan. The view is
     * NOT based on waveforms saved in the DataSource. Rather Waveform objects
     * are created based on the TimeSpan given. These are effectively 'requests'
     * that may or may not be successfully fulfilled when a call to
     * loadWaveforms() is made. The DataSource will be searced for the TimeSpan
     * specified to find phases, amps, etc.  <p>
     *
     * The list will end at either the  distance cutoff or the station count,
     * whichever comes first. For example, assume there are 50 channels within
     * 100 km of the epicenter; if distCutoff=100 & maxCount=20, only the
     * nearest 20 channels will be included. If distCutoff=100 & maxCount=200,
     * only the 50 stations within 100 km will be include. The station list
     * comes from the channel list in * the Channel class.
     *
     * @see: defineByParameters()*/

    public MasterView (long id, double distCutoff, int maxCount, TimeSpan ts) {

	this();

	defineByParameters(id, distCutoff, maxCount, ts);

    }

    /** Create MasterView defining time window as 'preOT' seconds before origin time
     * and 'postOT' seconds after origin time. The Total window size is preOT+postOT. */
    public MasterView (Solution sol, double distCutoff, int maxCount,
		       double preOT, double postOT) {

	this();

	defineByParameters(sol, distCutoff, maxCount, preOT, postOT);

    }

    /** Create MasterView defining time window as 'preOT' seconds before origin time
     * and 'postOT' seconds after origin time. The Total window size is preOT+postOT. */
    public MasterView (long evid, double distCutoff, int maxCount,
		       double preOT, double postOT) {

	this();

	defineByParameters(evid, distCutoff, maxCount, new TimeSpan(preOT, postOT));

    }

/** Set the statusPanel where we should repor progress. */
  public void setStatusPanel (StatusPanel sp) {

       statusPanel = sp;
  }

/** Report to statusPanel */
  void report (String msg, int val) {
       if (statusPanel == null) return;

//doesn't work//       statusPanel.setProgressBarValue(val, msg);
  }
  void report (String msg) {
       report (msg, 0);   // sets status bar to min value
  }
  void report (int val) {
       if (statusPanel == null) return;
//doesn't work//           statusPanel.setProgressBarValue(val);
       statusPanel.validate();  // redundant???
  }

  /** Make a Solution from scratch and add it to the solList. Returns the
  * new solution. */
  public Solution createSolution() {

     Solution sol = Solution.create();

     addSolution(sol);

     return sol;
  }

  /** Add solution to the master view. Will not add again if it's already in the list.
  * Fires solList change event. Adds reading list change listeners. Returns true
  * if Solution was added, false if not.*/
  public boolean addSolution(Solution sol) {

	// adds sol to list in proper time order, notifies observers
	if (solList.add(sol)) {

        // add listeners to keep individual WFView lists in synch
        sol.phaseList.addChangeListener(jasiReadingListModel);
        sol.ampList.addChangeListener(jasiReadingListModel);
        sol.codaList.addChangeListener(jasiReadingListModel);
	return true;
     } else {
        return false;
     }
  }
/**
 * Remove this solution and all associated data from this MasterView. Does NOT
 * delete it from the data source. Does NOT set delete flags in the solution.
 */
public void removeSolution (Solution sol) {

    //Stop wf cache manager if this sol was selected. */
    if (sol == solList.getSelected()) {
       wfvList.stopCacheManager();
    }

    // remove listeners else you have dangling references
    sol.phaseList.removeChangeListener(jasiReadingListModel);
    sol.ampList.removeChangeListener(jasiReadingListModel);
    sol.codaList.removeChangeListener(jasiReadingListModel);

    // remove solution
    solList.remove(sol);

    // Re-make a local phase and amp lists for each WFView to reflect change.
    makeLocalLists();
}
/** Remove all solutions for the MasterView's solutionList. */
public void clearSolutionList() {

    // Stop wf cache manager if there is one running
    wfvList.stopCacheManager();

    Solution sol[] = solList.getArray();
    for (int i = 0; i<sol.length; i++) {
           // remove listeners else you have dangling references
          sol[i].phaseList.removeChangeListener(jasiReadingListModel);
          sol[i].ampList.removeChangeListener(jasiReadingListModel);
          sol[i].codaList.removeChangeListener(jasiReadingListModel);
     }

     solList = new SolutionList();

     // Re-make a local phase and amp lists for each WFView to reflect change.
     makeLocalLists();
}
  /** Return the selected solution. */
  public Solution getSelectedSolution() {
    return solList.getSelected();
  }

  /** Return the selected solution. */
  public boolean setSelectedSolution(Solution solution) {
    return solList.setSelected(solution);
  }
    /**
     * Build a MasterView based on this solution containing stations within the
     * parameter bounds and with waveforms with the given timespan. The view is
     * NOT based on waveforms saved in the DataSource. Rather Waveform objects
     * are created based on the TimeSpan given. These are effectively 'requests'
     * that may or may not be successfully fulfilled when a call to
     * loadWaveforms() is made. The DataSource will be searced for the TimeSpan
     * specified to find phases, amps, etc.  <p>
     *
     * The list will end at either the  distance cutoff or the station count,
     * whichever comes first. For example, assume there are 50 channels within
     * 100 km of the epicenter; if distCutoff=100 & maxCount=20, only the
     * nearest 20 channels will be included. If distCutoff=100 & maxCount=200,
     * only the 50 stations within 100 km will be include. The station list
     * comes from the c
     */
    public void defineByParameters(Solution sol, double distCutoff,
				               int maxCount, TimeSpan ts) {

	if (sol == null) return;

	// adds sol to list in proper time order, notifies observers
	addSolution(sol);
	setSelectedSolution(sol);

	makeWFViewList(distCutoff, maxCount, ts);

	// load Phases, Amps, * Codas
	loadReadings();

	// copy lat/lon info from Channel class to WFViews
 	loadChannelData();

	// calc distances and sort by dist from selected Solution
	distanceSort(sol);

	// Time align the waveforms by setting all their viewSpans equal to the
	// master View's timeSpan. Obviously must do AFTER the timeSpan is set
	// by all data in loop above.
	alignViews();

	// Get timeseries if flag is set
	loadWaveforms();

     }

     /**
     * Load all readings; Phases, Amps & Codas IF the loader flag of each is set
     */
     protected void loadReadings () {

⌨️ 快捷键说明

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