Search in sources :

Example 1 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.

the class TextController method registerNodeTextTooltip.

private void registerNodeTextTooltip() {
    modeController.addToolTipProvider(NODE_TOOLTIP, new ITooltipProvider() {

        @Override
        public String getTooltip(final ModeController modeController, NodeModel node, Component view) {
            return getTooltip(modeController, node, (MainView) view);
        }

        private String getTooltip(final ModeController modeController, NodeModel node, MainView view) {
            if (!ShortenedTextModel.isShortened(node)) {
                return null;
            }
            final NodeStyleController style = modeController.getExtension(NodeStyleController.class);
            final Font font = style.getFont(node);
            float zoom = view.getNodeView().getMap().getZoom();
            final StringBuilder htmlBodyStyle = new StringBuilder("<body><div style=\"").append(new CssRuleBuilder().withHTMLFont(font).withColor(view.getForeground()).withBackground(view.getNodeView().getTextBackground()).withAlignment(view.getHorizontalAlignment()).withMaxWidthAsPt(zoom, style.getMaxWidth(node)));
            final Object data = node.getUserObject();
            String text;
            try {
                text = getTransformedText(data, node, data);
                if (text.equals(getShortText(text)))
                    return null;
            } catch (Exception e) {
                text = TextUtils.format("MainView.errorUpdateText", data, e.getLocalizedMessage());
                htmlBodyStyle.append("color:red;");
            }
            htmlBodyStyle.append("\">");
            if (!HtmlUtils.isHtmlNode(text)) {
                text = HtmlUtils.plainToHTML(text);
            }
            final String tooltipText = text.replaceFirst("<body>", htmlBodyStyle.toString()).replaceFirst("</body>", "</div></body>");
            return tooltipText;
        }
    });
}
Also used : MainView(org.freeplane.view.swing.map.MainView) CssRuleBuilder(org.freeplane.core.ui.components.html.CssRuleBuilder) ModeController(org.freeplane.features.mode.ModeController) Font(java.awt.Font) NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) ITooltipProvider(org.freeplane.features.map.ITooltipProvider) Component(java.awt.Component)

Example 2 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.

the class MapView method updateContentStyle.

private void updateContentStyle() {
    final NodeStyleController style = Controller.getCurrentModeController().getExtension(NodeStyleController.class);
    MapModel map = getModel();
    final MapStyleModel model = MapStyleModel.getExtension(map);
    final NodeModel detailStyleNode = model.getStyleNodeSafe(MapStyleModel.DETAILS_STYLE);
    detailFont = UITools.scale(style.getFont(detailStyleNode));
    detailBackground = style.getBackgroundColor(detailStyleNode);
    detailForeground = style.getColor(detailStyleNode);
    detailHorizontalAlignment = style.getHorizontalTextAlignment(detailStyleNode).swingConstant;
    final NodeModel noteStyleNode = model.getStyleNodeSafe(MapStyleModel.NOTE_STYLE);
    noteFont = UITools.scale(style.getFont(noteStyleNode));
    noteBackground = style.getBackgroundColor(noteStyleNode);
    noteForeground = style.getColor(noteStyleNode);
    noteHorizontalAlignment = style.getHorizontalTextAlignment(noteStyleNode).swingConstant;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MapModel(org.freeplane.features.map.MapModel)

Example 3 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.

the class NodeView method update.

public void update() {
    invalidate();
    updateShape();
    updateEdge();
    if (!isContentVisible()) {
        mainView.setVisible(false);
        return;
    }
    mainView.setVisible(true);
    mainView.updateTextColor(this);
    mainView.updateFont(this);
    mainView.updateHorizontalTextAlignment(this);
    mainView.updateBorder(this);
    MapView map = getMap();
    final ModeController modeController = map.getModeController();
    final NodeStyleController nsc = NodeStyleController.getController(modeController);
    final int minNodeWidth = map.getZoomed(nsc.getMinWidth(getModel()).toBaseUnits());
    final int maxNodeWidth = Math.max(map.getLayoutSpecificMaxNodeWidth(), map.getZoomed(nsc.getMaxWidth(getModel()).toBaseUnits()));
    mainView.setMinimumWidth(minNodeWidth);
    mainView.setMaximumWidth(maxNodeWidth);
    createAttributeView();
    if (attributeView != null) {
        attributeView.update();
    }
    final boolean textShortened = isShortened();
    if (!textShortened) {
        final NodeViewFactory nodeViewFactory = NodeViewFactory.getInstance();
        nodeViewFactory.updateDetails(this, minNodeWidth, maxNodeWidth);
        nodeViewFactory.updateNoteViewer(this, minNodeWidth, maxNodeWidth);
        if (contentPane != null) {
            final int componentCount = contentPane.getComponentCount();
            for (int i = 1; i < componentCount; i++) {
                final Component component = contentPane.getComponent(i);
                if (component instanceof JComponent) {
                    ((JComponent) component).revalidate();
                }
            }
        }
    }
    updateShortener(getModel(), textShortened);
    mainView.updateIcons(this);
    mainView.updateText(getModel());
    updateCloud();
    modelBackgroundColor = NodeStyleController.getController(getMap().getModeController()).getBackgroundColor(model);
    revalidate();
    repaint();
}
Also used : NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) JComponent(javax.swing.JComponent) ModeController(org.freeplane.features.mode.ModeController) Component(java.awt.Component) JComponent(javax.swing.JComponent) Point(java.awt.Point)

Example 4 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.

the class MainView method updateBorder.

public void updateBorder(NodeView nodeView) {
    final NodeStyleController controller = NodeStyleController.getController(nodeView.getMap().getModeController());
    final NodeModel node = nodeView.getModel();
    final Boolean borderWidthMatchesEdgeWidth = controller.getBorderWidthMatchesEdgeWidth(node);
    if (borderWidthMatchesEdgeWidth)
        unzoomedBorderWidth = getUnzoomedEdgeWidth();
    else
        unzoomedBorderWidth = (float) controller.getBorderWidth(node).toBaseUnits();
    final Boolean borderDashMatchesEdgeDash = controller.getBorderDashMatchesEdgeDash(node);
    if (borderDashMatchesEdgeDash)
        dash = nodeView.getEdgeDash();
    else
        dash = controller.getBorderDash(node);
    borderColorMatchesEdgeColor = controller.getBorderColorMatchesEdgeColor(node);
    if (borderColorMatchesEdgeColor)
        borderColor = null;
    else
        borderColor = controller.getBorderColor(node);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController)

Example 5 with NodeStyleController

use of org.freeplane.features.nodestyle.NodeStyleController in project freeplane by freeplane.

the class LatexRenderer method getIcon.

@Override
public Icon getIcon(TextController textController, Object content, NodeModel node, Object transformedExtension) {
    if (transformedExtension == node.getUserObject()) {
        String string = content.toString();
        String nodeFormat = textController.getNodeFormat(node);
        if (PatternFormat.IDENTITY_PATTERN.equals(nodeFormat))
            return null;
        final String latext = getLatexNode(string, nodeFormat, TargetMode.FOR_ICON);
        if (latext == null)
            return null;
        final NodeStyleController ncs = NodeStyleController.getController(textController.getModeController());
        final int maxWidth = ncs.getMaxWidth(node).toBaseUnitsRounded();
        TeXText teXt = new TeXText(latext);
        int fontSize = Math.round(ncs.getFontSize(node) * UITools.FONT_SCALE_FACTOR);
        TeXIcon icon = teXt.createTeXIcon(TeXConstants.STYLE_DISPLAY, fontSize, TeXConstants.ALIGN_LEFT, maxWidth);
        return icon;
    }
    return null;
}
Also used : NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) TeXIcon(org.scilab.forge.jlatexmath.TeXIcon)

Aggregations

NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)12 NodeModel (org.freeplane.features.map.NodeModel)6 ModeController (org.freeplane.features.mode.ModeController)6 Color (java.awt.Color)3 Font (java.awt.Font)3 Point (java.awt.Point)3 CssRuleBuilder (org.freeplane.core.ui.components.html.CssRuleBuilder)3 MapView (org.freeplane.view.swing.map.MapView)3 Component (java.awt.Component)2 Dimension (java.awt.Dimension)2 JPopupMenu (javax.swing.JPopupMenu)2 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)2 ClipboardController (org.freeplane.features.clipboard.ClipboardController)2 CloudController (org.freeplane.features.cloud.CloudController)2 EdgeController (org.freeplane.features.edge.EdgeController)2 FilterController (org.freeplane.features.filter.FilterController)2 IconController (org.freeplane.features.icon.IconController)2 LinkController (org.freeplane.features.link.LinkController)2 MapModel (org.freeplane.features.map.MapModel)2 Controller (org.freeplane.features.mode.Controller)2