use of org.loboevolution.html.dom.svg.SVGAnimatedTransformList in project LoboEvolution by LoboEvolution.
the class SVGAElementImpl method createShape.
/**
* {@inheritDoc}
*/
@Override
public Shape createShape(AffineTransform transform) {
GeneralPath path = new GeneralPath();
if (hasChildNodes()) {
NodeListImpl children = (NodeListImpl) getChildNodes();
children.forEach(child -> {
Shape childShape = null;
if (child instanceof SVGGElementImpl) {
childShape = ((SVGGElementImpl) child).createShape(transform);
} else if (child instanceof SVGAElementImpl) {
childShape = ((SVGAElementImpl) child).createShape(transform);
} else if (child instanceof SVGImageElementImpl) {
SVGRect bbox = ((SVGImageElement) child).getBBox();
childShape = new Rectangle2D.Float(bbox.getX(), bbox.getY(), bbox.getWidth(), bbox.getHeight());
} else if (child instanceof SVGUseElementImpl) {
SVGRect bbox = ((SVGUseElement) child).getBBox();
childShape = new Rectangle2D.Float(bbox.getX(), bbox.getY(), bbox.getWidth(), bbox.getHeight());
} else if (child instanceof SVGSVGElementImpl) {
SVGSVGElement svg = (SVGSVGElement) child;
AffineTransform ctm = getCTM().getAffineTransform();
AffineTransform inverseTransform;
try {
inverseTransform = ctm.createInverse();
} catch (NoninvertibleTransformException e) {
inverseTransform = null;
}
float x = ((SVGLengthImpl) svg.getX()).getTransformedLength(inverseTransform);
float y = ((SVGLengthImpl) svg.getY()).getTransformedLength(inverseTransform);
float width = ((SVGLengthImpl) svg.getWidth()).getTransformedLength(inverseTransform);
float height = ((SVGLengthImpl) svg.getHeight()).getTransformedLength(inverseTransform);
childShape = new Rectangle2D.Float(x, y, width, height);
}
if (child instanceof SVGTransformable) {
SVGAnimatedTransformList childTransformList = ((SVGTransformable) child).getTransform();
AffineTransform childTransform = ((SVGTransformListImpl) childTransformList.getAnimVal()).getAffineTransform();
childShape = childTransform.createTransformedShape(childShape);
}
if (childShape != null) {
path.append(childShape, false);
}
});
}
return path;
}
use of org.loboevolution.html.dom.svg.SVGAnimatedTransformList in project LoboEvolution by LoboEvolution.
the class SVGGraphic method drawable.
/**
* <p>drawable.</p>
*
* @param graphics a {@link java.awt.Graphics2D} object.
* @param shape a {@link java.awt.Shape} object.
*/
protected void drawable(Graphics2D graphics, Shape shape) {
final Paint fillPaint = getFillPaint(shape);
final Paint strokePaint = getStrokelPaint(shape);
final BasicStroke stroke = getStroke();
SVGClipPathElementImpl clipPath = getClippingPath();
SVGAnimatedTransformList animateTransformList = getTransform();
graphics.setStroke(stroke);
if (clipPath != null) {
Shape clipShape = clipPath.getClippingShape(this);
if (clipShape != null) {
graphics.setClip(clipShape);
}
}
if (animateTransformList != null) {
SVGTransformList transformList = animateTransformList.getBaseVal();
if (transformList != null) {
transform(graphics, transformList);
}
}
if (fillPaint == null && strokePaint == null) {
graphics.setPaint(Color.BLACK);
graphics.fill(shape);
}
if (fillPaint != null) {
graphics.setPaint(fillPaint);
graphics.fill(shape);
}
if (strokePaint != null) {
graphics.setPaint(strokePaint);
graphics.draw(shape);
}
}
Aggregations