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 2008/05/09 14:30:42 UTC
svn commit: r654783 [3/3] - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/apps/ src/java/org/apache/fop/fonts/
src/java/org/apache/fop/fonts/autodetect/
src/java/org/apache/fop/fonts/base14/
src/java/org/apache/fop/fonts/substitute/ src/java/org/a...
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java Fri May 9 05:30:40 2008
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.pcl;
//Java
@@ -111,14 +111,14 @@
/** The MIME type for PCL */
public static final String MIME_TYPE = MimeConstants.MIME_PCL_ALT;
- private static final QName CONV_MODE
+ private static final QName CONV_MODE
= new QName(ExtensionElementMapping.URI, null, "conversion-mode");
- private static final QName SRC_TRANSPARENCY
+ private static final QName SRC_TRANSPARENCY
= new QName(ExtensionElementMapping.URI, null, "source-transparency");
-
+
/** The OutputStream to write the PCL stream to */
protected OutputStream out;
-
+
/** The PCL generator */
protected PCLGenerator gen;
private boolean ioTrouble = false;
@@ -130,13 +130,13 @@
private int currentPrintDirection = 0;
private GeneralPath currentPath = null;
private java.awt.Color currentFillColor = null;
-
+
/**
* Controls whether appearance is more important than speed. False can cause some FO feature
- * to be ignored (like the advanced borders).
+ * to be ignored (like the advanced borders).
*/
private boolean qualityBeforeSpeed = false;
-
+
/**
* Controls whether all text should be painted as text. This is a fallback setting in case
* the mixture of native and bitmapped text does not provide the necessary quality.
@@ -149,17 +149,17 @@
* this to true will increase memory consumption.
*/
private boolean useColorCanvas = false;
-
+
/**
- * Controls whether the generation of PJL commands gets disabled.
+ * Controls whether the generation of PJL commands gets disabled.
*/
private boolean disabledPJL = false;
-
+
/** contains the pageWith of the last printed page */
private long pageWidth = 0;
/** contains the pageHeight of the last printed page */
private long pageHeight = 0;
-
+
/**
* Create the PCL renderer
*/
@@ -182,7 +182,7 @@
public void setPJLDisabled(boolean disable) {
this.disabledPJL = disable;
}
-
+
/**
* Indicates whether PJL generation is disabled.
* @return true if PJL generation is disabled.
@@ -190,7 +190,7 @@
public boolean isPJLDisabled() {
return this.disabledPJL;
}
-
+
/**
* {@inheritDoc}
*/
@@ -203,9 +203,9 @@
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = fontImage.createGraphics();
//The next line is important to get accurate font metrics!
- graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+ graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-
+
userAgent.getFactory().getFontManager().setupRenderer(this, graphics2D);
}
@@ -231,7 +231,7 @@
public GraphicContext getGraphicContext() {
return this.graphicContext;
}
-
+
/** @return the target resolution */
protected int getResolution() {
int resolution = (int)Math.round(userAgent.getTargetResolution());
@@ -241,7 +241,7 @@
return 600;
}
}
-
+
/**
* Sets the current font (NOTE: Hard-coded font mappings ATM!)
* @param name the font name (internal F* names for now)
@@ -317,25 +317,25 @@
case 9: // F9 = Courier
gen.writeCommand("(0N");
- gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f))
+ gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f))
+ "h0s0b4099T");
break;
case 10: // F10 = Courier Oblique
gen.writeCommand("(0N");
- gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f))
+ gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f))
+ "h1s0b4099T");
break;
case 11: // F11 = Courier Bold
gen.writeCommand("(0N");
- gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f))
+ gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f))
+ "h0s3b4099T");
break;
case 12: // F12 = Courier Bold Oblique
gen.writeCommand("(0N");
- gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f))
+ gen.writeCommand("(s0p" + gen.formatDouble2(120.01f / (size / 1000.00f))
+ "h1s3b4099T");
break;
case 13: // F13 = Symbol
@@ -400,52 +400,52 @@
*/
public void renderPage(PageViewport page) throws IOException, FOPException {
saveGraphicsState();
-
+
//Paper source
String paperSource = page.getForeignAttributeValue(
new QName(PCLElementMapping.NAMESPACE, null, "paper-source"));
if (paperSource != null) {
gen.selectPaperSource(Integer.parseInt(paperSource));
}
-
+
//Page size
final long pagewidth = Math.round(page.getViewArea().getWidth());
final long pageheight = Math.round(page.getViewArea().getHeight());
selectPageFormat(pagewidth, pageheight);
-
+
super.renderPage(page);
-
+
//Eject page
gen.formFeed();
restoreGraphicsState();
}
private void selectPageFormat(long pagewidth, long pageheight) throws IOException {
- //Only set the page format if it changes (otherwise duplex printing won't work)
+ //Only set the page format if it changes (otherwise duplex printing won't work)
if ((pagewidth != this.pageWidth) || (pageheight != this.pageHeight)) {
this.pageWidth = pagewidth;
this.pageHeight = pageheight;
-
+
this.currentPageDefinition = PCLPageDefinition.getPageDefinition(
pagewidth, pageheight, 1000);
-
+
if (this.currentPageDefinition == null) {
this.currentPageDefinition = PCLPageDefinition.getDefaultPageDefinition();
- log.warn("Paper type could not be determined. Falling back to: "
+ log.warn("Paper type could not be determined. Falling back to: "
+ this.currentPageDefinition.getName());
}
if (log.isDebugEnabled()) {
log.debug("page size: " + currentPageDefinition.getPhysicalPageSize());
log.debug("logical page: " + currentPageDefinition.getLogicalPageRect());
}
-
+
if (this.currentPageDefinition.isLandscapeFormat()) {
gen.writeCommand("&l1O"); //Landscape Orientation
} else {
gen.writeCommand("&l0O"); //Portrait Orientation
}
gen.selectPageSize(this.currentPageDefinition.getSelector());
-
+
gen.clearHorizontalMargins();
gen.setTopMargin(0);
}
@@ -461,7 +461,7 @@
protected void restoreGraphicsState() {
graphicContext = (GraphicContext)graphicContextStack.pop();
}
-
+
/**
* Clip an area. write a clipping operation given coordinates in the current
* transform. Coordinates are in points.
@@ -478,7 +478,7 @@
private Point2D transformedPoint(float x, float y) {
return transformedPoint(Math.round(x), Math.round(y));
}
-
+
private Point2D transformedPoint(int x, int y) {
AffineTransform at = graphicContext.getTransform();
if (log.isTraceEnabled()) {
@@ -488,7 +488,7 @@
Point2D.Float transPoint = new Point2D.Float();
at.transform(orgPoint, transPoint);
//At this point we have the absolute position in FOP's coordinate system
-
+
//Now get PCL coordinates taking the current print direction and the logical page
//into account.
Dimension pageSize = currentPageDefinition.getPhysicalPageSize();
@@ -527,18 +527,18 @@
}
return transPoint;
}
-
+
private void changePrintDirection() {
AffineTransform at = graphicContext.getTransform();
int newDir;
try {
- if (at.getScaleX() == 0 && at.getScaleY() == 0
+ if (at.getScaleX() == 0 && at.getScaleY() == 0
&& at.getShearX() == 1 && at.getShearY() == -1) {
newDir = 90;
- } else if (at.getScaleX() == -1 && at.getScaleY() == -1
+ } else if (at.getScaleX() == -1 && at.getScaleY() == -1
&& at.getShearX() == 0 && at.getShearY() == 0) {
newDir = 180;
- } else if (at.getScaleX() == 0 && at.getScaleY() == 0
+ } else if (at.getScaleX() == 0 && at.getScaleY() == 0
&& at.getShearX() == -1 && at.getShearY() == 1) {
newDir = 270;
} else {
@@ -588,7 +588,7 @@
protected void handleBlockTraits(Block block) {
int borderPaddingStart = block.getBorderAndPaddingWidthStart();
int borderPaddingBefore = block.getBorderAndPaddingWidthBefore();
-
+
float startx = currentIPPosition / 1000f;
float starty = currentBPPosition / 1000f;
float width = block.getIPD() / 1000f;
@@ -628,7 +628,7 @@
*/
protected void renderText(final TextArea text) {
renderInlineAreaBackAndBorders(text);
-
+
String fontname = getInternalFontNameForArea(text);
final int fontsize = text.getTraitAsInteger(Trait.FONT_SIZE);
@@ -640,9 +640,9 @@
try {
final Color col = (Color)text.getTrait(Trait.COLOR);
- boolean pclFont = allTextAsBitmaps
+ boolean pclFont = allTextAsBitmaps
? false
- : setFont(fontname, fontsize, text.getText());
+ : setFont(fontname, fontsize, text.getText());
if (pclFont) {
//this.currentFill = col;
if (col != null) {
@@ -650,7 +650,7 @@
gen.setTransparencyMode(true, false);
gen.selectGrayscale(col);
}
-
+
saveGraphicsState();
graphicContext.translate(rx, bl);
setCursorPos(0, 0);
@@ -667,25 +667,25 @@
//Use Java2D to paint different fonts via bitmap
final Font font = getFontFromArea(text);
final int baseline = text.getBaselineOffset();
-
+
//for cursive fonts, so the text isn't clipped
int extraWidth = font.getFontSize() / 3;
final FontMetricsMapper mapper = (FontMetricsMapper)fontInfo.getMetricsFor(
font.getFontName());
int maxAscent = mapper.getMaxAscent(font.getFontSize()) / 1000;
final int additionalBPD = maxAscent - baseline;
-
+
Graphics2DAdapter g2a = getGraphics2DAdapter();
final Rectangle paintRect = new Rectangle(
rx, currentBPPosition + text.getOffset() - additionalBPD,
text.getIPD() + extraWidth, text.getBPD() + additionalBPD);
- RendererContext rc = createRendererContext(paintRect.x, paintRect.y,
+ RendererContext rc = createRendererContext(paintRect.x, paintRect.y,
paintRect.width, paintRect.height, null);
Map atts = new java.util.HashMap();
atts.put(CONV_MODE, "bitmap");
atts.put(SRC_TRANSPARENCY, "true");
rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
-
+
Graphics2DImagePainter painter = new Graphics2DImagePainter() {
public void paint(Graphics2D g2d, Rectangle2D area) {
@@ -696,17 +696,17 @@
Java2DRenderer.renderText(text, g2d, font);
renderTextDecoration(g2d, mapper, fontsize, text, 0, 0);
}
-
+
public Dimension getImageSize() {
return paintRect.getSize();
}
-
+
};
- g2a.paintImage(painter, rc,
+ g2a.paintImage(painter, rc,
paintRect.x, paintRect.y, paintRect.width, paintRect.height);
currentIPPosition = saveIP + text.getAllocIPD();
}
-
+
} catch (IOException ioe) {
handleIOTrouble(ioe);
}
@@ -721,11 +721,11 @@
* @param baseline position of the baseline
* @param startx start IPD
*/
- private static void renderTextDecoration(Graphics2D g2d,
- FontMetrics fm, int fontsize, InlineArea inline,
+ private static void renderTextDecoration(Graphics2D g2d,
+ FontMetrics fm, int fontsize, InlineArea inline,
int baseline, int startx) {
- boolean hasTextDeco = inline.hasUnderline()
- || inline.hasOverline()
+ boolean hasTextDeco = inline.hasUnderline()
+ || inline.hasOverline()
|| inline.hasLineThrough();
if (hasTextDeco) {
float descender = fm.getDescender(fontsize) / 1000f;
@@ -737,7 +737,7 @@
g2d.setColor(ct);
float y = baseline - descender / 2f;
g2d.setStroke(new BasicStroke(lineWidth));
- g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
+ g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
endx, y / 1000f));
}
if (inline.hasOverline()) {
@@ -745,7 +745,7 @@
g2d.setColor(ct);
float y = (float)(baseline - (1.1 * capHeight));
g2d.setStroke(new BasicStroke(lineWidth));
- g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
+ g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
endx, y / 1000f));
}
if (inline.hasLineThrough()) {
@@ -753,12 +753,12 @@
g2d.setColor(ct);
float y = (float)(baseline - (0.45 * capHeight));
g2d.setStroke(new BasicStroke(lineWidth));
- g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
+ g2d.draw(new Line2D.Float(startx / 1000f, y / 1000f,
endx, y / 1000f));
}
}
}
-
+
/**
* Sets the current cursor position. The coordinates are transformed to the absolute position
* on the logical PCL page and then passed on to the PCLGenerator.
@@ -784,7 +784,7 @@
}
/**
- * Closes the current subpath by appending a straight line segment from
+ * Closes the current subpath by appending a straight line segment from
* the current point to the starting point of the subpath.
*/
protected void closePath() {
@@ -792,8 +792,8 @@
}
/**
- * Appends a straight line segment from the current point to (x, y). The
- * new current point is (x, y).
+ * Appends a straight line segment from the current point to (x, y). The
+ * new current point is (x, y).
* @param x x coordinate
* @param y y coordinate
*/
@@ -805,7 +805,7 @@
}
/**
- * Moves the current point to (x, y), omitting any connecting line segment.
+ * Moves the current point to (x, y), omitting any connecting line segment.
* @param x x coordinate
* @param y y coordinate
*/
@@ -815,7 +815,7 @@
}
currentPath.moveTo(x, y);
}
-
+
/**
* Fill a rectangular area.
* @param x the x coordinate (in pt)
@@ -826,13 +826,13 @@
protected void fillRect(float x, float y, float width, float height) {
try {
setCursorPos(x * 1000, y * 1000);
- gen.fillRect((int)(width * 1000), (int)(height * 1000),
+ gen.fillRect((int)(width * 1000), (int)(height * 1000),
this.currentFillColor);
} catch (IOException ioe) {
handleIOTrouble(ioe);
}
}
-
+
/**
* Sets the new current fill color.
* @param color the color
@@ -866,9 +866,9 @@
String s = space.getSpace();
char sp = s.charAt(0);
Font font = getFontFromArea(textArea);
-
- int tws = (space.isAdjustable()
- ? textArea.getTextWordSpaceAdjust()
+
+ int tws = (space.isAdjustable()
+ ? textArea.getTextWordSpaceAdjust()
+ 2 * textArea.getTextLetterSpaceAdjust()
: 0);
@@ -893,10 +893,10 @@
float y = (currentBPPosition + viewport.getOffset()) / 1000f;
float width = viewport.getIPD() / 1000f;
float height = viewport.getBPD() / 1000f;
- // TODO: Calculate the border rect correctly.
+ // TODO: Calculate the border rect correctly.
float borderPaddingStart = viewport.getBorderAndPaddingWidthStart() / 1000f;
float borderPaddingBefore = viewport.getBorderAndPaddingWidthBefore() / 1000f;
- float bpwidth = borderPaddingStart
+ float bpwidth = borderPaddingStart
+ (viewport.getBorderAndPaddingWidthEnd() / 1000f);
float bpheight = borderPaddingBefore
+ (viewport.getBorderAndPaddingWidthAfter() / 1000f);
@@ -931,7 +931,7 @@
//This is the content-rect
float width = (float)bv.getIPD() / 1000f;
float height = (float)bv.getBPD() / 1000f;
-
+
if (bv.getPositioning() == Block.ABSOLUTE
|| bv.getPositioning() == Block.FIXED) {
@@ -943,17 +943,17 @@
if (bv.getPositioning() == Block.FIXED) {
breakOutList = breakOutOfStateStack();
}
-
+
AffineTransform positionTransform = new AffineTransform();
positionTransform.translate(bv.getXOffset(), bv.getYOffset());
-
+
//"left/"top" (bv.getX/YOffset()) specify the position of the content rectangle
positionTransform.translate(-borderPaddingStart, -borderPaddingBefore);
saveGraphicsState();
//Viewport position
concatenateTransformationMatrix(mptToPt(positionTransform));
-
+
//Background and borders
float bpwidth = (borderPaddingStart + bv.getBorderAndPaddingWidthEnd()) / 1000f;
float bpheight = (borderPaddingBefore + bv.getBorderAndPaddingWidthAfter()) / 1000f;
@@ -963,7 +963,7 @@
AffineTransform contentRectTransform = new AffineTransform();
contentRectTransform.translate(borderPaddingStart, borderPaddingBefore);
concatenateTransformationMatrix(mptToPt(contentRectTransform));
-
+
//Clipping
if (bv.getClip()) {
clipRect(0f, 0f, width, height);
@@ -973,7 +973,7 @@
//Set up coordinate system for content rectangle
AffineTransform contentTransform = ctm.toAffineTransform();
concatenateTransformationMatrix(mptToPt(contentTransform));
-
+
currentIPPosition = 0;
currentBPPosition = 0;
renderBlocks(bv, children);
@@ -984,7 +984,7 @@
if (breakOutList != null) {
restoreStateStackAfterBreakOut(breakOutList);
}
-
+
currentIPPosition = saveIP;
currentBPPosition = saveBP;
} else {
@@ -999,16 +999,16 @@
CTM tempctm = new CTM(containingIPPosition, currentBPPosition);
ctm = tempctm.multiply(ctm);
-
+
//Now adjust for border/padding
currentBPPosition += borderPaddingBefore;
Rectangle2D clippingRect = null;
if (bv.getClip()) {
- clippingRect = new Rectangle(currentIPPosition, currentBPPosition,
+ clippingRect = new Rectangle(currentIPPosition, currentBPPosition,
bv.getIPD(), bv.getBPD());
}
-
+
startVParea(ctm, clippingRect);
currentIPPosition = 0;
currentBPPosition = 0;
@@ -1017,7 +1017,7 @@
currentIPPosition = saveIP;
currentBPPosition = saveBP;
-
+
currentBPPosition += (int)(bv.getAllocBPD());
}
//currentFontName = saveFontName;
@@ -1034,7 +1034,7 @@
changePrintDirection();
}
}
-
+
private List breakOutOfStateStack() {
log.debug("Block.FIXED --> break out");
List breakOutList = new java.util.ArrayList();
@@ -1054,7 +1054,7 @@
}
/** {@inheritDoc} */
- protected RendererContext createRendererContext(int x, int y, int width, int height,
+ protected RendererContext createRendererContext(int x, int y, int width, int height,
Map foreignAttributes) {
RendererContext context = super.createRendererContext(
x, y, width, height, foreignAttributes);
@@ -1070,7 +1070,7 @@
private static final ImageFlavor[] FLAVORS = new ImageFlavor[]
{ImageFlavor.GRAPHICS2D,
- ImageFlavor.BUFFERED_IMAGE,
+ ImageFlavor.BUFFERED_IMAGE,
ImageFlavor.RENDERED_IMAGE,
ImageFlavor.XML_DOM};
/**
@@ -1089,18 +1089,18 @@
Point origin = new Point(currentIPPosition, currentBPPosition);
int x = origin.x + posInt.x;
int y = origin.y + posInt.y;
-
+
ImageManager manager = getUserAgent().getFactory().getImageManager();
ImageInfo info = null;
try {
ImageSessionContext sessionContext = getUserAgent().getImageSessionContext();
info = manager.getImageInfo(uri, sessionContext);
-
+
//Only now fully load/prepare the image
Map hints = ImageUtil.getDefaultHints(sessionContext);
org.apache.xmlgraphics.image.loader.Image img = manager.getImage(
info, FLAVORS, hints, sessionContext);
-
+
//...and process the image
if (img instanceof ImageGraphics2D) {
ImageGraphics2D imageG2D = (ImageGraphics2D)img;
@@ -1113,8 +1113,8 @@
ImageRendered imgRend = (ImageRendered)img;
RenderedImage ri = imgRend.getRenderedImage();
setCursorPos(x, y);
- gen.paintBitmap(ri,
- new Dimension(posInt.width, posInt.height),
+ gen.paintBitmap(ri,
+ new Dimension(posInt.width, posInt.height),
false);
} else if (img instanceof ImageXMLDOM) {
ImageXMLDOM imgXML = (ImageXMLDOM)img;
@@ -1160,18 +1160,18 @@
float height = area.getBPD() / 1000f;
float borderPaddingStart = area.getBorderAndPaddingWidthStart() / 1000f;
float borderPaddingBefore = area.getBorderAndPaddingWidthBefore() / 1000f;
- float bpwidth = borderPaddingStart
+ float bpwidth = borderPaddingStart
+ (area.getBorderAndPaddingWidthEnd() / 1000f);
float bpheight = borderPaddingBefore
+ (area.getBorderAndPaddingWidthAfter() / 1000f);
-
+
if (height != 0.0f || bpheight != 0.0f && bpwidth != 0.0f) {
drawBackAndBorders(area, x, y - borderPaddingBefore
, width + bpwidth
, height + bpheight);
}
}
-
+
/**
* Draw the background and borders. This draws the background and border
* traits for an area given the position.
@@ -1188,18 +1188,18 @@
BorderProps bpsAfter = (BorderProps) area.getTrait(Trait.BORDER_AFTER);
BorderProps bpsStart = (BorderProps) area.getTrait(Trait.BORDER_START);
BorderProps bpsEnd = (BorderProps) area.getTrait(Trait.BORDER_END);
-
+
// draw background
Trait.Background back;
back = (Trait.Background) area.getTrait(Trait.BACKGROUND);
if (back != null) {
-
+
// Calculate padding rectangle
float sx = startx;
float sy = starty;
float paddRectWidth = width;
float paddRectHeight = height;
-
+
if (bpsStart != null) {
sx += bpsStart.width / 1000f;
paddRectWidth -= bpsStart.width / 1000f;
@@ -1214,15 +1214,15 @@
if (bpsAfter != null) {
paddRectHeight -= bpsAfter.width / 1000f;
}
-
+
if (back.getColor() != null) {
updateFillColor(back.getColor());
fillRect(sx, sy, paddRectWidth, paddRectHeight);
}
-
+
// background image
if (back.getImageInfo() != null) {
- ImageSize imageSize = back.getImageInfo().getSize();
+ ImageSize imageSize = back.getImageInfo().getSize();
saveGraphicsState();
clipRect(sx, sy, paddRectWidth, paddRectHeight);
int horzCount = (int) ((paddRectWidth * 1000 / imageSize.getWidthMpt()) + 1.0f);
@@ -1250,7 +1250,7 @@
Rectangle2D pos;
// Image positions are relative to the currentIP/BP
pos = new Rectangle2D.Float(
- sx - currentIPPosition
+ sx - currentIPPosition
+ (x * imageSize.getWidthMpt()),
sy - currentBPPosition
+ (y * imageSize.getHeightMpt()),
@@ -1262,7 +1262,7 @@
restoreGraphicsState();
}
}
-
+
Rectangle2D.Float borderRect = new Rectangle2D.Float(startx, starty, width, height);
drawBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
}
@@ -1275,8 +1275,8 @@
* @param bpsStart the border specification on the start side
* @param bpsEnd the border specification on the end side
*/
- protected void drawBorders(Rectangle2D.Float borderRect,
- final BorderProps bpsBefore, final BorderProps bpsAfter,
+ protected void drawBorders(Rectangle2D.Float borderRect,
+ final BorderProps bpsBefore, final BorderProps bpsAfter,
final BorderProps bpsStart, final BorderProps bpsEnd) {
if (bpsBefore == null && bpsAfter == null && bpsStart == null && bpsEnd == null) {
return; //no borders to paint
@@ -1287,7 +1287,7 @@
drawFastBorders(borderRect, bpsBefore, bpsAfter, bpsStart, bpsEnd);
}
}
-
+
/**
* Draws borders. Borders are drawn as shaded rectangles with no clipping.
* @param borderRect the border rectangle
@@ -1296,8 +1296,8 @@
* @param bpsStart the border specification on the start side
* @param bpsEnd the border specification on the end side
*/
- protected void drawFastBorders(Rectangle2D.Float borderRect,
- final BorderProps bpsBefore, final BorderProps bpsAfter,
+ protected void drawFastBorders(Rectangle2D.Float borderRect,
+ final BorderProps bpsBefore, final BorderProps bpsAfter,
final BorderProps bpsStart, final BorderProps bpsEnd) {
float startx = borderRect.x;
float starty = borderRect.y;
@@ -1311,7 +1311,7 @@
if (bpsAfter != null) {
float borderWidth = bpsAfter.width / 1000f;
updateFillColor(bpsAfter.color);
- fillRect(startx, (starty + height - borderWidth),
+ fillRect(startx, (starty + height - borderWidth),
width, borderWidth);
}
if (bpsStart != null) {
@@ -1325,7 +1325,7 @@
fillRect((startx + width - borderWidth), starty, borderWidth, height);
}
}
-
+
/**
* Draws borders. Borders are drawn in-memory and painted as a bitmap.
* @param borderRect the border rectangle
@@ -1334,8 +1334,8 @@
* @param bpsStart the border specification on the start side
* @param bpsEnd the border specification on the end side
*/
- protected void drawQualityBorders(Rectangle2D.Float borderRect,
- final BorderProps bpsBefore, final BorderProps bpsAfter,
+ protected void drawQualityBorders(Rectangle2D.Float borderRect,
+ final BorderProps bpsBefore, final BorderProps bpsAfter,
final BorderProps bpsStart, final BorderProps bpsEnd) {
Graphics2DAdapter g2a = getGraphics2DAdapter();
final Rectangle.Float effBorderRect = new Rectangle2D.Float(
@@ -1345,7 +1345,7 @@
borderRect.height);
final Rectangle paintRect = new Rectangle(
(int)Math.round(borderRect.x * 1000f),
- (int)Math.round(borderRect.y * 1000f),
+ (int)Math.round(borderRect.y * 1000f),
(int)Math.floor(borderRect.width * 1000f) + 1,
(int)Math.floor(borderRect.height * 1000f) + 1);
//Add one pixel wide safety margin around the paint area
@@ -1356,14 +1356,14 @@
paintRect.y += yoffset;
paintRect.width += 2 * pixelWidth;
paintRect.height += 2 * pixelWidth;
-
- RendererContext rc = createRendererContext(paintRect.x, paintRect.y,
+
+ RendererContext rc = createRendererContext(paintRect.x, paintRect.y,
paintRect.width, paintRect.height, null);
Map atts = new java.util.HashMap();
atts.put(CONV_MODE, "bitmap");
atts.put(SRC_TRANSPARENCY, "true");
rc.setProperty(RendererContextConstants.FOREIGN_ATTRIBUTES, atts);
-
+
Graphics2DImagePainter painter = new Graphics2DImagePainter() {
public void paint(Graphics2D g2d, Rectangle2D area) {
@@ -1374,7 +1374,7 @@
float width = effBorderRect.width;
float height = effBorderRect.height;
boolean[] b = new boolean[] {
- (bpsBefore != null), (bpsEnd != null),
+ (bpsBefore != null), (bpsEnd != null),
(bpsAfter != null), (bpsStart != null)};
if (!b[0] && !b[1] && !b[2] && !b[3]) {
return;
@@ -1385,9 +1385,9 @@
(b[2] ? bpsAfter.width / 1000f : 0.0f),
(b[3] ? bpsStart.width / 1000f : 0.0f)};
float[] clipw = new float[] {
- BorderProps.getClippedWidth(bpsBefore) / 1000f,
- BorderProps.getClippedWidth(bpsEnd) / 1000f,
- BorderProps.getClippedWidth(bpsAfter) / 1000f,
+ BorderProps.getClippedWidth(bpsBefore) / 1000f,
+ BorderProps.getClippedWidth(bpsEnd) / 1000f,
+ BorderProps.getClippedWidth(bpsAfter) / 1000f,
BorderProps.getClippedWidth(bpsStart) / 1000f};
starty += clipw[0];
height -= clipw[0];
@@ -1395,7 +1395,7 @@
startx += clipw[3];
width -= clipw[3];
width -= clipw[1];
-
+
boolean[] slant = new boolean[] {
(b[3] && b[0]), (b[0] && b[1]), (b[1] && b[2]), (b[2] && b[3])};
if (bpsBefore != null) {
@@ -1433,7 +1433,7 @@
currentPath = null;
Rectangle2D.Float lineRect = new Rectangle2D.Float(
sx1a, outery, ex1a - sx1a, innery - outery);
- Java2DRenderer.drawBorderLine(lineRect, true, true,
+ Java2DRenderer.drawBorderLine(lineRect, true, true,
bpsBefore.style, bpsBefore.color, g);
//restoreGraphicsState();
}
@@ -1447,7 +1447,7 @@
float outerx = startx + width + clipw[1];
float clipx = outerx - clipw[1];
float innerx = outerx - bw[1];
-
+
//saveGraphicsState();
Graphics2D g = (Graphics2D)g2d.create();
moveTo(clipx, sy1);
@@ -1472,7 +1472,7 @@
currentPath = null;
Rectangle2D.Float lineRect = new Rectangle2D.Float(
innerx, sy1a, outerx - innerx, ey1a - sy1a);
- Java2DRenderer.drawBorderLine(lineRect, false, false,
+ Java2DRenderer.drawBorderLine(lineRect, false, false,
bpsEnd.style, bpsEnd.color, g);
//restoreGraphicsState();
}
@@ -1511,7 +1511,7 @@
currentPath = null;
Rectangle2D.Float lineRect = new Rectangle2D.Float(
sx1a, innery, ex1a - sx1a, outery - innery);
- Java2DRenderer.drawBorderLine(lineRect, true, false,
+ Java2DRenderer.drawBorderLine(lineRect, true, false,
bpsAfter.style, bpsAfter.color, g);
//restoreGraphicsState();
}
@@ -1550,7 +1550,7 @@
currentPath = null;
Rectangle2D.Float lineRect = new Rectangle2D.Float(
outerx, sy1a, innerx - outerx, ey1a - sy1a);
- Java2DRenderer.drawBorderLine(lineRect, false, false,
+ Java2DRenderer.drawBorderLine(lineRect, false, false,
bpsStart.style, bpsStart.color, g);
//restoreGraphicsState();
}
@@ -1559,10 +1559,10 @@
public Dimension getImageSize() {
return paintRect.getSize();
}
-
+
};
try {
- g2a.paintImage(painter, rc,
+ g2a.paintImage(painter, rc,
paintRect.x - xoffset, paintRect.y, paintRect.width, paintRect.height);
} catch (IOException ioe) {
handleIOTrouble(ioe);
@@ -1577,7 +1577,7 @@
public void setAllTextAsBitmaps(boolean allTextAsBitmaps) {
this.allTextAsBitmaps = allTextAsBitmaps;
}
-
-
-
+
+
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java Fri May 9 05:30:40 2008
@@ -16,7 +16,7 @@
*/
/* $Id$ */
-
+
package org.apache.fop.render.ps;
@@ -91,28 +91,28 @@
* @exception TranscoderException if an error occured while transcoding
*/
protected void transcode(Document document, String uri,
- TranscoderOutput output)
+ TranscoderOutput output)
throws TranscoderException {
graphics = createDocumentGraphics2D();
if (!isTextStroked()) {
- FontInfo fontInfo = new FontInfo();
- //TODO Do custom font configuration here somewhere/somehow
- FontSetup.setup(fontInfo);
+ FontInfo fontInfo = new FontInfo();
+ //TODO Do custom font configuration here somewhere/somehow
+ FontSetup.setup(fontInfo);
graphics.setCustomTextHandler(new NativeTextHandler(graphics, fontInfo));
}
super.transcode(document, uri, output);
getLogger().trace("document size: " + width + " x " + height);
-
+
// prepare the image to be painted
- UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
+ UnitProcessor.Context uctx = UnitProcessor.createContext(ctx,
document.getDocumentElement());
- float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT,
+ float widthInPt = UnitProcessor.userSpaceToSVG(width, SVGLength.SVG_LENGTHTYPE_PT,
UnitProcessor.HORIZONTAL_LENGTH, uctx);
int w = (int)(widthInPt + 0.5);
- float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT,
+ float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT,
UnitProcessor.HORIZONTAL_LENGTH, uctx);
int h = (int)(heightInPt + 0.5);
getLogger().trace("document size: " + w + "pt x " + h + "pt");
@@ -140,7 +140,7 @@
throw new TranscoderException(ex);
}
}
-
+
/** {@inheritDoc} */
protected BridgeContext createBridgeContext() {
@@ -148,7 +148,7 @@
if (!isTextStroked()) {
TextHandler handler = graphics.getCustomTextHandler();
if (handler instanceof NativeTextHandler) {
- NativeTextHandler nativeTextHandler = (NativeTextHandler)handler;
+ NativeTextHandler nativeTextHandler = (NativeTextHandler)handler;
PSTextPainter textPainter = new PSTextPainter(nativeTextHandler);
ctx.setTextPainter(textPainter);
ctx.putBridge(new PSTextElementBridge(textPainter));
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java Fri May 9 05:30:40 2008
@@ -38,16 +38,16 @@
public class NativeTextHandler implements PSTextHandler {
private PSGraphics2D g2d;
-
+
/** FontInfo containing all available fonts */
protected FontInfo fontInfo;
/** Currently valid Font */
protected Font font;
-
+
/** Overriding FontState */
protected Font overrideFont = null;
-
+
/** the current (internal) font name */
protected String currentFontName;
@@ -67,13 +67,13 @@
setupFontInfo();
}
}
-
+
private void setupFontInfo() {
//Sets up a FontInfo with default fonts
fontInfo = new FontInfo();
FontSetup.setup(fontInfo);
}
-
+
/**
* Return the font information associated with this object
* @return the FontInfo object
@@ -85,7 +85,7 @@
private PSGenerator getPSGenerator() {
return this.g2d.getPSGenerator();
}
-
+
/** {@inheritDoc} */
public void writeSetup() throws IOException {
if (fontInfo != null) {
@@ -99,9 +99,9 @@
}
/**
- * Draw a string to the PostScript document. The text is painted using
+ * Draw a string to the PostScript document. The text is painted using
* text operations.
- * {@inheritDoc}
+ * {@inheritDoc}
*/
public void drawString(String s, float x, float y) throws IOException {
g2d.preparePainting();
@@ -112,7 +112,7 @@
this.font = this.overrideFont;
this.overrideFont = null;
}
-
+
//Color and Font state
g2d.establishColor(g2d.getColor());
establishCurrentFont();
@@ -130,14 +130,14 @@
gen.writeln(gen.formatDouble(x) + " "
+ gen.formatDouble(y) + " moveto ");
gen.writeln("1 -1 scale");
-
+
StringBuffer sb = new StringBuffer("(");
escapeText(s, sb);
sb.append(") t ");
gen.writeln(sb.toString());
-
- gen.restoreGraphicsState();
+
+ gen.restoreGraphicsState();
}
private void escapeText(final String text, StringBuffer target) {
@@ -157,7 +157,7 @@
int fontSize = 1000 * f.getSize();
String style = f.isItalic() ? "italic" : "normal";
int weight = f.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;
-
+
FontTriplet triplet = fontInfo.findAdjustWeight(fontFamily, style, weight);
if (triplet == null) {
triplet = fontInfo.findAdjustWeight("sans-serif", style, weight);
@@ -166,10 +166,10 @@
}
private void establishCurrentFont() throws IOException {
- if ((currentFontName != this.font.getFontName())
+ if ((currentFontName != this.font.getFontName())
|| (currentFontSize != this.font.getFontSize())) {
PSGenerator gen = getPSGenerator();
- gen.writeln(this.font.getFontName() + " "
+ gen.writeln(this.font.getFontName() + " "
+ gen.formatDouble(font.getFontSize() / 1000f) + " F");
currentFontName = this.font.getFontName();
currentFontSize = this.font.getFontSize();
@@ -183,6 +183,6 @@
public void setOverrideFont(Font override) {
this.overrideFont = override;
}
-
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java Fri May 9 05:30:40 2008
@@ -56,7 +56,7 @@
private int width;
private int height;
-
+
//for SVG scaling
private float svgWidth;
private float svgHeight;
@@ -65,7 +65,7 @@
public static final int NORMAL_PDF_RESOLUTION = 72;
/** Default device resolution (300dpi is a resonable quality for most purposes) */
public static final int DEFAULT_NATIVE_DPI = 300;
-
+
/**
* The device resolution may be different from the normal target resolution. See
* http://issues.apache.org/bugzilla/show_bug.cgi?id=37305
@@ -96,7 +96,7 @@
public PDFDocumentGraphics2D(boolean textAsShapes) {
super(textAsShapes);
- this.pdfDoc = new PDFDocument("Apache FOP Version " + Version.getVersion()
+ this.pdfDoc = new PDFDocument("Apache FOP Version " + Version.getVersion()
+ ": PDFDocumentGraphics2D");
this.pdfContext = new PDFContext();
}
@@ -150,7 +150,7 @@
}
/**
- * Setup a default FontInfo instance if none has been setup before.
+ * Setup a default FontInfo instance if none has been setup before.
*/
public void setupDefaultFontInfo() {
if (fontInfo == null) {
@@ -160,7 +160,7 @@
setFontInfo(fontInfo);
}
}
-
+
/**
* Set the device resolution for rendering. Will take effect at the
* start of the next page.
@@ -184,7 +184,7 @@
public void setFontInfo(FontInfo fontInfo) {
this.fontInfo = fontInfo;
}
-
+
/**
* Get the font info for this pdf document.
* @return the font information
@@ -208,7 +208,7 @@
public PDFContext getPDFContext() {
return this.pdfContext;
}
-
+
/**
* Set the dimensions of the svg document that will be drawn.
* This is useful if the dimensions of the svg document are different
@@ -248,9 +248,9 @@
public void nextPage() {
closePage();
}
-
+
/**
- * Closes the current page and adds it to the PDF file.
+ * Closes the current page and adds it to the PDF file.
*/
protected void closePage() {
if (!pdfContext.isPagePending()) {
@@ -270,7 +270,7 @@
this.pdfDoc.addObject(pdfContext.getCurrentPage());
pdfContext.clearCurrentPage();
}
-
+
/** {@inheritDoc} */
protected void preparePainting() {
if (pdfContext.isPagePending()) {
@@ -300,7 +300,7 @@
if (this.initialTransform == null) {
//Save initial transformation matrix
this.initialTransform = getTransform();
- this.initialClip = getClip();
+ this.initialClip = getClip();
} else {
//Reset transformation matrix
setTransform(this.initialTransform);
@@ -313,7 +313,7 @@
if (currentStream == null) {
currentStream = new StringWriter();
}
-
+
PDFResources pdfResources = this.pdfDoc.getResources();
PDFPage page = this.pdfDoc.getFactory().makePage(pdfResources,
width, height);
@@ -321,7 +321,7 @@
pdfContext.setCurrentPage(page);
pageRef = page.referencePDF();
- AffineTransform at = new AffineTransform(1.0, 0.0, 0.0, -1.0,
+ AffineTransform at = new AffineTransform(1.0, 0.0, 0.0, -1.0,
0.0, (double)height);
currentStream.write("1 0 0 -1 0 " + height + " cm\n");
if (svgWidth != 0) {
@@ -336,7 +336,7 @@
at.scale(s, s);
currentStream.write("" + PDFNumber.doubleOut(s) + " 0 0 "
+ PDFNumber.doubleOut(s) + " 0 0 cm\n");
-
+
scale(1 / s, 1 / s);
}
// Remember the transform we installed.
@@ -344,8 +344,8 @@
pdfContext.increasePageCount();
}
-
-
+
+
/**
* The rendering process has finished.
* This should be called after the rendering has completed as there is
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Fri May 9 05:30:40 2008
@@ -44,23 +44,23 @@
* @param cfg the configuration
* @throws ConfigurationException if an error occurs while configuring the object
*/
- public void configure(PDFDocumentGraphics2D graphics, Configuration cfg)
+ public void configure(PDFDocumentGraphics2D graphics, Configuration cfg)
throws ConfigurationException {
PDFDocument pdfDoc = graphics.getPDFDocument();
-
+
//Filter map
pdfDoc.setFilterMap(
PDFRendererConfigurator.buildFilterMapFromConfiguration(cfg));
-
+
//Fonts
try {
FontResolver fontResolver = FontManager.createMinimalFontResolver();
//TODO The following could be optimized by retaining the FontManager somewhere
FontManager fontManager = new FontManager();
-
+
//TODO Make use of fontBaseURL, font substitution and referencing configuration
//Requires a change to the expected configuration layout
-
+
List/*<EmbedFontInfo>*/ embedFontInfoList
= PrintRendererConfigurator.buildFontListFromConfiguration(
cfg, fontResolver, false, fontManager);
@@ -74,5 +74,5 @@
throw new ConfigurationException("Error while setting up fonts", e);
}
}
-
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java Fri May 9 05:30:40 2008
@@ -106,13 +106,13 @@
public class PDFGraphics2D extends AbstractGraphics2D {
private static final AffineTransform IDENTITY_TRANSFORM = new AffineTransform();
-
- /** The number of decimal places. */
+
+ /** The number of decimal places. */
private static final int DEC = 8;
/** Convenience constant for full opacity */
static final int OPAQUE = 255;
-
+
/**
* the PDF Document being created
*/
@@ -308,7 +308,7 @@
public String getPageReference() {
return this.pageRef;
}
-
+
/**
* Set the Graphics context.
* @param c the graphics context to use
@@ -319,10 +319,10 @@
}
private void setPrivateHints() {
- setRenderingHint(RenderingHintsKeyExt.KEY_AVOID_TILE_PAINTING,
+ setRenderingHint(RenderingHintsKeyExt.KEY_AVOID_TILE_PAINTING,
RenderingHintsKeyExt.VALUE_AVOID_TILE_PAINTING_ON);
}
-
+
/**
* Set the override font state for drawing text.
* This is used by the PDF text painter so that it can temporarily
@@ -362,7 +362,7 @@
concatMatrix(matrix);
}
}
-
+
/**
* This is mainly used for shading patterns which use the document-global coordinate system
* instead of the local one.
@@ -372,7 +372,7 @@
AffineTransform at = new AffineTransform(graphicsState.getTransform());
return at;
}
-
+
/**
* This is a pdf specific method used to add a link to the
* pdf document.
@@ -417,7 +417,7 @@
* @param width the width to draw the image
* @param height the height to draw the image
*/
- void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y,
+ void addNativeImage(org.apache.xmlgraphics.image.loader.Image image, float x, float y,
float width, float height) {
preparePainting();
String key = image.getInfo().getOriginalURI();
@@ -425,10 +425,10 @@
// Need to include hash code as when invoked from FO you
// may have several 'independent' PDFGraphics2D so the
// count is not enough.
- key = "__AddNative_" + hashCode() + "_" + nativeCount;
+ key = "__AddNative_" + hashCode() + "_" + nativeCount;
nativeCount++;
}
-
+
PDFImage pdfImage;
if (image instanceof ImageRawJPEG) {
pdfImage = new ImageRawJPEGAdapter((ImageRawJPEG)image, key);
@@ -438,7 +438,7 @@
throw new IllegalArgumentException(
"Unsupported Image subclass: " + image.getClass().getName());
}
-
+
PDFXObject xObject = this.pdfDoc.addImage(resourceContext, pdfImage);
if (outputStream != null) {
try {
@@ -649,7 +649,7 @@
graphicsState.pop();
}
}
-
+
/*
// in theory we could set the clip using these methods
// it doesn't seem to improve the file sizes much
@@ -784,8 +784,8 @@
(float) gpaint.getPoint1().getX(),
(float) gpaint.getPoint1().getY(),
(float) gpaint.getPoint2().getX(),
- (float) gpaint.getPoint2().getY(),
- new float[] {0, 1},
+ (float) gpaint.getPoint2().getY(),
+ new float[] {0, 1},
new Color[] {gpaint.getColor1(), gpaint.getColor2()},
gpaint.isCyclic() ? LinearGradientPaint.REPEAT : LinearGradientPaint.NO_CYCLE);
}
@@ -927,7 +927,7 @@
return false; // PDF can't do alpha
}
- someColors.add(new PDFColor(cc.getRed(), cc.getGreen(),
+ someColors.add(new PDFColor(cc.getRed(), cc.getGreen(),
cc.getBlue()));
}
@@ -947,7 +947,7 @@
currentStream.write(myPat.getColorSpaceOut(fill));
return true;
- }
+ }
if (paint instanceof PatternPaint) {
PatternPaint pp = (PatternPaint)paint;
return createPattern(pp, fill);
@@ -990,14 +990,14 @@
// double patMaxX = rect.getX() + rect.getWidth();
// double patMaxY = rect.getY() + rect.getHeight();
// double stepX = rect.getWidth();
- // double stepY = rect.getHeight();
- //
+ // double stepY = rect.getHeight();
+ //
// int startX = (int)((rect.getX() - gnMaxX)/stepX);
// int startY = (int)((rect.getY() - gnMaxY)/stepY);
- //
+ //
// int endX = (int)((patMaxX - gnMinX)/stepX);
// int endY = (int)((patMaxY - gnMinY)/stepY);
- //
+ //
// pattGraphic.translate(startX*stepX, startY*stepY);
// for (int yIdx=startY; yIdx<=endY; yIdx++) {
// for (int xIdx=startX; xIdx<=endX; xIdx++) {
@@ -1027,14 +1027,14 @@
}
/** @todo see if pdfDoc and res can be linked here,
- (currently res <> PDFDocument's resources) so addFonts()
+ (currently res <> PDFDocument's resources) so addFonts()
can be moved to PDFDocument class */
res.addFonts(pdfDoc, specialFontInfo);
PDFPattern myPat = pdfDoc.getFactory().makePattern(
resourceContext, 1, res, 1, 1, bbox,
rect.getWidth(), rect.getHeight(),
- theMatrix, null,
+ theMatrix, null,
pattGraphic.getBuffer());
currentStream.write(myPat.getColorSpaceOut(fill));
@@ -1094,7 +1094,7 @@
(rgbCS, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
false, DataBuffer.TYPE_BYTE);
- PaintContext pctx = paint.createContext(rgbCM, devBounds, usrBounds,
+ PaintContext pctx = paint.createContext(rgbCM, devBounds, usrBounds,
at, getRenderingHints());
PDFXObject imageInfo = pdfDoc.getXObject
("TempImage:" + pctx.toString());
@@ -1112,7 +1112,7 @@
final int[] line = new int[devW];
final byte[] mask;
int x, y, val, rgbIdx = 0;
-
+
if (pcm.hasAlpha()) {
mask = new byte[devW * devH];
int maskIdx = 0;
@@ -1611,7 +1611,7 @@
return;
}
}
-
+
AffineTransform trans = getTransform();
double[] tranvals = new double[6];
trans.getMatrix(tranvals);
@@ -1709,7 +1709,7 @@
iter.next();
}
}
-
+
/**
* Do the PDF drawing command.
* This does the PDF drawing command according to fill
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java Fri May 9 05:30:40 2008
@@ -33,7 +33,7 @@
import org.xml.sax.SAXException;
/**
- * Basic runtime test for FOP's font configuration. It is used to verify that
+ * Basic runtime test for FOP's font configuration. It is used to verify that
* nothing obvious is broken after compiling.
*/
public abstract class BaseUserConfigTestCase extends BasePDFTestCase {
@@ -59,7 +59,7 @@
}
protected void initConfig() throws Exception {
- fopFactory.setUserConfig(getUserConfig());
+ fopFactory.setUserConfig(getUserConfig());
}
protected void convertFO() throws Exception {
@@ -70,7 +70,7 @@
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
convertFO(foFile, foUserAgent, dumpOutput);
}
-
+
/**
* get test FOP config File
* @return fo test filepath
@@ -82,9 +82,9 @@
/**
* get test FOP Configuration
* @return fo test filepath
- * @throws IOException
- * @throws SAXException
- * @throws ConfigurationException
+ * @throws IOException
+ * @throws SAXException
+ * @throws ConfigurationException
*/
protected Configuration getUserConfig(String configString) throws ConfigurationException, SAXException, IOException {
return cfgBuilder.build(new ByteArrayInputStream(configString.getBytes()));
@@ -114,11 +114,11 @@
/**
* get test FOP Configuration
* @return fo test filepath
- * @throws IOException
- * @throws SAXException
- * @throws ConfigurationException
+ * @throws IOException
+ * @throws SAXException
+ * @throws ConfigurationException
*/
protected Configuration getUserConfig() throws ConfigurationException, SAXException, IOException {
return cfgBuilder.buildFromFile(getUserConfigFile());
- }
+ }
}
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java Fri May 9 05:30:40 2008
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-/* $Id: $ */
+/* $Id$ */
package org.apache.fop.config;
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java Fri May 9 05:30:40 2008
@@ -68,26 +68,26 @@
public class LayoutEngineTester {
private static final Map CHECK_CLASSES = new java.util.HashMap();
-
+
// configure fopFactory as desired
private FopFactory fopFactory = FopFactory.newInstance();
private FopFactory fopFactoryWithBase14Kerning = FopFactory.newInstance();
-
- private SAXTransformerFactory tfactory
+
+ private SAXTransformerFactory tfactory
= (SAXTransformerFactory)SAXTransformerFactory.newInstance();
private Templates testcase2fo;
private Templates testcase2checks;
-
+
private File areaTreeBackupDir;
-
+
static {
CHECK_CLASSES.put("true", TrueCheck.class);
CHECK_CLASSES.put("eval", EvalCheck.class);
CHECK_CLASSES.put("element-list", ElementListCheck.class);
CHECK_CLASSES.put("result", ResultCheck.class);
}
-
+
/**
* Constructs a new instance.
* @param areaTreeBackupDir Optional directory that receives the generated
@@ -98,7 +98,7 @@
fopFactory.getFontManager().setBase14KerningEnabled(false);
fopFactoryWithBase14Kerning.getFontManager().setBase14KerningEnabled(true);
}
-
+
private Templates getTestcase2FOStylesheet() throws TransformerConfigurationException {
if (testcase2fo == null) {
//Load and cache stylesheet
@@ -107,7 +107,7 @@
}
return testcase2fo;
}
-
+
private Templates getTestcase2ChecksStylesheet() throws TransformerConfigurationException {
if (testcase2checks == null) {
//Load and cache stylesheet
@@ -116,7 +116,7 @@
}
return testcase2checks;
}
-
+
/**
* Runs a single layout engine test case.
* @param testFile Test case to run
@@ -125,14 +125,14 @@
* @throws SAXException In case of a problem during SAX processing
* @throws ParserConfigurationException In case of a problem with the XML parser setup
*/
- public void runTest(File testFile)
+ public void runTest(File testFile)
throws TransformerException, SAXException, IOException, ParserConfigurationException {
-
+
DOMResult domres = new DOMResult();
ElementListCollector elCollector = new ElementListCollector();
ElementListObserver.addObserver(elCollector);
-
+
Fop fop;
try {
@@ -141,47 +141,47 @@
dbf.setValidating(false);
DocumentBuilder builder = dbf.newDocumentBuilder();
Document testDoc = builder.parse(testFile);
-
+
XObject xo = XPathAPI.eval(testDoc, "/testcase/cfg/base14kerning");
String s = xo.str();
boolean base14kerning = ("true".equalsIgnoreCase(s));
FopFactory effFactory = (base14kerning ? fopFactoryWithBase14Kerning : fopFactory);
-
+
//Setup Transformer to convert the testcase XML to XSL-FO
Transformer transformer = getTestcase2FOStylesheet().newTransformer();
Source src = new DOMSource(testDoc);
-
+
//Setup Transformer to convert the area tree to a DOM
TransformerHandler athandler = tfactory.newTransformerHandler();
athandler.setResult(domres);
-
+
//Setup FOP for area tree rendering
FOUserAgent ua = effFactory.newFOUserAgent();
ua.setBaseURL(testFile.getParentFile().toURL().toString());
ua.getEventBroadcaster().addEventListener(
new ConsoleEventListenerForTests(testFile.getName()));
-
+
XMLRenderer atrenderer = new XMLRenderer();
atrenderer.setUserAgent(ua);
atrenderer.setContentHandler(athandler);
ua.setRendererOverride(atrenderer);
fop = effFactory.newFop(ua);
-
+
SAXResult fores = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, fores);
} finally {
ElementListObserver.removeObserver(elCollector);
}
-
+
Document doc = (Document)domres.getNode();
if (this.areaTreeBackupDir != null) {
saveAreaTreeXML(doc, new File(this.areaTreeBackupDir, testFile.getName() + ".at.xml"));
}
- FormattingResults results = fop.getResults();
+ FormattingResults results = fop.getResults();
LayoutResult result = new LayoutResult(doc, elCollector, results);
checkAll(testFile, result);
}
-
+
/**
* Factory method to create checks from DOM elements.
* @param el DOM element to create the check from
@@ -196,14 +196,14 @@
LayoutEngineCheck instance = (LayoutEngineCheck)c.newInstance(new Object[] {el});
return instance;
} catch (Exception e) {
- throw new RuntimeException("Error while instantiating check '"
+ throw new RuntimeException("Error while instantiating check '"
+ name + "': " + e.getMessage());
}
} else {
throw new IllegalArgumentException("No check class found: " + name);
}
}
-
+
/**
* Perform all checks on the area tree.
* @param testFile Test case XML file
@@ -215,7 +215,7 @@
Source src = new StreamSource(testFile);
DOMResult res = new DOMResult();
transformer.transform(src, res);
-
+
List checks = new java.util.ArrayList();
Document doc = (Document)res.getNode();
NodeList nodes = doc.getDocumentElement().getChildNodes();
@@ -225,7 +225,7 @@
checks.add(createCheck((Element)node));
}
}
-
+
if (checks.size() == 0) {
throw new RuntimeException("No checks are available!");
}
@@ -235,7 +235,7 @@
check.check(result);
}
}
-
+
/**
* Save the area tree XML for later inspection.
* @param doc area tree as a DOM document
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java Fri May 9 05:30:40 2008
@@ -112,10 +112,10 @@
}
return e;
}
-
+
/**
- * get FOP config File
- * @return user config file to be used for testing
+ * get FOP config File
+ * @return user config file to be used for testing
*/
protected File getUserConfigFile() {
return new File("test/test.xconf");
Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java?rev=654783&r1=654782&r2=654783&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java Fri May 9 05:30:40 2008
@@ -31,7 +31,7 @@
private File foBaseDir = new File("test/xml/pdf-a");
private boolean dumpPDF = Boolean.getBoolean("PDFAConformanceTestCase.dumpPDF");
-
+
/**
* Main constructor
* @param name the name of the test case
@@ -40,7 +40,7 @@
super(name);
}
- /** create an FOUserAgent for our tests
+ /** create an FOUserAgent for our tests
* @return an initialized FOUserAgent
* */
protected FOUserAgent getUserAgent() {
@@ -48,7 +48,7 @@
userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
return userAgent;
}
-
+
/**
* Test exception when PDF/A-1 is enabled and everything is as it should.
* @throws Exception if the test fails
@@ -57,7 +57,7 @@
File foFile = new File(foBaseDir, "minimal-pdf-a.fo");
convertFO(foFile, getUserAgent(), dumpPDF);
}
-
+
/**
* Test exception when PDF/A-1 is enabled together with encryption.
* @throws Exception if the test fails
@@ -73,7 +73,7 @@
//Good!
}
}
-
+
/**
* Test exception when PDF/A-1 is enabled and a font is used which is not embedded.
* @throws Exception if the test fails
@@ -87,7 +87,7 @@
//Good!
}
}
-
+
/**
* Test exception when PDF/A-1 is enabled and images.
* @throws Exception if the test fails
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org