📄 masterview.java
字号:
return knt;
}
/**
* Delete all phases associated with this solution that are in WFViews greater
* than or equal to this dist. (This function is here rather than in PhaseList or
* Solution because the WFViews are the only components garenteed to have the
* distance set) . Returns the number of deleted phases.
*/
public int stripPhasesByDistance(double cutDist, Solution sol) {
int knt = 0;
Phase ph[] = sol.phaseList.getArray();
for (int i = 0;i<ph.length; i++) {
// must delete from Soltions's list *NOT* WFView's list because
// the MV's list is Active and will notify observers of change
// This, in turn, will update the WFView.phaseLists
if (ph[i].getDistance() > cutDist) {
sol.deletePhase(ph[i]);
knt++;
}
}
return knt;
}
public void setResidualStripValue(double value) {
residualStripValue = value;
}
public double getResidualStripValue() {
return residualStripValue;
}
public void setClockQualityThreshold (double value) {
clockQualityThreshold = value;
}
public double getClockQualityThreshold() {
return clockQualityThreshold;
}
/**
* Delete all phases associated with the selected solution that have a residual greater
* than or equal to the value set by setResidualStripValue().
* Returns the number of deleted phases.
*/
public int stripPhasesByResidual() {
return stripPhasesByResidual(getSelectedSolution());
}
/**
* Delete all phases associated with this solution that have a residual greater
* than or equal to the value set by setResidualStripValue().
* Returns the number of deleted phases.
*/
public int stripPhasesByResidual(Solution sol) {
return stripPhasesByResidual(getResidualStripValue(), sol);
}
/**
* Delete all phases associated with this solution that have a residual greater
* than or equal to this value. Returns the number of deleted phases.
*/
public int stripPhasesByResidual(double val, Solution sol) {
return sol.phaseList.stripByResidual(val, sol);
/*
int knt = 0;
System.out.println ("Stripping by residule = "+val+"\n"+sol.toString());
Phase ph[] = sol.phaseList.getArray();
for (int i = 0; i<ph.length; i++) {
if (ph[i].residual.doubleValue() >= val) {
// see deletePhase() for more info
sol.phaseList.delete(ph[i]);
System.out.println ("Deleting: "+ph[i].toString());
}
}
return knt;
*/
}
/** This is here because we must delete phases from two lists; the MasterView's and
* the Solution's. These should be coordinated in a more clever way but that's for
* the TODO list.... The MasterView's list is Active and will notify observers of change
* This, in turn, will update the WFView.phaseLists. */
/*
public void deletePhase (Phase ph) {
// ph.sol.phaseList.delete(ph); // just sets the delete flag doens't remove from list
this.phaseList.delete(ph);
}
*/
/** Locate the given event. The PropertyList must have values for:
* locationEngineAddress & locationEnginePort which identify a socket based
* location engine. @See: org.trinet.jiggle.LocationEngine */
public boolean locate (GenericPropertyList props, Solution sol) {
String locEngAddr = props.getProperty("locationEngineAddress");
int locEngPort = props.getInt("locationEnginePort");
LocationEngine locEng = LocationEngine.CreateLocationEngine(props.getProperty("LocationEngine",
"org.trinet.jiggle.LocalEngineHypoInverse"));
locEng.setServer(locEngAddr, locEngPort);
return locEng.solve(sol, sol.phaseList);
}
/**
* Locate the selected event.
*/
public boolean locate (GenericPropertyList props) {
return locate (props, solList.getSelected());
}
/**
* Create a new masterView containing only the first 'maxViews' components in 'mv'.
* This will generally be used to create a more managable MasterView for events
* with lots of components. If the original MasterView has 'maxViews' WFViews or
* fewer it is returned without modification.
*/
public static MasterView subset (MasterView mv, int maxViews) {
if (mv.getWFViewCount() <= maxViews) return mv;
MasterView mvNew = new MasterView();
// copy the solution list
mvNew.solList = new SolutionList(mv.solList);
WFView wfv[] = mv.wfvList.getArray();
// select the proper WFView's
for ( int i=0; i < wfv.length; i++)
{
mvNew.addWFView(wfv[i]);
if (i == maxViews-1) break; // got enough
}
mvNew.alignViews();
return mvNew;
}
/**
* Create a new masterView containing only vertical components. It will contain no more
* then 'maxViews' WFViews.
*/
// Is there a more general way to do this sort of thing?
public static MasterView vertOnly(MasterView mv, int maxViews) {
MasterView mvNew = new MasterView();
// copy the solution list
// mvNew.solList = new ActiveSolutionList(mv.solList);
mvNew.solList = new SolutionList(mv.solList);
WFView wfv[] = mv.wfvList.getArray();
// select the proper WFView's
for ( int i=0; i < wfv.length; i++)
{
if (wfv[i].chan.isVertical()) mvNew.addWFView(wfv[i]);
if (i == maxViews) break; // got enough
}
mvNew.alignViews();
return mvNew;
}
/**
* Create a new masterView containing only components that have phase picks.
*/
public static MasterView withPhasesOnly(MasterView mv) {
return withPhasesOnly (mv, Integer.MAX_VALUE);
}
/**
* Create a new masterView containing only components that have phase picks.
* It will contain no more then 'maxViews' WFViews.
*/
// Is there a more general way to do this sort of thing?
public static MasterView withPhasesOnly(MasterView mv, int maxViews) {
MasterView mvNew = new MasterView();
// copy the solution list
mvNew.solList = new SolutionList(mv.solList);
WFView wfv[] = mv.wfvList.getArray();
// select the proper WFView's
for ( int i=0; i < wfv.length; i++) {
if (wfv[i].hasPhases()) mvNew.addWFView(wfv[i]);
if (i == maxViews) break; // got enough
}
mvNew.alignViews();
return mvNew;
}
/**
* Calculate the true and horizontal distance from location in the argument for
* each site in the list. Requires that loadChannelData be called first.
*/
public void calcDistances (LatLonZ loc) {
wfvList.calcDistances(loc);
}
/**
* Calculate the distance from the given location
* Requires that loadChannelData be called first.
*/
public void calcDistances (float lat, float lon, float z)
{
calcDistances(new LatLonZ (lat, lon, z));
}
/**
* Calculate the distance from the location of the selected Solution.
* Requires that loadChannelData be called first.
*/
public void calcDistances ()
{
calcDistances(solList.getSelected().getLatLonZ());
}
/**
* If 'true' waveforms will be retreived. Deprecated.
*/
/*
public void setWfRetrieveFlag (boolean tf)
{
if (tf) {
waveformLoadMode = LoadAllInForeground;
} else {
waveformLoadMode = LoadNone;
}
}
*/
/**
* Depricated
*/
/*
public boolean getWfRetrieveFlag ()
{
return wfRetrieveFlag;
}
*/
//* Set the waveform loading method. Returns 'false' if the mode is invalid.
public boolean setWaveFormLoadMode (int mode) {
// check for valid mode type
if (mode > ModeCount) return false;
waveformLoadMode = mode;
if (waveformLoadMode == Cache) {
wfvList.setCachingEnabled(true);
}
return true;
}
public int getWaveFormLoadMode () {
return waveformLoadMode;
}
/** Pass-thru method */
public void setCacheSize (int above, int below) {
if (getWaveFormLoadMode() == Cache) {
wfvList.setCacheSize(above, below);
}
}
public void setLoadChannelData(boolean tf) {
loadChannelData = tf;
}
public boolean getLoadChannelData() {
return loadChannelData;
}
/** Cleanup stuff before this mv is destroyed. Otherwise, dangling references
* cause a memory leak. Stops the cache manager. */
public void destroy() {
solList.clearChangeListeners();
masterWFViewModel.clearChangeListeners();
masterWFWindowModel.clearChangeListeners();
wfvList.stopCacheManager();
wfvList.clearChangeListeners();
// remove solutions and delete listeners
clearSolutionList();
}
/**
* Dump some info about the views for debugging
*/
public void dump () {
System.out.println (dumpToString());
}
/** Returns a string containing a line describing each solution followed
* by a list of amplitudes associated with that solution. */
public String ampsToString() {
String str="";
Solution sol[] = solList.getArray();
for (int i = 0; i<sol.length; i++) {
str += sol[i].toString() + "\n";
if (sol[i].magnitude == null) {
str += " * No magnitude for this solution *\n";
} else {
str += sol[i].magnitude.toDumpString() + "\n";
// str += sol[i].magnitude.ampList.dumpToString()+"\n\n";
}
str += sol[i].ampList.dumpToString()+"\n\n";
}
return str;
}
/** Returns a string containing a line describing each solution followed
* by a list of phases associated with that solution. */
public String phasesToString() {
String str="";
Solution sol[] = solList.getArray();
for (int i = 0; i<sol.length; i++) {
str += sol[i].toString() + "\n";
// This is not just the raw phaseList to weed out virtually deleted events
str += sol[i].phaseList.getAssociated(sol[i]).dumpToArcString()+"\n\n";
// str += sol[i].phaseList.dumpToArcString()+"\n\n";
}
return str;
}
public String dumpToString()
{
String str;
str = solList.size() + " origins\n";
str += solList.dumpToString() + "\n";
str += wfvList.size() + " waveforms\n";
// show info about WFViews
WFView wfv[] = wfvList.getArray();
for ( int i=0; i < wfv.length; i++)
{
str += "\n";
str += wfv[i].dumpToString()+"\n";
if (wfv[i].wf == null) {
str += " (no waveform)";
} else {
str += wfv[i].wf.toString() +"\n";
}
}
return str;
}
/**
* Dump the MasterView to the given JTextArea
*/
public void dumpToJTextArea(JTextArea jtext)
{
jtext.setText(dumpToString());
}
/// --------------------------------------------------------------------------
/**
* Main for testing
*/
public static void main (String args[])
{
int evid;
if (args.length <= 0) // no args
{
System.out.println ("Usage: java MasterView [evid])");
evid = 9723237;
System.out.println ("Using evid "+ evid+" as a test...");
} else {
Integer val = Integer.valueOf(args[0]); // convert arg String to 'double'
evid = (int) val.intValue();
}
System.out.println ("Making connection...");
DataSource db = new TestDataSource(); // make connection
System.out.println ("DataSource = "+db.toS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -