loadIntegerAttribute(e,shape,"sides");
loadNumberAttribute(e,shape,"angle");
loadBooleanAttribute(e,shape,"star");
}
if(e.attrEquals("type","area")) {
shape = new SArea(new Area());
}
if(e.attrEquals("type","arrow")) {
shape = new SArrow(
Double.parseDouble(e.attr("startX")),
Double.parseDouble(e.attr("startY")),
Double.parseDouble(e.attr("endX")),
Double.parseDouble(e.attr("endY")));
((SArrow)shape).setHeadEnd(SArrow.HeadEnd.valueOf(e.attr("headEnd")));
}
if(shape == null) {
Log.warning("warning. shape not detected. Shape type is: ",e.attr("type"));
return null;
}
loadStringAttribute(e,shape,"id");
loadStringAttribute(e,shape,"linkTarget");
if(e.hasAttr("fillPaint")) {
shape.setFillPaint(loadFillPaint(e, "fillPaint", zipFile));
} else {
shape.setFillPaint(null);
}
loadNumberAttribute(e,shape,"fillOpacity");
if(e.hasAttr("strokePaint")) {
loadFlatColorAttribute(e,shape,"strokePaint", FlatColor.class);
} else {
shape.setStrokePaint(null);
}
loadNumberAttribute(e,shape,"strokeWidth");
loadNumberAttribute(e,shape,"translateX");
loadNumberAttribute(e,shape,"translateY");
loadNumberAttribute(e,shape,"anchorX");
loadNumberAttribute(e,shape,"anchorY");
loadNumberAttribute(e,shape,"scaleX");
loadNumberAttribute(e,shape,"scaleY");
loadNumberAttribute(e,shape,"rotate");
if(e.attrEquals("type","path")) {
SPath path = (SPath) shape;
//handle oldstyle first
for(Elem element : e.xpath("pathpoint")) {
path.addPoint(new SPath.PathPoint(
Double.parseDouble(element.attr("x")),
Double.parseDouble(element.attr("y")),
Double.parseDouble(element.attr("cx1")),
Double.parseDouble(element.attr("cy1")),
Double.parseDouble(element.attr("cx2")),
Double.parseDouble(element.attr("cy2"))
));
}
//now handle the newstyle
boolean first = true;
for(Elem subelement : e.xpath("subpath")) {
if(!first) path.newSubPath();
for(Elem element : subelement.xpath("pathpoint")) {
path.addPoint(new SPath.PathPoint(
Double.parseDouble(element.attr("x")),
Double.parseDouble(element.attr("y")),
Double.parseDouble(element.attr("cx1")),
Double.parseDouble(element.attr("cy1")),
Double.parseDouble(element.attr("cx2")),
Double.parseDouble(element.attr("cy2"))
));
}
if(subelement.attrEquals("closed","true")) {
path.close();
}
first = false;
}
if(e.attrEquals("closed","true")) {
path.close();
}
path.recalcPath();
}
if(e.attrEquals("type","area")) {
SArea area = (SArea) shape;
Path2D.Double path = new Path2D.Double();
for(Elem element : e.xpath("*")) {
if(element.name().equals("move")) {
path.moveTo(
Double.parseDouble(element.attr("x")),
Double.parseDouble(element.attr("y"))
);
}
if(element.name().equals("lineto")) {
path.lineTo(
Double.parseDouble(element.attr("x")),
Double.parseDouble(element.attr("y"))
);
}
if(element.name().equals("curveto")) {
path.curveTo(
Double.parseDouble(element.attr("cx1")),
Double.parseDouble(element.attr("cy1")),
Double.parseDouble(element.attr("cx2")),
Double.parseDouble(element.attr("cy2")),
Double.parseDouble(element.attr("x2")),
Double.parseDouble(element.attr("y2"))
);
}
if(element.name().equals("close")) {
path.closePath();
}
}
area.setArea(new Area(path));
}
loadProperties(e,shape);
return shape;
}