📄 activewfpanel.java
字号:
if (mv == null) return;
sol = mv.getSelectedSolution();
// Delete the nearest pick associated with the selected solution
if (action == "Delete Pick") {
// Delete it in Solutions's list so listeners know.
// Nearest phase could be null (no phase) but phaseList.delete()
// copes with that
sol.deletePhase(wfv.phaseList.getNearestPhase(clickTime, sol));
} else if (action == "Delete Amp") {
sol.ampList.delete(wfv.ampList.getNearestToTime(clickTime, sol));
} else if (action == "Delete Coda") {
sol.ampList.delete(wfv.codaList.getNearestToTime(clickTime, sol));
} else if (action == "Strip by residual") {
mv.stripPhasesByResidual();
} else if (action == "Strip more distant picks") {
mv.stripPhasesByDistance(wfv.getDistance(), sol);
} else if (action == "Strip more distant amps") {
mv.stripAmpsByDistance(wfv.getDistance(), sol);
} else if (action == "Strip more distant codas") {
mv.stripCodasByDistance(wfv.getDistance(), sol);
} else if (action == "Show waveform info") {
//String msg = "<html>"+wfv.wf.toBlockString()+"</html>";
String msg = wfv.wf.toBlockString();
JOptionPane.showMessageDialog(null, msg, "Waveform Info",
JOptionPane.INFORMATION_MESSAGE);
} else
if (action == "Close Popup") {
// noop
}
}
}
/** THIS IS THE *VIEW* PART OF THE MVC INTERACTION.
* This is the method that is called by the ActiveWFVModel when the
* selection changes. The TYPE of 'arg' is used to determine what action
* to take. Two things can change; 1) the selected WFView and 2) the selected
* time/amp box. <p>
* An ActiveWFPanel is assumed to contain a WFView that is NOT
* changed by the ActiveWFVModel. The ActiveWFPanel will change its look or
* behavior if its WFView is the same as the one selected by the MasterWFVModel
* but the WFView itself is constant.
*/
/*
public void update (Observable obs, Object arg) {
// System.out.println ("UPDATE: "+ arg.getClass().toString());
if (arg instanceof WFView) // what changed?
{
WFView newWFV = (WFView) arg;
boolean itsMe = (newWFV == wfv); // clever readability step
if (!amSelected) { // not currently selected
if (itsMe) { // I am newly selected
amSelected = true;
} else { // no effect on me, don't repaint
return;
}
} else {
if (!itsMe) { // I just got deselected
amSelected = false;
}
}
// note that if (amSelected && itsMe) a repaint happens this
// behavior is used to force a repaint if something else changes
// like the phase list.
// validate();
repaint();
}
// only the viewport changed
if (arg instanceof WFSelectionBox)
{
if (amSelected) repaint();
}
} // end of update
*/
/**
* Add the listener that handles waveform load events. This is to support
* asynchronous loading of timeseries in background. This overrides the
* method in WFPanel because we must use a different inner class. */
// private void addWFLoadListener () {
protected void addWFLoadListener () {
// System.out.println ("addWFLoadListener - ActiveWFPanel");
if (getWf() != null) {
getWf().addChangeListener (new ActiveWFLoadListener());
}
}
/** INNER CLASS: Handle changes to the JasiObject lists. */
class JasiReadingChangeListener implements ChangeListener {
public void stateChanged (ChangeEvent changeEvent) {
// 'arg' will be either a JasiReading or a JasiReadingList
Object arg = changeEvent.getSource();
// phase changed
if (arg instanceof Phase) {
Phase ph = (Phase) arg;
// if it affects us, rebuild our local phaseList
// This contributes to efficiency, otherwise ALL panels would repaint
// on every phase edit!
if (ph.getChannelObj().equals(wfv.chan)) {
//x// wfv.updatePhaseList();
repaint();
}
}
// phaseList changed don't know if it affects us, so rebuild local list
else if (arg instanceof PhaseList) {
//x// wfv.updatePhaseList();
repaint();
}
// amp changed
else if (arg instanceof Amplitude) {
Amplitude amp = (Amplitude) arg;
// if it affects us, rebuild our local phaseList
// This contributes to efficiency, otherwise ALL panels would repaint
// on every phase edit!
if (amp.getChannelObj().equals(wfv.chan)) {
//x// wfv.updateAmpList();
repaint();
}
}
// phaseList changed don't know if it affects us, so rebuild local list
else if (arg instanceof org.trinet.jasi.AmpList) {
//x// wfv.updateAmpList();
repaint();
}
// coda changed
else if (arg instanceof Coda) {
Coda coda = (Coda) arg;
// if it affects us, rebuild our local phaseList
// This contributes to efficiency, otherwise ALL panels would repaint
// on every phase edit!
if (coda.getChannelObj().equals(wfv.chan)) {
//x// wfv.updateCodaList();
repaint();
}
}
// phaseList changed don't know if it affects us, so rebuild local list
else if (arg instanceof CodaList) {
//x// wfv.updateCodaList();
repaint();
}
} // end of stateChanged
} // end of JasiReadingChangeListener
/** INNER CLASS: Handle changes to the phase list. */
class PhaseListChangeListener implements ChangeListener {
public void stateChanged (ChangeEvent changeEvent) {
// wfv.updatePhaseList();
// repaint();
Object arg = changeEvent.getSource();
// phase changed
if (arg instanceof Phase)
{
Phase ph = (Phase) arg;
// if it affects us, rebuild our local phaseList
// This contributes to efficiency, otherwise ALL panels would repaint
// on every phase edit!
if (ph.getChannelObj().equals(wfv.chan)) {
wfv.updatePhaseList();
repaint();
}
}
// phaseList changed don't know if it affects us, so rebuild local list
if (arg instanceof PhaseList)
{
wfv.updatePhaseList();
repaint();
}
}
} // end of PhaseListChangeListener
/** INNER CLASS: Handle changes to the amp list. */
class AmpListChangeListener implements ChangeListener {
public void stateChanged (ChangeEvent changeEvent) {
Object arg = changeEvent.getSource();
// amp changed
if (arg instanceof Amplitude) {
Amplitude amp = (Amplitude) arg;
// if it affects us, rebuild our local phaseList
// This contributes to efficiency, otherwise ALL panels would repaint
// on every phase edit!
if (amp.getChannelObj().equals(wfv.chan)) {
wfv.updateAmpList();
repaint();
}
}
// phaseList changed don't know if it affects us, so rebuild local list
if (arg instanceof org.trinet.jasi.AmpList) {
wfv.updateAmpList();
repaint();
}
}
} // end of PhaseListChangeListener
/** INNER CLASS: Handle changes to the selected WFView. */
/** This listener is really only used to UN-select a WFView. It is too costly to have
* 1200+ WFPanels listening to see if they are selected, so the listener is only "added"
* to the SelectedWFViewModel WHEN the WFView is selected. This is done in the
* setSelected(tf) method which is called by the ActiveWFPanel MsHandler. */
/* class WFViewListener implements ChangeListener {
public void stateChanged (ChangeEvent changeEvent) {
WFView newWFV = ((SelectedWFViewModel) changeEvent.getSource()).get();
// selection logic
if (newWFV == wfv) { // its us
if (amSelected) {
// already selected :. noop
} else {
setSelected(true); // shouldn't happen since no listener if
// not already selected
}
} else { // its NOT us
if (amSelected) {
setSelected(false); // we were UNselected
} else { // not us & we're not selected, who cares?
// noop
}
}
// if (amSelected && newWFV != wfv) setSelected(false);
}
} // end of WFViewListener
*/
/** INNER CLASS: Handle changes to the selected time/amp window. */
class WFWindowListener implements ChangeListener {
public void stateChanged (ChangeEvent changeEvent) {
if (amSelected) repaint();
}
} // end of WFWindowListener
/** INNER CLASS: Change events are expected from Waveform objects when the
* timeseries is loaded. Repaint the WFPanel when timeseries shows up.
* This is to support asynchronous loading of timeseries in background.
* This over-rides WFPanel.WFLoadListener because it must update the
* ActiveWFVModel. If this WFPanel "isSelected" and the ActiveWFVModel was
* set BEFORE time-series was available the max/min amp bounds could not be
* set to fit the data. This must be adjusted now that the time-series is
* loaded. */
class ActiveWFLoadListener implements ChangeListener {
public void stateChanged (ChangeEvent changeEvent) {
setupWf();
// set box bounds based on the data
// dataBox.set (getWf()); // a null wf is OK here
// setPanelBoxSize();
// Adjust WFWindowModel's ampspan to the max/min of the data if
// Waveform data just got loaded for the first time
if (amSelected){
if (mv != null) mv.masterWFWindowModel.setAmpSpan(getWf(),
dataBox.getMaxAmp(),
dataBox.getMinAmp());
}
repaint();
}
} // end of Listener
/** */
public void paintBackground (Graphics g) {
if (amSelected) {
setBackgroundColor(selectedColor);
} else {
setBackgroundColor(unselectedColor);
}
super.paintBackground(g);
// paint any highlight areas over the background but under the foreground
if (mv != null) {
WFSelectionBox viewBox = mv.masterWFWindowModel.getSelectionBox(getWf());
if (amSelected) paintHighlight (g, viewBox, highlightColor);
// paint phase location cues
if (getShowPhaseCues()) paintPhaseCues(g);
if (amDragging) paintHighlight (g, dragBox, dragColor);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -