Search in sources :

Example 16 with XMLElement

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

the class FormatController method saveFormats.

private void saveFormats(final List<PatternFormat> formats) throws IOException {
    final XMLElement saver = new XMLElement();
    saver.setName(ROOT_ELEMENT);
    final String sep = System.getProperty("line.separator");
    final String header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + // 
    sep + "<!-- 'type' selects the kind of data the formatter is intended to format. -->" + // 
    sep + "<!-- 'style' selects the formatter implementation: -->" + // 
    sep + "<!--   - 'date': http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html -->" + // 
    sep + "<!--   - 'decimal': http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html -->" + // 
    sep + "<!--   - 'formatter': http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html -->" + // 
    sep + "<!--   - 'name': a informal name, a comment that's not visible in the app -->" + // 
    sep + "<!--   - 'locale': the name of the locale, only set for locale dependent format codes -->" + sep;
    for (PatternFormat patternFormat : formats) {
        if (!patternFormat.getType().equals(PatternFormat.TYPE_IDENTITY) && !patternFormat.getType().equals(PatternFormat.TYPE_STANDARD)) {
            saver.addChild(patternFormat.toXml());
        }
    }
    final Writer writer = new FileWriter(pathToFile);
    final XMLWriter xmlWriter = new XMLWriter(writer);
    xmlWriter.addRawContent(header);
    xmlWriter.write(saver, true);
    writer.close();
}
Also used : FileWriter(java.io.FileWriter) XMLElement(org.freeplane.n3.nanoxml.XMLElement) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter) FileWriter(java.io.FileWriter) XMLWriter(org.freeplane.n3.nanoxml.XMLWriter) Writer(java.io.Writer)

Example 17 with XMLElement

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

the class Parser method toXml.

public XMLElement toXml() {
    final XMLElement xmlElement = new XMLElement("parser");
    xmlElement.setAttribute("type", getType());
    xmlElement.setAttribute("style", getStyle());
    if (getFormat() != null)
        xmlElement.setAttribute("format", getFormat());
    if (getComment() != null)
        xmlElement.setAttribute("comment", getComment());
    return xmlElement;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 18 with XMLElement

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

the class Scanner method toXml.

public XMLElement toXml() {
    final XMLElement xmlElement = new XMLElement(ELEM_SCANNER);
    xmlElement.setAttribute(ATTRIB_LOCALE, StringUtils.join(locales.iterator(), ","));
    if (isDefault)
        xmlElement.setAttribute(ATTRIB_DEFAULT, "true");
    xmlElement.addChild(firstCharsToXml());
    for (Parser parser : parsers) {
        xmlElement.addChild(parser.toXml());
    }
    return xmlElement;
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 19 with XMLElement

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

the class NodeStyleBuilder method writeContent.

private void writeContent(final ITreeWriter writer, final NodeModel node, final NodeStyleModel style, final boolean forceFormatting) throws IOException {
    if (!NodeWriter.shouldWriteSharedContent(writer))
        return;
    if (forceFormatting || style != null) {
        final XMLElement fontElement = new XMLElement();
        fontElement.setName("font");
        boolean isRelevant = forceFormatting;
        final String fontFamilyName = forceFormatting ? nsc.getFontFamilyName(node) : style.getFontFamilyName();
        if (fontFamilyName != null) {
            fontElement.setAttribute("NAME", fontFamilyName);
            isRelevant = true;
        }
        final Integer fontSize = forceFormatting ? Integer.valueOf(nsc.getFontSize(node)) : style.getFontSize();
        if (fontSize != null) {
            fontElement.setAttribute("SIZE", Integer.toString(fontSize));
            isRelevant = true;
        }
        final Boolean bold = forceFormatting ? Boolean.valueOf(nsc.isBold(node)) : style.isBold();
        if (bold != null) {
            fontElement.setAttribute("BOLD", bold ? "true" : "false");
            isRelevant = true;
        }
        final Boolean italic = forceFormatting ? Boolean.valueOf(nsc.isItalic(node)) : style.isItalic();
        if (italic != null) {
            fontElement.setAttribute("ITALIC", italic ? "true" : "false");
            isRelevant = true;
        }
        if (isRelevant) {
            writer.addElement(style, fontElement);
        }
    }
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Example 20 with XMLElement

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

the class AddOnProperties method addAsChildWithContent.

private void addAsChildWithContent(XMLElement parent, String name, String content) {
    final XMLElement xmlElement = new XMLElement(name);
    xmlElement.setContent(content);
    parent.addChild(xmlElement);
}
Also used : XMLElement(org.freeplane.n3.nanoxml.XMLElement)

Aggregations

XMLElement (org.freeplane.n3.nanoxml.XMLElement)65 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 Point (java.awt.Point)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Locale (java.util.Locale)2