protected void build() throws SVGException
{
super.build();
StyleAttribute sty = new StyleAttribute();
//Load style string
String href = null;
if (getPres(sty.setName("xlink:href")))
{
href = sty.getStringValue();
}
//String href = attrs.getValue("xlink:href");
//If we have a link to another pattern, initialize ourselves with it's values
if (href != null)
{
//System.err.println("Gradient.loaderStartElement() href '" + href + "'");
try
{
URI src = getXMLBase().resolve(href);
PatternSVG patSrc = (PatternSVG) diagram.getUniverse().getElement(src);
gradientUnits = patSrc.gradientUnits;
x = patSrc.x;
y = patSrc.y;
width = patSrc.width;
height = patSrc.height;
viewBox = patSrc.viewBox;
patternXform.setTransform(patSrc.patternXform);
children.addAll(patSrc.children);
} catch (Exception e)
{
Logger.getLogger(SVGConst.SVG_LOGGER).log(Level.WARNING,
"Could not parse xlink:href", e);
}
}
String gradientUnits = "";
if (getPres(sty.setName("gradientUnits")))
{
gradientUnits = sty.getStringValue().toLowerCase();
}
if (gradientUnits.equals("userspaceonuse"))
{
this.gradientUnits = GU_USER_SPACE_ON_USE;
} else
{
this.gradientUnits = GU_OBJECT_BOUNDING_BOX;
}
String patternTransform = "";
if (getPres(sty.setName("patternTransform")))
{
patternTransform = sty.getStringValue();
}
patternXform = parseTransform(patternTransform);
if (getPres(sty.setName("x")))
{
x = sty.getFloatValueWithUnits();
}
if (getPres(sty.setName("y")))
{
y = sty.getFloatValueWithUnits();
}
if (getPres(sty.setName("width")))
{
width = sty.getFloatValueWithUnits();
}
if (getPres(sty.setName("height")))
{
height = sty.getFloatValueWithUnits();
}
if (getPres(sty.setName("viewBox")))
{
float[] dim = sty.getFloatList();
viewBox = new Rectangle2D.Float(dim[0], dim[1], dim[2], dim[3]);
}
preparePattern();
}