Search in sources :

Example 21 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class AttributeTable method updateGridColor.

private void updateGridColor() {
    final NodeView nodeView = attributeView.getNodeView();
    if (!SwingUtilities.isDescendingFrom(this, nodeView))
        return;
    final MapView mapView = nodeView.getMap();
    final MapStyleModel model = MapStyleModel.getExtension(mapView.getModel());
    final NodeModel attributeStyleNode = model.getStyleNodeSafe(MapStyleModel.ATTRIBUTE_STYLE);
    final EdgeModel edge = EdgeModel.getModel(attributeStyleNode);
    if (edge != null) {
        final Color edgeColor = edge.getColor();
        setGridAndBorderColor(edgeColor);
    } else
        this.gridColor = null;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapView(org.freeplane.view.swing.map.MapView) NodeView(org.freeplane.view.swing.map.NodeView) EdgeModel(org.freeplane.features.edge.EdgeModel)

Example 22 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class MapProxy method setBackgroundColor.

// Map: R/W
public void setBackgroundColor(Color color) {
    final MapStyle mapStyle = (MapStyle) Controller.getCurrentModeController().getExtension(MapStyle.class);
    final MapStyleModel model = (MapStyleModel) mapStyle.getMapHook(getDelegate());
    mapStyle.setBackgroundColor(model, color);
}
Also used : MapStyleModel(org.freeplane.features.styles.MapStyleModel) MapStyle(org.freeplane.features.styles.MapStyle)

Example 23 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class LinkController method formatNodeAsHyperlink.

public boolean formatNodeAsHyperlink(final NodeModel node) {
    String text = node.getText();
    if (text.isEmpty() || HtmlUtils.isHtmlNode(text))
        return false;
    final Boolean ownFlag = ownFormatNodeAsHyperlink(node);
    if (ownFlag != null)
        return ownFlag;
    Collection<IStyle> collection = LogicalStyleController.getController(modeController).getStyles(node);
    final MapStyleModel mapStyles = MapStyleModel.getExtension(node.getMap());
    for (IStyle styleKey : collection) {
        final NodeModel styleNode = mapStyles.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final Boolean styleFlag = ownFormatNodeAsHyperlink(styleNode);
        if (styleFlag != null)
            return styleFlag;
    }
    return false;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 24 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class NoteController method getNoteCSSStyle.

protected String getNoteCSSStyle(ModeController modeController, NodeModel node, float zoom, boolean asHtmlFragment) {
    final StringBuilder rule = new StringBuilder();
    // set default font for notes:
    final NodeStyleController style = (NodeStyleController) Controller.getCurrentModeController().getExtension(NodeStyleController.class);
    MapModel map = modeController.getController().getMap();
    if (map != null) {
        final MapStyleModel model = MapStyleModel.getExtension(map);
        final NodeModel noteStyleNode = model.getStyleNodeSafe(MapStyleModel.NOTE_STYLE);
        final Font noteFont = style.getFont(noteStyleNode);
        Color noteBackground = style.getBackgroundColor(noteStyleNode);
        Color noteForeground = style.getColor(noteStyleNode);
        final int alignment = style.getHorizontalTextAlignment(noteStyleNode).swingConstant;
        final CssRuleBuilder cssRuleBuilder = new CssRuleBuilder();
        if (asHtmlFragment)
            cssRuleBuilder.withHTMLFont(noteFont);
        else
            cssRuleBuilder.withCSSFont(noteFont);
        cssRuleBuilder.withColor(noteForeground).withBackground(noteBackground).withAlignment(alignment);
        if (asHtmlFragment)
            cssRuleBuilder.withMaxWidthAsPt(zoom, NodeSizeModel.getMaxNodeWidth(noteStyleNode), style.getMaxWidth(node));
        rule.append(cssRuleBuilder);
    }
    return rule.toString();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CssRuleBuilder(org.freeplane.core.ui.components.html.CssRuleBuilder) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color) MapModel(org.freeplane.features.map.MapModel) Font(java.awt.Font)

Example 25 with MapStyleModel

use of org.freeplane.features.styles.MapStyleModel in project freeplane by freeplane.

the class AManageConditionalStylesAction method createConditionalStylePane.

protected Component createConditionalStylePane(final MapModel map, final ConditionalStyleModel conditionalStyleModel) {
    final JPanel pane = new JPanel(new BorderLayout());
    final MapStyleModel styles = MapStyleModel.getExtension(map);
    final TableModel tableModel = MLogicalStyleController.getController().getConditionalStyleModelAsTableModel(map, conditionalStyleModel);
    final ConditionalStyleTable conditionalStyleTable = new ConditionalStyleTable(styles, tableModel);
    if (conditionalStyleTable.getRowCount() > 0) {
        conditionalStyleTable.setRowSelectionInterval(0, 0);
    }
    JScrollPane scrollPane = new JScrollPane(conditionalStyleTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    final int tablePreferredWidth = scrollPane.getViewport().getViewSize().width;
    scrollPane.setPreferredSize(new Dimension(tablePreferredWidth, 400));
    pane.add(scrollPane, BorderLayout.CENTER);
    final Box buttons = Box.createVerticalBox();
    JButton create = new JButton();
    LabelAndMnemonicSetter.setLabelAndMnemonic(create, TextUtils.getRawText("new"));
    create.setMaximumSize(UITools.MAX_BUTTON_DIMENSION);
    create.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int row = conditionalStyleTable.getRowCount();
            final ConditionalStyleModel conditionalStyleModel = getConditionalStyleModel();
            ((MLogicalStyleController) LogicalStyleController.getController()).addConditionalStyle(map, conditionalStyleModel, true, null, MapStyleModel.DEFAULT_STYLE, false);
            conditionalStyleTable.setRowSelectionInterval(row, row);
        }
    });
    JButton edit = new JButton();
    LabelAndMnemonicSetter.setLabelAndMnemonic(edit, TextUtils.getRawText("edit"));
    edit.setMaximumSize(UITools.MAX_BUTTON_DIMENSION);
    edit.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int selectedRow = conditionalStyleTable.getSelectedRow();
            if (selectedRow == -1) {
                return;
            }
            final FilterComposerDialog filterComposerDialog = new FilterComposerDialog();
            filterComposerDialog.addCondition(null);
            filterComposerDialog.setConditionRenderer(ConditionalStyleTable.createConditionRenderer());
            for (int i = 0; i < conditionalStyleTable.getRowCount(); i++) {
                final ASelectableCondition condition = (ASelectableCondition) conditionalStyleTable.getValueAt(i, 1);
                filterComposerDialog.addCondition(condition);
            }
            final ASelectableCondition value = (ASelectableCondition) conditionalStyleTable.getValueAt(selectedRow, 1);
            final ASelectableCondition newCondition = filterComposerDialog.editCondition(value);
            conditionalStyleTable.setValueAt(newCondition, selectedRow, 1);
        }
    });
    JButton delete = new JButton();
    LabelAndMnemonicSetter.setLabelAndMnemonic(delete, TextUtils.getRawText("delete"));
    delete.setMaximumSize(UITools.MAX_BUTTON_DIMENSION);
    delete.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int selectedRow = conditionalStyleTable.getSelectedRow();
            if (selectedRow == -1) {
                return;
            }
            final ConditionalStyleModel conditionalStyleModel = getConditionalStyleModel();
            ((MLogicalStyleController) LogicalStyleController.getController()).removeConditionalStyle(map, conditionalStyleModel, selectedRow);
            if (conditionalStyleTable.getRowCount() == selectedRow) {
                selectedRow--;
            }
            if (selectedRow == -1) {
                return;
            }
            conditionalStyleTable.setRowSelectionInterval(selectedRow, selectedRow);
        }
    });
    JButton up = new JButton();
    LabelAndMnemonicSetter.setLabelAndMnemonic(up, TextUtils.getRawText("up"));
    up.setMaximumSize(UITools.MAX_BUTTON_DIMENSION);
    up.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int selectedRow = conditionalStyleTable.getSelectedRow();
            if (selectedRow <= 0) {
                return;
            }
            final ConditionalStyleModel conditionalStyleModel = getConditionalStyleModel();
            ((MLogicalStyleController) LogicalStyleController.getController()).moveConditionalStyleUp(map, conditionalStyleModel, selectedRow);
            selectedRow--;
            conditionalStyleTable.setRowSelectionInterval(selectedRow, selectedRow);
        }
    });
    JButton down = new JButton();
    LabelAndMnemonicSetter.setLabelAndMnemonic(down, TextUtils.getRawText("down"));
    down.setMaximumSize(UITools.MAX_BUTTON_DIMENSION);
    down.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int selectedRow = conditionalStyleTable.getSelectedRow();
            if (selectedRow == -1 || selectedRow == conditionalStyleTable.getRowCount() - 1) {
                return;
            }
            final ConditionalStyleModel conditionalStyleModel = getConditionalStyleModel();
            ((MLogicalStyleController) LogicalStyleController.getController()).moveConditionalStyleDown(map, conditionalStyleModel, selectedRow);
            selectedRow++;
            conditionalStyleTable.setRowSelectionInterval(selectedRow, selectedRow);
        }
    });
    buttons.add(Box.createVerticalStrut(BUTTON_GAP));
    buttons.add(create);
    buttons.add(Box.createVerticalStrut(BUTTON_GAP));
    buttons.add(edit);
    buttons.add(Box.createVerticalStrut(BUTTON_GAP));
    buttons.add(delete);
    buttons.add(Box.createVerticalStrut(BUTTON_GAP));
    buttons.add(up);
    buttons.add(Box.createVerticalStrut(BUTTON_GAP));
    buttons.add(down);
    buttons.add(Box.createVerticalGlue());
    pane.add(buttons, BorderLayout.EAST);
    UITools.focusOn(conditionalStyleTable);
    return pane;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) ActionEvent(java.awt.event.ActionEvent) FilterComposerDialog(org.freeplane.features.filter.FilterComposerDialog) JButton(javax.swing.JButton) ConditionalStyleModel(org.freeplane.features.styles.ConditionalStyleModel) Box(javax.swing.Box) Dimension(java.awt.Dimension) ASelectableCondition(org.freeplane.features.filter.condition.ASelectableCondition) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) TableModel(javax.swing.table.TableModel)

Aggregations

MapStyleModel (org.freeplane.features.styles.MapStyleModel)48 NodeModel (org.freeplane.features.map.NodeModel)39 IStyle (org.freeplane.features.styles.IStyle)30 Color (java.awt.Color)10 MapModel (org.freeplane.features.map.MapModel)10 Controller (org.freeplane.features.mode.Controller)6 LengthUnits (org.freeplane.core.ui.LengthUnits)5 IActor (org.freeplane.core.undo.IActor)5 MMapController (org.freeplane.features.map.mindmapmode.MMapController)5 StyleTranslatedObject (org.freeplane.features.styles.StyleTranslatedObject)4 ModeController (org.freeplane.features.mode.ModeController)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)3 MapStyle (org.freeplane.features.styles.MapStyle)3 Font (java.awt.Font)2 ArrayList (java.util.ArrayList)2 DashVariant (org.freeplane.features.DashVariant)2 ConditionalStyleModel (org.freeplane.features.styles.ConditionalStyleModel)2 MapView (org.freeplane.view.swing.map.MapView)2 NodeView (org.freeplane.view.swing.map.NodeView)2