1 package edu.sc.seis.TauP;
2 import java.awt.Color;
3 import java.awt.Graphics;
4
5
6
7
8 /***
9 * CurvePlot.java
10 *
11 *
12 * Created: Thu Jun 22 13:19:37 2000
13 *
14 * @author Philip Crotwell
15 * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
16
17
18
19 */
20
21 public class CurvePlot extends ArrivalPlot {
22
23 public CurvePlot() {
24 super();
25 setOpaque(true);
26 }
27
28 public void paintBackground(Graphics g) {
29
30 }
31
32
33 public void paintArrivals(Graphics g) {
34 for (int i=0;i<arrivals.size(); i++) {
35 paintCurve(g, i);
36 }
37 }
38
39 public void paintForeground(Graphics g) {
40 Color orig = g.getColor();
41 g.setColor(Color.red);
42 paintCurve(g, selectedIndex);
43 g.setColor(orig);
44 }
45
46
47 protected void paintCurve(Graphics g, int i) {
48 Arrival a;
49 int[] x, y;
50 int xOffset = getSize().width/2;
51 int yOffset = getSize().height/2;
52 int pixelRad = Math.min(xOffset,
53 yOffset);
54 double roe = 6371;
55
56
57 a = (Arrival)arrivals.elementAt(i);
58 x = new int[a.getNumPathPoints()];
59 y = new int[a.getNumPathPoints()];
60 for (int j = 0; j < x.length; j++) {
61 x[j] = xOffset +(int)Math.rint(Math.sin(a.getPathPoint(j).dist)
62 * ( roe-a.getPathPoint(j).depth) /
63 roe * pixelRad);
64 y[j] = yOffset -(int)Math.rint(Math.cos(a.getPathPoint(j).dist)
65 * ( roe-a.getPathPoint(j).depth) /
66 roe * pixelRad);
67 }
68
69 g.drawPolyline(x, y, x.length);
70 }
71
72 }