use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class LinkBuilder method save.
public void save(final ITreeWriter writer, final ConnectorModel model) throws IOException {
final NodeModel target = model.getTarget();
if (target == null) {
return;
}
final XMLElement arrowLink = new XMLElement();
arrowLink.setName("arrowlink");
final Shape shape = model.getShape();
arrowLink.setAttribute("SHAPE", shape.toString());
final Color color = model.getColor();
arrowLink.setAttribute("COLOR", ColorUtils.colorToString(color));
final int width = model.getWidth();
arrowLink.setAttribute("WIDTH", Integer.toString(width));
final int alpha = model.getAlpha();
arrowLink.setAttribute("TRANSPARENCY", Integer.toString(alpha));
final int[] dash = model.getDash();
if (dash != null) {
StringBuilder sb = null;
for (int i : dash) {
if (sb == null) {
sb = new StringBuilder(dash.length * 4);
} else {
sb.append(' ');
}
sb.append(i);
}
if (sb != null) {
arrowLink.setAttribute("DASH", sb.toString());
}
}
final int fontSize = model.getLabelFontSize();
arrowLink.setAttribute("FONT_SIZE", Integer.toString(fontSize));
final String fontFamily = model.getLabelFontFamily();
arrowLink.setAttribute("FONT_FAMILY", fontFamily);
final String destinationLabel = target.createID();
if (destinationLabel != null) {
arrowLink.setAttribute("DESTINATION", destinationLabel);
}
final String sourceLabel = model.getSourceLabel();
if (sourceLabel != null) {
arrowLink.setAttribute("SOURCE_LABEL", sourceLabel);
}
final String targetLabel = model.getTargetLabel();
if (targetLabel != null) {
arrowLink.setAttribute("TARGET_LABEL", targetLabel);
}
final String middleLabel = model.getMiddleLabel();
if (middleLabel != null) {
arrowLink.setAttribute("MIDDLE_LABEL", middleLabel);
}
final Point startInclination = model.getStartInclination();
if (startInclination != null) {
arrowLink.setAttribute("STARTINCLINATION", TreeXmlWriter.PointToXml(startInclination));
}
final Point endInclination = model.getEndInclination();
if (endInclination != null) {
arrowLink.setAttribute("ENDINCLINATION", TreeXmlWriter.PointToXml(endInclination));
}
final String startArrow = model.getStartArrow().toString();
if (startArrow != null) {
arrowLink.setAttribute("STARTARROW", startArrow);
}
final String endArrow = model.getEndArrow().toString();
if (endArrow != null) {
arrowLink.setAttribute("ENDARROW", endArrow);
}
writer.addElement(model, arrowLink);
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class MapWriter method writeMapAsXml.
public void writeMapAsXml(final MapModel map, final Writer fileout, final Mode mode, final boolean saveInvisible, final boolean forceFormat) throws IOException {
final TreeXmlWriter xmlWriter = new TreeXmlWriter(writeManager, fileout);
xmlWriter.setHint(Hint.MODE, mode);
if (forceFormat) {
xmlWriter.setHint(WriterHint.FORCE_FORMATTING);
}
final XMLElement xmlMap = new XMLElement("map");
setSaveInvisible(saveInvisible);
xmlWriter.addElement(map, xmlMap);
xmlWriter.flush();
fileout.close();
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class ScriptEditorWindowConfigurationStorage method decorateDialog.
public static ScriptEditorWindowConfigurationStorage decorateDialog(final String marshalled, final JDialog dialog) {
final ScriptEditorWindowConfigurationStorage storage = new ScriptEditorWindowConfigurationStorage();
final XMLElement xml = storage.unmarschall(marshalled, dialog);
if (xml != null) {
storage.leftRatio = Integer.parseInt(xml.getAttribute("left_ratio", null));
storage.topRatio = Integer.parseInt(xml.getAttribute("top_ratio", null));
return storage;
}
return null;
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class ScriptAddOnProperties method parseScripts.
private List<Script> parseScripts(Vector<XMLElement> xmlElements) {
final ArrayList<Script> scripts = new ArrayList<Script>();
if (xmlElements == null || xmlElements.isEmpty())
return scripts;
for (XMLElement scriptXmlNode : xmlElements.get(0).getChildren()) {
final Script script = new Script();
for (Entry<Object, Object> entry : scriptXmlNode.getAttributes().entrySet()) {
if (entry.getKey().equals("name")) {
script.name = (String) entry.getValue();
} else if (entry.getKey().equals("executionMode")) {
script.executionMode = parseExecutionMode(entry.getValue().toString());
} else if (entry.getKey().equals("menuTitleKey")) {
script.menuTitleKey = entry.getValue().toString();
} else if (entry.getKey().equals("menuLocation")) {
script.menuLocation = entry.getValue().toString();
}
}
script.permissions = new ScriptingPermissions(scriptXmlNode.getAttributes());
scripts.add(script);
}
return scripts;
}
use of org.freeplane.n3.nanoxml.XMLElement in project freeplane by freeplane.
the class ScriptAddOnProperties method addScriptsAsChild.
private void addScriptsAsChild(XMLElement parent) {
XMLElement xmlElement = new XMLElement("scripts");
for (Script script : scripts) {
XMLElement scriptXmlElement = new XMLElement("script");
scriptXmlElement.setAttribute("name", script.name);
scriptXmlElement.setAttribute("menuTitleKey", script.menuTitleKey);
scriptXmlElement.setAttribute("menuLocation", script.menuLocation);
scriptXmlElement.setAttribute("executionMode", script.executionMode.toString());
final List<String> permissionNames = ScriptingPermissions.getPermissionNames();
for (String permission : permissionNames) {
scriptXmlElement.setAttribute(permission, Boolean.toString(script.permissions.get(permission)));
}
xmlElement.addChild(scriptXmlElement);
}
parent.addChild(xmlElement);
}
Aggregations