Debian Codegraph @

src/dr/app/beauti/treespanel/TreeDisplayPanel.java

raw symbols SCIP
1 /*
2 * TreeDisplayPanel.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.beauti.treespanel;
27
28 import dr.app.beauti.BeautiFrame;
29 import dr.app.pathogen.TemporalRooting;
30 import dr.evolution.tree.Tree;
31 import dr.app.gui.tree.JTreeDisplay;
32 import dr.app.gui.tree.SquareTreePainter;
33
34 import javax.swing.*;
35 import java.awt.*;
36
37 /**
38 * @author Andrew Rambaut
39 * @author Alexei Drummond
40 * @version $Id: PriorsPanel.java,v 1.9 2006/09/05 13:29:34 rambaut Exp $
41 */
42 public class TreeDisplayPanel extends JPanel {
43
44 private Tree tree = null;
45
46 BeautiFrame frame = null;
47 JTabbedPane tabbedPane = new JTabbedPane();
48
49 JTreeDisplay treePanel;
50 JTreeDisplay scaledTreePanel;
51 // JChartPanel rootToTipPanel;
52 // JChart rootToTipChart;
53
54 public TreeDisplayPanel(BeautiFrame parent) {
55 super(new BorderLayout());
56
57 this.frame = parent;
58
59 treePanel = new JTreeDisplay(new SquareTreePainter());
60
61 tabbedPane.add("Starting Tree", treePanel);
62
63 // AR - have removed root-to-tip chart for now.
64 // rootToTipChart = new JChart(new LinearAxis(), new LinearAxis(Axis.AT_ZERO, Axis.AT_MINOR_TICK));
65 // rootToTipPanel = new JChartPanel(rootToTipChart, "", "time", "divergence");
66 // rootToTipPanel.setOpaque(false);
67 //
68 // tabbedPane.add("Root-to-tip", rootToTipPanel);
69
70 scaledTreePanel = new JTreeDisplay(new SquareTreePainter());
71 tabbedPane.add("Re-scaled tree", scaledTreePanel);
72
73 setOpaque(false);
74
75 add(tabbedPane, BorderLayout.CENTER);
76 }
77
78 public void setTree(Tree tree) {
79 this.tree = tree;
80 setupPanel();
81 }
82
83 private void setupPanel() {
84 if (tree != null) {
85 treePanel.setTree(tree);
86 TemporalRooting temporalRooting = new TemporalRooting(tree);
87
88 // Regression r = temporalRooting.getRootToTipRegression(tree);
89 //
90 // rootToTipChart.removeAllPlots();
91 // rootToTipChart.addPlot(new ScatterPlot(r.getXData(), r.getYData()));
92 // rootToTipChart.addPlot(new RegressionPlot(r));
93 // rootToTipChart.getXAxis().addRange(r.getXIntercept(), r.getXData().getMax());
94
95 scaledTreePanel.setTree(temporalRooting.adjustTreeToConstraints(tree, null));
96 } else {
97 treePanel.setTree(null);
98 // rootToTipChart.removeAllPlots();
99 scaledTreePanel.setTree(null);
100 }
101
102 repaint();
103 }
104 }