| 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 |
package dr.geo; |
| 27 |
|
| 28 |
import java.awt.*; |
| 29 |
import java.awt.geom.AffineTransform; |
| 30 |
import java.awt.geom.Ellipse2D; |
| 31 |
import java.awt.geom.Point2D; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class SpaceTime { |
| 38 |
|
| 39 |
double[] space; |
| 40 |
double time; |
| 41 |
|
| 42 |
public SpaceTime(SpaceTime s) { |
| 43 |
|
| 44 |
this.space = new double[s.space.length]; |
| 45 |
System.arraycopy(s.space, 0, this.space, 0, s.space.length); |
| 46 |
this.time = s.time; |
| 47 |
} |
| 48 |
|
| 49 |
public SpaceTime(double time, Point2D space) { |
| 50 |
this.time = time; |
| 51 |
this.space = new double[]{space.getX(), space.getY()}; |
| 52 |
} |
| 53 |
|
| 54 |
public SpaceTime(double time, double[] space) { |
| 55 |
this.time = time; |
| 56 |
this.space = space; |
| 57 |
} |
| 58 |
|
| 59 |
public double[] getX() { |
| 60 |
return space; |
| 61 |
} |
| 62 |
|
| 63 |
public double getX(int index) { |
| 64 |
return space[index]; |
| 65 |
} |
| 66 |
|
| 67 |
public double getTime() { |
| 68 |
return time; |
| 69 |
} |
| 70 |
|
| 71 |
public String toString() { |
| 72 |
StringBuilder builder = new StringBuilder(); |
| 73 |
builder.append(time); |
| 74 |
for (double s : space) { |
| 75 |
builder.append("\t").append(s); |
| 76 |
} |
| 77 |
return builder.toString(); |
| 78 |
} |
| 79 |
|
| 80 |
public static void paintDot(SpaceTime s, double radius, AffineTransform transform, Graphics2D g2d) { |
| 81 |
|
| 82 |
Point2D pointRaw = new Point2D.Double(s.getX(0), s.getX(1)); |
| 83 |
Point2D pointT = new Point2D.Double(); |
| 84 |
|
| 85 |
transform.transform(pointRaw, pointT); |
| 86 |
|
| 87 |
Shape pointShape = new Ellipse2D.Double(pointT.getX() - radius, pointT.getY() - radius, 2.0 * radius, 2.0 * radius); |
| 88 |
|
| 89 |
g2d.fill(pointShape); |
| 90 |
} |
| 91 |
|
| 92 |
} |