Search in sources :

Example 31 with NodeModel

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

the class IconBuilder method endElement.

@Override
public void endElement(final Object parent, final String tag, final Object userObject, final XMLElement dom) {
    if (parent instanceof NodeModel && tag.equals("icon")) {
        final NodeModel node = (NodeModel) parent;
        final IconProperties ip = (IconProperties) userObject;
        final String iconName = ip.iconName;
        if (iconName != null)
            node.addIcon(store.getMindIcon(iconName));
        return;
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Example 32 with NodeModel

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

the class IconController method getStyleIconSize.

private Quantity<LengthUnits> getStyleIconSize(final MapModel map, final Collection<IStyle> styleKeys) {
    final MapStyleModel model = MapStyleModel.getExtension(map);
    for (IStyle styleKey : styleKeys) {
        final NodeModel styleNode = model.getStyleNode(styleKey);
        if (styleNode == null) {
            continue;
        }
        final Quantity<LengthUnits> iconSize = styleNode.getSharedData().getIcons().getIconSize();
        if (iconSize == null) {
            continue;
        }
        return iconSize;
    }
    return DEFAULT_ICON_SIZE;
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) LengthUnits(org.freeplane.core.ui.LengthUnits) MapStyleModel(org.freeplane.features.styles.MapStyleModel)

Example 33 with NodeModel

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

the class FollowLinkAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    LinkController linkController = LinkController.getController();
    NodeModel selNode = mapController.getSelectedNode();
    linkController.loadURL(selNode, e);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ModeController(org.freeplane.features.mode.ModeController) MapController(org.freeplane.features.map.MapController)

Example 34 with NodeModel

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

the class LinkBuilder method registerAttributeHandlers.

private void registerAttributeHandlers(final ReadManager reader) {
    reader.addAttributeHandler(NodeBuilder.XML_NODE, LINK, new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final NodeModel node = (NodeModel) userObject;
            linkController.loadLink(node, value);
            final Collection<NodeLinkModel> links = NodeLinks.getLinks(node);
            processedLinks.addAll(links);
        }
    });
    final IAttributeHandler hyperlinkHandler = new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final NodeModel node = (NodeModel) userObject;
            linkController.loadLinkFormat(node, Boolean.parseBoolean(value));
        }
    };
    reader.addAttributeHandler(NodeBuilder.XML_NODE, FORMAT_AS_HYPERLINK, hyperlinkHandler);
    reader.addAttributeHandler(NodeBuilder.XML_STYLENODE, FORMAT_AS_HYPERLINK, hyperlinkHandler);
    reader.addAttributeHandler("arrowlink", "EDGE_LIKE", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setShape(Shape.EDGE_LIKE);
        }
    });
    reader.addAttributeHandler("arrowlink", "SHAPE", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setShape(Shape.valueOf(value));
        }
    });
    reader.addAttributeHandler("arrowlink", "DASH", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            final String[] split = value.split(" ");
            int[] dash = new int[split.length];
            int i = 0;
            for (String s : split) {
                dash[i++] = Integer.parseInt(s);
            }
            arrowLink.setDash(dash);
        }
    });
    reader.addAttributeHandler("arrowlink", "DESTINATION", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setTargetID(value);
            processedLinks.add(arrowLink);
        }
    });
    reader.addAttributeHandler("arrowlink", "SOURCE_LABEL", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setSourceLabel(value.toString());
        }
    });
    reader.addAttributeHandler("arrowlink", "MIDDLE_LABEL", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setMiddleLabel(value.toString());
        }
    });
    reader.addAttributeHandler("arrowlink", "TARGET_LABEL", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setTargetLabel(value.toString());
        }
    });
    reader.addAttributeHandler("arrowlink", "STARTINCLINATION", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setStartInclination(TreeXmlReader.xmlToPoint(value.toString()));
        }
    });
    reader.addAttributeHandler("arrowlink", "ENDINCLINATION", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setEndInclination(TreeXmlReader.xmlToPoint(value.toString()));
        }
    });
    reader.addAttributeHandler("arrowlink", "STARTARROW", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setStartArrow(ArrowType.valueOf(value.toUpperCase(Locale.ENGLISH)));
        }
    });
    reader.addAttributeHandler("arrowlink", "ENDARROW", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setEndArrow(ArrowType.valueOf(value.toUpperCase(Locale.ENGLISH)));
        }
    });
    reader.addAttributeHandler("arrowlink", "WIDTH", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setWidth(Integer.parseInt(value.toString()));
        }
    });
    reader.addAttributeHandler("arrowlink", "FONT_FAMILY", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setLabelFontFamily(value.toString());
        }
    });
    reader.addAttributeHandler("arrowlink", "FONT_SIZE", new IAttributeHandler() {

        public void setAttribute(final Object userObject, final String value) {
            final ConnectorModel arrowLink = (ConnectorModel) userObject;
            arrowLink.setLabelFontSize(Integer.parseInt(value.toString()));
        }
    });
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IAttributeHandler(org.freeplane.core.io.IAttributeHandler) Collection(java.util.Collection)

Example 35 with NodeModel

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

the class NodeStyleBuilder method endElement.

public void endElement(final Object parent, final String tag, final Object userObject, final XMLElement dom) {
    if (parent instanceof NodeModel) {
        final NodeModel node = (NodeModel) parent;
        if (tag.equals("font")) {
            final FontProperties fp = (FontProperties) userObject;
            NodeStyleModel nodeStyleModel = NodeStyleModel.getModel(node);
            if (nodeStyleModel == null) {
                nodeStyleModel = new NodeStyleModel();
                node.addExtension(nodeStyleModel);
            }
            nodeStyleModel.setFontFamilyName(fp.fontName);
            nodeStyleModel.setFontSize(fp.fontSize);
            nodeStyleModel.setItalic(fp.isItalic);
            nodeStyleModel.setBold(fp.isBold);
            nodeStyleModel.setStrikedThrough(fp.isStrikedThrough);
            return;
        }
        return;
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)408 ModeController (org.freeplane.features.mode.ModeController)89 MapModel (org.freeplane.features.map.MapModel)47 Controller (org.freeplane.features.mode.Controller)44 MapStyleModel (org.freeplane.features.styles.MapStyleModel)39 IMapSelection (org.freeplane.features.map.IMapSelection)34 MapController (org.freeplane.features.map.MapController)33 Point (java.awt.Point)32 MMapController (org.freeplane.features.map.mindmapmode.MMapController)31 IStyle (org.freeplane.features.styles.IStyle)31 IActor (org.freeplane.core.undo.IActor)30 NodeView (org.freeplane.view.swing.map.NodeView)22 ArrayList (java.util.ArrayList)20 Color (java.awt.Color)16 URI (java.net.URI)16 ResourceController (org.freeplane.core.resources.ResourceController)16 Component (java.awt.Component)15 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15 File (java.io.File)14