<target name="hyphenation-jar" depends="hyphenation">
<tstamp>
- <format property="ts" pattern="yyyy-MM-dd'T'HH:mm:ssZ"/>
+ <format property="ts" pattern="yyyyMMdd-HHmmss-z"/>
</tstamp>
<jar jarfile="${build.dir}/fop-hyph.jar" basedir="${build.dest}" includes="hyph/**">
<manifest>
*/
public class PageSequenceLayoutManager extends AbstractLayoutManager {
- private Log log = LogFactory.getLog(PageSequenceLayoutManager.class);
+ private static Log log = LogFactory.getLog(PageSequenceLayoutManager.class);
/**
* AreaTreeHandler which activates the PSLM and controls
needColumnBalancing = (childLC.getNextSpan() == Constants.EN_ALL);
}
if (needColumnBalancing) {
- log.debug("Column balancing necessary for the next element list!!!");
+ this.log.debug("Column balancing necessary for the next element list!!!");
}
return nextSequenceStartsOn;
}
protected void doPhase3(PageBreakingAlgorithm alg, int partCount,
BlockSequence originalList, BlockSequence effectiveList) {
if (needColumnBalancing) {
- log.debug("Column balancing now!!!");
- log.debug("===================================================");
+ this.log.debug("Column balancing now!!!");
+ this.log.debug("===================================================");
int restartPoint = pvProvider.getStartingPartIndexForLastPage(partCount);
if (restartPoint > 0) {
addAreas(alg, restartPoint, originalList, effectiveList);
} else {
newStartPos = 0;
}
- log.debug("Restarting at " + restartPoint + ", new start position: " + newStartPos);
+ this.log.debug("Restarting at " + restartPoint + ", new start position: " + newStartPos);
//Handle page break right here to avoid any side-effects
handleBreakTrait(EN_PAGE);
int iOptPageCount = algRestart.findBreakingPoints(effectiveList,
newStartPos,
1, true, true);
- log.debug("restart: iOptPageCount= " + iOptPageCount
+ this.log.debug("restart: iOptPageCount= " + iOptPageCount
+ " pageBreaks.size()= " + algRestart.getPageBreaks().size());
if (iOptPageCount > getCurrentPV().getBodyRegion().getColumnCount()) {
/* reenable when everything works
//Make sure we only add the areas we haven't added already
effectiveList.ignoreAtStart = newStartPos;
addAreas(algRestart, iOptPageCount, originalList, effectiveList);
- log.debug("===================================================");
+ this.log.debug("===================================================");
} else {
//Directly add areas after finding the breaks
addAreas(alg, partCount, originalList, effectiveList);
}
protected void startPart(BlockSequence list, int breakClass) {
- log.debug("startPart() breakClass=" + breakClass);
+ this.log.debug("startPart() breakClass=" + breakClass);
if (curPV == null) {
throw new IllegalStateException("curPV must not be null");
}
import java.security.Security;
import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class acts as a factory for PDF encryption support. It enables the
*/
public class PDFEncryptionManager {
+ /** logging instance */
+ protected static Log log = LogFactory.getLog(PDFEncryptionManager.class);
+
/**
* Indicates whether JCE is available.
* @return boolean true if JCE is present
* @param log the logger to send warnings to
*/
public static void setupPDFEncryption(PDFEncryptionParams params,
- PDFDocument pdf,
- Log log) {
+ PDFDocument pdf) {
if (pdf == null) {
throw new NullPointerException("PDF document must not be null");
}
public abstract class AbstractRenderer
implements Renderer, Configurable, Constants {
+ /** logging instance */
+ protected static Log log = LogFactory.getLog("org.apache.fop.render");
+
/**
* user agent
*/
protected FOUserAgent userAgent;
- /**
- * logging instance
- */
- protected static Log logger = LogFactory.getLog("org.apache.fop.render");
-
/**
* block progression position
*/
public void configure(Configuration conf) throws ConfigurationException {
}
- /**
- * Returns the Commons-Logging instance for this class
- * @return The Commons-Logging instance
- */
- protected Log getLogger() {
- return logger;
- }
-
/**
* @see org.apache.fop.render.Renderer
*/
handler.handleXML(ctx, doc, namespace);
} catch (Throwable t) {
// could not handle document
- getLogger().error("Some XML content will be ignored. "
+ log.error("Some XML content will be ignored. "
+ "Could not render XML", t);
}
} else {
if (!warnedXMLHandlers.contains(namespace)) {
// no handler found for document
warnedXMLHandlers.add(namespace);
- getLogger().warn("Some XML content will be ignored. "
+ log.warn("Some XML content will be ignored. "
+ "No handler defined for XML: " + namespace);
}
}
/** @see org.apache.fop.render.Renderer#startRenderer(java.io.OutputStream) */
public void startRenderer(OutputStream outputStream) throws IOException {
- getLogger().info("rendering areas to PNG");
+ log.info("rendering areas to PNG");
setOutputDirectory();
this.firstOutputStream = outputStream;
}
OutputStream os = getCurrentOutputStream(i);
if (os == null) {
- getLogger().warn("No filename information available."
+ log.warn("No filename information available."
+ " Stopping early after the first page.");
break;
}
.get(i));
// Encode this image
- getLogger().debug("Encoding page " + (i + 1));
+ log.debug("Encoding page " + (i + 1));
renderParams = PNGEncodeParam.getDefaultEncodeParam(image);
// Set resolution
/** @see org.apache.fop.render.Renderer#startRenderer(java.io.OutputStream) */
public void startRenderer(OutputStream outputStream) throws IOException {
- getLogger().info("rendering areas to PNG");
+ log.info("rendering areas to PNG");
setOutputDirectory();
this.firstOutputStream = outputStream;
}
RenderedImage image = (RenderedImage) getPageImage(pageViewport);
// Encode this image
- getLogger().debug("Encoding Page" + (getCurrentPageNumber() + 1));
+ log.debug("Encoding page" + (getCurrentPageNumber() + 1));
renderParams = PNGEncodeParam.getDefaultEncodeParam(image);
OutputStream os = getCurrentOutputStream(getCurrentPageNumber());
PNGImageEncoder encoder = new PNGImageEncoder(os, renderParams);
import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageDecoder;
import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageEncoder;
import org.apache.batik.ext.awt.image.rendered.FormatRed;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.fop.apps.FOPException;
import org.apache.fop.render.java2d.Java2DRenderer;
name = "COMPRESSION_DEFLATE";
break;
default:
- getLogger().info("TIFF compression not supported: " + comp);
+ log.info("TIFF compression not supported: " + comp);
return;
}
- getLogger().info("TIFF compression set to " + name);
+ log.info("TIFF compression set to " + name);
}
public void stopRenderer() throws IOException {
super.stopRenderer();
- getLogger().debug("Starting Tiff encoding ...");
+ log.debug("Starting Tiff encoding ...");
//Set resolution
float pixSzMM = userAgent.getPixelUnitToMillimeter();
TIFFImageEncoder enc = new TIFFImageEncoder(outputStream, renderParams);
// Creates lazy iterator over generated page images
- Iterator pageImagesItr = new LazyPageImagesIterator(getNumberOfPages());
+ Iterator pageImagesItr = new LazyPageImagesIterator(getNumberOfPages(), log);
// The first image to be passed to enc
RenderedImage first = (RenderedImage) pageImagesItr.next();
// Cleaning
outputStream.flush();
clearViewportList();
- getLogger().debug("Tiff encoding done.");
+ log.debug("Tiff encoding done.");
}
/** Private inner class to lazy page rendering. */
private class LazyPageImagesIterator implements Iterator {
+ /** logging instance */
+ private Log log;
+
private int count;
private int current = 0;
- public LazyPageImagesIterator(int c) {
+ /**
+ * Main constructor
+ * @param c number of pages to iterate over
+ * @param log the logger to use (this is a hack so this compiles under JDK 1.3)
+ */
+ public LazyPageImagesIterator(int c, Log log) {
count = c;
+ this.log = log;
}
public boolean hasNext() {
}
public Object next() {
- getLogger().debug("[" + (current + 1) + "]");
+ log.debug("[" + (current + 1) + "]");
// Renders current page as image
BufferedImage pageImage = null;
}
public void stopRenderer() throws IOException {
- getLogger().debug("Java2DRenderer stopped");
+ log.debug("Java2DRenderer stopped");
renderingDone = true;
numberOfPages = currentPageNumber;
// TODO set all vars to null for gc
pageWidth = (int) Math.round(bounds.getWidth() / 1000f);
pageHeight = (int) Math.round(bounds.getHeight() / 1000f);
- getLogger().info(
+ log.info(
"Rendering Page " + pageViewport.getPageNumberString()
+ " (pageWidth " + pageWidth + ", pageHeight "
+ pageHeight + ")");
// after the block-container has been painted. See below.
List breakOutList = null;
if (bv.getPositioning() == Block.FIXED) {
- getLogger().debug("Block.FIXED --> break out");
+ log.debug("Block.FIXED --> break out");
breakOutList = new java.util.ArrayList();
Graphics2D graph;
while (true) {
}
breakOutList.add(0, graph); // Insert because of
// stack-popping
- getLogger().debug("Adding to break out list: " + graph);
+ log.debug("Adding to break out list: " + graph);
}
}
// clip if necessary
if (breakOutList != null) {
- getLogger().debug(
+ log.debug(
"Block.FIXED --> restoring context after break-out");
Graphics2D graph;
Iterator i = breakOutList.iterator();
while (i.hasNext()) {
graph = (Graphics2D) i.next();
- getLogger().debug("Restoring: " + graph);
+ log.debug("Restoring: " + graph);
state.push();
}
}
}
} else {
- getLogger().warn(
+ log.warn(
"Can't find background image: " + back.getURL());
}
}
state.getGraph().draw(line);
// lower Leader
line.setLine(startx, starty + thickness, endx, starty + thickness);
- state.getGraph().setColor(Color.WHITE);
+ state.getGraph().setColor(Color.white);
state.getGraph().draw(line);
// TODO the implementation could be nicer, f.eg. with triangles at
state.getGraph().draw(line);
// upperLeader
line.setLine(startx, starty, endx, starty);
- state.getGraph().setColor(Color.WHITE);
+ state.getGraph().setColor(Color.white);
state.getGraph().draw(line);
// TODO the implementation could be nicer, f.eg. with triangles at
renderSVGDocument(doc, pos); // TODO check if ok.
} else if ("image/eps".equals(mime)) {
- getLogger().warn("EPS images are not supported by this renderer");
+ log.warn("EPS images are not supported by this renderer");
currentBPPosition += (h * 1000);
} else if ("image/jpeg".equals(mime)) {
if (!fopimage.load(FopImage.ORIGINAL_DATA)) {
currentBPPosition += (h * 1000);
} else {
if (!fopimage.load(FopImage.BITMAP)) {
- getLogger().warn("Loading of bitmap failed: " + url);
+ log.warn("Loading of bitmap failed: " + url);
return;
}
byte[] raw = fopimage.getBitmaps();
// TODO Hardcoded color and sample models, FIX ME!
- ColorModel cm = new ComponentColorModel(ColorSpace
- .getInstance(ColorSpace.CS_LINEAR_RGB), false, false,
+ ColorModel cm = new ComponentColorModel(
+ ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB),
+ new int[] {8, 8, 8},
+ false, false,
ColorModel.OPAQUE, DataBuffer.TYPE_BYTE);
SampleModel sampleModel = new PixelInterleavedSampleModel(
DataBuffer.TYPE_BYTE, w, h, 3, w * 3, new int[] { 0, 1, 2 });
try {
root = builder.build(ctx, doc);
} catch (Exception e) {
- getLogger().error(
+ log.error(
"svg graphic could not be built: " + e.getMessage(), e);
return;
}
try {
inverse = at.createInverse();
} catch (NoninvertibleTransformException e) {
- getLogger().warn(e);
+ log.warn(e);
}
if (!at.isIdentity()) {
state.getGraph().transform(at);
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
public void startRenderer(OutputStream outputStream) throws IOException {
- getLogger().info("rendering areas to PCL");
+ log.info("rendering areas to PCL");
currentStream = new PCLStream(outputStream);
// Set orientation.
//Setup encryption if necessary
PDFEncryptionManager.setupPDFEncryption(
- userAgent.getPDFEncryptionParams(), this.pdfDoc, getLogger());
+ userAgent.getPDFEncryptionParams(), this.pdfDoc);
}
/**
restoreGraphicsState();
} else {
- getLogger().warn("Can't find background image: " + back.getURL());
+ log.warn("Can't find background image: " + back.getURL());
}
}
}
float w = x2 - x1;
float h = y2 - y1;
if ((w < 0) || (h < 0)) {
- getLogger().error("Negative extent received. Border won't be painted.");
+ log.error("Negative extent received. Border won't be painted.");
return;
}
switch (style) {
PDFRenderer renderer = (PDFRenderer)context.getRenderer();
renderer.saveGraphicsState();
//pdfInfo.currentStream.add("q\n");
- renderer.setColor(Color.BLACK, false, null);
- renderer.setColor(Color.BLACK, true, null);
+ renderer.setColor(Color.black, false, null);
+ renderer.setColor(Color.black, true, null);
// transform so that the coordinates (0,0) is from the top left
// and positive is down and to the right. (0,0) is where the
// viewBox puts it.
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
protected void handleIOTrouble(IOException ioe) {
if (!ioTrouble) {
- getLogger().error("Error while writing to target file", ioe);
+ log.error("Error while writing to target file", ioe);
ioTrouble = true;
}
}
*/
public void startRenderer(OutputStream outputStream)
throws IOException {
- getLogger().debug("rendering areas to PostScript");
+ log.debug("rendering areas to PostScript");
//Setup for PostScript generation
this.gen = new PSGenerator(outputStream);
*/
public void renderPage(PageViewport page)
throws IOException, FOPException {
- getLogger().debug("renderPage(): " + page);
+ log.debug("renderPage(): " + page);
this.currentPageNumber++;
gen.writeDSCComment(DSCConstants.PAGE, new Object[]
try {
svgT.transcode(input, output);
} catch (TranscoderException e) {
- getLogger().error("could not write svg file :" + e.getMessage(), e);
+ log.error("could not write svg file :" + e.getMessage(), e);
}
ostream.flush();
ostream = null;
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private void addStr(int row, int col, String str, boolean ischar) {
if (debug) {
- getLogger().debug("TXTRenderer.addStr(" + row + ", " + col
+ log.debug("TXTRenderer.addStr(" + row + ", " + col
+ ", \"" + str + "\", " + ischar + ")");
}
if (suppressGraphics && !ischar) {
sb.append(' ');
}
if (debug) {
- getLogger().debug("TXTRenderer.addStr() sb.length()="
+ log.debug("TXTRenderer.addStr() sb.length()="
+ sb.length());
}
for (int countr = col; countr < (col + str.length()); countr++) {
sb.append(str.charAt(countr - col));
} else {
if (debug) {
- getLogger().debug("TXTRenderer.addStr() sb.length()="
+ log.debug("TXTRenderer.addStr() sb.length()="
+ sb.length() + " countr=" + countr);
}
sb.setCharAt(countr, str.charAt(countr - col));
*/
public void startRenderer(OutputStream outputStream)
throws IOException {
- getLogger().debug("Rendering areas to Area Tree XML");
+ log.debug("Rendering areas to Area Tree XML");
if (this.handler == null) {
SAXTransformerFactory factory
if (this.out != null) {
this.out.flush();
}
- getLogger().debug("Written out Area Tree XML");
+ log.debug("Written out Area Tree XML");
}
/**
/*
- * Copyright 2004 The Apache Software Foundation.
+ * Copyright 2004-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
import org.apache.commons.io.IOUtils;
public class FOPTestbed extends AbstractLogEnabled
//Initialize threads
List threadList = new java.util.LinkedList();
for (int ti = 0; ti < this.threads; ti++) {
- Thread thread = new Thread(new TaskRunner());
+ TaskRunner runner = new TaskRunner();
+ ContainerUtil.enableLogging(runner, getLogger());
+ Thread thread = new Thread(runner);
threadList.add(thread);
}
getLogger().info("Stress test duration: " + (System.currentTimeMillis() - start) + "ms");
}
- private class TaskRunner implements Runnable {
+ private class TaskRunner extends AbstractLogEnabled implements Runnable {
public void run() {
try {
while (i.hasNext()) {
TaskDef def = (TaskDef)i.next();
final Task task = new Task(def, counter++);
+ ContainerUtil.enableLogging(task, getLogger());
task.execute();
}
}
public FOProcessor createFOProcessor() {
try {
- Class clazz = Class.forName(this.fopCfg.getAttribute("class", "org.apache.fop.threading.FOProcessorImpl"));
+ Class clazz = Class.forName(this.fopCfg.getAttribute("class",
+ "org.apache.fop.threading.FOProcessorImpl"));
FOProcessor fop = (FOProcessor)clazz.newInstance();
ContainerUtil.enableLogging(fop, getLogger());
ContainerUtil.configure(fop, this.fopCfg);
}
- private class Task implements Executable {
+ private class Task extends AbstractLogEnabled implements Executable {
private TaskDef def;
private int num;
public void execute() throws Exception {
- getLogger().info("Processing: "+def);
+ getLogger().info("Processing: " + def);
FOProcessor fop = (FOProcessor)createFOProcessor();
DecimalFormat df = new DecimalFormat("00000");
File outfile = new File(outputDir, df.format(num) + ".pdf");