Search in sources :

Example 31 with XMLElement

use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class LinkBuilder method save.

public void save(final ITreeWriter writer, final ConnectorModel model) throws IOException {
    final NodeModel target = model.getTarget();
    if (target == null) {
        return;
    }
    final XMLElement arrowLink = new XMLElement();
    arrowLink.setName("arrowlink");
    final Shape shape = model.getShape();
    arrowLink.setAttribute("SHAPE", shape.toString());
    final Color color = model.getColor();
    arrowLink.setAttribute("COLOR", ColorUtils.colorToString(color));
    final int width = model.getWidth();
    arrowLink.setAttribute("WIDTH", Integer.toString(width));
    final int alpha = model.getAlpha();
    arrowLink.setAttribute("TRANSPARENCY", Integer.toString(alpha));
    final int[] dash = model.getDash();
    if (dash != null) {
        StringBuilder sb = null;
        for (int i : dash) {
            if (sb == null) {
                sb = new StringBuilder(dash.length * 4);
            } else {
                sb.append(' ');
            }
            sb.append(i);
        }
        if (sb != null) {
            arrowLink.setAttribute("DASH", sb.toString());
        }
    }
    final int fontSize = model.getLabelFontSize();
    arrowLink.setAttribute("FONT_SIZE", Integer.toString(fontSize));
    final String fontFamily = model.getLabelFontFamily();
    arrowLink.setAttribute("FONT_FAMILY", fontFamily);
    final String destinationLabel = target.createID();
    if (destinationLabel != null) {
        arrowLink.setAttribute("DESTINATION", destinationLabel);
    }
    final String sourceLabel = model.getSourceLabel();
    if (sourceLabel != null) {
        arrowLink.setAttribute("SOURCE_LABEL", sourceLabel);
    }
    final String targetLabel = model.getTargetLabel();
    if (targetLabel != null) {
        arrowLink.setAttribute("TARGET_LABEL", targetLabel);
    }
    final String middleLabel = model.getMiddleLabel();
    if (middleLabel != null) {
        arrowLink.setAttribute("MIDDLE_LABEL", middleLabel);
    }
    final Point startInclination = model.getStartInclination();
    if (startInclination != null) {
        arrowLink.setAttribute("STARTINCLINATION", TreeXmlWriter.PointToXml(startInclination));
    }
    final Point endInclination = model.getEndInclination();
    if (endInclination != null) {
        arrowLink.setAttribute("ENDINCLINATION", TreeXmlWriter.PointToXml(endInclination));
    }
    final String startArrow = model.getStartArrow().toString();
    if (startArrow != null) {
        arrowLink.setAttribute("STARTARROW", startArrow);
    }
    final String endArrow = model.getEndArrow().toString();
    if (endArrow != null) {
        arrowLink.setAttribute("ENDARROW", endArrow);
    }
    writer.addElement(model, arrowLink);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Shape(org.freeplane.features.link.ConnectorModel.Shape) Color(java.awt.Color) Point(java.awt.Point) XMLElement(org.freeplane.n3.nanoxml.XMLElement) Point(java.awt.Point)

Example 32 with XMLElement

use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class MapWriter method writeMapAsXml.

public void writeMapAsXml(final MapModel map, final Writer fileout, final Mode mode, final boolean saveInvisible, final boolean forceFormat) throws IOException {
    final TreeXmlWriter xmlWriter = new TreeXmlWriter(writeManager, fileout);
    xmlWriter.setHint(Hint.MODE, mode);
    if (forceFormat) {
        xmlWriter.setHint(WriterHint.FORCE_FORMATTING);
    }
    final XMLElement xmlMap = new XMLElement("map");
    setSaveInvisible(saveInvisible);
    xmlWriter.addElement(map, xmlMap);
    xmlWriter.flush();
    fileout.close();
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement) TreeXmlWriter(org.freeplane.core.io.xml.TreeXmlWriter)

Example 33 with XMLElement

use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class ScriptEditorWindowConfigurationStorage method decorateDialog.

public static ScriptEditorWindowConfigurationStorage decorateDialog(final String marshalled, final JDialog dialog) {
    final ScriptEditorWindowConfigurationStorage storage = new ScriptEditorWindowConfigurationStorage();
    final XMLElement xml = storage.unmarschall(marshalled, dialog);
    if (xml != null) {
        storage.leftRatio = Integer.parseInt(xml.getAttribute("left_ratio", null));
        storage.topRatio = Integer.parseInt(xml.getAttribute("top_ratio", null));
        return storage;
    }
    return null;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 34 with XMLElement

use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class ScriptAddOnProperties method parseScripts.

private List<Script> parseScripts(Vector<XMLElement> xmlElements) {
    final ArrayList<Script> scripts = new ArrayList<Script>();
    if (xmlElements == null || xmlElements.isEmpty())
        return scripts;
    for (XMLElement scriptXmlNode : xmlElements.get(0).getChildren()) {
        final Script script = new Script();
        for (Entry<Object, Object> entry : scriptXmlNode.getAttributes().entrySet()) {
            if (entry.getKey().equals("name")) {
                script.name = (String) entry.getValue();
            } else if (entry.getKey().equals("executionMode")) {
                script.executionMode = parseExecutionMode(entry.getValue().toString());
            } else if (entry.getKey().equals("menuTitleKey")) {
                script.menuTitleKey = entry.getValue().toString();
            } else if (entry.getKey().equals("menuLocation")) {
                script.menuLocation = entry.getValue().toString();
            }
        }
        script.permissions = new ScriptingPermissions(scriptXmlNode.getAttributes());
        scripts.add(script);
    }
    return scripts;
}
Also used : ArrayList(java.util.ArrayList) ScriptingPermissions(org.freeplane.plugin.script.ScriptingPermissions) XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 35 with XMLElement

use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.

the class ScriptAddOnProperties method addScriptsAsChild.

private void addScriptsAsChild(XMLElement parent) {
    XMLElement xmlElement = new XMLElement("scripts");
    for (Script script : scripts) {
        XMLElement scriptXmlElement = new XMLElement("script");
        scriptXmlElement.setAttribute("name", script.name);
        scriptXmlElement.setAttribute("menuTitleKey", script.menuTitleKey);
        scriptXmlElement.setAttribute("menuLocation", script.menuLocation);
        scriptXmlElement.setAttribute("executionMode", script.executionMode.toString());
        final List<String> permissionNames = ScriptingPermissions.getPermissionNames();
        for (String permission : permissionNames) {
            scriptXmlElement.setAttribute(permission, Boolean.toString(script.permissions.get(permission)));
        }
        xmlElement.addChild(scriptXmlElement);
    }
    parent.addChild(xmlElement);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Aggregations

XMLElement (org.freeplane.n3.nanoxml.XMLElement)63 IOException (java.io.IOException)8 IXMLParser (org.freeplane.n3.nanoxml.IXMLParser)7 IXMLReader (org.freeplane.n3.nanoxml.IXMLReader)7 StdXMLReader (org.freeplane.n3.nanoxml.StdXMLReader)7 BufferedInputStream (java.io.BufferedInputStream)5 File (java.io.File)5 FileInputStream (java.io.FileInputStream)5 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)5 NodeModel (org.freeplane.features.map.NodeModel)5 XMLWriter (org.freeplane.n3.nanoxml.XMLWriter)4 Color (java.awt.Color)3 FileWriter (java.io.FileWriter)3 Writer (java.io.Writer)3 IXMLElement (net.n3.nanoxml.IXMLElement)3 XMLElement (net.n3.nanoxml.XMLElement)3 XMLException (org.freeplane.n3.nanoxml.XMLException)3 Point (java.awt.Point)2 FilenameFilter (java.io.FilenameFilter)2 HashMap (java.util.HashMap)2