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  package edu.sc.seis.TauP;
29  
30  import java.awt.Container;
31  import java.awt.Graphics;
32  import java.util.Vector;
33  
34  /***
35    * time versus ray parameter plot.
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 TimePlot extends XYPlot {
44  
45     public TimePlot(Container parent) {
46        super(parent);
47        title = "Time";
48        xLabel = "p (sec/km or km-sec/km)";
49        yLabel = "time (sec)";
50     }
51  
52     public TimePlot(Container parent, int width, int height) {
53        super(parent, width, height);
54        title = "Time";
55        xLabel = "p (sec/km or km-sec/km)";
56        yLabel = "depth (sec)";
57     }
58  
59     public void plot(TauModel tModel, boolean isPWave) {
60  
61  		int waveNum;
62        if (! isPWave) {
63  			waveNum = 1;
64           minX = 0.0;
65           zoomMinX = minX;
66           maxX = 2500.0;
67           zoomMaxX = maxX;
68           minY = 0.0;
69           zoomMinY = minY;
70           maxY = 2500.0;
71           zoomMaxY = maxY;
72        } else {
73  			waveNum = 0;
74           minX = 0.0;
75           zoomMinX = minX;
76           maxX = 1300.0;
77           zoomMaxX = maxX;
78           minY = 0.0;
79           zoomMinY = minY;
80           maxY = 1300.0;
81           zoomMaxY = maxY;
82        }
83  
84        int jj=0;
85        double x, y;
86        double[] tempXData, tempYData;
87        xSegments = new Vector();
88        ySegments = new Vector();
89  
90        for (int i=0;i<tModel.tauBranches[waveNum].length;i++) {
91           jj=0;
92           tempXData = new double[tModel.rayParams.length];
93           tempYData = new double[tModel.rayParams.length];
94           for (int j=0;j<tModel.rayParams.length;j++) {
95              x=tModel.rayParams[j];
96              y=0;
97              for (int k=0;k<=i;k++) {
98                 y += 2*tModel.tauBranches[waveNum][k].time[j];
99              }
100             if ((y!=0 || x==0 ) && tModel.tauBranches[waveNum][i].time[j] != 0.0) {
101                tempXData[jj]=x;
102                tempYData[jj]=y;
103                if (DEBUG) System.out.println(x+" "+y);
104                jj++;
105             }
106          }
107          if (DEBUG) System.out.println("> ");
108          xData= new double[jj];
109          System.arraycopy(tempXData, 0, xData, 0, jj);
110          yData= new double[jj];
111          System.arraycopy(tempYData, 0, yData, 0, jj);
112          xSegments.addElement(xData);
113          ySegments.addElement(yData);
114          xData=null;
115          yData=null;
116       }
117       repaint();
118    }
119  
120    public void paint(Graphics g) {
121       super.paint(g);
122    }
123 }