Search in sources :

Example 36 with ModeController

use of org.freeplane.features.mode.ModeController 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 37 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class MapViewController method setMapTitles.

public void setMapTitles() {
    final ModeController modeController = Controller.getCurrentModeController();
    if (modeController == null) {
        controller.getViewController().setTitle("");
        return;
    }
    final Object[] messageArguments = { TextUtils.getText(("mode_" + modeController.getModeName())) };
    final MessageFormat formatter = new MessageFormat(TextUtils.getText("mode_title"));
    String frameTitle = formatter.format(messageArguments);
    String viewName = "";
    final MapModel model = getModel();
    if (model != null) {
        viewName = getMapViewComponent().getName();
        frameTitle = viewName + ((model.isSaved() || model.isReadOnly()) ? "" : "*") + " - " + frameTitle + (model.isReadOnly() ? " (" + TextUtils.getText("read_only") + ")" : "");
        final File file = model.getFile();
        if (file != null) {
            frameTitle += " " + file.getAbsolutePath();
        }
    }
    controller.getViewController().setTitle(frameTitle);
    modeController.getUserInputListenerFactory().updateMapList();
}
Also used : MessageFormat(java.text.MessageFormat) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) File(java.io.File)

Example 38 with ModeController

use of org.freeplane.features.mode.ModeController 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 39 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class NodeView method isShortened.

public boolean isShortened() {
    final ModeController modeController = getMap().getModeController();
    final TextController textController = TextController.getController(modeController);
    final boolean textShortened = textController.isMinimized(getModel());
    return textShortened;
}
Also used : TextController(org.freeplane.features.text.TextController) ModeController(org.freeplane.features.mode.ModeController)

Example 40 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class NodeView method setMainView.

void setMainView(final MainView newMainView) {
    if (contentPane != null) {
        assert (contentPane.getParent() == this);
        if (mainView != null)
            removeContent(MAIN_VIEWER_POSITION);
        addContent(newMainView, MAIN_VIEWER_POSITION);
        assert (contentPane.getParent() == this);
    } else if (mainView != null) {
        final Container c = mainView.getParent();
        int i;
        for (i = c.getComponentCount() - 1; i >= 0 && mainView != c.getComponent(i); i--) {
            ;
        }
        c.remove(i);
        c.add(newMainView, i);
    } else {
        add(newMainView);
    }
    mainView = newMainView;
    ModeController modeController = getMap().getModeController();
    if (modeController.canEdit(getModel())) {
        final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
        mainView.addMouseListener(userInputListenerFactory.getNodeMouseMotionListener());
        mainView.addMouseMotionListener(userInputListenerFactory.getNodeMouseMotionListener());
        mainView.addMouseWheelListener(userInputListenerFactory.getNodeMouseWheelListener());
        mainView.addKeyListener(userInputListenerFactory.getNodeKeyListener());
        addDragListener(userInputListenerFactory.getNodeDragListener());
        addDropListener(userInputListenerFactory.getNodeDropTargetListener());
    }
}
Also used : Container(java.awt.Container) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) ModeController(org.freeplane.features.mode.ModeController)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)185 NodeModel (org.freeplane.features.map.NodeModel)80 Controller (org.freeplane.features.mode.Controller)43 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)36 MapController (org.freeplane.features.map.MapController)31 MapModel (org.freeplane.features.map.MapModel)30 IActor (org.freeplane.core.undo.IActor)28 ResourceController (org.freeplane.core.resources.ResourceController)21 MMapController (org.freeplane.features.map.mindmapmode.MMapController)21 Point (java.awt.Point)16 TextController (org.freeplane.features.text.TextController)16 Component (java.awt.Component)13 MapView (org.freeplane.view.swing.map.MapView)13 LinkController (org.freeplane.features.link.LinkController)12 NodeView (org.freeplane.view.swing.map.NodeView)12 Color (java.awt.Color)11 File (java.io.File)11 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)11 IMapSelection (org.freeplane.features.map.IMapSelection)10 ViewController (org.freeplane.features.ui.ViewController)10