aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2008-07-28 13:01:58 +0000
committerJeremias Maerki <jeremias@apache.org>2008-07-28 13:01:58 +0000
commit909b93a2b94ac18245103d7f5e6231b0595f6fcd (patch)
tree38b5ca089374d4b96ee2a5e5cc512a481ae0c779 /src/java
parentdde2759a2110f3ab7b5d54712591087109e7b84a (diff)
downloadxmlgraphics-fop-909b93a2b94ac18245103d7f5e6231b0595f6fcd.tar.gz
xmlgraphics-fop-909b93a2b94ac18245103d7f5e6231b0595f6fcd.zip
Reduce code duplication and make the toString() methods available to the outside (need them for debugging later).
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@680338 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java36
-rw-r--r--src/java/org/apache/fop/render/intermediate/IFSerializer.java26
2 files changed, 39 insertions, 23 deletions
diff --git a/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java b/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java
index cd341be16..9e0f97699 100644
--- a/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java
+++ b/src/java/org/apache/fop/render/intermediate/AbstractXMLWritingIFPainter.java
@@ -120,7 +120,7 @@ public abstract class AbstractXMLWritingIFPainter extends AbstractIFPainter {
* @param sb the StringBuffer to write the transform method to
* @return the StringBuffer passed to this method
*/
- protected StringBuffer toString(AffineTransform transform, StringBuffer sb) {
+ public static StringBuffer toString(AffineTransform transform, StringBuffer sb) {
if (transform.isIdentity()) {
return sb;
}
@@ -146,6 +146,40 @@ public abstract class AbstractXMLWritingIFPainter extends AbstractIFPainter {
}
/**
+ * Converts an {@code AffineTransform} array to an SVG style transform method sequence.
+ * @param transforms the transformation matrix array
+ * @param sb the StringBuffer to write the transform method sequence to
+ * @return the StringBuffer passed to this method
+ */
+ public static StringBuffer toString(AffineTransform[] transforms, StringBuffer sb) {
+ for (int i = 0, c = transforms.length; i < c; i++) {
+ if (i > 0) {
+ sb.append(' ');
+ }
+ toString(transforms[i], sb);
+ }
+ return sb;
+ }
+
+ /**
+ * Converts an {@code AffineTransform} array to an SVG style transform method sequence.
+ * @param transforms the transformation matrix array
+ * @return the formatted array
+ */
+ public static String toString(AffineTransform[] transforms) {
+ return toString(transforms, new StringBuffer()).toString();
+ }
+
+ /**
+ * Converts an {@code AffineTransform} instance to an SVG style transform method.
+ * @param transform the transformation matrix
+ * @return the formatted array
+ */
+ public static String toString(AffineTransform transform) {
+ return toString(transform, new StringBuffer()).toString();
+ }
+
+ /**
* Convenience method to generate a startElement SAX event.
* @param localName the local name of the element
* @param atts the attributes
diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
index f05485a59..601732b39 100644
--- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java
+++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java
@@ -202,22 +202,13 @@ public class IFSerializer extends AbstractXMLWritingIFPainter implements IFConst
/** {@inheritDoc} */
public void startViewport(AffineTransform transform, Dimension size, Rectangle clipRect)
throws IFException {
- StringBuffer sb = new StringBuffer();
- toString(transform, sb);
- startViewport(sb.toString(), size, clipRect);
+ startViewport(toString(transform), size, clipRect);
}
/** {@inheritDoc} */
public void startViewport(AffineTransform[] transforms, Dimension size, Rectangle clipRect)
throws IFException {
- StringBuffer sb = new StringBuffer();
- for (int i = 0, c = transforms.length; i < c; i++) {
- if (i > 0) {
- sb.append(' ');
- }
- toString(transforms[i], sb);
- }
- startViewport(sb.toString(), size, clipRect);
+ startViewport(toString(transforms), size, clipRect);
}
private void startViewport(String transform, Dimension size, Rectangle clipRect) throws IFException {
@@ -248,21 +239,12 @@ public class IFSerializer extends AbstractXMLWritingIFPainter implements IFConst
/** {@inheritDoc} */
public void startGroup(AffineTransform[] transforms) throws IFException {
- StringBuffer sb = new StringBuffer();
- for (int i = 0, c = transforms.length; i < c; i++) {
- if (i > 0) {
- sb.append(' ');
- }
- toString(transforms[i], sb);
- }
- startGroup(sb.toString());
+ startGroup(toString(transforms));
}
/** {@inheritDoc} */
public void startGroup(AffineTransform transform) throws IFException {
- StringBuffer sb = new StringBuffer();
- toString(transform, sb);
- startGroup(sb.toString());
+ startGroup(toString(transform));
}
private void startGroup(String transform) throws IFException {