diff options
author | Keiron Liddle <keiron@apache.org> | 2000-11-08 05:10:21 +0000 |
---|---|---|
committer | Keiron Liddle <keiron@apache.org> | 2000-11-08 05:10:21 +0000 |
commit | ee02c5afb9640f494d5763df8452b63c21b25dc9 (patch) | |
tree | 93b0aa949d73d47b257507bed7276fa22bc6d897 /src/org/apache/fop/dom | |
parent | d9a4798d5dd355f282f13ade19addbf19f7a954a (diff) | |
download | xmlgraphics-fop-ee02c5afb9640f494d5763df8452b63c21b25dc9.tar.gz xmlgraphics-fop-ee02c5afb9640f494d5763df8452b63c21b25dc9.zip |
gets viewport element and transform matrix
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193748 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/dom')
-rw-r--r-- | src/org/apache/fop/dom/svg/GraphicElement.java | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/src/org/apache/fop/dom/svg/GraphicElement.java b/src/org/apache/fop/dom/svg/GraphicElement.java index 8be3028ed..676310f37 100644 --- a/src/org/apache/fop/dom/svg/GraphicElement.java +++ b/src/org/apache/fop/dom/svg/GraphicElement.java @@ -71,14 +71,33 @@ public abstract class GraphicElement extends SVGElementImpl implements SVGTransf SVGAnimatedTransformList transform; String xmlspace = "default"; - public SVGElement getNearestViewportElement( ) + public SVGElement getNearestViewportElement() { + Node node = getParentNode(); + while(node != null) { + if(node instanceof SVGGElement) { + return (SVGElement)node; + } else if(node instanceof SVGSVGElement) { + return (SVGElement)node; + } + node = getParentNode(); + } return null; } - public SVGElement getFarthestViewportElement( ) + public SVGElement getFarthestViewportElement() { - return null; + Node node = getParentNode(); + SVGElement viewport = null; + while(node != null) { + if(node instanceof SVGGElement) { + viewport = (SVGElement)node; + } else if(node instanceof SVGSVGElement) { + viewport = (SVGElement)node; + } + node = getParentNode(); + } + return viewport; } public SVGAnimatedTransformList getTransform() @@ -104,14 +123,42 @@ public abstract class GraphicElement extends SVGElementImpl implements SVGTransf return null; } + /** + * Returns the transformation matrix from current user units (i.e., after + * application of the transform attribute) to the viewport coordinate system + * for the nearestViewportElement. + */ public SVGMatrix getCTM() { - return null; + return transform.getBaseVal().consolidate().getMatrix(); } + /** + * Returns the transformation matrix from current user units (i.e., after + * application of the transform attribute) to the parent user agent's notice + * of a "pixel". For display devices, ideally this represents a physical + * screen pixel. For other devices or environments where physical pixel sizes + * are not known, then an algorithm similar to the CSS2 definition of a "pixel" + * can be used instead. + * This is the matrix that converts from the user space to the position + * on the screen. + */ public SVGMatrix getScreenCTM() { - return null; + if(transform == null) { + return new SVGMatrixImpl(); + } + Node node = getParentNode(); + SVGMatrix matrix = null; + if(node != null && node instanceof SVGTransformable) { + matrix = ((SVGTransformable)node).getScreenCTM(); + } + if(matrix != null) { + matrix = transform.getBaseVal().consolidate().getMatrix().multiply(matrix); + } else { + matrix = transform.getBaseVal().consolidate().getMatrix(); + } + return matrix; } public SVGMatrix getTransformToElement(SVGElement element) |