Search in sources :

Example 1 with SVGTransformList

use of org.loboevolution.html.dom.svg.SVGTransformList in project LoboEvolution by LoboEvolution.

the class SVGLocatableImpl method getCTM.

/**
 * {@inheritDoc}
 */
@Override
public SVGMatrix getCTM() {
    SVGMatrix thisMatrix = new SVGMatrixImpl();
    if (this instanceof SVGTransformable) {
        SVGTransformList transofrm = ((SVGTransformable) this).getTransform().getAnimVal();
        if (transofrm != null) {
            SVGTransform consolidate = transofrm.consolidate();
            if (consolidate != null) {
                thisMatrix = new SVGMatrixImpl((SVGMatrixImpl) consolidate.getMatrix());
            }
        }
    }
    Node parent = getParentNode();
    while (parent != null && parent != getViewportElement() && !(parent instanceof SVGTransformable)) {
        parent = parent.getParentNode();
    }
    if (parent instanceof SVGTransformable) {
        SVGMatrix parentMatrix = ((SVGTransformable) parent).getCTM();
        return parentMatrix.multiply(thisMatrix);
    } else {
        return thisMatrix;
    }
}
Also used : SVGTransformable(org.loboevolution.html.dom.svg.SVGTransformable) SVGTransform(org.loboevolution.html.dom.svg.SVGTransform) SVGMatrix(org.loboevolution.html.dom.svg.SVGMatrix) Node(org.loboevolution.html.node.Node) SVGTransformList(org.loboevolution.html.dom.svg.SVGTransformList)

Example 2 with SVGTransformList

use of org.loboevolution.html.dom.svg.SVGTransformList in project LoboEvolution by LoboEvolution.

the class SVGTransformableImpl method getTransform.

/**
 * {@inheritDoc}
 */
@Override
public SVGAnimatedTransformList getTransform() {
    AbstractCSSProperties style = getStyle();
    String transformString = Strings.isNotBlank(style.getTransform()) ? style.getTransform() : this.getAttribute("transform");
    SVGTransformList createTransformList = SVGTransformListImpl.createTransformList(transformString);
    return new SVGAnimatedTransformListImpl((SVGTransformListImpl) createTransformList);
}
Also used : AbstractCSSProperties(org.loboevolution.html.style.AbstractCSSProperties) SVGTransformList(org.loboevolution.html.dom.svg.SVGTransformList)

Example 3 with SVGTransformList

use of org.loboevolution.html.dom.svg.SVGTransformList 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);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) SVGAnimatedTransformList(org.loboevolution.html.dom.svg.SVGAnimatedTransformList) Shape(java.awt.Shape) Paint(java.awt.Paint) SVGTransformList(org.loboevolution.html.dom.svg.SVGTransformList)

Aggregations

SVGTransformList (org.loboevolution.html.dom.svg.SVGTransformList)3 BasicStroke (java.awt.BasicStroke)1 Paint (java.awt.Paint)1 Shape (java.awt.Shape)1 SVGAnimatedTransformList (org.loboevolution.html.dom.svg.SVGAnimatedTransformList)1 SVGMatrix (org.loboevolution.html.dom.svg.SVGMatrix)1 SVGTransform (org.loboevolution.html.dom.svg.SVGTransform)1 SVGTransformable (org.loboevolution.html.dom.svg.SVGTransformable)1 Node (org.loboevolution.html.node.Node)1 AbstractCSSProperties (org.loboevolution.html.style.AbstractCSSProperties)1