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