You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ke...@locus.apache.org on 2000/11/08 06:10:23 UTC
cvs commit: xml-fop/src/org/apache/fop/dom/svg GraphicElement.java
keiron 00/11/07 21:10:22
Modified: src/org/apache/fop/dom/svg GraphicElement.java
Log:
gets viewport element and transform matrix
Revision Changes Path
1.5 +53 -6 xml-fop/src/org/apache/fop/dom/svg/GraphicElement.java
Index: GraphicElement.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/dom/svg/GraphicElement.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- GraphicElement.java 2000/08/29 00:00:23 1.4
+++ GraphicElement.java 2000/11/08 05:10:21 1.5
@@ -1,4 +1,4 @@
-/*-- $Id: GraphicElement.java,v 1.4 2000/08/29 00:00:23 keiron Exp $ --
+/*-- $Id: GraphicElement.java,v 1.5 2000/11/08 05:10:21 keiron Exp $ --
============================================================================
The Apache Software License, Version 1.1
@@ -71,14 +71,33 @@
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 @@
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)