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  /*** Plots distance versus ray parameter.
36    *
37    * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
38  
39  
40  
41    * @author H. Philip Crotwell
42    */
43  public class DistPlot extends XYPlot {
44  
45     public DistPlot(Container parent) {
46        super(parent);
47        title = "Dist";
48        xLabel = "p (sec/km or km-sec/km)";
49        yLabel = "dist (sec)";
50        yTickWidth = 10;
51     }
52  
53     public DistPlot(Container parent, int width, int height) {
54        super(parent, width, height);
55        title = "Dist (km)";
56        xLabel = "p (sec/km or km-sec/km)";
57        yLabel = "distance (km)";
58        yTickWidth = 10;
59     }
60  
61     public void plot(TauModel tModel, boolean isPWave) {
62  
63  		int waveNum;
64        if (! isPWave) {
65  			waveNum = 1;
66           minX = 0.0;
67           zoomMinX = minX;
68           maxX = 2000.0;
69           zoomMaxX = maxX;
70           minY = 0.0;
71           zoomMinY = minY;
72           maxY = 270.0;
73           zoomMaxY = maxY;
74        } else {
75  			waveNum = 0;
76           minX = 0.0;
77           zoomMinX = minX;
78           maxX = 1300.0;
79           zoomMaxX = maxX;
80           minY = 0.0;
81           zoomMinY = minY;
82           maxY = 200.0;
83           zoomMaxY = maxY;
84        }
85  
86        int jj=0;
87        double x, y;
88        double[] tempXData, tempYData;
89        xSegments = new Vector();
90        ySegments = new Vector();
91  
92        for (int i=0;i<tModel.tauBranches[waveNum].length;i++) {
93           jj=0;
94           tempXData = new double[tModel.rayParams.length];
95           tempYData = new double[tModel.rayParams.length];
96           for (int j=0;j<tModel.rayParams.length;j++) {
97              x=tModel.rayParams[j];
98              y=0;
99              for (int k=0;k<=i;k++) {
100                y += 2*tModel.tauBranches[waveNum][k].getDist(j);
101             }
102             y*=180/Math.PI;
103             if ((y!=0 || x==0 ) && tModel.tauBranches[waveNum][i].getDist(j) != 0.0) {
104                tempXData[jj]=x;
105                tempYData[jj]=y;
106                if (DEBUG) System.out.println(x+" "+y);
107                jj++;
108             }
109          }
110          if (DEBUG) System.out.println("> ");
111          xData= new double[jj];
112          System.arraycopy(tempXData, 0, xData, 0, jj);
113          yData= new double[jj];
114          System.arraycopy(tempYData, 0, yData, 0, jj);
115          xSegments.addElement(xData);
116          ySegments.addElement(yData);
117          xData=null;
118          yData=null;
119       }
120       
121       repaint();
122    }
123  
124    public void paint(Graphics g) {
125       super.paint(g);
126    }
127 }