Debian Codegraph @

src/dr/geo/SpaceTime.java

raw symbols SCIP
1 /*
2 * SpaceTime.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
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 * @author Alexei Drummond
35 * @author Marc Suchard
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 }