Debian Codegraph @

src/dr/app/tempest/ParentPlot.java

raw symbols SCIP
1 /*
2 * ParentPlot.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.app.tempest;
27
28 import dr.app.gui.chart.Plot;
29 import dr.stats.Variate;
30
31 import java.awt.*;
32 import java.awt.geom.GeneralPath;
33 import java.util.ArrayList;
34 import java.util.List;
35 import java.util.Set;
36
37 /**
38 * Description: A line plot.
39 *
40 * @author Andrew Rambaut
41 * @version $Id$
42 */
43
44 public class ParentPlot extends Plot.AbstractPlot {
45
46
47 /**
48 * Constructor
49 */
50 public ParentPlot(Variate xData, Variate yData, List<Double> xParentData, List<Double> yParentData) {
51 super(xParentData, yParentData);
52
53 this.xTipData = xData;
54 this.yTipData = yData;
55
56 this.xParentData = new Variate.D(xParentData);
57 this.yParentData = new Variate.D(yParentData);
58 }
59
60 /**
61 * Paint data series
62 */
63 protected void paintData(Graphics2D g2, Variate.N xData, Variate.N yData) {
64
65 g2.setPaint(linePaint);
66 g2.setStroke(lineStroke);
67
68 if (getSelectedPoints() != null && getSelectedPoints().size() > 0) {
69 for (int i : getSelectedPoints()) {
70
71 double x = ((Number) xTipData.get(i)).doubleValue();
72 double y = ((Number) yTipData.get(i)).doubleValue();
73
74 double x1 = transformX(x);
75 double y1 = transformY(y);
76
77 double x2 = transformX(((Number) xData.get(0)).doubleValue());
78 double y2 = transformY(((Number) yData.get(0)).doubleValue());
79
80 GeneralPath path = new GeneralPath();
81 path.moveTo((float) x1, (float) y1);
82 // path.lineTo((float) x2, (float) y1);
83 path.lineTo((float) x2, (float) y2);
84
85 g2.draw(path);
86 }
87 } else {
88 for (int i = 0; i < xData.getCount(); i++) {
89
90 double x1 = transformX(((Number) xTipData.get(i)).doubleValue());
91 double y1 = transformY(((Number) yTipData.get(i)).doubleValue());
92
93 double x2 = transformX(((Number) xData.get(i)).doubleValue());
94 double y2 = transformY(((Number) yData.get(i)).doubleValue());
95
96 GeneralPath path = new GeneralPath();
97 path.moveTo((float) x1, (float) y1);
98 // path.lineTo((float) x2, (float) y1);
99 path.lineTo((float) x2, (float) y2);
100
101 g2.draw(path);
102 }
103 }
104
105
106 }
107
108 private final Variate xTipData;
109 private final Variate yTipData;
110
111 private final Variate.N xParentData;
112 private final Variate.N yParentData;
113
114 public void setSelectedPoints(Set<Integer> selectedPoints, double mrcaTime, double mrcaDistance) {
115 List<Double> x = new ArrayList<Double>();
116 x.add(mrcaTime);
117 List<Double> y = new ArrayList<Double>();
118 y.add(mrcaDistance);
119 setData(x, y);
120 setSelectedPoints(selectedPoints);
121 }
122
123 public void clearSelection() {
124 setData(xParentData, yParentData);
125 super.clearSelection();
126 }
127
128 }
129