Search in sources :

Example 81 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class MClipboardController method pasteStringWithoutRedisplay.

private void pasteStringWithoutRedisplay(final TextFragment[] textFragments, NodeModel parent, final boolean asSibling, final boolean isLeft) {
    final MapModel map = parent.getMap();
    int insertionIndex;
    if (asSibling) {
        NodeModel target = parent;
        parent = parent.getParentNode();
        insertionIndex = parent.getChildPosition(target);
    } else {
        insertionIndex = parent.getChildCount();
    }
    final ArrayList<NodeModel> parentNodes = new ArrayList<NodeModel>();
    final ArrayList<Integer> parentNodesDepths = new ArrayList<Integer>();
    parentNodes.add(parent);
    parentNodesDepths.add(new Integer(-1));
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    for (int i = 0; i < textFragments.length; ++i) {
        final TextFragment textFragment = textFragments[i];
        String text = textFragment.text;
        final String link = textFragment.link;
        URI uri = null;
        if (link != null) {
            try {
                URI linkUri = new URI(link);
                uri = linkUri;
                File absoluteFile = UrlManager.getController().getAbsoluteFile(map, uri);
                if (absoluteFile != null) {
                    // if ("file".equals(linkUri.getScheme())) {
                    final File mapFile = map.getFile();
                    uri = LinkController.toLinkTypeDependantURI(mapFile, absoluteFile);
                    if (link.equals(text)) {
                        text = uri.toString();
                    }
                }
            } catch (Exception e) {
            }
        }
        final NodeModel node = mapController.newNode(text, map);
        if (uri != null) {
            NodeLinks.createLinkExtension(node).setHyperLink(uri);
        }
        for (int j = parentNodes.size() - 1; j >= 0; --j) {
            if (textFragment.depth > ((Integer) parentNodesDepths.get(j)).intValue()) {
                for (int k = j + 1; k < parentNodes.size(); ++k) {
                    final NodeModel n = (NodeModel) parentNodes.get(k);
                    if (n.getParentNode() == null) {
                        mapController.insertNode(n, parent, insertionIndex++);
                    }
                    parentNodes.remove(k);
                    parentNodesDepths.remove(k);
                }
                final NodeModel target = (NodeModel) parentNodes.get(j);
                node.setLeft(isLeft);
                if (target != parent) {
                    target.setFolded(true);
                    target.insert(node, target.getChildCount());
                }
                parentNodes.add(node);
                parentNodesDepths.add(new Integer(textFragment.depth));
                break;
            }
        }
    }
    {
        for (int k = 0; k < parentNodes.size(); ++k) {
            final NodeModel n = (NodeModel) parentNodes.get(k);
            if (map.getRootNode() != n && n.getParentNode() == null) {
                mapController.insertNode(n, parent, insertionIndex++);
            }
        }
    }
}
Also used : MMapController(org.freeplane.features.map.mindmapmode.MMapController) ArrayList(java.util.ArrayList) MapModel(org.freeplane.features.map.MapModel) URI(java.net.URI) Hint(org.freeplane.features.map.MapWriter.Hint) XMLException(org.freeplane.n3.nanoxml.XMLException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) BadLocationException(javax.swing.text.BadLocationException) IOException(java.io.IOException) NodeModel(org.freeplane.features.map.NodeModel) File(java.io.File)

Example 82 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class EdgeController method getStyleEdgeColor.

private Color getStyleEdgeColor(final MapModel map, final Collection<IStyle> collection) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : collection) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final EdgeModel styleModel = EdgeModel.getModel(styleNode);
        if (styleModel == null) {
            continue;
        }
        final Color styleColor = styleModel.getColor();
        if (styleColor == null) {
            continue;
        }
        return styleColor;
    }
    return null;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) Color(java.awt.Color)

Example 83 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class CloudShapeAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    ModeController controller;
    {
        controller = Controller.getCurrentModeController();
        final NodeModel selected = controller.getMapController().getSelectedNode();
        final MCloudController cloudController = (MCloudController) CloudController.getController();
        cloudController.setCloud(selected, true);
    }
    super.actionPerformed(e);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ModeController(org.freeplane.features.mode.ModeController)

Example 84 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class CloudShapeAction method setSelected.

@Override
public void setSelected() {
    final NodeModel node = Controller.getCurrentModeController().getMapController().getSelectedNode();
    final CloudModel model = CloudModel.getModel(node);
    if (model != null) {
        if (actionShape.equals(model.getShape())) {
            setSelected(true);
            return;
        }
    }
    setSelected(false);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) CloudModel(org.freeplane.features.cloud.CloudModel)

Example 85 with NodeModel

use of org.freeplane.features.map.NodeModel in project freeplane by freeplane.

the class EdgeBuilder method endElement.

public void endElement(final Object parent, final String tag, final Object userObject, final XMLElement dom) {
    /* attributes */
    if (parent instanceof NodeModel) {
        final NodeModel node = (NodeModel) parent;
        if (userObject instanceof EdgeModel) {
            final EdgeModel edge = (EdgeModel) userObject;
            EdgeModel.setModel(node, edge);
        }
        return;
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)450 ModeController (org.freeplane.features.mode.ModeController)100 MapModel (org.freeplane.features.map.MapModel)53 Controller (org.freeplane.features.mode.Controller)46 MapStyleModel (org.freeplane.features.styles.MapStyleModel)46 MMapController (org.freeplane.features.map.mindmapmode.MMapController)39 MapController (org.freeplane.features.map.MapController)38 Point (java.awt.Point)37 IStyle (org.freeplane.features.styles.IStyle)36 IActor (org.freeplane.core.undo.IActor)34 IMapSelection (org.freeplane.features.map.IMapSelection)33 ArrayList (java.util.ArrayList)22 NodeView (org.freeplane.view.swing.map.NodeView)20 URI (java.net.URI)19 Color (java.awt.Color)18 Component (java.awt.Component)17 ResourceController (org.freeplane.core.resources.ResourceController)17 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15