/**
*
*/
protected void initHandlers()
{
handlers.put("save", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.save();
}
});
handlers.put("restore", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.restore();
}
});
handlers.put("scale", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.scale(Double.parseDouble(elt.getAttribute("scale")));
}
});
handlers.put("translate", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.translate(Double.parseDouble(elt.getAttribute("dx")),
Double.parseDouble(elt.getAttribute("dy")));
}
});
handlers.put("rotate", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.rotate(Double.parseDouble(elt.getAttribute("theta")),
elt.getAttribute("flipH").equals("1"), elt
.getAttribute("flipV").equals("1"), Double
.parseDouble(elt.getAttribute("cx")), Double
.parseDouble(elt.getAttribute("cy")));
}
});
handlers.put("strokewidth", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setStrokeWidth(Double.parseDouble(elt
.getAttribute("width")));
}
});
handlers.put("strokecolor", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setStrokeColor(elt.getAttribute("color"));
}
});
handlers.put("dashed", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setDashed(elt.getAttribute("dashed").equals("1"));
}
});
handlers.put("dashpattern", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setDashPattern(elt.getAttribute("pattern"));
}
});
handlers.put("linecap", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setLineCap(elt.getAttribute("cap"));
}
});
handlers.put("linejoin", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setLineJoin(elt.getAttribute("join"));
}
});
handlers.put("miterlimit", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setMiterLimit(Double.parseDouble(elt
.getAttribute("limit")));
}
});
handlers.put("fontsize", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setFontSize(Double.parseDouble(elt.getAttribute("size")));
}
});
handlers.put("fontcolor", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setFontColor(elt.getAttribute("color"));
}
});
handlers.put("fontbackgroundcolor", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setFontBackgroundColor(elt.getAttribute("color"));
}
});
handlers.put("fontbordercolor", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setFontBorderColor(elt.getAttribute("color"));
}
});
handlers.put("fontfamily", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setFontFamily(elt.getAttribute("family"));
}
});
handlers.put("fontstyle", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setFontStyle(Integer.parseInt(elt.getAttribute("style")));
}
});
handlers.put("alpha", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setAlpha(Double.parseDouble(elt.getAttribute("alpha")));
}
});
handlers.put("fillcolor", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setFillColor(elt.getAttribute("color"));
}
});
handlers.put("shadowcolor", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setShadowColor(elt.getAttribute("color"));
}
});
handlers.put("shadowalpha", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setShadowAlpha(Double.parseDouble(elt.getAttribute("alpha")));
}
});
handlers.put("shadowoffset", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setShadowOffset(Double.parseDouble(elt.getAttribute("dx")),
Double.parseDouble(elt.getAttribute("dy")));
}
});
handlers.put("shadow", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setShadow(elt.getAttribute("enabled").equals("1"));
}
});
handlers.put("gradient", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.setGradient(elt.getAttribute("c1"),
elt.getAttribute("c2"),
Double.parseDouble(elt.getAttribute("x")),
Double.parseDouble(elt.getAttribute("y")),
Double.parseDouble(elt.getAttribute("w")),
Double.parseDouble(elt.getAttribute("h")),
elt.getAttribute("direction"),
Double.parseDouble(getValue(elt, "alpha1", "1")),
Double.parseDouble(getValue(elt, "alpha2", "1")));
}
});
handlers.put("rect", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.rect(Double.parseDouble(elt.getAttribute("x")),
Double.parseDouble(elt.getAttribute("y")),
Double.parseDouble(elt.getAttribute("w")),
Double.parseDouble(elt.getAttribute("h")));
}
});
handlers.put("roundrect", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.roundrect(Double.parseDouble(elt.getAttribute("x")),
Double.parseDouble(elt.getAttribute("y")),
Double.parseDouble(elt.getAttribute("w")),
Double.parseDouble(elt.getAttribute("h")),
Double.parseDouble(elt.getAttribute("dx")),
Double.parseDouble(elt.getAttribute("dy")));
}
});
handlers.put("ellipse", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.ellipse(Double.parseDouble(elt.getAttribute("x")),
Double.parseDouble(elt.getAttribute("y")),
Double.parseDouble(elt.getAttribute("w")),
Double.parseDouble(elt.getAttribute("h")));
}
});
handlers.put("image", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.image(Double.parseDouble(elt.getAttribute("x")), Double
.parseDouble(elt.getAttribute("y")), Double
.parseDouble(elt.getAttribute("w")), Double
.parseDouble(elt.getAttribute("h")), elt
.getAttribute("src"), elt.getAttribute("aspect")
.equals("1"), elt.getAttribute("flipH").equals("1"),
elt.getAttribute("flipV").equals("1"));
}
});
handlers.put("text", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.text(Double.parseDouble(elt.getAttribute("x")),
Double.parseDouble(elt.getAttribute("y")),
Double.parseDouble(elt.getAttribute("w")),
Double.parseDouble(elt.getAttribute("h")),
elt.getAttribute("str"),
elt.getAttribute("align"),
elt.getAttribute("valign"),
getValue(elt, "wrap", "").equals("1"),
elt.getAttribute("format"),
elt.getAttribute("overflow"),
getValue(elt, "clip", "").equals("1"),
Double.parseDouble(getValue(elt, "rotation", "0")));
}
});
handlers.put("begin", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.begin();
}
});
handlers.put("move", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.moveTo(Double.parseDouble(elt.getAttribute("x")),
Double.parseDouble(elt.getAttribute("y")));
}
});
handlers.put("line", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.lineTo(Double.parseDouble(elt.getAttribute("x")),
Double.parseDouble(elt.getAttribute("y")));
}
});
handlers.put("quad", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.quadTo(Double.parseDouble(elt.getAttribute("x1")),
Double.parseDouble(elt.getAttribute("y1")),
Double.parseDouble(elt.getAttribute("x2")),
Double.parseDouble(elt.getAttribute("y2")));
}
});
handlers.put("curve", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.curveTo(Double.parseDouble(elt.getAttribute("x1")),
Double.parseDouble(elt.getAttribute("y1")),
Double.parseDouble(elt.getAttribute("x2")),
Double.parseDouble(elt.getAttribute("y2")),
Double.parseDouble(elt.getAttribute("x3")),
Double.parseDouble(elt.getAttribute("y3")));
}
});
handlers.put("close", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.close();
}
});
handlers.put("stroke", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.stroke();
}
});
handlers.put("fill", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.fill();
}
});
handlers.put("fillstroke", new IElementHandler()
{
public void parseElement(Element elt)
{
canvas.fillAndStroke();
}