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();
}
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;
}
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;
}
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);
}
}
}
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;
}
Aggregations