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