View Javadoc

1   /*
2     The TauP Toolkit: Flexible Seismic Travel-Time and Raypath Utilities.
3     Copyright (C) 1998-2000 University of South Carolina
4   
5     This program is free software; you can redistribute it and/or
6     modify it under the terms of the GNU General Public License
7     as published by the Free Software Foundation; either version 2
8     of the License, or (at your option) any later version.
9   
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14  
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  
19    The current version can be found at 
20    <A HREF="www.seis.sc.edu">http://www.seis.sc.edu</A>
21  
22    Bug reports and comments should be directed to 
23    H. Philip Crotwell, crotwell@seis.sc.edu or
24    Tom Owens, owens@seis.sc.edu
25  
26  */
27  
28  
29  package edu.sc.seis.TauP;
30  
31  import java.awt.Container;
32  import java.awt.Graphics;
33  import java.util.Vector;
34  
35  /*** Time versus Distance plot.
36    *
37    *
38    * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
39  
40  
41  
42    * @author H. Philip Crotwell
43    *
44    */
45  public class TimeDistPlot extends XYPlot {
46  
47     public TimeDistPlot(Container parent) {
48        super(parent);
49        title = "Time/Distance";
50        xLabel = "distance (deg)";
51        yLabel = "time (sec)";
52        xTickWidth = 10;
53        yTickWidth = 200;
54        minX = 0.0;
55        maxX = 270.0;
56        minY = 0.0;
57        maxY = 2800.0;
58     }
59  
60     public TimeDistPlot(Container parent, int width, int height) {
61        super(parent, width, height);
62        title = "Time/Distance";
63        xLabel = "distance (deg)";
64        yLabel = "time (sec)";
65        xTickWidth = 10;
66        yTickWidth = 200;
67     }
68  
69     public void plot(TauModel tModel, boolean isPWave) {
70  		int waveNum;
71        if (! isPWave) {
72  			waveNum = 1;
73           minX = 0.0;
74           maxX = 270.0;
75           minY = 0.0;
76           maxY = 2800.0;
77        } else {
78  			waveNum = 0;
79           minX = 0.0;
80           maxX = 200.0;
81           minY = 0.0;
82           maxY = 1300.0;
83        }
84        zoomMinX = minX;
85        zoomMaxX = maxX;
86        zoomMinY = minY;
87        zoomMaxY = maxY;
88  
89        int jj=0;
90        double x, y;
91        double[] tempXData, tempYData;
92        xSegments = new Vector();
93        ySegments = new Vector();
94  
95        for (int i=0;i<tModel.getNumBranches();i++) {
96           jj=0;
97           tempXData = new double[tModel.rayParams.length];
98           tempYData = new double[tModel.rayParams.length];
99           for (int j=0;j<tModel.rayParams.length;j++) {
100             y=0;
101             x=0;
102             for (int k=0;k<=i;k++) {
103                x += 2*tModel.tauBranches[waveNum][k].getDist(j);
104                y += 2*tModel.tauBranches[waveNum][k].time[j];
105             }
106             x*=180/Math.PI;
107             if (tModel.tauBranches[waveNum][i].time[j]!=0 || (i==0 && x==0)) {
108 //               System.out.println("branch "+i+" dist="+x+" time="+y+
109 //                  " p="+tModel.rayParams[j]);
110                tempXData[jj]=x;
111                tempYData[jj]=y;
112                if (DEBUG) System.out.println(x+" "+y);
113                jj++;
114             }
115          }
116          if (DEBUG) System.out.println("> ");
117          xData= new double[jj];
118          System.arraycopy(tempXData, 0, xData, 0, jj);
119          yData= new double[jj];
120          System.arraycopy(tempYData, 0, yData, 0, jj);
121          xSegments.addElement(xData);
122          ySegments.addElement(yData);
123       }
124       repaint();
125    }
126  
127    public void paint(Graphics g) {
128       super.paint(g);
129    }
130 }