GradientFill fill = new GradientFill(start,end,angle,true);
return fill;
}
*/
if("linearGradient".equals(e.attr(attName))) {
Elem egrad = e.xpath("linearGradient").iterator().next();
LinearGradientFill fill = new LinearGradientFill()
.setStartX(Double.parseDouble(egrad.attr("startX")))
.setStartY(Double.parseDouble(egrad.attr("startY")))
.setEndX(Double.parseDouble(egrad.attr("endX")))
.setEndY(Double.parseDouble(egrad.attr("endY")))
;
if(egrad.hasAttr("startXSnapped")) fill.setStartXSnapped(LinearGradientFill.Snap.valueOf(egrad.attr("startXSnapped")));
if(egrad.hasAttr("startYSnapped"))fill.setStartYSnapped(LinearGradientFill.Snap.valueOf(egrad.attr("startYSnapped")));
if(egrad.hasAttr("endXSnapped"))fill.setEndXSnapped(LinearGradientFill.Snap.valueOf(egrad.attr("endXSnapped")));
if(egrad.hasAttr("endYSnapped"))fill.setEndYSnapped(LinearGradientFill.Snap.valueOf(egrad.attr("endYSnapped")));
for(Elem stop : egrad.xpath("stop")) {
fill.addStop(
Double.parseDouble(stop.attr("position")),
new FlatColor(stop.attr("color"))
);
}
return fill;
}
if("radialGradient".equals(e.attr(attName))) {
Elem egrad = e.xpath("radialGradient").iterator().next();
RadialGradientFill fill = new RadialGradientFill()
.setCenterX(Double.parseDouble(egrad.attr("centerX")))
.setCenterY(Double.parseDouble(egrad.attr("centerY")))
.setRadius(Double.parseDouble(egrad.attr("radius")))
;
for(Elem stop : egrad.xpath("stop")) {
fill.addStop(
Double.parseDouble(stop.attr("position")),
new FlatColor(stop.attr("color"))
);
}
return fill;
}
if("patternPaint".equals(e.attr(attName))) {
Elem pp = e.xpath("patternPaint").iterator().next();
PatternPaint pat = null;
u.p("using url " + pp.attr("relativeURL"));
try {
u.p("loading an image from a file");
String path = pp.attr("relativeURL");
String fullpath = "resources/"+path;
u.p("path = " + path);
u.p("fullpath = " + fullpath);
String zfname = zipFile.getName();
u.p("name = " + zfname);
String pth = zfname.substring(
zfname.lastIndexOf(File.separator)+1,
zfname.lastIndexOf(".")
)+"/"+fullpath;
u.p("pth = " + pth);
ZipEntry entry = zipFile.getEntry(pth);
u.p("entry = " + entry);
BufferedImage img = ImageIO.read(zipFile.getInputStream(entry));
pat = PatternPaint
.create(img,path)
.deriveNewStart(new Point2D.Double(
Double.parseDouble(pp.attr("startX")),
Double.parseDouble(pp.attr("startY"))))
.deriveNewEnd(new Point2D.Double(
Double.parseDouble(pp.attr("endX")),
Double.parseDouble(pp.attr("endY"))));
} catch (IOException e1) {
e1.printStackTrace();
}
return pat;
}