Search in sources :

Example 6 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() {

        public String getTooltip(final ModeController modeController, NodeModel node, Component view) {
            if (!ShortenedTextModel.isShortened(node)) {
                return null;
            }
            final NodeStyleController style = (NodeStyleController) modeController.getExtension(NodeStyleController.class);
            final Font font = style.getFont(node);
            final StringBuilder rule = new StringBuilder();
            rule.append("font-family: " + font.getFamily() + ";");
            rule.append("font-size: " + font.getSize() + "pt;");
            rule.append("margin-top:0;");
            if (font.isItalic()) {
                rule.append("font-style: italic; ");
            }
            if (font.isBold()) {
                rule.append("font-weight: bold; ");
            }
            final Color nodeTextColor = view.getForeground();
            rule.append("color: ").append(ColorUtils.colorToString(nodeTextColor)).append(";");
            final Object data = node.getUserObject();
            String text;
            try {
                text = getTransformedText(data, node, data);
            } catch (Exception e) {
                text = TextUtils.format("MainView.errorUpdateText", data, e.getLocalizedMessage());
                rule.append("color:red;");
            }
            if (!HtmlUtils.isHtmlNode(text)) {
                text = HtmlUtils.plainToHTML(text);
            }
            final String tooltipText = text.replaceFirst("<body>", "<body><div style=\"" + rule + "\">").replaceFirst("</body>", "</div></body>");
            return tooltipText;
        }
    });
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) Color(java.awt.Color) ITooltipProvider(org.freeplane.features.map.ITooltipProvider) ModeController(org.freeplane.features.mode.ModeController) Component(java.awt.Component) Font(java.awt.Font)

Example 7 with NodeStyleController

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

the class FModeControllerFactory method createModeController.

public static FModeController createModeController() {
    final Controller controller = Controller.getCurrentController();
    modeController = new FModeController(controller);
    final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController, false);
    modeController.setUserInputListenerFactory(userInputListenerFactory);
    controller.addModeController(modeController);
    controller.selectModeForBuild(modeController);
    new FMapController(modeController);
    UrlManager.install(new UrlManager());
    MapIO.install(modeController);
    IconController.install(new IconController(modeController));
    NodeStyleController.install(new NodeStyleController(modeController));
    EdgeController.install(new EdgeController(modeController));
    TextController.install(new TextController(modeController));
    LinkController.install(new LinkController());
    CloudController.install(new CloudController(modeController));
    ClipboardController.install(new ClipboardController());
    LocationController.install(new LocationController());
    LogicalStyleController.install(new LogicalStyleController(modeController));
    MapStyle.install(true);
    NodeStyleController.getController().addShapeGetter(new Integer(0), new IPropertyHandler<String, NodeModel>() {

        public String getProperty(final NodeModel node, final String currentValue) {
            return "fork";
        }
    });
    modeController.addAction(new CenterAction());
    modeController.addAction(new OpenPathAction());
    userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
    final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
    FrameController frameController = (FrameController) controller.getViewController();
    UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
    userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
    userInputListenerFactory.addToolBar("/filter_toolbar", ViewController.BOTTOM, FilterController.getCurrentFilterController().getFilterToolbar());
    userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
    NodeHistory.install(modeController);
    return modeController;
}
Also used : OpenPathAction(org.freeplane.features.map.filemode.OpenPathAction) UrlManager(org.freeplane.features.url.UrlManager) ClipboardController(org.freeplane.features.clipboard.ClipboardController) EdgeController(org.freeplane.features.edge.EdgeController) TextController(org.freeplane.features.text.TextController) LinkController(org.freeplane.features.link.LinkController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) UserInputListenerFactory(org.freeplane.view.swing.ui.UserInputListenerFactory) LocationController(org.freeplane.features.nodelocation.LocationController) FMapController(org.freeplane.features.map.filemode.FMapController) ClipboardController(org.freeplane.features.clipboard.ClipboardController) FModeController(org.freeplane.features.mode.filemode.FModeController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) EdgeController(org.freeplane.features.edge.EdgeController) ViewController(org.freeplane.features.ui.ViewController) CloudController(org.freeplane.features.cloud.CloudController) LinkController(org.freeplane.features.link.LinkController) FilterController(org.freeplane.features.filter.FilterController) LocationController(org.freeplane.features.nodelocation.LocationController) FrameController(org.freeplane.features.ui.FrameController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) FMapController(org.freeplane.features.map.filemode.FMapController) JPopupMenu(javax.swing.JPopupMenu) IconController(org.freeplane.features.icon.IconController) CenterAction(org.freeplane.features.map.filemode.CenterAction) NodeModel(org.freeplane.features.map.NodeModel) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CloudController(org.freeplane.features.cloud.CloudController) FModeController(org.freeplane.features.mode.filemode.FModeController) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) FrameController(org.freeplane.features.ui.FrameController)

Example 8 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();
    noteFont = UITools.scale(style.getDefaultFont(map, MapStyleModel.NOTE_STYLE));
    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);
}
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 9 with NodeStyleController

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

the class ZoomableLabel method updateTextUnsafe.

private void updateTextUnsafe(String nodeText) throws Exception {
    final NodeView node = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, this);
    final MapView map = node.getMap();
    if (map == null || nodeText == null) {
        return;
    }
    final boolean isHtml = nodeText.startsWith("<html>");
    boolean widthMustBeRestricted = false;
    boolean isLong = false;
    final ModeController modeController = map.getModeController();
    final NodeStyleController nsc = NodeStyleController.getController(modeController);
    final int maxNodeWidth = nsc.getMaxWidth(node.getModel());
    if (!isHtml) {
        final String[] lines = nodeText.split("\n");
        for (int line = 0; line < lines.length; line++) {
            setText(lines[line]);
            widthMustBeRestricted = getPreferredSize().width > map.getZoomed(maxNodeWidth);
            if (widthMustBeRestricted) {
                break;
            }
        }
        isLong = widthMustBeRestricted || lines.length > 1;
    }
    if (isHtml) {
        if (nodeText.indexOf("<img") >= 0 && nodeText.indexOf("<base ") < 0) {
            nodeText = "<html><base href=\"" + map.getModel().getURL() + "\">" + nodeText.substring(6);
        }
        final String htmlLongNodeHead = ResourceController.getResourceController().getProperty("html_long_node_head");
        if (htmlLongNodeHead != null && !htmlLongNodeHead.equals("")) {
            if (nodeText.matches("(?ims).*<head>.*")) {
                nodeText = nodeText.replaceFirst("(?ims).*<head>.*", "<head>" + htmlLongNodeHead);
            } else {
                nodeText = nodeText.replaceFirst("(?ims)<html>", "<html><head>" + htmlLongNodeHead + "</head>");
            }
        }
        setText(nodeText);
    } else if (nodeText.startsWith("<table>")) {
        final String[] lines = nodeText.split("\n");
        lines[0] = lines[0].substring(7);
        final int startingLine = lines[0].matches("\\s*") ? 1 : 0;
        String text = "<html><table border=1 style=\"border-color: white\">";
        for (int line = startingLine; line < lines.length; line++) {
            text += "<tr><td style=\"border-color: white;\">" + HtmlUtils.toXMLEscapedText(lines[line]).replaceAll("\t", "<td style=\"border-color: white\">");
        }
        setText(text);
    } else if (isLong) {
        String text = HtmlUtils.plainToHTML(nodeText);
        setText(text);
    } else {
        setText(nodeText);
    }
}
Also used : NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) ModeController(org.freeplane.features.mode.ModeController) Point(java.awt.Point)

Example 10 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);
        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)18 ModeController (org.freeplane.features.mode.ModeController)8 Color (java.awt.Color)5 Dimension (java.awt.Dimension)5 NodeModel (org.freeplane.features.map.NodeModel)5 Font (java.awt.Font)4 CloudController (org.freeplane.features.cloud.CloudController)4 EdgeController (org.freeplane.features.edge.EdgeController)4 MapModel (org.freeplane.features.map.MapModel)4 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)4 Component (java.awt.Component)3 Point (java.awt.Point)3 JPopupMenu (javax.swing.JPopupMenu)3 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)3 ClipboardController (org.freeplane.features.clipboard.ClipboardController)3 FilterController (org.freeplane.features.filter.FilterController)3 IconController (org.freeplane.features.icon.IconController)3 LinkController (org.freeplane.features.link.LinkController)3 Controller (org.freeplane.features.mode.Controller)3 LocationController (org.freeplane.features.nodelocation.LocationController)3