1
package figtree.application;
3
import figtree.treeviewer.decorators.AttributableDecorator;
4
import jam.controlpalettes.ControlPalette;
5
import jam.disclosure.SlideOpenPanel;
6
import figtree.treeviewer.*;
7
import figtree.treeviewer.painters.*;
13
* This is a panel that has a TreeViewer and a BasicControlPalette with
14
* the default Controllers and Painters.
16
* @author Andrew Rambaut
17
* @version $Id: FigTreePanel.java,v 1.13 2007/09/05 10:51:49 rambaut Exp $
19
public class FigTreePanel extends JPanel {
21
public FigTreePanel(JFrame frame, final ExtendedTreeViewer treeViewer, ControlPalette controlPalette) {
23
this.treeViewer = treeViewer;
24
this.controlPalette = controlPalette;
26
controlPalette.getPanel().setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.GRAY));
27
controlPalette.getPanel().setBackground(new Color(231, 237, 246));
28
controlPalette.getPanel().setOpaque(true);
30
treeViewerController = new TreeViewerController(treeViewer);
31
controlPalette.addController(treeViewerController);
33
controlPalette.addController(new MultipleTreesController(treeViewer));
35
controlPalette.addController(new TreeAppearanceController(treeViewer, frame));
37
treesController = new TreesController(treeViewer);
38
controlPalette.addController(treesController);
40
controlPalette.addController(new TimeScaleController(treeViewer));
42
// Create a tip label painter and its controller
43
final BasicLabelPainter tipLabelPainter = new BasicLabelPainter(BasicLabelPainter.PainterIntent.TIP);
44
controlPalette.addController(new LabelPainterController("Tip Labels", "tipLabels", tipLabelPainter, frame));
45
treeViewer.setTipLabelPainter(tipLabelPainter);
47
// Create a node label painter and its controller
48
final BasicLabelPainter nodeLabelPainter = new BasicLabelPainter(BasicLabelPainter.PainterIntent.NODE);
49
nodeLabelPainter.setVisible(false);
50
controlPalette.addController(new LabelPainterController("Node Labels", "nodeLabels", nodeLabelPainter, frame));
51
treeViewer.setNodeLabelPainter(nodeLabelPainter);
53
// Create a node shape painter and its controller
54
final NodeBarPainter nodeBarPainter = new NodeBarPainter();
55
nodeBarPainter.setForeground(new Color(24, 32, 228, 128));
56
nodeBarPainter.setVisible(false);
57
controlPalette.addController(new NodeBarController("Node Bars", nodeBarPainter));
58
treeViewer.setNodeBarPainter(nodeBarPainter);
60
// Create a branch label painter and its controller
61
final BasicLabelPainter branchLabelPainter = new BasicLabelPainter(BasicLabelPainter.PainterIntent.BRANCH);
62
branchLabelPainter.setVisible(false);
63
controlPalette.addController(new LabelPainterController("Branch Labels", "branchLabels", branchLabelPainter, frame));
64
treeViewer.setBranchLabelPainter(branchLabelPainter);
66
// Create a scale controller
67
final ScaleBarPainter scaleBarPainter = new ScaleBarPainter();
68
scaleBarPainter.setVisible(true);
69
controlPalette.addController(new ScaleBarPainterController(scaleBarPainter));
70
treeViewer.addScalePainter(scaleBarPainter);
72
// Create a scale axis controller
73
final ScaleAxisPainter scaleAxisPainter = new ScaleAxisPainter();
74
final ScaleGridPainter scaleGridPainter = new ScaleGridPainter();
75
scaleAxisPainter.setVisible(false);
76
scaleGridPainter.setVisible(false);
77
controlPalette.addController(new ScaleAxisPainterController(scaleAxisPainter, scaleGridPainter));
78
treeViewer.addScalePainter(scaleAxisPainter);
79
treeViewer.setScaleGridPainter(scaleGridPainter);
81
slideOpenPanel = new SlideOpenPanel(treeViewer);
83
setLayout(new BorderLayout());
84
add(slideOpenPanel, BorderLayout.CENTER);
85
add(controlPalette.getPanel(), BorderLayout.WEST);
87
treeViewer.addAnnotationsListener(new AnnotationsListener() {
88
public void annotationsChanged() {
90
tipLabelPainter.setupAttributes(treeViewer.getTrees());
91
nodeLabelPainter.setupAttributes(treeViewer.getTrees());
92
nodeBarPainter.setupAttributes(treeViewer.getTrees());
93
branchLabelPainter.setupAttributes(treeViewer.getTrees());
98
public TreeViewer getTreeViewer() {
102
public ControlPalette getControlPalette() {
103
return controlPalette;
106
public void showUtilityPanel(JPanel utilityPanel) {
107
if (utilityPanel == null) {
110
slideOpenPanel.showUtilityPanel(utilityPanel);
113
public void hideUtilityPanel() {
114
slideOpenPanel.hideUtilityPanel();
118
public JPanel getUtilityPanel() {
119
return slideOpenPanel.getUtilityPanel();
122
public void toggleMidpointRoot() {
123
treesController.toggleMidpointRoot();
126
public void toggleIncreasingNodeOrder() {
127
treesController.toggleIncreasingNodeOrder();
130
public void toggleDecreasingNodeOrder() {
131
treesController.toggleDecreasingNodeOrder();
134
private final TreeViewer treeViewer;
135
private final TreeViewerController treeViewerController;
136
private final TreesController treesController;
137
private final ControlPalette controlPalette;
138
private final SlideOpenPanel slideOpenPanel;