Search in sources :

Example 1 with AutomaticEdgeColor

use of org.freeplane.features.edge.AutomaticEdgeColor in project freeplane by freeplane.

the class StyleControlGroup method setStyle.

@Override
public void setStyle(NodeModel node) {
    internalChange = true;
    try {
        final LogicalStyleController logicalStyleController = LogicalStyleController.getController();
        if (addStyleBox) {
            final boolean isStyleSet = LogicalStyleModel.getStyle(node) != null;
            mSetStyle.setValue(isStyleSet);
            setStyleList(mMapStyleButton, logicalStyleController.getMapStyleNames(node, "\n"));
        }
        setStyleList(mNodeStyleButton, logicalStyleController.getNodeStyleNames(node, "\n"));
        if (mAutomaticLayoutComboBox != null) {
            final ModeController modeController = Controller.getCurrentModeController();
            AutomaticLayoutController al = modeController.getExtension(AutomaticLayoutController.class);
            IExtension extension = al.getExtension(node);
            if (extension == null)
                mAutomaticLayoutComboBox.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
            else
                mAutomaticLayoutComboBox.setSelectedIndex(((AutomaticLayout) extension).ordinal());
        }
        if (mAutomaticEdgeColorComboBox != null) {
            final ModeController modeController = Controller.getCurrentModeController();
            AutomaticEdgeColorHook al = (AutomaticEdgeColorHook) modeController.getExtension(AutomaticEdgeColorHook.class);
            final AutomaticEdgeColor extension = (AutomaticEdgeColor) al.getExtension(node);
            if (extension == null) {
                mAutomaticEdgeColorComboBox.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
                mEditEdgeColorsBtn.setEnabled(false);
            } else {
                mAutomaticEdgeColorComboBox.setSelectedIndex(extension.rule.ordinal());
                mEditEdgeColorsBtn.setEnabled(true);
            }
        }
    } finally {
        internalChange = false;
    }
}
Also used : AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) AutomaticEdgeColorHook(org.freeplane.features.edge.AutomaticEdgeColorHook) IExtension(org.freeplane.core.extension.IExtension) AutomaticLayout(org.freeplane.features.styles.AutomaticLayout) MLogicalStyleController(org.freeplane.features.styles.mindmapmode.MLogicalStyleController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ModeController(org.freeplane.features.mode.ModeController) AutomaticEdgeColor(org.freeplane.features.edge.AutomaticEdgeColor)

Example 2 with AutomaticEdgeColor

use of org.freeplane.features.edge.AutomaticEdgeColor in project freeplane by freeplane.

the class StyleControlGroup method addEdgeColoringControls.

private void addEdgeColoringControls(final DefaultFormBuilder formBuilder) {
    TranslatedObject[] automaticLayoutTypes = TranslatedObject.fromEnum(AutomaticEdgeColor.class.getSimpleName() + ".", AutomaticEdgeColor.Rule.class);
    mAutomaticEdgeColorComboBox = new JComboBoxWithBorder(automaticLayoutTypes);
    DefaultComboBoxModel automaticEdgeColorComboBoxModel = (DefaultComboBoxModel) mAutomaticEdgeColorComboBox.getModel();
    automaticEdgeColorComboBoxModel.addElement(AUTOMATIC_LAYOUT_DISABLED);
    automaticEdgeColorComboBoxModel.setSelectedItem(AUTOMATIC_LAYOUT_DISABLED);
    mAutomaticEdgeColorComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (internalChange)
                return;
            final ModeController modeController = Controller.getCurrentModeController();
            AutomaticEdgeColorHook hook = modeController.getExtension(AutomaticEdgeColorHook.class);
            TranslatedObject selectedItem = (TranslatedObject) mAutomaticEdgeColorComboBox.getSelectedItem();
            final MapModel map = Controller.getCurrentController().getMap();
            final AutomaticEdgeColor oldExtension = (AutomaticEdgeColor) hook.getMapHook(map);
            final int colorCount = oldExtension == null ? 0 : oldExtension.getColorCounter();
            final NodeModel rootNode = map.getRootNode();
            hook.undoableDeactivateHook(rootNode);
            if (!selectedItem.equals(AUTOMATIC_LAYOUT_DISABLED)) {
                final AutomaticEdgeColor newExtension = new AutomaticEdgeColor((AutomaticEdgeColor.Rule) selectedItem.getObject(), colorCount);
                hook.undoableActivateHook(rootNode, newExtension);
            }
        }
    });
    appendLabeledComponent(formBuilder, "AutomaticEdgeColorHookAction.text", mAutomaticEdgeColorComboBox);
    mEditEdgeColorsBtn = TranslatedElementFactory.createButton("editEdgeColors");
    mEditEdgeColorsBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final MEdgeController edgeController = (MEdgeController) modeController.getExtension(EdgeController.class);
            edgeController.editEdgeColorConfiguration(Controller.getCurrentController().getMap());
        }
    });
    formBuilder.appendLineGapRow();
    formBuilder.nextLine();
    formBuilder.appendRow(FormSpecs.PREF_ROWSPEC);
    formBuilder.setColumn(1);
    formBuilder.append(mEditEdgeColorsBtn, 7);
    formBuilder.nextLine();
}
Also used : AutomaticEdgeColorHook(org.freeplane.features.edge.AutomaticEdgeColorHook) ActionEvent(java.awt.event.ActionEvent) TranslatedObject(org.freeplane.core.resources.TranslatedObject) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) AutomaticEdgeColor(org.freeplane.features.edge.AutomaticEdgeColor) NodeModel(org.freeplane.features.map.NodeModel) ActionListener(java.awt.event.ActionListener) JComboBoxWithBorder(org.freeplane.core.ui.components.JComboBoxWithBorder) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController)

Aggregations

AutomaticEdgeColor (org.freeplane.features.edge.AutomaticEdgeColor)2 AutomaticEdgeColorHook (org.freeplane.features.edge.AutomaticEdgeColorHook)2 ModeController (org.freeplane.features.mode.ModeController)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)1 IExtension (org.freeplane.core.extension.IExtension)1 TranslatedObject (org.freeplane.core.resources.TranslatedObject)1 JComboBoxWithBorder (org.freeplane.core.ui.components.JComboBoxWithBorder)1 MEdgeController (org.freeplane.features.edge.mindmapmode.MEdgeController)1 MapModel (org.freeplane.features.map.MapModel)1 NodeModel (org.freeplane.features.map.NodeModel)1 AutomaticLayout (org.freeplane.features.styles.AutomaticLayout)1 AutomaticLayoutController (org.freeplane.features.styles.AutomaticLayoutController)1 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)1 MLogicalStyleController (org.freeplane.features.styles.mindmapmode.MLogicalStyleController)1