Search in sources :

Example 1 with XMLElement

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

the class WindowConfigurationStorage method marshall.

private String marshall() {
    final XMLElement xml = new XMLElement();
    xml.setAttribute("x", Integer.toString(x));
    xml.setAttribute("y", Integer.toString(y));
    xml.setAttribute("width", Integer.toString(width));
    xml.setAttribute("height", Integer.toString(height));
    xml.setName(name);
    marshallSpecificElements(xml);
    final StringWriter string = new StringWriter();
    final XMLWriter writer = new XMLWriter(string);
    try {
        writer.write(xml);
        return string.toString();
    } catch (final IOException e) {
        LogUtils.severe(e);
        return null;
    }
}
Also used : StringWriter(java.io.StringWriter) IOException(java.io.IOException) XMLElement(org.freeplane.n3.nanoxml.XMLElement) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter)

Example 2 with XMLElement

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

the class CloudBuilder method writeContentImpl.

private void writeContentImpl(final ITreeWriter writer, final NodeModel node, final IExtension extension) throws IOException {
    final CloudModel model = extension != null ? (CloudModel) extension : cc.getCloud(node);
    if (model == null) {
        return;
    }
    final XMLElement cloud = new XMLElement();
    cloud.setName("cloud");
    // final String style = model.getStyle();
    // if (style != null) {
    // cloud.setAttribute("STYLE", style);
    // }
    final Color color = model.getColor();
    if (color != null) {
        ColorUtils.setColorAttributes(cloud, "COLOR", "ALPHA", color);
    }
    final CloudModel.Shape shape = model.getShape();
    if (shape != null) {
        cloud.setAttribute("SHAPE", shape.toString());
    }
    // final int width = model.getWidth();
    // if (width != CloudController.DEFAULT_WIDTH) {
    // cloud.setAttribute("WIDTH", Integer.toString(width));
    // }
    writer.addElement(model, cloud);
}
Also used : Color(java.awt.Color) XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 3 with XMLElement

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

the class AttributeRegistryElement method save.

/**
 */
public XMLElement save() {
    final XMLElement element = new XMLElement();
    if (isVisible()) {
        element.setAttribute("VISIBLE", "true");
    }
    if (isManual()) {
        element.setAttribute("MANUAL", "true");
    }
    if (isRestricted()) {
        element.setAttribute("RESTRICTED", "true");
    }
    if (isManual() || isRestricted()) {
        for (int i = 0; i < values.getSize(); i++) {
            final XMLElement xmlValue = new XMLElement();
            xmlValue.setName(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_VALUE);
            final Object value = values.getElementAt(i);
            final String string = value.toString();
            xmlValue.setAttribute("VALUE", string);
            if (!(value instanceof String)) {
                final String spec = TypeReference.toSpec(value);
                xmlValue.setAttribute("OBJECT", spec);
            }
            element.addChild(xmlValue);
        }
    }
    element.setName(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_NAME);
    element.setAttribute("NAME", key.toString());
    return element;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 4 with XMLElement

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

the class AttributeBuilder method saveAttribute.

private void saveAttribute(NodeModel node, final ITreeWriter writer, final Attribute attr) throws IOException {
    final XMLElement attributeElement = new XMLElement();
    attributeElement.setName(AttributeBuilder.XML_NODE_ATTRIBUTE);
    attributeElement.setAttribute("NAME", attr.getName());
    final Object value = attr.getValue();
    final boolean forceFormatting = Boolean.TRUE.equals(writer.getHint(MapWriter.WriterHint.FORCE_FORMATTING));
    if (forceFormatting) {
        attributeElement.setAttribute("VALUE", TextController.getController().getTransformedTextNoThrow(value, node, null));
    } else {
        attributeElement.setAttribute("VALUE", value.toString());
        if (!(value instanceof String))
            attributeElement.setAttribute("OBJECT", TypeReference.toSpec(value));
    }
    writer.addElement(attr, attributeElement);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 5 with XMLElement

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

the class ScannerController method parseScanner.

private Scanner parseScanner(XMLElement elem) {
    final String locales = elem.getAttribute("locale", "");
    final String isDefault = elem.getAttribute("default", "false");
    if (StringUtils.isEmpty(locales)) {
        throw new RuntimeException("wrong scanner in " + pathToFile + ": none of the following must be empty: locales=" + locales + ".");
    }
    final Scanner scanner = new Scanner(locales.trim().split(","), Boolean.parseBoolean(isDefault));
    final Locale locale = new Locale(scanner.getLocales().get(0));
    for (XMLElement child : elem.getChildren()) {
        if (child.getName().equals("checkfirstchar")) {
            final String chars = elem.getAttribute("chars", "");
            final boolean disabled = Boolean.parseBoolean(elem.getAttribute("disabled", "false"));
            if (!disabled)
                scanner.setFirstChars(chars);
        } else if (child.getName().equals("parser")) {
            scanner.addParser(parseParser(child, locale));
        }
    }
    return scanner;
}
Also used : Locale(java.util.Locale) 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)6 IXMLReader (org.freeplane.n3.nanoxml.IXMLReader)6 StdXMLReader (org.freeplane.n3.nanoxml.StdXMLReader)6 ASelectableCondition (org.freeplane.features.filter.condition.ASelectableCondition)5 NodeModel (org.freeplane.features.map.NodeModel)5 BufferedInputStream (java.io.BufferedInputStream)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 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 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2