~ubuntu-branches/ubuntu/utopic/figtree/utopic

« back to all changes in this revision

Viewing changes to src/figtree/panel/TreeLayoutController.java

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-02-21 08:17:38 UTC
  • Revision ID: james.westby@ubuntu.com-20110221081738-80pe2ulo8rg7up10
Tags: upstream-1.3.1
ImportĀ upstreamĀ versionĀ 1.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package figtree.panel;
 
2
 
 
3
import jam.controlpalettes.AbstractController;
 
4
import jam.panels.OptionsPanel;
 
5
 
 
6
import javax.swing.*;
 
7
import javax.swing.event.ChangeEvent;
 
8
import javax.swing.event.ChangeListener;
 
9
import java.util.Map;
 
10
 
 
11
import figtree.treeviewer.treelayouts.RectilinearTreeLayout;
 
12
 
 
13
/**
 
14
 * @author Andrew Rambaut
 
15
 * @version $Id: TreeLayoutController.java,v 1.1 2007/08/14 15:50:42 rambaut Exp $
 
16
 */
 
17
public class TreeLayoutController extends AbstractController {
 
18
 
 
19
    private static final String RECTILINEAR_LAYOUT_KEY = "rectilinearLayout";
 
20
    private static final String ALIGN_TIP_LABELS_KEY = "alignTipLabels";
 
21
 
 
22
    public TreeLayoutController(final RectilinearTreeLayout treeLayout) {
 
23
        titleLabel = new JLabel("Rectangular Layout");
 
24
        optionsPanel = new OptionsPanel();
 
25
 
 
26
        alignTipLabelsCheck = new JCheckBox("Align Tip Labels");
 
27
        alignTipLabelsCheck.setOpaque(false);
 
28
 
 
29
        alignTipLabelsCheck.setSelected(treeLayout.isAlignTipLabels());
 
30
        alignTipLabelsCheck.addChangeListener(new ChangeListener() {
 
31
            public void stateChanged(ChangeEvent changeEvent) {
 
32
                treeLayout.setAlignTipLabels(alignTipLabelsCheck.isSelected());
 
33
            }
 
34
        });
 
35
        optionsPanel.addComponent(alignTipLabelsCheck);
 
36
    }
 
37
 
 
38
    public JComponent getTitleComponent() {
 
39
        return titleLabel;
 
40
    }
 
41
 
 
42
    public JPanel getPanel() {
 
43
        return optionsPanel;
 
44
    }
 
45
 
 
46
    public boolean isInitiallyVisible() {
 
47
        return false;
 
48
    }
 
49
 
 
50
    public void initialize() {
 
51
        // nothing to do
 
52
    }
 
53
 
 
54
    public void setSettings(Map<String,Object> settings) {
 
55
        alignTipLabelsCheck.setSelected((Boolean) settings.get(RECTILINEAR_LAYOUT_KEY + "." + ALIGN_TIP_LABELS_KEY));
 
56
    }
 
57
 
 
58
    public void getSettings(Map<String, Object> settings) {
 
59
        settings.put(RECTILINEAR_LAYOUT_KEY + "." + ALIGN_TIP_LABELS_KEY, alignTipLabelsCheck.isSelected());
 
60
    }
 
61
 
 
62
    private final JLabel titleLabel;
 
63
    private final OptionsPanel optionsPanel;
 
64
 
 
65
    private final JCheckBox alignTipLabelsCheck;
 
66
 
 
67
}
 
 
b'\\ No newline at end of file'