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 vh...@apache.org on 2012/04/05 18:20:17 UTC
svn commit: r1309921 [29/42] - in
/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./ examples/embedding/
examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/
examples/embedding/java/embedding/tools/ examples/plan/src/org/apa...
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java Thu Apr 5 16:19:19 2012
@@ -34,6 +34,7 @@ import org.apache.xmlgraphics.image.load
import org.apache.xmlgraphics.util.QName;
import org.apache.xmlgraphics.util.UnitConv;
+import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.BlockViewport;
@@ -44,7 +45,7 @@ import org.apache.fop.area.RegionViewpor
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.ForeignObject;
import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.Viewport;
+import org.apache.fop.area.inline.InlineViewport;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionElementMapping;
import org.apache.fop.fonts.FontMetrics;
@@ -57,6 +58,13 @@ import org.apache.fop.traits.BorderProps
public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
/**
+ * @param userAgent the user agent that contains configuration details. This cannot be null.
+ */
+ public AbstractPathOrientedRenderer(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
+ /**
* Handle block traits.
* The block could be any sort of block with any positioning
* so this should render the traits such as border and background
@@ -65,29 +73,31 @@ public abstract class AbstractPathOrient
* @param block the block to render the traits
*/
protected void handleBlockTraits(Block block) {
- int borderPaddingStart = block.getBorderAndPaddingWidthStart();
- int borderPaddingBefore = block.getBorderAndPaddingWidthBefore();
+ float borderPaddingStart = block.getBorderAndPaddingWidthStart() / 1000f;
+ float borderPaddingEnd = block.getBorderAndPaddingWidthEnd() / 1000f;
+ float borderPaddingBefore = block.getBorderAndPaddingWidthBefore() / 1000f;
+ float borderPaddingAfter = block.getBorderAndPaddingWidthAfter() / 1000f;
float startx = currentIPPosition / 1000f;
float starty = currentBPPosition / 1000f;
float width = block.getIPD() / 1000f;
float height = block.getBPD() / 1000f;
- /* using start-indent now
- Integer spaceStart = (Integer) block.getTrait(Trait.SPACE_START);
- if (spaceStart != null) {
- startx += spaceStart.floatValue() / 1000f;
- }*/
- startx += block.getStartIndent() / 1000f;
- startx -= block.getBorderAndPaddingWidthStart() / 1000f;
-
- width += borderPaddingStart / 1000f;
- width += block.getBorderAndPaddingWidthEnd() / 1000f;
- height += borderPaddingBefore / 1000f;
- height += block.getBorderAndPaddingWidthAfter() / 1000f;
+ int level = block.getBidiLevel();
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ startx += block.getStartIndent() / 1000f;
+ startx -= borderPaddingStart;
+ } else {
+ startx += block.getEndIndent() / 1000f;
+ startx -= borderPaddingEnd;
+ }
+
+ width += borderPaddingStart;
+ width += borderPaddingEnd;
+ height += borderPaddingBefore;
+ height += borderPaddingAfter;
- drawBackAndBorders(block, startx, starty,
- width, height);
+ drawBackAndBorders(block, startx, starty, width, height);
}
/**
@@ -106,7 +116,12 @@ public abstract class AbstractPathOrient
// adjust the current position according to region borders and padding
currentBPPosition = referenceArea.getBorderAndPaddingWidthBefore();
- currentIPPosition = referenceArea.getBorderAndPaddingWidthStart();
+ int level = region.getBidiLevel();
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ currentIPPosition = referenceArea.getBorderAndPaddingWidthStart();
+ } else {
+ currentIPPosition = referenceArea.getBorderAndPaddingWidthEnd();
+ }
// draw background (traits are in the RegionViewport)
// and borders (traits are in the RegionReference)
drawBackAndBorders(region, referenceArea, startx, starty, width, height);
@@ -153,9 +168,9 @@ public abstract class AbstractPathOrient
drawBackground(startx, starty, width, height,
(Trait.Background) backgroundArea.getTrait(Trait.BACKGROUND),
- bpsBefore, bpsAfter, bpsStart, bpsEnd);
+ bpsBefore, bpsAfter, bpsStart, bpsEnd, backgroundArea.getBidiLevel());
drawBorders(startx, starty, width, height,
- bpsBefore, bpsAfter, bpsStart, bpsEnd);
+ bpsBefore, bpsAfter, bpsStart, bpsEnd, borderArea.getBidiLevel());
}
/**
@@ -171,11 +186,44 @@ public abstract class AbstractPathOrient
* @param bpsAfter the border-after traits
* @param bpsStart the border-start traits
* @param bpsEnd the border-end traits
+ * @param level of bidirectional embedding
*/
protected void drawBackground( // CSOK: ParameterNumber
float startx, float starty, float width, float height, Trait.Background back,
BorderProps bpsBefore, BorderProps bpsAfter,
- BorderProps bpsStart, BorderProps bpsEnd) {
+ BorderProps bpsStart, BorderProps bpsEnd, int level) {
+ BorderProps bpsTop = bpsBefore;
+ BorderProps bpsBottom = bpsAfter;
+ BorderProps bpsLeft;
+ BorderProps bpsRight;
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ bpsLeft = bpsStart;
+ bpsRight = bpsEnd;
+ } else {
+ bpsLeft = bpsEnd;
+ bpsRight = bpsStart;
+ }
+ drawBackground(startx, starty, width, height, back, bpsTop, bpsBottom, bpsLeft, bpsRight);
+ }
+
+ /**
+ * Draw the background.
+ * This draws the background given the position and the traits.
+ *
+ * @param startx the start x position
+ * @param starty the start y position
+ * @param width the width of the area
+ * @param height the height of the area
+ * @param back the background traits
+ * @param bpsTop the border specification on the top edge
+ * @param bpsBottom the border traits associated with bottom edge
+ * @param bpsLeft the border specification on the left edge
+ * @param bpsRight the border specification on the right edge
+ */
+ protected void drawBackground( // CSOK: ParameterNumber
+ float startx, float starty, float width, float height, Trait.Background back,
+ BorderProps bpsTop, BorderProps bpsBottom,
+ BorderProps bpsLeft, BorderProps bpsRight) {
if (back != null) {
endTextObject();
@@ -184,19 +232,19 @@ public abstract class AbstractPathOrient
float sy = starty;
float paddRectWidth = width;
float paddRectHeight = height;
- if (bpsStart != null) {
- sx += bpsStart.width / 1000f;
- paddRectWidth -= bpsStart.width / 1000f;
- }
- if (bpsBefore != null) {
- sy += bpsBefore.width / 1000f;
- paddRectHeight -= bpsBefore.width / 1000f;
+ if (bpsLeft != null) {
+ sx += bpsLeft.width / 1000f;
+ paddRectWidth -= bpsLeft.width / 1000f;
+ }
+ if (bpsTop != null) {
+ sy += bpsTop.width / 1000f;
+ paddRectHeight -= bpsTop.width / 1000f;
}
- if (bpsEnd != null) {
- paddRectWidth -= bpsEnd.width / 1000f;
+ if (bpsRight != null) {
+ paddRectWidth -= bpsRight.width / 1000f;
}
- if (bpsAfter != null) {
- paddRectHeight -= bpsAfter.width / 1000f;
+ if (bpsBottom != null) {
+ paddRectHeight -= bpsBottom.width / 1000f;
}
if (back.getColor() != null) {
@@ -256,86 +304,99 @@ public abstract class AbstractPathOrient
* @param starty the start y position
* @param width the width of the area
* @param height the height of the area
- * @param bpsBefore the border-before traits
- * @param bpsAfter the border-after traits
- * @param bpsStart the border-start traits
- * @param bpsEnd the border-end traits
+ * @param bpsBefore the border traits associated with before edge
+ * @param bpsAfter the border traits associated with after edge
+ * @param bpsStart the border traits associated with start edge
+ * @param bpsEnd the border traits associated with end edge
+ * @param level of bidirectional embedding
*/
protected void drawBorders( // CSOK: ParameterNumber
float startx, float starty, float width, float height,
BorderProps bpsBefore, BorderProps bpsAfter,
- BorderProps bpsStart, BorderProps bpsEnd) {
+ BorderProps bpsStart, BorderProps bpsEnd, int level) {
Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height);
- drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
+ BorderProps bpsTop = bpsBefore;
+ BorderProps bpsBottom = bpsAfter;
+ BorderProps bpsLeft;
+ BorderProps bpsRight;
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ bpsLeft = bpsStart;
+ bpsRight = bpsEnd;
+ } else {
+ bpsLeft = bpsEnd;
+ bpsRight = bpsStart;
+ }
+ drawBorders(borderRect, bpsTop, bpsBottom, bpsLeft, bpsRight);
}
- private static final int BEFORE = 0;
- private static final int END = 1;
- private static final int AFTER = 2;
- private static final int START = 3;
+ private static final int TOP = 0;
+ private static final int RIGHT = 1;
+ private static final int BOTTOM = 2;
+ private static final int LEFT = 3;
/**
* Draws borders.
* @param borderRect the border rectangle
- * @param bpsBefore the border specification on the before side
- * @param bpsAfter the border specification on the after side
- * @param bpsStart the border specification on the start side
- * @param bpsEnd the border specification on the end side
+ * @param bpsTop the border specification on the top edge
+ * @param bpsBottom the border traits associated with bottom edge
+ * @param bpsLeft the border specification on the left edge
+ * @param bpsRight the border specification on the right edge
*/
protected void drawBorders( // CSOK: MethodLength
Rectangle2D.Float borderRect,
- BorderProps bpsBefore, BorderProps bpsAfter, BorderProps bpsStart, BorderProps bpsEnd) {
+ BorderProps bpsTop, BorderProps bpsBottom, BorderProps bpsLeft, BorderProps bpsRight) {
//TODO generalize each of the four conditions into using a parameterized drawBorder()
boolean[] border = new boolean[] {
- (bpsBefore != null), (bpsEnd != null),
- (bpsAfter != null), (bpsStart != null)};
+ (bpsTop != null), (bpsRight != null),
+ (bpsBottom != null), (bpsLeft != null)};
float startx = borderRect.x;
float starty = borderRect.y;
float width = borderRect.width;
float height = borderRect.height;
float[] borderWidth = new float[] {
- (border[BEFORE] ? bpsBefore.width / 1000f : 0.0f),
- (border[END] ? bpsEnd.width / 1000f : 0.0f),
- (border[AFTER] ? bpsAfter.width / 1000f : 0.0f),
- (border[START] ? bpsStart.width / 1000f : 0.0f)};
+ (border[TOP] ? bpsTop.width / 1000f : 0.0f),
+ (border[RIGHT] ? bpsRight.width / 1000f : 0.0f),
+ (border[BOTTOM] ? bpsBottom.width / 1000f : 0.0f),
+ (border[LEFT] ? bpsLeft.width / 1000f : 0.0f)};
float[] clipw = new float[] {
- BorderProps.getClippedWidth(bpsBefore) / 1000f,
- BorderProps.getClippedWidth(bpsEnd) / 1000f,
- BorderProps.getClippedWidth(bpsAfter) / 1000f,
- BorderProps.getClippedWidth(bpsStart) / 1000f};
- starty += clipw[BEFORE];
- height -= clipw[BEFORE];
- height -= clipw[AFTER];
- startx += clipw[START];
- width -= clipw[START];
- width -= clipw[END];
+ BorderProps.getClippedWidth(bpsTop) / 1000f,
+ BorderProps.getClippedWidth(bpsRight) / 1000f,
+ BorderProps.getClippedWidth(bpsBottom) / 1000f,
+ BorderProps.getClippedWidth(bpsLeft) / 1000f};
+
+ starty += clipw[TOP];
+ height -= clipw[TOP];
+ height -= clipw[BOTTOM];
+ startx += clipw[LEFT];
+ width -= clipw[LEFT];
+ width -= clipw[RIGHT];
boolean[] slant = new boolean[] {
- (border[START] && border[BEFORE]),
- (border[BEFORE] && border[END]),
- (border[END] && border[AFTER]),
- (border[AFTER] && border[START])};
- if (bpsBefore != null) {
+ (border[LEFT] && border[TOP]),
+ (border[TOP] && border[RIGHT]),
+ (border[RIGHT] && border[BOTTOM]),
+ (border[BOTTOM] && border[LEFT])};
+ if (bpsTop != null) {
endTextObject();
float sx1 = startx;
- float sx2 = (slant[BEFORE] ? sx1 + borderWidth[START] - clipw[START] : sx1);
+ float sx2 = (slant[TOP] ? sx1 + borderWidth[LEFT] - clipw[LEFT] : sx1);
float ex1 = startx + width;
- float ex2 = (slant[END] ? ex1 - borderWidth[END] + clipw[END] : ex1);
- float outery = starty - clipw[BEFORE];
- float clipy = outery + clipw[BEFORE];
- float innery = outery + borderWidth[BEFORE];
+ float ex2 = (slant[RIGHT] ? ex1 - borderWidth[RIGHT] + clipw[RIGHT] : ex1);
+ float outery = starty - clipw[TOP];
+ float clipy = outery + clipw[TOP];
+ float innery = outery + borderWidth[TOP];
saveGraphicsState();
moveTo(sx1, clipy);
float sx1a = sx1;
float ex1a = ex1;
- if (bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
- if (bpsStart != null && bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
- sx1a -= clipw[START];
+ if (bpsTop.mode == BorderProps.COLLAPSE_OUTER) {
+ if (bpsLeft != null && bpsLeft.mode == BorderProps.COLLAPSE_OUTER) {
+ sx1a -= clipw[LEFT];
}
- if (bpsEnd != null && bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
- ex1a += clipw[END];
+ if (bpsRight != null && bpsRight.mode == BorderProps.COLLAPSE_OUTER) {
+ ex1a += clipw[RIGHT];
}
lineTo(sx1a, outery);
lineTo(ex1a, outery);
@@ -346,30 +407,30 @@ public abstract class AbstractPathOrient
closePath();
clip();
drawBorderLine(sx1a, outery, ex1a, innery, true, true,
- bpsBefore.style, bpsBefore.color);
+ bpsTop.style, bpsTop.color);
restoreGraphicsState();
}
- if (bpsEnd != null) {
+ if (bpsRight != null) {
endTextObject();
float sy1 = starty;
- float sy2 = (slant[END] ? sy1 + borderWidth[BEFORE] - clipw[BEFORE] : sy1);
+ float sy2 = (slant[RIGHT] ? sy1 + borderWidth[TOP] - clipw[TOP] : sy1);
float ey1 = starty + height;
- float ey2 = (slant[AFTER] ? ey1 - borderWidth[AFTER] + clipw[AFTER] : ey1);
- float outerx = startx + width + clipw[END];
- float clipx = outerx - clipw[END];
- float innerx = outerx - borderWidth[END];
+ float ey2 = (slant[BOTTOM] ? ey1 - borderWidth[BOTTOM] + clipw[BOTTOM] : ey1);
+ float outerx = startx + width + clipw[RIGHT];
+ float clipx = outerx - clipw[RIGHT];
+ float innerx = outerx - borderWidth[RIGHT];
saveGraphicsState();
moveTo(clipx, sy1);
float sy1a = sy1;
float ey1a = ey1;
- if (bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
- if (bpsBefore != null && bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
- sy1a -= clipw[BEFORE];
+ if (bpsRight.mode == BorderProps.COLLAPSE_OUTER) {
+ if (bpsTop != null && bpsTop.mode == BorderProps.COLLAPSE_OUTER) {
+ sy1a -= clipw[TOP];
}
- if (bpsAfter != null && bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
- ey1a += clipw[AFTER];
+ if (bpsBottom != null && bpsBottom.mode == BorderProps.COLLAPSE_OUTER) {
+ ey1a += clipw[BOTTOM];
}
lineTo(outerx, sy1a);
lineTo(outerx, ey1a);
@@ -379,30 +440,31 @@ public abstract class AbstractPathOrient
lineTo(innerx, sy2);
closePath();
clip();
- drawBorderLine(innerx, sy1a, outerx, ey1a, false, false, bpsEnd.style, bpsEnd.color);
+ drawBorderLine(innerx, sy1a, outerx, ey1a, false, false,
+ bpsRight.style, bpsRight.color);
restoreGraphicsState();
}
- if (bpsAfter != null) {
+ if (bpsBottom != null) {
endTextObject();
float sx1 = startx;
- float sx2 = (slant[START] ? sx1 + borderWidth[START] - clipw[START] : sx1);
+ float sx2 = (slant[LEFT] ? sx1 + borderWidth[LEFT] - clipw[LEFT] : sx1);
float ex1 = startx + width;
- float ex2 = (slant[AFTER] ? ex1 - borderWidth[END] + clipw[END] : ex1);
- float outery = starty + height + clipw[AFTER];
- float clipy = outery - clipw[AFTER];
- float innery = outery - borderWidth[AFTER];
+ float ex2 = (slant[BOTTOM] ? ex1 - borderWidth[RIGHT] + clipw[RIGHT] : ex1);
+ float outery = starty + height + clipw[BOTTOM];
+ float clipy = outery - clipw[BOTTOM];
+ float innery = outery - borderWidth[BOTTOM];
saveGraphicsState();
moveTo(ex1, clipy);
float sx1a = sx1;
float ex1a = ex1;
- if (bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
- if (bpsStart != null && bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
- sx1a -= clipw[START];
+ if (bpsBottom.mode == BorderProps.COLLAPSE_OUTER) {
+ if (bpsLeft != null && bpsLeft.mode == BorderProps.COLLAPSE_OUTER) {
+ sx1a -= clipw[LEFT];
}
- if (bpsEnd != null && bpsEnd.mode == BorderProps.COLLAPSE_OUTER) {
- ex1a += clipw[END];
+ if (bpsRight != null && bpsRight.mode == BorderProps.COLLAPSE_OUTER) {
+ ex1a += clipw[RIGHT];
}
lineTo(ex1a, outery);
lineTo(sx1a, outery);
@@ -412,30 +474,31 @@ public abstract class AbstractPathOrient
lineTo(ex2, innery);
closePath();
clip();
- drawBorderLine(sx1a, innery, ex1a, outery, true, false, bpsAfter.style, bpsAfter.color);
+ drawBorderLine(sx1a, innery, ex1a, outery, true, false,
+ bpsBottom.style, bpsBottom.color);
restoreGraphicsState();
}
- if (bpsStart != null) {
+ if (bpsLeft != null) {
endTextObject();
float sy1 = starty;
- float sy2 = (slant[BEFORE] ? sy1 + borderWidth[BEFORE] - clipw[BEFORE] : sy1);
+ float sy2 = (slant[TOP] ? sy1 + borderWidth[TOP] - clipw[TOP] : sy1);
float ey1 = sy1 + height;
- float ey2 = (slant[START] ? ey1 - borderWidth[AFTER] + clipw[AFTER] : ey1);
- float outerx = startx - clipw[START];
- float clipx = outerx + clipw[START];
- float innerx = outerx + borderWidth[START];
+ float ey2 = (slant[LEFT] ? ey1 - borderWidth[BOTTOM] + clipw[BOTTOM] : ey1);
+ float outerx = startx - clipw[LEFT];
+ float clipx = outerx + clipw[LEFT];
+ float innerx = outerx + borderWidth[LEFT];
saveGraphicsState();
moveTo(clipx, ey1);
float sy1a = sy1;
float ey1a = ey1;
- if (bpsStart.mode == BorderProps.COLLAPSE_OUTER) {
- if (bpsBefore != null && bpsBefore.mode == BorderProps.COLLAPSE_OUTER) {
- sy1a -= clipw[BEFORE];
+ if (bpsLeft.mode == BorderProps.COLLAPSE_OUTER) {
+ if (bpsTop != null && bpsTop.mode == BorderProps.COLLAPSE_OUTER) {
+ sy1a -= clipw[TOP];
}
- if (bpsAfter != null && bpsAfter.mode == BorderProps.COLLAPSE_OUTER) {
- ey1a += clipw[AFTER];
+ if (bpsBottom != null && bpsBottom.mode == BorderProps.COLLAPSE_OUTER) {
+ ey1a += clipw[BOTTOM];
}
lineTo(outerx, ey1a);
lineTo(outerx, sy1a);
@@ -445,7 +508,7 @@ public abstract class AbstractPathOrient
lineTo(innerx, ey2);
closePath();
clip();
- drawBorderLine(outerx, sy1a, innerx, ey1a, false, true, bpsStart.style, bpsStart.color);
+ drawBorderLine(outerx, sy1a, innerx, ey1a, false, true, bpsLeft.style, bpsLeft.color);
restoreGraphicsState();
}
}
@@ -458,16 +521,16 @@ public abstract class AbstractPathOrient
*/
protected void renderInlineAreaBackAndBorders(InlineArea area) {
float borderPaddingStart = area.getBorderAndPaddingWidthStart() / 1000f;
+ float borderPaddingEnd = area.getBorderAndPaddingWidthEnd() / 1000f;
float borderPaddingBefore = area.getBorderAndPaddingWidthBefore() / 1000f;
- float bpwidth = borderPaddingStart
- + (area.getBorderAndPaddingWidthEnd() / 1000f);
- float bpheight = borderPaddingBefore
- + (area.getBorderAndPaddingWidthAfter() / 1000f);
+ float borderPaddingAfter = area.getBorderAndPaddingWidthAfter() / 1000f;
+ float bpwidth = borderPaddingStart + borderPaddingEnd;
+ float bpheight = borderPaddingBefore + borderPaddingAfter;
float height = area.getBPD() / 1000f;
if (height != 0.0f || bpheight != 0.0f && bpwidth != 0.0f) {
float x = currentIPPosition / 1000f;
- float y = (currentBPPosition + area.getOffset()) / 1000f;
+ float y = (currentBPPosition + area.getBlockProgressionOffset()) / 1000f;
float width = area.getIPD() / 1000f;
drawBackAndBorders(area, x, y - borderPaddingBefore
, width + bpwidth
@@ -504,10 +567,16 @@ public abstract class AbstractPathOrient
AffineTransform positionTransform = new AffineTransform();
positionTransform.translate(bv.getXOffset(), bv.getYOffset());
+ int level = bv.getBidiLevel();
int borderPaddingStart = bv.getBorderAndPaddingWidthStart();
+ int borderPaddingEnd = bv.getBorderAndPaddingWidthEnd();
//"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle
- positionTransform.translate(-borderPaddingStart, -borderPaddingBefore);
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ positionTransform.translate(-borderPaddingStart, -borderPaddingBefore);
+ } else {
+ positionTransform.translate(-borderPaddingEnd, -borderPaddingBefore);
+ }
//Free transformation for the block-container viewport
String transf;
@@ -528,21 +597,25 @@ public abstract class AbstractPathOrient
//Background and borders
float borderPaddingWidth
- = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
+ = (borderPaddingStart + borderPaddingEnd) / 1000f;
float borderPaddingHeight
= (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f;
drawBackAndBorders(bv, 0, 0, width + borderPaddingWidth, height + borderPaddingHeight);
//Shift to content rectangle after border painting
AffineTransform contentRectTransform = new AffineTransform();
- contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
+ } else {
+ contentRectTransform.translate(borderPaddingEnd, borderPaddingBefore);
+ }
if (!contentRectTransform.isIdentity()) {
establishTransformationMatrix(contentRectTransform);
}
//Clipping
- if (bv.getClip()) {
+ if (bv.hasClip()) {
clipRect(0f, 0f, width, height);
}
@@ -593,8 +666,8 @@ public abstract class AbstractPathOrient
//Now adjust for border/padding
currentBPPosition += borderPaddingBefore;
- Rectangle2D clippingRect = null;
- if (bv.getClip()) {
+ Rectangle clippingRect = null;
+ if (bv.hasClip()) {
clippingRect = new Rectangle(currentIPPosition, currentBPPosition,
bv.getIPD(), bv.getBPD());
}
@@ -685,30 +758,33 @@ public abstract class AbstractPathOrient
* This renders an inline viewport by clipping if necessary.
* @param viewport the viewport to handle
*/
- public void renderViewport(Viewport viewport) {
-
+ public void renderInlineViewport(InlineViewport viewport) {
+ int level = viewport.getBidiLevel();
float x = currentIPPosition / 1000f;
- float y = (currentBPPosition + viewport.getOffset()) / 1000f;
+ float y = (currentBPPosition + viewport.getBlockProgressionOffset()) / 1000f;
float width = viewport.getIPD() / 1000f;
float height = viewport.getBPD() / 1000f;
// TODO: Calculate the border rect correctly.
float borderPaddingStart = viewport.getBorderAndPaddingWidthStart() / 1000f;
+ float borderPaddingEnd = viewport.getBorderAndPaddingWidthEnd() / 1000f;
float borderPaddingBefore = viewport.getBorderAndPaddingWidthBefore() / 1000f;
- float bpwidth = borderPaddingStart
- + (viewport.getBorderAndPaddingWidthEnd() / 1000f);
- float bpheight = borderPaddingBefore
- + (viewport.getBorderAndPaddingWidthAfter() / 1000f);
+ float borderPaddingAfter = viewport.getBorderAndPaddingWidthAfter() / 1000f;
+ float bpwidth = borderPaddingStart + borderPaddingEnd;
+ float bpheight = borderPaddingBefore + borderPaddingAfter;
drawBackAndBorders(viewport, x, y, width + bpwidth, height + bpheight);
- if (viewport.getClip()) {
+ if (viewport.hasClip()) {
saveGraphicsState();
-
- clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height);
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ clipRect(x + borderPaddingStart, y + borderPaddingBefore, width, height);
+ } else {
+ clipRect(x + borderPaddingEnd, y + borderPaddingBefore, width, height);
+ }
}
- super.renderViewport(viewport);
+ super.renderInlineViewport(viewport);
- if (viewport.getClip()) {
+ if (viewport.hasClip()) {
restoreGraphicsState();
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/AbstractRenderer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/AbstractRenderer.java Thu Apr 5 16:19:19 2012
@@ -25,8 +25,8 @@ import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Set;
import org.w3c.dom.Document;
@@ -56,16 +56,17 @@ import org.apache.fop.area.RegionViewpor
import org.apache.fop.area.Span;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.Container;
+import org.apache.fop.area.inline.FilledArea;
import org.apache.fop.area.inline.ForeignObject;
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.InlineBlockParent;
import org.apache.fop.area.inline.InlineParent;
+import org.apache.fop.area.inline.InlineViewport;
import org.apache.fop.area.inline.Leader;
import org.apache.fop.area.inline.Space;
import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.Viewport;
import org.apache.fop.area.inline.WordArea;
import org.apache.fop.fo.Constants;
import org.apache.fop.fonts.FontInfo;
@@ -116,16 +117,16 @@ public abstract class AbstractRenderer
/** {@inheritDoc} */
public abstract void setupFontInfo(FontInfo fontInfo) throws FOPException;
- /** {@inheritDoc} */
- public void setUserAgent(FOUserAgent agent) {
- userAgent = agent;
+ /**
+ *
+ * @param userAgent the user agent that contains configuration details. This cannot be null.
+ */
+ public AbstractRenderer(FOUserAgent userAgent) {
+ this.userAgent = userAgent;
}
/** {@inheritDoc} */
public FOUserAgent getUserAgent() {
- if (userAgent == null) {
- throw new IllegalStateException("FOUserAgent has not been set on Renderer");
- }
return userAgent;
}
@@ -152,6 +153,10 @@ public abstract class AbstractRenderer
return false;
}
+ /** {@inheritDoc} */
+ public void setDocumentLocale(Locale locale) {
+ }
+
/**
* {@inheritDoc}
*/
@@ -208,15 +213,17 @@ public abstract class AbstractRenderer
return sb.toString();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ * @deprecated
+ */
public void startPageSequence(LineArea seqTitle) {
//do nothing
}
/** {@inheritDoc} */
public void startPageSequence(PageSequence pageSequence) {
- //TODO Discuss removing old deprecated method startPageSequence(LineArea)
- startPageSequence(pageSequence.getTitle());
+ // do nothing
}
// normally this would be overriden to create a page in the
@@ -276,7 +283,6 @@ public abstract class AbstractRenderer
* @param port The region viewport to be rendered
*/
protected void renderRegionViewport(RegionViewport port) {
- Rectangle2D view = port.getViewArea();
// The CTM will transform coordinates relative to
// this region-reference area into page coords, so
// set origin for the region to 0,0.
@@ -287,7 +293,7 @@ public abstract class AbstractRenderer
handleRegionTraits(port);
// shouldn't the viewport have the CTM
- startVParea(regionReference.getCTM(), port.isClip() ? view : null);
+ startVParea(regionReference.getCTM(), port.getClipRectangle());
// do after starting viewport area
if (regionReference.getRegionClass() == FO_REGION_BODY) {
renderBodyRegion((BodyRegion) regionReference);
@@ -304,7 +310,7 @@ public abstract class AbstractRenderer
* @param clippingRect the clipping rectangle if the viewport should be clipping,
* null if no clipping is performed.
*/
- protected abstract void startVParea(CTM ctm, Rectangle2D clippingRect);
+ protected abstract void startVParea(CTM ctm, Rectangle clippingRect);
/**
* Signals exit from a viewport area. Subclasses can restore transformation matrices
@@ -396,22 +402,34 @@ public abstract class AbstractRenderer
* @param mr The main reference area
*/
protected void renderMainReference(MainReference mr) {
- int saveIPPos = currentIPPosition;
-
Span span = null;
List spans = mr.getSpans();
int saveBPPos = currentBPPosition;
int saveSpanBPPos = saveBPPos;
+ int saveIPPos = currentIPPosition;
for (int count = 0; count < spans.size(); count++) {
span = (Span) spans.get(count);
+ int level = span.getBidiLevel();
+ if ( level < 0 ) {
+ level = 0;
+ }
+ if ( ( level & 1 ) == 1 ) {
+ currentIPPosition += span.getIPD();
+ currentIPPosition += mr.getColumnGap();
+ }
for (int c = 0; c < span.getColumnCount(); c++) {
NormalFlow flow = span.getNormalFlow(c);
-
if (flow != null) {
currentBPPosition = saveSpanBPPos;
+ if ( ( level & 1 ) == 1 ) {
+ currentIPPosition -= flow.getIPD();
+ currentIPPosition -= mr.getColumnGap();
+ }
renderFlow(flow);
- currentIPPosition += flow.getIPD();
- currentIPPosition += mr.getColumnGap();
+ if ( ( level & 1 ) == 0 ) {
+ currentIPPosition += flow.getIPD();
+ currentIPPosition += mr.getColumnGap();
+ }
}
}
currentIPPosition = saveIPPos;
@@ -459,8 +477,8 @@ public abstract class AbstractRenderer
int saveIP = currentIPPosition;
int saveBP = currentBPPosition;
- Rectangle2D clippingRect = null;
- if (bv.getClip()) {
+ Rectangle clippingRect = null;
+ if (bv.hasClip()) {
clippingRect = new Rectangle(saveIP, saveBP, bv.getIPD(), bv.getBPD());
}
@@ -506,17 +524,10 @@ public abstract class AbstractRenderer
*/
protected void renderBlocks(Block parent, List blocks) {
int saveIP = currentIPPosition;
-// int saveBP = currentBPPosition;
// Calculate the position of the content rectangle.
if (parent != null && !parent.getTraitAsBoolean(Trait.IS_VIEWPORT_AREA)) {
currentBPPosition += parent.getBorderAndPaddingWidthBefore();
- /* This is unnecessary now as we're going to use the *-indent traits
- currentIPPosition += parent.getBorderAndPaddingWidthStart();
- Integer spaceStart = (Integer) parent.getTrait(Trait.SPACE_START);
- if (spaceStart != null) {
- currentIPPosition += spaceStart.intValue();
- }*/
}
// the position of the containing block is used for
@@ -535,15 +546,19 @@ public abstract class AbstractRenderer
renderBlock((Block) obj);
containingBPPosition = contBP;
containingIPPosition = contIP;
- } else {
+ } else if (obj instanceof LineArea) {
// a line area is rendered from the top left position
// of the line, each inline object is offset from there
LineArea line = (LineArea) obj;
- currentIPPosition = contIP
- + parent.getStartIndent()
- + line.getStartIndent();
+ if ( parent != null ) {
+ int level = parent.getBidiLevel();
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ currentIPPosition += parent.getStartIndent();
+ } else {
+ currentIPPosition += parent.getEndIndent();
+ }
+ }
renderLineArea(line);
- //InlineArea child = (InlineArea) line.getInlineAreas().get(0);
currentBPPosition += line.getAllocBPD();
}
currentIPPosition = saveIP;
@@ -556,6 +571,7 @@ public abstract class AbstractRenderer
* @param block The block area
*/
protected void renderBlock(Block block) {
+ assert block != null;
List children = block.getChildAreas();
if (block instanceof BlockViewport) {
if (children != null) {
@@ -605,13 +621,40 @@ public abstract class AbstractRenderer
List children = line.getInlineAreas();
int saveBP = currentBPPosition;
currentBPPosition += line.getSpaceBefore();
- for (int count = 0; count < children.size(); count++) {
- InlineArea inline = (InlineArea) children.get(count);
+ int bl = line.getBidiLevel();
+ if ( bl >= 0 ) {
+ if ( ( bl & 1 ) == 0 ) {
+ currentIPPosition += line.getStartIndent();
+ } else {
+ currentIPPosition += line.getEndIndent();
+ // if line's content overflows line area, then
+ // ensure that overflow is drawn (extends)
+ // outside of left side of line area
+ int overflow = computeInlinesOverflow ( line );
+ if ( overflow > 0 ) {
+ currentIPPosition -= overflow;
+ }
+ }
+ } else {
+ currentIPPosition += line.getStartIndent();
+ }
+ for (int i = 0, l = children.size(); i < l; i++) {
+ InlineArea inline = (InlineArea) children.get(i);
renderInlineArea(inline);
}
currentBPPosition = saveBP;
}
+ private int computeInlinesOverflow ( LineArea line ) {
+ List children = line.getInlineAreas();
+ int ipdConsumed = 0;
+ for (int i = 0, l = children.size(); i < l; i++) {
+ InlineArea inline = (InlineArea) children.get(i);
+ ipdConsumed += inline.getIPD();
+ }
+ return ipdConsumed - line.getIPD();
+ }
+
/**
* Render the given InlineArea.
* @param inlineArea inline area text to render
@@ -631,8 +674,8 @@ public abstract class AbstractRenderer
renderInlineBlockParent((InlineBlockParent) inlineArea);
} else if (inlineArea instanceof Space) {
renderInlineSpace((Space) inlineArea);
- } else if (inlineArea instanceof Viewport) {
- renderViewport((Viewport) inlineArea);
+ } else if (inlineArea instanceof InlineViewport) {
+ renderInlineViewport((InlineViewport) inlineArea);
} else if (inlineArea instanceof Leader) {
renderLeader((Leader) inlineArea);
}
@@ -672,11 +715,12 @@ public abstract class AbstractRenderer
* @param text the text to render
*/
protected void renderText(TextArea text) {
+ List children = text.getChildAreas();
int saveIP = currentIPPosition;
int saveBP = currentBPPosition;
- Iterator iter = text.getChildAreas().iterator();
- while (iter.hasNext()) {
- renderInlineArea((InlineArea) iter.next());
+ for (int i = 0, l = children.size(); i < l; i++) {
+ InlineArea inline = (InlineArea) children.get(i);
+ renderInlineArea(inline);
}
currentIPPosition = saveIP + text.getAllocIPD();
}
@@ -702,14 +746,39 @@ public abstract class AbstractRenderer
* @param ip the inline parent to render
*/
protected void renderInlineParent(InlineParent ip) {
+ int level = ip.getBidiLevel();
+ List children = ip.getChildAreas();
renderInlineAreaBackAndBorders(ip);
int saveIP = currentIPPosition;
int saveBP = currentBPPosition;
- currentIPPosition += ip.getBorderAndPaddingWidthStart();
- currentBPPosition += ip.getOffset();
- Iterator iter = ip.getChildAreas().iterator();
- while (iter.hasNext()) {
- renderInlineArea((InlineArea) iter.next());
+ // if inline parent is a filled area (generated by Leader), and if
+ // it is right-to-left, then adjust starting ip position in order to
+ // align children to starting (right) edge of filled area
+ int ipAdjust;
+ if ( ( ip instanceof FilledArea ) && ( ( level & 1 ) != 0 ) ) {
+ int ipdChildren = 0;
+ for (int i = 0, l = children.size(); i < l; i++) {
+ InlineArea inline = (InlineArea) children.get(i);
+ ipdChildren += inline.getAllocIPD();
+ }
+ ipAdjust = ip.getAllocIPD() - ipdChildren;
+ } else {
+ ipAdjust = 0;
+ }
+ // perform inline position adjustments
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ currentIPPosition += ip.getBorderAndPaddingWidthStart();
+ } else {
+ currentIPPosition += ip.getBorderAndPaddingWidthEnd();
+ if ( ipAdjust > 0 ) {
+ currentIPPosition += ipAdjust;
+ }
+ }
+ currentBPPosition += ip.getBlockProgressionOffset();
+ // render children inlines
+ for (int i = 0, l = children.size(); i < l; i++) {
+ InlineArea inline = (InlineArea) children.get(i);
+ renderInlineArea(inline);
}
currentIPPosition = saveIP + ip.getAllocIPD();
currentBPPosition = saveBP;
@@ -720,11 +789,16 @@ public abstract class AbstractRenderer
* @param ibp the inline block parent to render
*/
protected void renderInlineBlockParent(InlineBlockParent ibp) {
+ int level = ibp.getBidiLevel();
renderInlineAreaBackAndBorders(ibp);
- currentIPPosition += ibp.getBorderAndPaddingWidthStart();
+ if ( ( level == -1 ) || ( ( level & 1 ) == 0 ) ) {
+ currentIPPosition += ibp.getBorderAndPaddingWidthStart();
+ } else {
+ currentIPPosition += ibp.getBorderAndPaddingWidthEnd();
+ }
// For inline content the BP position is updated by the enclosing line area
int saveBP = currentBPPosition;
- currentBPPosition += ibp.getOffset();
+ currentBPPosition += ibp.getBlockProgressionOffset();
renderBlock(ibp.getChildArea());
currentBPPosition = saveBP;
}
@@ -733,10 +807,10 @@ public abstract class AbstractRenderer
* Render the given Viewport.
* @param viewport the viewport to render
*/
- protected void renderViewport(Viewport viewport) {
+ protected void renderInlineViewport(InlineViewport viewport) {
Area content = viewport.getContent();
int saveBP = currentBPPosition;
- currentBPPosition += viewport.getOffset();
+ currentBPPosition += viewport.getBlockProgressionOffset();
Rectangle2D contpos = viewport.getContentPosition();
if (content instanceof Image) {
renderImage((Image) content, contpos);
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/DefaultFontResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/DefaultFontResolver.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/DefaultFontResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/DefaultFontResolver.java Thu Apr 5 16:19:19 2012
@@ -44,4 +44,9 @@ public class DefaultFontResolver impleme
return userAgent.resolveURI(href, userAgent.getFactory().getFontManager().getFontBaseURL());
}
+ /** {@inheritDoc} */
+ public boolean isComplexScriptFeaturesEnabled() {
+ return userAgent.isComplexScriptFeaturesEnabled();
+ }
+
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/DummyPercentBaseContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/DummyPercentBaseContext.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/DummyPercentBaseContext.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/DummyPercentBaseContext.java Thu Apr 5 16:19:19 2012
@@ -44,4 +44,4 @@ public final class DummyPercentBaseConte
public int getBaseLength(int lengthBase, FObj fo) {
return 0;
}
-}
\ No newline at end of file
+}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ImageHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ImageHandler.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ImageHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ImageHandler.java Thu Apr 5 16:19:19 2012
@@ -23,7 +23,6 @@ import java.awt.Rectangle;
import java.io.IOException;
import org.apache.xmlgraphics.image.loader.Image;
-import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM;
/**
* This interface is a service provider interface for image handlers.
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ImageHandlerRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ImageHandlerRegistry.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ImageHandlerRegistry.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ImageHandlerRegistry.java Thu Apr 5 16:19:19 2012
@@ -42,18 +42,20 @@ public class ImageHandlerRegistry {
/** the logger */
private static Log log = LogFactory.getLog(ImageHandlerRegistry.class);
- private static final Comparator HANDLER_COMPARATOR = new Comparator() {
- public int compare(Object o1, Object o2) {
- ImageHandler h1 = (ImageHandler)o1;
- ImageHandler h2 = (ImageHandler)o2;
+ private static final Comparator<ImageHandler> HANDLER_COMPARATOR
+ = new Comparator<ImageHandler>() {
+ public int compare(ImageHandler o1, ImageHandler o2) {
+ ImageHandler h1 = o1;
+ ImageHandler h2 = o2;
return h1.getPriority() - h2.getPriority();
}
};
/** Map containing image handlers for various {@link Image} subclasses. */
- private Map handlers = new java.util.HashMap();
+ private Map<Class<? extends Image>, ImageHandler> handlers
+ = new java.util.HashMap<Class<? extends Image>, ImageHandler>();
/** List containing the same handlers as above but ordered by priority */
- private List handlerList = new java.util.LinkedList();
+ private List<ImageHandler> handlerList = new java.util.LinkedList<ImageHandler>();
private int handlerRegistrations;
@@ -94,14 +96,14 @@ public class ImageHandlerRegistry {
* @param handler the ImageHandler instance
*/
public synchronized void addHandler(ImageHandler handler) {
- Class imageClass = handler.getSupportedImageClass();
+ Class<? extends Image> imageClass = handler.getSupportedImageClass();
//List
this.handlers.put(imageClass, handler);
//Sorted insert (sort by priority)
- ListIterator iter = this.handlerList.listIterator();
+ ListIterator<ImageHandler> iter = this.handlerList.listIterator();
while (iter.hasNext()) {
- ImageHandler h = (ImageHandler)iter.next();
+ ImageHandler h = iter.next();
if (HANDLER_COMPARATOR.compare(handler, h) < 0) {
iter.previous();
break;
@@ -119,9 +121,7 @@ public class ImageHandlerRegistry {
* @return the image handler responsible for handling the image or null if none is available
*/
public ImageHandler getHandler(RenderingContext targetContext, Image image) {
- ListIterator iter = this.handlerList.listIterator();
- while (iter.hasNext()) {
- ImageHandler h = (ImageHandler)iter.next();
+ for (ImageHandler h : this.handlerList) {
if (h.isCompatible(targetContext, image)) {
//Return the first handler in the prioritized list that is compatible
return h;
@@ -138,10 +138,8 @@ public class ImageHandlerRegistry {
*/
public synchronized ImageFlavor[] getSupportedFlavors(RenderingContext context) {
//Extract all ImageFlavors into a single array
- List flavors = new java.util.ArrayList();
- Iterator iter = this.handlerList.iterator();
- while (iter.hasNext()) {
- ImageHandler handler = (ImageHandler)iter.next();
+ List<ImageFlavor> flavors = new java.util.ArrayList<ImageFlavor>();
+ for (ImageHandler handler : this.handlerList) {
if (handler.isCompatible(context, null)) {
ImageFlavor[] f = handler.getSupportedImageFlavors();
for (int i = 0; i < f.length; i++) {
@@ -149,7 +147,7 @@ public class ImageHandlerRegistry {
}
}
}
- return (ImageFlavor[])flavors.toArray(new ImageFlavor[flavors.size()]);
+ return flavors.toArray(new ImageFlavor[flavors.size()]);
}
/**
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRenderer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRenderer.java Thu Apr 5 16:19:19 2012
@@ -27,6 +27,7 @@ import java.util.Map;
import org.w3c.dom.Document;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.Area;
import org.apache.fop.area.Trait;
import org.apache.fop.fonts.CustomFontCollection;
@@ -42,6 +43,13 @@ import org.apache.fop.fonts.base14.Base1
/** Abstract base class of "Print" type renderers. */
public abstract class PrintRenderer extends AbstractRenderer {
+ /**
+ * @param userAgent the user agent that contains configuration details. This cannot be null.
+ */
+ public PrintRenderer(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
/** Font configuration */
protected FontInfo fontInfo;
@@ -83,7 +91,8 @@ public abstract class PrintRenderer exte
FontManager fontManager = userAgent.getFactory().getFontManager();
FontCollection[] fontCollections = new FontCollection[] {
new Base14FontCollection(fontManager.isBase14KerningEnabled()),
- new CustomFontCollection(getFontResolver(), getFontList())
+ new CustomFontCollection(getFontResolver(), getFontList(),
+ userAgent.isComplexScriptFeaturesEnabled())
};
fontManager.setup(getFontInfo(), fontCollections);
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRendererConfigurator.java Thu Apr 5 16:19:19 2012
@@ -95,7 +95,9 @@ public class PrintRendererConfigurator e
FontManager fontManager = factory.getFontManager();
if (fontResolver == null) {
//Ensure that we have minimal font resolution capabilities
- fontResolver = FontManager.createMinimalFontResolver();
+ fontResolver
+ = FontManager.createMinimalFontResolver
+ ( userAgent.isComplexScriptFeaturesEnabled() );
}
boolean strict = factory.validateUserConfigStrictly();
@@ -128,7 +130,8 @@ public class PrintRendererConfigurator e
FontEventListener listener = new FontEventAdapter(
userAgent.getEventBroadcaster());
List<EmbedFontInfo> fontList = buildFontList(cfg, fontResolver, listener);
- fontCollections.add(new CustomFontCollection(fontResolver, fontList));
+ fontCollections.add(new CustomFontCollection(fontResolver, fontList,
+ userAgent.isComplexScriptFeaturesEnabled()));
}
fontManager.setup(fontInfo,
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/Renderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/Renderer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/Renderer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/Renderer.java Thu Apr 5 16:19:19 2012
@@ -22,6 +22,7 @@ package org.apache.fop.render;
// Java
import java.io.IOException;
import java.io.OutputStream;
+import java.util.Locale;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
@@ -82,13 +83,6 @@ public interface Renderer {
throws IOException;
/**
- * Set the User Agent.
- *
- * @param agent The User Agent
- */
- void setUserAgent(FOUserAgent agent);
-
- /**
* Returns the associated user agent.
* @return the user agent
*/
@@ -116,6 +110,12 @@ public interface Renderer {
boolean supportsOutOfOrder();
/**
+ *
+ * @param locale Locale of the language
+ */
+ void setDocumentLocale(Locale locale);
+
+ /**
* Tells the renderer to process an item not explicitly placed on the
* document (e.g., PDF bookmarks). Note - not all renderers will process
* all off-document items.
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererEventProducer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererEventProducer.java Thu Apr 5 16:19:19 2012
@@ -53,4 +53,11 @@ public interface RendererEventProducer e
* @event.severity ERROR
*/
void ioError(Object source, IOException ioe);
+
+ /**
+ * Triggered at the end of page rendering.
+ * @param source the event source
+ * @param number the page number
+ */
+ void endPage(Object source, int number);
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererEventProducer.xml?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererEventProducer.xml (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererEventProducer.xml Thu Apr 5 16:19:19 2012
@@ -18,4 +18,5 @@
<!-- $Id$ -->
<catalogue xml:lang="en">
<message key="ioError">I/O error while writing to target file.[ Reason: {ioe}]</message>
+ <message key="endPage">Rendered page #{number}.</message>
</catalogue>
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererFactory.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/RendererFactory.java Thu Apr 5 16:19:19 2012
@@ -35,6 +35,7 @@ import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.fo.FOEventHandler;
import org.apache.fop.render.intermediate.AbstractIFDocumentHandlerMaker;
+import org.apache.fop.render.intermediate.EventProducingFilter;
import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
import org.apache.fop.render.intermediate.IFRenderer;
@@ -298,7 +299,6 @@ public class RendererFactory {
AbstractRendererMaker maker = getRendererMaker(outputFormat);
if (maker != null) {
Renderer rend = maker.makeRenderer(userAgent);
- rend.setUserAgent(userAgent);
RendererConfigurator configurator = maker.getConfigurator(userAgent);
if (configurator != null) {
configurator.configure(rend);
@@ -310,8 +310,7 @@ public class RendererFactory {
}
private Renderer createRendererForDocumentHandler(IFDocumentHandler documentHandler) {
- IFRenderer rend = new IFRenderer();
- rend.setUserAgent(documentHandler.getContext().getUserAgent());
+ IFRenderer rend = new IFRenderer(documentHandler.getContext().getUserAgent());
rend.setDocumentHandler(documentHandler);
return rend;
}
@@ -389,7 +388,7 @@ public class RendererFactory {
if (configurator != null) {
configurator.configure(documentHandler);
}
- return documentHandler;
+ return new EventProducingFilter(documentHandler, userAgent);
}
/**
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/XMLHandlerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/XMLHandlerConfigurator.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/XMLHandlerConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/XMLHandlerConfigurator.java Thu Apr 5 16:19:19 2012
@@ -21,8 +21,10 @@ package org.apache.fop.render;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/XMLHandlerRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/XMLHandlerRegistry.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/XMLHandlerRegistry.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/XMLHandlerRegistry.java Thu Apr 5 16:19:19 2012
@@ -39,7 +39,8 @@ public class XMLHandlerRegistry {
private static Log log = LogFactory.getLog(XMLHandlerRegistry.class);
/** Map containing XML handlers for various document types */
- private Map handlers = new java.util.HashMap();
+ private Map<String, List<XMLHandler>> handlers
+ = new java.util.HashMap<String, List<XMLHandler>>();
/**
* Default constructor.
@@ -98,11 +99,10 @@ public class XMLHandlerRegistry {
* @param ns Namespace URI
* @param handler XMLHandler to use
*/
- private void addXMLHandler(String ns,
- XMLHandler handler) {
- List lst = (List)handlers.get(ns);
+ private void addXMLHandler(String ns, XMLHandler handler) {
+ List<XMLHandler> lst = handlers.get(ns);
if (lst == null) {
- lst = new java.util.ArrayList();
+ lst = new java.util.ArrayList<XMLHandler>();
handlers.put(ns, lst);
}
lst.add(handler);
@@ -118,21 +118,21 @@ public class XMLHandlerRegistry {
public XMLHandler getXMLHandler(Renderer renderer, String ns) {
XMLHandler handler;
- List lst = (List)handlers.get(ns);
+ List<XMLHandler> lst = handlers.get(ns);
handler = getXMLHandler(renderer, lst);
if (handler == null) {
- lst = (List)handlers.get(XMLHandler.HANDLE_ALL);
+ lst = handlers.get(XMLHandler.HANDLE_ALL);
handler = getXMLHandler(renderer, lst);
}
return handler;
}
- private XMLHandler getXMLHandler(Renderer renderer, List lst) {
+ private XMLHandler getXMLHandler(Renderer renderer, List<XMLHandler> lst) {
XMLHandler handler;
if (lst != null) {
for (int i = 0, c = lst.size(); i < c; i++) {
//TODO Maybe add priorities later
- handler = (XMLHandler)lst.get(i);
+ handler = lst.get(i);
if (handler.supportsRenderer(renderer)) {
return handler;
}
@@ -147,7 +147,7 @@ public class XMLHandlerRegistry {
*/
private void discoverXMLHandlers() {
// add mappings from available services
- Iterator providers = Service.providers(XMLHandler.class);
+ Iterator<Object> providers = Service.providers(XMLHandler.class);
if (providers != null) {
while (providers.hasNext()) {
XMLHandler handler = (XMLHandler)providers.next();
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPCustomizable.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPCustomizable.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPCustomizable.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPCustomizable.java Thu Apr 5 16:19:19 2012
@@ -72,6 +72,16 @@ public interface AFPCustomizable {
void setDitheringQuality(float quality);
/**
+ * Sets the image encoding quality setting to use when encoding bitmap images.
+ * The default setting is 1.0 which means loss-less encoding. Settings of less than 1.0
+ * allow loss-less encoding schemes like JPEG. The value serves as quality setting for
+ * the encoders in that case.
+ * @param quality Defines the desired quality level.
+ * Valid values: a value between 0.0f (lowest) and 1.0f (best, loss-less)
+ */
+ void setBitmapEncodingQuality(float quality);
+
+ /**
* Sets the output/device resolution
*
* @param resolution
@@ -87,6 +97,30 @@ public interface AFPCustomizable {
int getResolution();
/**
+ * Controls whether GOCA is enabled or disabled.
+ * @param enabled true if GOCA is enabled, false if it is disabled
+ */
+ void setGOCAEnabled(boolean enabled);
+
+ /**
+ * Indicates whether GOCA is enabled or disabled.
+ * @return true if GOCA is enabled, false if GOCA is disabled
+ */
+ boolean isGOCAEnabled();
+
+ /**
+ * Controls whether to stroke text in GOCA mode or to use text operators where possible.
+ * @param stroke true to stroke, false to paint with text operators where possible
+ */
+ void setStrokeGOCAText(boolean stroke);
+
+ /**
+ * Indicates whether to stroke text in GOCA mode or to use text operators where possible.
+ * @return true to stroke, false to paint with text operators where possible
+ */
+ boolean isStrokeGOCAText();
+
+ /**
* Sets the default resource group file path
* @param filePath the default resource group file path
*/
@@ -99,4 +133,11 @@ public interface AFPCustomizable {
*/
void setResourceLevelDefaults(AFPResourceLevelDefaults defaults);
+ /**
+ * Sets whether or not to JPEG images can be embedded in the AFP document.
+ *
+ * @param canEmbed whether or not to embed JPEG image
+ */
+ void canEmbedJpeg(boolean canEmbed);
+
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPDocumentHandler.java Thu Apr 5 16:19:19 2012
@@ -23,6 +23,8 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.geom.AffineTransform;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.apache.fop.afp.AFPDitheredRectanglePainter;
@@ -49,8 +51,8 @@ import org.apache.fop.render.afp.extensi
import org.apache.fop.render.afp.extensions.AFPPageOverlay;
import org.apache.fop.render.afp.extensions.AFPPageSegmentElement;
import org.apache.fop.render.afp.extensions.AFPPageSetup;
+import org.apache.fop.render.afp.extensions.ExtensionPlacement;
import org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler;
-import org.apache.fop.render.intermediate.IFDocumentHandler;
import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator;
import org.apache.fop.render.intermediate.IFException;
import org.apache.fop.render.intermediate.IFPainter;
@@ -77,17 +79,18 @@ public class AFPDocumentHandler extends
private DataStream dataStream;
/** the map of page segments */
- private Map/*<String,PageSegmentDescriptor>*/pageSegmentMap
- = new java.util.HashMap/*<String,PageSegmentDescriptor>*/();
+ private Map<String, PageSegmentDescriptor> pageSegmentMap
+ = new java.util.HashMap<String, PageSegmentDescriptor>();
- /** Medium Map referenced on previous page **/
- private String lastMediumMap;
+ private static enum Location {
+ ELSEWHERE, IN_DOCUMENT_HEADER, FOLLOWING_PAGE_SEQUENCE, IN_PAGE_HEADER
+ }
- private static final int LOC_ELSEWHERE = 0;
- private static final int LOC_FOLLOWING_PAGE_SEQUENCE = 1;
- private static final int LOC_IN_PAGE_HEADER = 2;
+ private Location location = Location.ELSEWHERE;
- private int location = LOC_ELSEWHERE;
+ /** temporary holds extensions that have to be deferred until the end of the page-sequence */
+ private List<AFPPageSetup> deferredPageSequenceExtensions
+ = new java.util.LinkedList<AFPPageSetup>();
/** the shading mode for filled rectangles */
private AFPShadingMode shadingMode = AFPShadingMode.COLOR;
@@ -117,6 +120,7 @@ public class AFPDocumentHandler extends
}
/** {@inheritDoc} */
+ @Override
public void setDefaultFontInfo(FontInfo fontInfo) {
FontManager fontManager = getUserAgent().getFactory().getFontManager();
FontCollection[] fontCollections = new FontCollection[] {
@@ -152,6 +156,7 @@ public class AFPDocumentHandler extends
}
/** {@inheritDoc} */
+ @Override
public void startDocument() throws IFException {
super.startDocument();
try {
@@ -165,11 +170,23 @@ public class AFPDocumentHandler extends
}
}
+
+ /** {@inheritDoc} */
+ @Override
+ public void startDocumentHeader() throws IFException {
+ super.startDocumentHeader();
+ this.location = Location.IN_DOCUMENT_HEADER;
+ }
+
/** {@inheritDoc} */
+ @Override
public void endDocumentHeader() throws IFException {
+ super.endDocumentHeader();
+ this.location = Location.ELSEWHERE;
}
/** {@inheritDoc} */
+ @Override
public void endDocument() throws IFException {
try {
this.dataStream.endDocument();
@@ -189,12 +206,30 @@ public class AFPDocumentHandler extends
} catch (IOException ioe) {
throw new IFException("I/O error in startPageSequence()", ioe);
}
- this.location = LOC_FOLLOWING_PAGE_SEQUENCE;
+ this.location = Location.FOLLOWING_PAGE_SEQUENCE;
}
/** {@inheritDoc} */
public void endPageSequence() throws IFException {
- //nop
+ try {
+ //Process deferred page-sequence-level extensions
+ Iterator<AFPPageSetup> iter = this.deferredPageSequenceExtensions.iterator();
+ while (iter.hasNext()) {
+ AFPPageSetup aps = iter.next();
+ iter.remove();
+ if (AFPElementMapping.NO_OPERATION.equals(aps.getElementName())) {
+ handleNOP(aps);
+ } else {
+ throw new UnsupportedOperationException("Don't know how to handle " + aps);
+ }
+ }
+
+ //End page sequence
+ dataStream.endPageGroup();
+ } catch (IOException ioe) {
+ throw new IFException("I/O error in endPageSequence()", ioe);
+ }
+ this.location = Location.ELSEWHERE;
}
/**
@@ -212,7 +247,7 @@ public class AFPDocumentHandler extends
/** {@inheritDoc} */
public void startPage(int index, String name, String pageMasterName, Dimension size)
throws IFException {
- this.location = LOC_ELSEWHERE;
+ this.location = Location.ELSEWHERE;
paintingState.clear();
AffineTransform baseTransform = getBaseTransform();
@@ -232,14 +267,16 @@ public class AFPDocumentHandler extends
}
/** {@inheritDoc} */
+ @Override
public void startPageHeader() throws IFException {
super.startPageHeader();
- this.location = LOC_IN_PAGE_HEADER;
+ this.location = Location.IN_PAGE_HEADER;
}
/** {@inheritDoc} */
+ @Override
public void endPageHeader() throws IFException {
- this.location = LOC_ELSEWHERE;
+ this.location = Location.ELSEWHERE;
super.endPageHeader();
}
@@ -272,17 +309,37 @@ public class AFPDocumentHandler extends
AFPPageSetup aps = (AFPPageSetup)extension;
String element = aps.getElementName();
if (AFPElementMapping.TAG_LOGICAL_ELEMENT.equals(element)) {
- if (this.location != LOC_IN_PAGE_HEADER
- && this.location != LOC_FOLLOWING_PAGE_SEQUENCE) {
+ switch (this.location) {
+ case FOLLOWING_PAGE_SEQUENCE:
+ case IN_PAGE_HEADER:
+ String name = aps.getName();
+ String value = aps.getValue();
+ dataStream.createTagLogicalElement(name, value);
+ break;
+ default:
throw new IFException(
"TLE extension must be in the page header or between page-sequence"
+ " and the first page: " + aps, null);
}
- String name = aps.getName();
- String value = aps.getValue();
- dataStream.createTagLogicalElement(name, value);
+ } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
+ switch (this.location) {
+ case FOLLOWING_PAGE_SEQUENCE:
+ if (aps.getPlacement() == ExtensionPlacement.BEFORE_END) {
+ this.deferredPageSequenceExtensions.add(aps);
+ break;
+ }
+ case IN_DOCUMENT_HEADER:
+ case IN_PAGE_HEADER:
+ handleNOP(aps);
+ break;
+ default:
+ throw new IFException(
+ "NOP extension must be in the document header, the page header"
+ + " or between page-sequence"
+ + " and the first page: " + aps, null);
+ }
} else {
- if (this.location != LOC_IN_PAGE_HEADER) {
+ if (this.location != Location.IN_PAGE_HEADER) {
throw new IFException(
"AFP page setup extension encountered outside the page header: " + aps,
null);
@@ -294,16 +351,11 @@ public class AFPDocumentHandler extends
String source = apse.getValue();
String uri = apse.getResourceSrc();
pageSegmentMap.put(source, new PageSegmentDescriptor(name, uri));
- } else if (AFPElementMapping.NO_OPERATION.equals(element)) {
- String content = aps.getContent();
- if (content != null) {
- dataStream.createNoOperation(content);
- }
}
}
} else if (extension instanceof AFPPageOverlay) {
AFPPageOverlay ipo = (AFPPageOverlay)extension;
- if (this.location != LOC_IN_PAGE_HEADER) {
+ if (this.location != Location.IN_PAGE_HEADER) {
throw new IFException(
"AFP page overlay extension encountered outside the page header: " + ipo,
null);
@@ -313,8 +365,8 @@ public class AFPDocumentHandler extends
dataStream.createIncludePageOverlay(overlay, ipo.getX(), ipo.getY());
}
} else if (extension instanceof AFPInvokeMediumMap) {
- if (this.location != LOC_FOLLOWING_PAGE_SEQUENCE
- && this.location != LOC_IN_PAGE_HEADER) {
+ if (this.location != Location.FOLLOWING_PAGE_SEQUENCE
+ && this.location != Location.IN_PAGE_HEADER) {
throw new IFException(
"AFP IMM extension must be between page-sequence"
@@ -323,9 +375,8 @@ public class AFPDocumentHandler extends
}
AFPInvokeMediumMap imm = (AFPInvokeMediumMap)extension;
String mediumMap = imm.getName();
- if (mediumMap != null && !mediumMap.equals(lastMediumMap)) {
+ if (mediumMap != null) {
dataStream.createInvokeMediumMap(mediumMap);
- lastMediumMap = mediumMap;
}
} else if (extension instanceof AFPIncludeFormMap) {
AFPIncludeFormMap formMap = (AFPIncludeFormMap)extension;
@@ -342,6 +393,13 @@ public class AFPDocumentHandler extends
}
}
+ private void handleNOP(AFPPageSetup nop) {
+ String content = nop.getContent();
+ if (content != null) {
+ dataStream.createNoOperation(content);
+ }
+ }
+
// ---=== AFPCustomizable ===---
/** {@inheritDoc} */
@@ -370,6 +428,11 @@ public class AFPDocumentHandler extends
}
/** {@inheritDoc} */
+ public void setBitmapEncodingQuality(float quality) {
+ this.paintingState.setBitmapEncodingQuality(quality);
+ }
+
+ /** {@inheritDoc} */
public void setShadingMode(AFPShadingMode shadingMode) {
this.shadingMode = shadingMode;
}
@@ -385,6 +448,26 @@ public class AFPDocumentHandler extends
}
/** {@inheritDoc} */
+ public void setGOCAEnabled(boolean enabled) {
+ this.paintingState.setGOCAEnabled(enabled);
+ }
+
+ /** {@inheritDoc} */
+ public boolean isGOCAEnabled() {
+ return this.paintingState.isGOCAEnabled();
+ }
+
+ /** {@inheritDoc} */
+ public void setStrokeGOCAText(boolean stroke) {
+ this.paintingState.setStrokeGOCAText(stroke);
+ }
+
+ /** {@inheritDoc} */
+ public boolean isStrokeGOCAText() {
+ return this.paintingState.isStrokeGOCAText();
+ }
+
+ /** {@inheritDoc} */
public void setDefaultResourceGroupFilePath(String filePath) {
resourceManager.setDefaultResourceGroupFilePath(filePath);
}
@@ -401,7 +484,12 @@ public class AFPDocumentHandler extends
* @return the page segment descriptor or null if there's no page segment for the given URI
*/
PageSegmentDescriptor getPageSegmentNameFor(String uri) {
- return (PageSegmentDescriptor)pageSegmentMap.get(uri);
+ return pageSegmentMap.get(uri);
+ }
+
+ /** {@inheritDoc} */
+ public void canEmbedJpeg(boolean canEmbed) {
+ paintingState.setCanEmbedJpeg(canEmbed);
}
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPGraphics2DAdapter.java Thu Apr 5 16:19:19 2012
@@ -25,6 +25,8 @@ import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
+import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
+
import org.apache.fop.afp.AFPGraphics2D;
import org.apache.fop.afp.AFPGraphicsObjectInfo;
import org.apache.fop.afp.AFPPaintingState;
@@ -32,7 +34,6 @@ import org.apache.fop.afp.AFPResourceMan
import org.apache.fop.render.AbstractGraphics2DAdapter;
import org.apache.fop.render.RendererContext;
import org.apache.fop.render.RendererContext.RendererContextWrapper;
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
/**
* Graphics2DAdapter implementation for AFP.
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandler.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandler.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandler.java Thu Apr 5 16:19:19 2012
@@ -62,24 +62,17 @@ public abstract class AFPImageHandler im
*/
public static AFPObjectAreaInfo createObjectAreaInfo(AFPPaintingState paintingState,
Rectangle targetRect) {
- AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo();
AFPUnitConverter unitConv = paintingState.getUnitConverter();
int[] coords = unitConv.mpts2units(new float[] {targetRect.x, targetRect.y});
- objectAreaInfo.setX(coords[X]);
- objectAreaInfo.setY(coords[Y]);
int width = Math.round(unitConv.mpt2units(targetRect.width));
- objectAreaInfo.setWidth(width);
int height = Math.round(unitConv.mpt2units(targetRect.height));
- objectAreaInfo.setHeight(height);
int resolution = paintingState.getResolution();
- objectAreaInfo.setHeightRes(resolution);
- objectAreaInfo.setWidthRes(resolution);
-
- objectAreaInfo.setRotation(paintingState.getRotation());
+ AFPObjectAreaInfo objectAreaInfo = new AFPObjectAreaInfo(coords[X], coords[Y], width,
+ height, resolution, paintingState.getRotation());
return objectAreaInfo;
}
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandlerGraphics2D.java Thu Apr 5 16:19:19 2012
@@ -26,8 +26,6 @@ import java.io.IOException;
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageGraphics2D;
-import org.apache.xmlgraphics.java2d.Graphics2DImagePainter;
-import org.apache.xmlgraphics.util.MimeConstants;
import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPGraphics2D;
@@ -74,6 +72,7 @@ public class AFPImageHandlerGraphics2D e
}
/** {@inheritDoc} */
+ @Override
protected AFPDataObjectInfo createDataObjectInfo() {
return new AFPGraphicsObjectInfo();
}
@@ -104,13 +103,13 @@ public class AFPImageHandlerGraphics2D e
// Image content
ImageGraphics2D imageG2D = (ImageGraphics2D)image;
- boolean textAsShapes = false; //TODO Make configurable
+ final boolean textAsShapes = paintingState.isStrokeGOCAText();
AFPGraphics2D g2d = new AFPGraphics2D(
textAsShapes,
afpContext.getPaintingState(),
afpContext.getResourceManager(),
graphicsObjectInfo.getResourceInfo(),
- afpContext.getFontInfo());
+ (textAsShapes ? null : afpContext.getFontInfo()));
g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
graphicsObjectInfo.setGraphics2D(g2d);
@@ -127,6 +126,10 @@ public class AFPImageHandlerGraphics2D e
boolean supported = (image == null || image instanceof ImageGraphics2D)
&& targetContext instanceof AFPRenderingContext;
if (supported) {
+ AFPRenderingContext afpContext = (AFPRenderingContext)targetContext;
+ if (!afpContext.getPaintingState().isGOCAEnabled()) {
+ return false;
+ }
String mode = (String)targetContext.getHint(ImageHandlerUtil.CONVERSION_MODE);
if (ImageHandlerUtil.isConversionModeBitmap(mode)) {
//Disabling this image handler automatically causes a bitmap to be generated
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPImageHandlerRawCCITTFax.java Thu Apr 5 16:19:19 2012
@@ -19,6 +19,12 @@
package org.apache.fop.render.afp;
+import java.awt.Rectangle;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.xmlgraphics.image.loader.Image;
import org.apache.xmlgraphics.image.loader.ImageFlavor;
import org.apache.xmlgraphics.image.loader.impl.ImageRawCCITTFax;
@@ -38,7 +44,11 @@ public class AFPImageHandlerRawCCITTFax
ImageFlavor.RAW_CCITTFAX,
};
+ /** logging instance */
+ private final Log log = LogFactory.getLog(AFPImageHandlerRawJPEG.class);
+
/** {@inheritDoc} */
+ @Override
protected void setAdditionalParameters(AFPDataObjectInfo dataObjectInfo,
ImageRawStream image) {
AFPImageObjectInfo imageObjectInfo = (AFPImageObjectInfo)dataObjectInfo;
@@ -54,6 +64,15 @@ public class AFPImageHandlerRawCCITTFax
}
/** {@inheritDoc} */
+ @Override
+ public void handleImage(RenderingContext context, Image image, Rectangle pos)
+ throws IOException {
+ log.debug("Embedding undecoded CCITT data as data container...");
+ super.handleImage(context, image, pos);
+ }
+
+ /** {@inheritDoc} */
+ @Override
protected AFPDataObjectInfo createDataObjectInfo() {
return new AFPImageObjectInfo();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org