1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package edu.sc.seis.TauP;
29
30 import java.applet.Applet;
31 import java.awt.Button;
32 import java.awt.CardLayout;
33 import java.awt.Color;
34 import java.awt.FlowLayout;
35 import java.awt.Frame;
36 import java.awt.Panel;
37 import java.awt.event.ActionEvent;
38 import java.awt.event.ActionListener;
39 import java.awt.event.WindowEvent;
40 import java.awt.event.WindowListener;
41 import java.io.IOException;
42
43 /***
44 * GUI for TauP_Create, a re-implementation of the seismic travel time
45 * calculation method described in "The Computation of Seismic Travel Times"
46 * by Buland and Chapman, BSSA vol. 73, No. 5, October 1983, pp 1271-1302
47 *
48 * TauP_WCreate can run as an applet or as a java application, except for
49 * the security restrictions on file access.
50 *
51 * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
52
53
54
55 * @author H. Philip Crotwell
56 */
57 public class TauP_WCreate extends Applet implements ActionListener {
58 VelocityPlot velocityPlot;
59 SlownessPlot slownessPlot;
60 TauPlot tauPPlot;
61 DistPlot distPlot;
62 TimePlot timePlot;
63 TimeDistPlot timeDistPlot;
64 String modelFilename = "iasp91.tvel";
65 String directory = ".";
66 TauP_Create tauPCreate = new TauP_Create();
67
68 Panel cardPanel = new Panel();
69 CardLayout cards = new CardLayout();
70 Button nextButton;
71 Button previousButton;
72 Button quitButton;
73
74 public void init() {
75 setBackground(Color.white);
76 setLayout(new FlowLayout());
77
78 cardPanel.setLayout(cards);
79 add(cardPanel);
80
81 previousButton = new Button("Previous");
82 add( previousButton);
83 previousButton.addActionListener(this);
84
85 nextButton = new Button("Next");
86 add( nextButton);
87 nextButton.addActionListener(this);
88
89 quitButton = new Button("Quit");
90 add( quitButton);
91 quitButton.addActionListener(this);
92
93 velocityPlot = new VelocityPlot(this);
94 velocityPlot.DEBUG = false;
95 cardPanel.add("Velocity",velocityPlot);
96
97 slownessPlot = new SlownessPlot(this);
98 slownessPlot.DEBUG = false;
99 cardPanel.add("Slowness",slownessPlot);
100
101 tauPPlot = new TauPlot(this);
102 tauPPlot.DEBUG = false;
103 cardPanel.add("Tau", tauPPlot);
104
105 distPlot = new DistPlot(this);
106 distPlot.DEBUG = false;
107 cardPanel.add("Dist", distPlot);
108
109 timePlot = new TimePlot(this);
110 timePlot.DEBUG = false;
111 cardPanel.add("Time", timePlot);
112
113 timeDistPlot = new TimeDistPlot(this);
114 timeDistPlot.DEBUG = false;
115 cardPanel.add("TimeDist", timeDistPlot);
116
117 validate();
118
119 tauPCreate.modelFilename = modelFilename;
120 tauPCreate.directory = directory;
121
122 try {
123 tauPCreate.init();
124 } catch (VelocityModelException e) {
125 System.err.println("Caught VelocityModelException: "+e.getMessage());
126 } catch (IOException e) {
127 System.err.println("Caught IOException: "+e.getMessage());
128 }
129 }
130
131 public void start() {
132
133 try {
134 tauPCreate.start();
135 } catch (SlownessModelException e) {
136 System.err.println("Caught SlownessModelException: "+e.getMessage());
137 e.printStackTrace();
138 } catch (TauModelException e) {
139 System.err.println("Caught TauModelException: "+e.getMessage());
140 e.printStackTrace();
141 }
142
143 try {
144 velocityPlot.plot(tauPCreate.vMod,'P','S');
145 } catch (NoSuchMatPropException e) {
146
147 System.err.println("Caught NoSuchMatPropException: "+e.getMessage());
148 e.printStackTrace();
149 }
150 slownessPlot.plot(tauPCreate.sMod, true);
151 tauPPlot.plot(tauPCreate.tMod, true);
152 timePlot.plot(tauPCreate.tMod, true);
153 distPlot.plot(tauPCreate.tMod, true);
154 timeDistPlot.plot(tauPCreate.tMod, true);
155 }
156
157 public void actionPerformed(ActionEvent action) {
158 String arg = action.getActionCommand();
159
160 if ("Previous".equals(arg)) {
161 cards.previous(cardPanel);
162 } else if ("Next".equals(arg)) {
163 cards.next(cardPanel);
164 } else if ("Quit".equals(arg)) {
165 System.exit(0);
166 }
167 }
168
169 public static void main(String[] args) {
170
171 if (args.length!=1 ) {
172 System.out.println("Usage java TauP_WCreate velocitymodel.tvel [wavetype]");
173 System.exit(1);
174 }
175
176 MainFrame f = new MainFrame("TauP_WCreate");
177
178 TauP_WCreate tauPWCreate = new TauP_WCreate();
179
180 int j = args[0].lastIndexOf(System.getProperty("file.separator"));
181 if (j== -1) {
182 tauPWCreate.modelFilename = args[0];
183 tauPWCreate.directory = ".";
184 } else {
185 tauPWCreate.modelFilename = args[0].substring(j+1);
186 tauPWCreate.directory = args[0].substring(0,j);
187 }
188
189 tauPWCreate.init();
190
191 f.add("Center", tauPWCreate);
192 f.pack();
193 f.show();
194
195 tauPWCreate.start();
196 }
197
198
199 }
200
201 class MainFrame extends Frame
202 implements WindowListener
203 {
204 MainFrame(String title) {
205 super(title);
206 addWindowListener(this);
207 }
208
209 public void windowClosed(WindowEvent event) {
210 }
211
212 public void windowDeiconified(WindowEvent event) {
213 }
214
215 public void windowIconified(WindowEvent event) {
216 }
217
218 public void windowActivated(WindowEvent event) {
219 }
220
221 public void windowDeactivated(WindowEvent event) {
222 }
223
224 public void windowOpened(WindowEvent event) {
225 }
226
227 public void windowClosing(WindowEvent event) {
228 System.exit(0);
229 }
230
231 }