Search in sources :

Example 6 with XMLElement

use of org.freeplane.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 7 with XMLElement

use of org.freeplane.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 8 with XMLElement

use of org.freeplane.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 9 with XMLElement

use of org.freeplane.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 strikedThrough = forceFormatting ? Boolean.valueOf(nsc.isStrikedThrough(node)) : style.isStrikedThrough();
        if (strikedThrough != null) {
            fontElement.setAttribute("STRIKETHROUGH", strikedThrough ? "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 10 with XMLElement

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

the class NoteWriter method writeContent.

/*
	 * (non-Javadoc)
	 * @see freeplane.io.INodeWriter#saveContent(freeplane.io.ITreeWriter,
	 * java.lang.Object, java.lang.String)
	 */
public void writeContent(final ITreeWriter writer, final Object element, final IExtension note) throws IOException {
    RichTextModel note1 = (RichTextModel) note;
    if (note1.getXml() != null) {
        final XMLElement htmlElement = new XMLElement();
        htmlElement.setName(NodeTextBuilder.XML_NODE_XHTML_CONTENT_TAG);
        if (note instanceof NoteModel) {
            htmlElement.setAttribute(NodeTextBuilder.XML_NODE_XHTML_TYPE_TAG, NodeTextBuilder.XML_NODE_XHTML_TYPE_NOTE);
        } else {
            htmlElement.setAttribute(NodeTextBuilder.XML_NODE_XHTML_TYPE_TAG, "UNKNOWN");
        }
        final String content = note1.getXml().replace('\0', ' ');
        writer.addElement('\n' + content + '\n', htmlElement);
    }
    return;
}
Also used : RichTextModel(org.freeplane.features.text.RichTextModel) 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