aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorAdrian Cumiskey <acumiskey@apache.org>2008-11-21 14:29:17 +0000
committerAdrian Cumiskey <acumiskey@apache.org>2008-11-21 14:29:17 +0000
commit6a1c75ff782f5cd334d96456eb2db7981dfffaf2 (patch)
tree27c4b1eaeb9eb80cc49e1d5245ba027b726b6241 /src/java
parent005e36da82c0bb31c6f906d4052dd6f00d810798 (diff)
downloadxmlgraphics-fop-6a1c75ff782f5cd334d96456eb2db7981dfffaf2.tar.gz
xmlgraphics-fop-6a1c75ff782f5cd334d96456eb2db7981dfffaf2.zip
<svg:image/> y-axis positioning fix in AFPGraphics2D.
GraphicsState inner class created in GraphicsObject. Unused methods setFill() and incrementPageFontCount() removed. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@719587 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/afp/AFPDataObjectFactory.java11
-rw-r--r--src/java/org/apache/fop/afp/AFPGraphics2D.java10
-rw-r--r--src/java/org/apache/fop/afp/AFPPaintingState.java23
-rw-r--r--src/java/org/apache/fop/afp/AFPResourceManager.java9
-rw-r--r--src/java/org/apache/fop/afp/modca/AbstractDescriptor.java20
-rw-r--r--src/java/org/apache/fop/afp/modca/GraphicsObject.java55
-rw-r--r--src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java9
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderer.java3
8 files changed, 80 insertions, 60 deletions
diff --git a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java
index 5463a336b..aba181358 100644
--- a/src/java/org/apache/fop/afp/AFPDataObjectFactory.java
+++ b/src/java/org/apache/fop/afp/AFPDataObjectFactory.java
@@ -63,6 +63,9 @@ public class AFPDataObjectFactory {
public ObjectContainer createObjectContainer(AFPDataObjectInfo dataObjectInfo) {
ObjectContainer objectContainer = factory.createObjectContainer();
+ // set data object viewport (i.e. position, rotation, dimension, resolution)
+ objectContainer.setViewport(dataObjectInfo);
+
// set object classification
Registry.ObjectType objectType = dataObjectInfo.getObjectType();
AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo();
@@ -87,6 +90,10 @@ public class AFPDataObjectFactory {
public ImageObject createImage(AFPImageObjectInfo imageObjectInfo) {
// IOCA bitmap image
ImageObject imageObj = factory.createImageObject();
+
+ // set data object viewport (i.e. position, rotation, dimension, resolution)
+ imageObj.setViewport(imageObjectInfo);
+
if (imageObjectInfo.hasCompression()) {
int compression = imageObjectInfo.getCompression();
switch (compression) {
@@ -124,6 +131,10 @@ public class AFPDataObjectFactory {
public GraphicsObject createGraphic(AFPGraphicsObjectInfo graphicsObjectInfo) {
// set newly created graphics object in g2d
GraphicsObject graphicsObj = factory.createGraphicsObject();
+
+ // set data object viewport (i.e. position, rotation, dimension, resolution)
+ graphicsObj.setViewport(graphicsObjectInfo);
+
AFPGraphics2D g2d = graphicsObjectInfo.getGraphics2D();
g2d.setGraphicsObject(graphicsObj);
diff --git a/src/java/org/apache/fop/afp/AFPGraphics2D.java b/src/java/org/apache/fop/afp/AFPGraphics2D.java
index e8eebce43..ee160feca 100644
--- a/src/java/org/apache/fop/afp/AFPGraphics2D.java
+++ b/src/java/org/apache/fop/afp/AFPGraphics2D.java
@@ -580,13 +580,17 @@ public class AFPGraphics2D extends AbstractGraphics2D implements NativeImageHand
/** {@inheritDoc} */
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
- int width = img.getWidth();
- int height = img.getHeight();
+ int imgWidth = img.getWidth();
+ int imgHeight = img.getHeight();
AffineTransform at = paintingState.getData().getTransform();
AffineTransform gat = gc.getTransform();
+ int graphicsObjectHeight
+ = graphicsObj.getObjectEnvironmentGroup().getObjectAreaDescriptor().getHeight();
int x = (int)Math.round(at.getTranslateX() + gat.getTranslateX());
- int y = (int)Math.round(at.getTranslateY());
+ int y = (int)Math.round(at.getTranslateY() - (gat.getTranslateY() - graphicsObjectHeight));
+ int width = (int)Math.round(imgWidth * gat.getScaleX());
+ int height = (int)Math.round(imgHeight * -gat.getScaleY());
try {
// get image object info
AFPImageObjectInfo imageObjectInfo
diff --git a/src/java/org/apache/fop/afp/AFPPaintingState.java b/src/java/org/apache/fop/afp/AFPPaintingState.java
index bf710b18d..95a310bcb 100644
--- a/src/java/org/apache/fop/afp/AFPPaintingState.java
+++ b/src/java/org/apache/fop/afp/AFPPaintingState.java
@@ -224,20 +224,6 @@ implements Cloneable {
}
/**
- * Sets if the current painted shape is to be filled
- *
- * @param fill true if the current painted shape is to be filled
- * @return true if the fill value has changed
- */
- protected boolean setFill(boolean fill) {
- if (fill != ((AFPData)getData()).filled) {
- ((AFPData)getData()).filled = fill;
- return true;
- }
- return false;
- }
-
- /**
* Gets the current page fonts
*
* @return the current page fonts
@@ -247,15 +233,6 @@ implements Cloneable {
}
/**
- * Increments and returns the page font count
- *
- * @return the page font count
- */
- public int incrementPageFontCount() {
- return pagePaintingState.incrementFontCount();
- }
-
- /**
* Sets the page width
*
* @param pageWidth the page width
diff --git a/src/java/org/apache/fop/afp/AFPResourceManager.java b/src/java/org/apache/fop/afp/AFPResourceManager.java
index 9a521dbe7..164ebfd2d 100644
--- a/src/java/org/apache/fop/afp/AFPResourceManager.java
+++ b/src/java/org/apache/fop/afp/AFPResourceManager.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
-import org.apache.fop.afp.modca.AbstractDataObject;
import org.apache.fop.afp.modca.AbstractNamedAFPObject;
import org.apache.fop.afp.modca.IncludeObject;
import org.apache.fop.afp.modca.Registry;
@@ -136,18 +135,12 @@ public class AFPResourceManager {
AFPGraphicsObjectInfo graphicsObjectInfo = (AFPGraphicsObjectInfo)dataObjectInfo;
namedObj = dataObjectFactory.createGraphic(graphicsObjectInfo);
} else {
- // natively embedded object
+ // natively embedded data object
namedObj = dataObjectFactory.createObjectContainer(dataObjectInfo);
objectType = dataObjectInfo.getObjectType();
useInclude = objectType != null && objectType.isIncludable();
}
- // set data object viewport (i.e. position, rotation, dimension, resolution)
- if (namedObj instanceof AbstractDataObject) {
- AbstractDataObject dataObj = (AbstractDataObject)namedObj;
- dataObj.setViewport(dataObjectInfo);
- }
-
AFPResourceLevel resourceLevel = resourceInfo.getLevel();
ResourceGroup resourceGroup = streamer.getResourceGroup(resourceLevel);
useInclude &= resourceGroup != null;
diff --git a/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java b/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java
index c471794e9..8344bf0d1 100644
--- a/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java
+++ b/src/java/org/apache/fop/afp/modca/AbstractDescriptor.java
@@ -23,6 +23,7 @@ package org.apache.fop.afp.modca;
* Base class for AFP descriptor objects
*/
public abstract class AbstractDescriptor extends AbstractTripletStructuredObject {
+
/** width of this descriptor */
protected int width = 0;
/** height of this descriptor */
@@ -61,4 +62,23 @@ public abstract class AbstractDescriptor extends AbstractTripletStructuredObject
+ ", widthRes=" + widthRes
+ ", heightRes=" + heightRes;
}
+
+ /**
+ * Returns the width
+ *
+ * @return the width
+ */
+ public int getWidth() {
+ return this.width;
+ }
+
+ /**
+ * Returns the height
+ *
+ * @return the height
+ */
+ public int getHeight() {
+ return this.height;
+ }
+
}
diff --git a/src/java/org/apache/fop/afp/modca/GraphicsObject.java b/src/java/org/apache/fop/afp/modca/GraphicsObject.java
index 710e7364b..7602f7dd5 100644
--- a/src/java/org/apache/fop/afp/modca/GraphicsObject.java
+++ b/src/java/org/apache/fop/afp/modca/GraphicsObject.java
@@ -55,27 +55,15 @@ import org.apache.fop.afp.goca.GraphicsSetProcessColor;
*/
public class GraphicsObject extends AbstractDataObject {
- /** The graphics data */
+ /** the graphics data */
private GraphicsData currentData = null;
/** list of objects contained within this container */
protected List/*<GraphicsDrawingOrder>*/ objects
= new java.util.ArrayList/*<GraphicsDrawingOrder>*/();
- /** the current color */
- private Color currentColor;
-
- /** the current line type */
- private byte currentLineType;
-
- /** the current line width */
- private int currentLineWidth;
-
- /** the current fill pattern */
- private byte currentPatternSymbol;
-
- /** the current character set */
- private int currentCharacterSet;
+ /** the graphics state */
+ private final GraphicsState graphicsState = new GraphicsState();
/**
* Default constructor
@@ -151,9 +139,9 @@ public class GraphicsObject extends AbstractDataObject {
* @param color the active color to use
*/
public void setColor(Color color) {
- if (!color.equals(currentColor)) {
- this.currentColor = color;
+ if (!color.equals(graphicsState.color)) {
addObject(new GraphicsSetProcessColor(color));
+ graphicsState.color = color;
}
}
@@ -172,9 +160,9 @@ public class GraphicsObject extends AbstractDataObject {
* @param lineWidth the line width multiplier
*/
public void setLineWidth(int lineWidth) {
- if (lineWidth != currentLineWidth) {
- currentLineWidth = lineWidth;
+ if (lineWidth != graphicsState.lineWidth) {
addObject(new GraphicsSetLineWidth(lineWidth));
+ graphicsState.lineWidth = lineWidth;
}
}
@@ -184,9 +172,9 @@ public class GraphicsObject extends AbstractDataObject {
* @param lineType the line type
*/
public void setLineType(byte lineType) {
- if (lineType != currentLineType) {
- currentLineType = lineType;
+ if (lineType != graphicsState.lineType) {
addObject(new GraphicsSetLineType(lineType));
+ graphicsState.lineType = lineType;
}
}
@@ -207,9 +195,9 @@ public class GraphicsObject extends AbstractDataObject {
* @param the fill pattern of the next shape
*/
public void setPatternSymbol(byte patternSymbol) {
- if (currentPatternSymbol != patternSymbol) {
- currentPatternSymbol = patternSymbol;
+ if (patternSymbol != graphicsState.patternSymbol) {
addObject(new GraphicsSetPatternSymbol(patternSymbol));
+ graphicsState.patternSymbol = patternSymbol;
}
}
@@ -219,9 +207,9 @@ public class GraphicsObject extends AbstractDataObject {
* @param characterSet the character set (font) reference
*/
public void setCharacterSet(int characterSet) {
- if (currentCharacterSet != characterSet) {
- currentCharacterSet = characterSet;
+ if (characterSet != graphicsState.characterSet) {
addObject(new GraphicsSetCharacterSet(characterSet));
+ graphicsState.characterSet = characterSet;
}
}
@@ -377,4 +365,21 @@ public class GraphicsObject extends AbstractDataObject {
os.write(data);
}
+ /** the internal graphics state */
+ private class GraphicsState {
+ /** the current color */
+ private Color color;
+
+ /** the current line type */
+ private byte lineType;
+
+ /** the current line width */
+ private int lineWidth;
+
+ /** the current fill pattern */
+ private byte patternSymbol;
+
+ /** the current character set */
+ private int characterSet;
+ }
} \ No newline at end of file
diff --git a/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java b/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java
index 883a5446d..bc0cc5a63 100644
--- a/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java
+++ b/src/java/org/apache/fop/afp/modca/ObjectEnvironmentGroup.java
@@ -172,4 +172,13 @@ public final class ObjectEnvironmentGroup extends AbstractNamedAFPObject {
this.mapContainerData = mapContainerData;
}
+ /**
+ * Returns the object area descriptor
+ *
+ * @return the object area descriptor
+ */
+ public ObjectAreaDescriptor getObjectAreaDescriptor() {
+ return this.objectAreaDescriptor;
+ }
+
}
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java
index edc8f7662..903099610 100644
--- a/src/java/org/apache/fop/render/afp/AFPRenderer.java
+++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java
@@ -517,7 +517,8 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
// register font as necessary
String internalFontName = getInternalFontNameForArea(text);
- AFPFont font = (AFPFont)fontInfo.getFonts().get(internalFontName);
+ Map/*<String,FontMetrics>*/ fontMetricMap = fontInfo.getFonts();
+ AFPFont font = (AFPFont)fontMetricMap.get(internalFontName);
AFPPageFonts pageFonts = paintingState.getPageFonts();
AFPFontAttributes fontAttributes = pageFonts.registerFont(internalFontName, font, fontSize);