| 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.app.pathogen; |
| 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 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
public class ParentPlot extends Plot.AbstractPlot { |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|