public TreeAppearanceController(final TreeViewer treeViewer) {
        this.treeViewer = treeViewer;

        final AttributableDecorator branchDecorator = new AttributableDecorator();
        branchDecorator.setPaintAttributeName("!color");
        branchDecorator.setStrokeAttributeName("!stroke");
        treeViewer.setBranchDecorator(branchDecorator);

        int foregroundRGB = TreeAppearanceController.PREFS.getInt(CONTROLLER_KEY + "." + FOREGROUND_COLOUR_KEY, DEFAULT_FOREGROUND_COLOUR.getRGB());
        int backgroundRGB = TreeAppearanceController.PREFS.getInt(CONTROLLER_KEY + "." + BACKGROUND_COLOUR_KEY, DEFAULT_BACKGROUND_COLOUR.getRGB());
        int selectionRGB = TreeAppearanceController.PREFS.getInt(CONTROLLER_KEY + "." + SELECTION_COLOUR_KEY, DEFAULT_SELECTION_COLOUR.getRGB());
        float branchLineWidth = TreeAppearanceController.PREFS.getFloat(CONTROLLER_KEY + "." + BRANCH_LINE_WIDTH_KEY, DEFAULT_BRANCH_LINE_WIDTH);

        treeViewer.setForeground(new Color(foregroundRGB));
        treeViewer.setBackground(new Color(backgroundRGB));
        treeViewer.setSelectionPaint(new Color(selectionRGB));
        treeViewer.setBranchStroke(new BasicStroke(branchLineWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

        titleLabel = new JLabel(CONTROLLER_TITLE);

        optionsPanel = new OptionsPanel();

        branchLineWidthSpinner = new JSpinner(new SpinnerNumberModel(1.0, 0.01, 48.0, 1.0));

        branchLineWidthSpinner.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent changeEvent) {
                float lineWidth = ((Double) branchLineWidthSpinner.getValue()).floatValue();
                treeViewer.setBranchStroke(new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
            }
        });
        optionsPanel.addComponentWithLabel("Line Weight:", branchLineWidthSpinner);

        branchColorAttributeCombo = new JComboBox(new String[] { "No attributes" });
        setupAttributes(treeViewer.getTrees());
        branchColorAttributeCombo.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent itemEvent) {
                if (branchColorAttributeCombo.getSelectedIndex() == 0) {
                    treeViewer.setBranchColouringDecorator(null, null);
                    treeViewer.setBranchDecorator(branchDecorator);
                } else {
                    Set<Node> nodes = new HashSet<Node>();
                    for (Tree tree : treeViewer.getTrees()) {
                        for (Node node : tree.getNodes()) {
                            nodes.add(node);
                        }
                    }
                    String attribute = (String)branchColorAttributeCombo.getSelectedItem();
                    if (attribute != null && attribute.length() > 0) {
                        if (attribute.endsWith("*")) {
                            Decorator decorator = new DiscreteColorDecorator();

                            treeViewer.setBranchColouringDecorator(attribute.substring(0, attribute.length() - 2), decorator);
                            treeViewer.setBranchDecorator(null);
                        } else if (DiscreteColorDecorator.isDiscrete(attribute, nodes)) {
	                        Decorator decorator = new DiscreteColorDecorator(attribute, nodes);

	                        treeViewer.setBranchColouringDecorator(null, null);
	                        treeViewer.setBranchDecorator(decorator);
                        } else {

                            Decorator decorator = new ContinuousColorDecorator(
                                    attribute, nodes,
                                    new Color(192, 16, 0), new Color(0, 16, 192));

                            treeViewer.setBranchColouringDecorator(null, null);
                            treeViewer.setBranchDecorator(decorator);
                        }
                    }
                }
            }
        });

        optionsPanel.addComponentWithLabel("Color by:", branchColorAttributeCombo);

        treeViewer.addTreeViewerListener(new TreeViewerListener() {
            public void treeChanged() {
                setupAttributes(treeViewer.getTrees());
                optionsPanel.repaint();
            }

            public void treeSettingsChanged() {
                // nothing to do
            }
        });
    }