📄 jiggle.java
字号:
public boolean locate() {
statusPanel.setText("Locating...");
// This allows for the fact that the address and port may have been changed
// since the last time. If it hasn't changed this is a nooop.
String address = props.getProperty("locationEngineAddress");
int port = props.getInt("locationEnginePort");
locEng.setUseTrialLocation(props.getBoolean("useTrialLocation"));
locEng.setServer(address, port);
locEng.reset();
// do the location
Solution sol = mv.getSelectedSolution();
boolean status = locEng.solve(sol); // locate
// failure, put message in tab pane
if (!status) {
// get error message from LocationEngine for display in text area
String str = locEng.getMessage();
statusPanel.setText(str);
System.out.println(str);
// pop a dialog
JOptionPane.showMessageDialog(null, str, "Location failed",
JOptionPane.INFORMATION_MESSAGE);
}
else {
statusPanel.clear();
sol.processingState.setValue("H");
// This is a site-specific kludge (naughty, naughty)
if (sol.getEventTypeString().equalsIgnoreCase("trigger")) {
sol.setEventType("local");
// recalc the mags with the new location
}
recalcPrefmag(sol);
// update the text the tabs & frame title
updateTextViews();
tabPane.setSelectedIndex(TAB_LOCATION);
}
return status;
}
/** Recalculate the prefered mag.
* This is too specific, needs to be generalized. */
void recalcPrefmag(Solution sol) {
// no mag to recalc.
if (sol.magnitude == null ||
sol.magnitude.isNull()) {
return;
}
// is this a mag with no supporting amps?
if (sol.magnitude.hasReadings()) {
if (sol.magnitude.isCodaMag()) {
calcMC(sol);
}
else {
calcML(sol);
}
}
else {
final String msg = "Magnitude has no supporting amps or codas\n" +
" and can not be recalculated.\n" +
"MAGNITUDE MAY BE INVALID FOR NEW LOCATION\n";
System.out.println("Mag not recalculated, no suppporting readings.");
JOptionPane.showMessageDialog(null, msg, "Old Magnitude Used",
JOptionPane.INFORMATION_MESSAGE);
}
}
/** Calculate the ML magnitude of this solution from scratch by scanning the
* Waveforms. */
public void scanML(Solution sol) {
if (!hasGoodLocation(sol)) {
return; // no solution
}
// Blow away the old amps associated with this solution,
// otherwise repeated calls will accumulate duplicates of the same amps!
// mv.ampList.removeAll(mv.ampList.getAssociated(sol));
sol.ampList.clear();
// TODO: allow different mag types
if (debug) {
System.out.println
(" Calculating mag (SoCalML) from scratch for: " + sol.toString());
/* DK Changed code from old magnitude engine instantiation
to new generic method.
* SoCalML ml = new SoCalML();
* set characteristics (should get from properties)
* ml.setTrimResidual(1.0);
* ml.setRequireCorrection(true);
* ml.setUseLowGains(false);
*
* MagnitudeEngine magEng = new MagnitudeEngine(ml);
*
* Magnitude newMag =
* magEng.solveFromWaveforms(sol, mv.getWaveformList());
**************************************************/
// DK 10/28/02 New code for magnitude instantiation
// BEGIN NEW
}
MagnitudeMethod ml =
MagnitudeMethod.CreateMagnitudeMethod(MLmagMethodClass);
MagnitudeEngine magEng =
MagnitudeEngine.CreateMagnitudeEngine(magEngineClass);
magEng.ConfigureMagnitudeEngine(ml);
// END NEW
Magnitude newMag = magEng.solve(sol, mv.getWaveformList());
if (newMag != null) {
sol.magnitude = newMag;
}
if (debug) {
System.out.println("Mag calc type: " + magEng.getMagMethod().getName());
System.out.println(sol.magnitude.neatDump());
}
// add new amps to MasterView's list
sol.ampList.addAll(sol.ampList);
//done via listener from above mv.makeLocalLists(); // update WFView lists
updateTextViews();
selectTab(TAB_MAGNITUDE);
}
/** Calculate the ML magnitude of currently selected solution from scratch by
* examining the Waveforms. */
public void scanML() {
scanML(mv.solList.getSelected());
}
/** Calculate the ML magnitude of this solution.
Does NOT re-examine the waveforms. */
public void calcML(Solution sol) {
if (sol.magnitude == null) {
return; // no mag
}
// TODO: allow different mag types
if (debug) {
System.out.println(" Calculating mag (SoCalML) for: " + sol.toString());
// DK Converted to new magnitude engine instantiation
// OLD MagnitudeEngine magEng = new MagnitudeEngine(new SoCalML());
// BEGIN NEW
}
MagnitudeMethod ml =
MagnitudeMethod.CreateMagnitudeMethod(MLmagMethodClass);
MagnitudeEngine magEng =
MagnitudeEngine.CreateMagnitudeEngine(magEngineClass);
magEng.ConfigureMagnitudeEngine(ml);
// END NEW
magEng.solve(sol.magnitude);
// if (debug) System.out.println (sol.magnitude.toDumpString()) ;
updateTextViews();
selectTab(TAB_MAGNITUDE);
// NEED TO sort out amps!!!!
}
/** Calculate the ML magnitude of currently selected solution.
Does NOT re-examine the waveforms. */
public void calcML() {
calcML(mv.solList.getSelected());
}
/** Calculate the MC magnitude of this solution from scratch. */
public void scanMC(Solution sol) {
if (!hasGoodLocation(sol)) {
return; // no solution
}
// create on 1st use then reuse
if (mcaMagEng == null) {
mcaMagEng =
new org.trinet.util.magnitudeengines.JiggleMCA(props.getProperty(
"mcaConfigFile"), MasterChannelList.get());
// Mca does not currently extend MagnitudeEngine
// mcaMagEng = MagnitudeEngine.CreateMagnitudeEngine(props.getProperty("MCAMagnitudeEngine"));
}
Magnitude newMag = mcaMagEng.calcSummaryMag(sol, mv.getWaveformList());
/** New code from DK -- problem here because the
* JiggleMCA - MCA - CodamagnitudeGenerator does NOT implement MagnitudeEngine and
* Throws incompatible type exception.
* Reverted to old code 11/25/02 until it can be fixed.
* Also need to create ML, Mc etc. buttons
* or whatever, dyamically as mag types are loaded at runtime.
*/
// if (mcaMagEng == null)
// {
// mcaMagEng = MagnitudeEngine.CreateMagnitudeEngine("org.trinet.util.magnitudeengines.JiggleMCA");
// mcaMagEng.ConfigureMagnitudeEngine(MagnitudeEngine.ConfigurationSourceFile,
// "mcaConfigFile", null,
// MasterChannelList.get()
// );
// }
// Magnitude newMag = mcaMagEng.solve(sol, mv.getWaveformList());
// Don't want to blow out previous mag if this one's no good
// Ask operator before setting as preferred??
if (newMag != null) {
sol.setPreferredMagnitude(newMag);
// dump results to tab
}
updateTextViews();
//updateMagTab();
selectTab(TAB_MAGNITUDE);
return;
}
/** Calculate the MC magnitude of currently selected solution from scratch. */
public void scanMC() {
scanMC(mv.getSelectedSolution());
}
/** Calculate the MC magnitude of this solution using the existing coda data.
Does NOT re-examine the waveforms. */
public void calcMC(Solution sol) {
if (sol.magnitude == null) {
return; // no mag
}
// create on 1st use then reuse
/* DK CLEANUP */
if (mcaMagEng == null) {
mcaMagEng =
new org.trinet.util.magnitudeengines.JiggleMCA(props.getProperty(
"mcaConfigFile"), MasterChannelList.get());
}
Magnitude newMag = mcaMagEng.calcSummaryMag(sol);
// if (mcaMagEng == null)
// {
// mcaMagEng = MagnitudeEngine.CreateMagnitudeEngine("org.trinet.util.magnitudeengines.JiggleMCA");
// mcaMagEng.ConfigureMagnitudeEngine(MagnitudeEngine.ConfigurationSourceFile,
// "mcaConfigFile",null,
// MasterChannelList.get()
// );
// }
// Magnitude newMag = mcaMagEng.solve(sol);
// Don't want to blow out previous mag if this one's no good
// Ask operator before setting as preferred??
if (newMag != null) {
sol.setPreferredMagnitude(newMag);
// dump results to tab
updateTextViews();
}
else {
JOptionPane.showMessageDialog(null,
"Mca calculation was not successful.\n" +
mcaMagEng.getResultsMessage() + "\n",
"Bad Mca",
JOptionPane.INFORMATION_MESSAGE);
}
return;
}
/** Calculate the MC magnitude of this solution using the existing coda data.
Does NOT re-examine the waveforms. */
public void calcMC() {
calcMC(mv.getSelectedSolution());
}
/**
* Check to see if this solution id is locked by another user. If it is, pop a dialog
* to inform the user and return 'false'. Otherwise, return true. Also returns 'true'
* if locking is not supported otherwise you would never be allowed access to events.
*/
public boolean handleLock(long id) {
// attempt lock. Remember, this returns 'true' if locking is NOT enabled
solLock.setSolution(id);
if (solLock.lock()) {
return true; // lock was successfull
// lock failed, pop a dialog
}
else {
String str = "EVENT " + id + " IS LOCKED.\n\n" +
"Username: " + solLock.getUsername() + "\n" +
"Hostname: " + solLock.host + "\n" +
"Application: " + solLock.application + "\n" +
"Time: " +
EpochTime.toString(solLock.datetime).substring(0, 19);
JOptionPane.showMessageDialog(null,
str, "Event Is Locked",
JOptionPane.INFORMATION_MESSAGE);
return false;
}
}
/** Release all Solution Locks */
public void releaseAllSolutionLocks() {
// SolutionLock solLock = SolutionLock.create();
if (solLock != null) {
solLock.unlockAllMyLocks();
}
}
/** Get an new MasterView instance. */
private MasterView clearMasterView() {
mv.destroy();
mv = new MasterView(statusPanel);
setMasterViewProperties();
mv.setWaveFormLoadMode(MasterView.Cache);
mv.setAlignmentMode(MasterView.AlignOnTime);
mv.solList.addChangeListener(new SolListChangeListener(this));
/* DK/JRR 032603 Add Repaint to handle corrupted redraw
problem when model is resized
Handle changes to the selected time/amp window. */
mv.masterWFWindowModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent changeEvent) {
if (changeEvent.getSource() != null) {
repaint();
}
}
}
); // end of ChangeListener
/* End DK/JRR 032603 Repaint */
return mv;
}
private void setMasterViewProperties() {
if (props != null) {
mv.setChannelTimeWindowModel(props.
getCurrentChannelTimeWindowModelInstance());
mv.setCacheSize(props.getInt("cacheAbove"), props.getInt("cacheBelow"));
mv.setResidualStripValue(props.getDouble("pickStripValue"));
mv.setClockQualityThreshold(props.getDouble("clockQualityThreshold"));
mv.setChannelTimeWindowModel(props.
getCurrentChannelTimeWindowModelInstance());
}
}
/** Clear the Master view, leaves GUI in virgin state, like at startup. */
public void clearGUI() {
releaseAllSolutionLocks();
// nuke the old MasterView
clearMasterView();
// mv.destroy();
// mv = new MasterView();
// mv.setChannelTimeWindowModel(props.getCurrentChannelTimeWindowModelInstance());
// Clear main frame
getContentPane().removeAll();
// remake the GUI
makeGUI();
// put the catalog panel in the new catalog tab
tabPanel[TAB_CATALOG].removeAll();
tabPanel[TAB_CATALOG].add(catPanel, BorderLayout.CENTER);
selectTab(TAB_CATALOG);
}
/**
* Load one event from the dataSource. This is only one way to create a
* MasterView. Others will be implemented later. */
public boolean loadSolution(Solution sol) {
return loadSolution(sol.id.longValue());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -