Skip to content

Commit

Permalink
Reverted changes made in r1234877, see bugzilla#52513
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1235189 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Mehdi Houshmand committed Jan 24, 2012
1 parent a7fb215 commit bfd20ff
Show file tree
Hide file tree
Showing 30 changed files with 169 additions and 113 deletions.
3 changes: 2 additions & 1 deletion examples/embedding/java/embedding/ExampleFO2JPSPrint.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public void printFO(File fo)
//Set up a custom user agent so we can supply our own renderer instance
FOUserAgent userAgent = fopFactory.newFOUserAgent();

PageableRenderer renderer = new PageableRenderer(userAgent);
PageableRenderer renderer = new PageableRenderer();
renderer.setUserAgent(userAgent);
userAgent.setRendererOverride(renderer);

// Construct FOP with desired output format
Expand Down
3 changes: 2 additions & 1 deletion examples/embedding/java/embedding/atxml/ExampleConcat.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public void convertToAreaTreeXML(Source src, Source xslt, File areaTreeFile)
userAgent, MimeConstants.MIME_PDF);

//Create the XMLRenderer to create the area tree XML
XMLRenderer xmlRenderer = new XMLRenderer(userAgent);
XMLRenderer xmlRenderer = new XMLRenderer();
xmlRenderer.setUserAgent(userAgent);

//Tell the XMLRenderer to mimic the target renderer
xmlRenderer.mimicRenderer(targetRenderer);
Expand Down
7 changes: 5 additions & 2 deletions src/java/org/apache/fop/cli/CommandLineOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,17 @@ public boolean parse(String[] args)
System.err.println("Couldn't set system look & feel!");
}

AWTRenderer renderer = new AWTRenderer(foUserAgent, inputHandler, true, true);
AWTRenderer renderer = new AWTRenderer(true);
renderer.setRenderable(inputHandler); //set before user agent!
renderer.setUserAgent(foUserAgent);
foUserAgent.setRendererOverride(renderer);
} else if (MimeConstants.MIME_FOP_AREA_TREE.equals(outputmode)
&& mimicRenderer != null) {
// render from FO to Intermediate Format
Renderer targetRenderer = foUserAgent.getRendererFactory().createRenderer(
foUserAgent, mimicRenderer);
XMLRenderer xmlRenderer = new XMLRenderer(foUserAgent);
XMLRenderer xmlRenderer = new XMLRenderer();
xmlRenderer.setUserAgent(foUserAgent);

//Tell the XMLRenderer to mimic the target renderer
xmlRenderer.mimicRenderer(targetRenderer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
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;
Expand All @@ -57,10 +56,6 @@
*/
public abstract class AbstractPathOrientedRenderer extends PrintRenderer {

public AbstractPathOrientedRenderer(FOUserAgent userAgent) {
super(userAgent);
}

/**
* Handle block traits.
* The block could be any sort of block with any positioning
Expand Down
14 changes: 7 additions & 7 deletions src/java/org/apache/fop/render/AbstractRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
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.InlineViewport;
import org.apache.fop.area.inline.WordArea;
import org.apache.fop.fo.Constants;
import org.apache.fop.fonts.FontInfo;
Expand Down Expand Up @@ -116,16 +116,16 @@ public abstract class AbstractRenderer
/** {@inheritDoc} */
public abstract void setupFontInfo(FontInfo fontInfo) throws FOPException;

/**
*
* @param userAgent the user agent that contains configuration details. This cannot be null.
*/
public AbstractRenderer(FOUserAgent userAgent) {
this.userAgent = userAgent;
/** {@inheritDoc} */
public void setUserAgent(FOUserAgent agent) {
userAgent = agent;
}

/** {@inheritDoc} */
public FOUserAgent getUserAgent() {
if (userAgent == null) {
throw new IllegalStateException("FOUserAgent has not been set on Renderer");
}
return userAgent;
}

Expand Down
5 changes: 0 additions & 5 deletions src/java/org/apache/fop/render/PrintRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
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;
Expand All @@ -43,10 +42,6 @@
/** Abstract base class of "Print" type renderers. */
public abstract class PrintRenderer extends AbstractRenderer {

public PrintRenderer(FOUserAgent userAgent) {
super(userAgent);
}

/** Font configuration */
protected FontInfo fontInfo;

Expand Down
7 changes: 7 additions & 0 deletions src/java/org/apache/fop/render/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ void startRenderer(OutputStream outputStream)
void stopRenderer()
throws IOException;

/**
* Set the User Agent.
*
* @param agent The User Agent
*/
void setUserAgent(FOUserAgent agent);

/**
* Returns the associated user agent.
* @return the user agent
Expand Down
4 changes: 3 additions & 1 deletion src/java/org/apache/fop/render/RendererFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ private Renderer tryRendererMaker(FOUserAgent userAgent, String outputFormat)
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);
Expand All @@ -310,7 +311,8 @@ private Renderer tryRendererMaker(FOUserAgent userAgent, String outputFormat)
}

private Renderer createRendererForDocumentHandler(IFDocumentHandler documentHandler) {
IFRenderer rend = new IFRenderer(documentHandler.getContext().getUserAgent());
IFRenderer rend = new IFRenderer();
rend.setUserAgent(documentHandler.getContext().getUserAgent());
rend.setDocumentHandler(documentHandler);
return rend;
}
Expand Down
62 changes: 43 additions & 19 deletions src/java/org/apache/fop/render/awt/AWTRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {
/** flag for debugging */
public boolean debug; // CSOK: VisibilityModifier

/** If true, preview dialog is shown. */
public boolean dialogDisplay = true; // CSOK: VisibilityModifier

/** true if the preview dialog should be the main window of the application */
private boolean previewAsMainWindow;

/**
* Renderable instance that can be used to reload and re-render a document after
* modifications.
*/
protected Renderable renderable;

/**
* Will be notified when rendering progresses
*/
Expand All @@ -72,35 +84,47 @@ public class AWTRenderer extends Java2DRenderer implements Pageable {

/**
* Creates a new AWTRenderer instance.
*
* @param userAgent the user agent that contains configuration data
*/
public AWTRenderer(FOUserAgent userAgent) {
this(userAgent, null, false, false);
public AWTRenderer() {
this(false);
}

/**
* Creates a new AWTRenderer instance.
*
* @param userAgent the user agent that contains configuration data
* @param renderable a Renderable instance can be set so the Preview Dialog can enable the
* "Reload" button which causes the current document to be reprocessed and redisplayed.
* @param previewAsMainWindow true if the preview dialog created by the renderer should be
* the main window of the application.
* @param show sets whether the preview dialog should be created and displayed when the
* rendering has finished.
* the main window of the application.
*/
public AWTRenderer(FOUserAgent userAgent, Renderable renderable, boolean previewAsMainWindow,
boolean show) {
super(userAgent);
if (show) {
// MH: Not sure about this??? If show is false, there's no way for this class
// to create a preview dialog... Previously a "setUserAgent" could be called.
setStatusListener(PreviewDialog.createPreviewDialog(userAgent, renderable,
previewAsMainWindow));
public AWTRenderer(boolean previewAsMainWindow) {
this.previewAsMainWindow = previewAsMainWindow;
}

/** {@inheritDoc} */
public void setUserAgent(FOUserAgent foUserAgent) {
super.setUserAgent(foUserAgent);
if (dialogDisplay) {
setStatusListener(PreviewDialog.createPreviewDialog(userAgent, this.renderable,
this.previewAsMainWindow));
}
}

/**
* A Renderable instance can be set so the Preview Dialog can enable the "Reload" button
* which causes the current document to be reprocessed and redisplayed.
* @param renderable the Renderable instance.
*/
public void setRenderable(Renderable renderable) {
this.renderable = renderable;
}

/**
* Sets whether the preview dialog should be created and displayed when
* the rendering is finished.
* @param show If false, preview dialog is not shown. True by default
*/
public void setPreviewDialogDisplayed(boolean show) {
dialogDisplay = show;
}

/**
* {@inheritDoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/java/org/apache/fop/render/awt/AWTRendererMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class AWTRendererMaker extends AbstractRendererMaker {

/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent ua) {
return new AWTRenderer(ua);
return new AWTRenderer();
}

/** {@inheritDoc} */
Expand Down
5 changes: 4 additions & 1 deletion src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@
* </p>
* <pre>
* FopFactory fopFactory = FopFactory.newInstance();
* AWTRenderer renderer = new AWTRenderer();
* FOUserAgent agent = fopFactory.newFOUserAgent();
* AWTRenderer renderer = new AWTRenderer(agent);
* agent.setRendererOverride(renderer);
* renderer.setPreviewDialogDisplayed(false);
* renderer.setUserAgent(agent);
* renderer.setUserAgent(agent);
* previewPanel = new PreviewPanel(agent, null, renderer);
* previewPanel = new PreviewPanel(ua);
* myGui.add(previewPanel);
Expand Down
5 changes: 0 additions & 5 deletions src/java/org/apache/fop/render/bitmap/PNGRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.xmlgraphics.image.writer.ImageWriterParams;
import org.apache.xmlgraphics.image.writer.ImageWriterRegistry;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.PageViewport;
import org.apache.fop.render.java2d.Java2DRenderer;
Expand All @@ -41,10 +40,6 @@
*/
public class PNGRenderer extends Java2DRenderer {

public PNGRenderer(FOUserAgent userAgent) {
super(userAgent);
}

/** The MIME type for png-Rendering */
public static final String MIME_TYPE = MimeConstants.MIME_PNG;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class PNGRendererMaker extends AbstractRendererMaker {

/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent ua) {
return new PNGRenderer(ua);
return new PNGRenderer();
}

/** {@inheritDoc} */
Expand Down
12 changes: 10 additions & 2 deletions src/java/org/apache/fop/render/bitmap/TIFFRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,19 @@ public String getMimeType() {
}

/** Creates TIFF renderer. */
public TIFFRenderer(FOUserAgent userAgent) {
super(userAgent);
public TIFFRenderer() {
writerParams = new ImageWriterParams();
writerParams.setCompressionMethod(COMPRESSION_PACKBITS);
}

/**
* {@inheritDoc}
* org.apache.fop.apps.FOUserAgent)
*/
public void setUserAgent(FOUserAgent foUserAgent) {
super.setUserAgent(foUserAgent);

//Set target resolution
int dpi = Math.round(userAgent.getTargetResolution());
writerParams.setResolution(dpi);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class TIFFRendererMaker extends AbstractRendererMaker {

/** {@inheritDoc} */
public Renderer makeRenderer(FOUserAgent userAgent) {
return new TIFFRenderer(userAgent);
return new TIFFRenderer();
}

/** {@inheritDoc} */
Expand Down
6 changes: 2 additions & 4 deletions src/java/org/apache/fop/render/intermediate/IFRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@

import org.apache.fop.Version;
import org.apache.fop.apps.FOPException;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.area.Area;
import org.apache.fop.area.AreaTreeObject;
Expand All @@ -71,10 +70,10 @@
import org.apache.fop.area.inline.Image;
import org.apache.fop.area.inline.InlineArea;
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.SpaceArea;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.inline.InlineViewport;
import org.apache.fop.area.inline.WordArea;
import org.apache.fop.datatypes.URISpecification;
import org.apache.fop.fo.extensions.ExtensionAttachment;
Expand Down Expand Up @@ -159,8 +158,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer {
/**
* Main constructor
*/
public IFRenderer(FOUserAgent userAgent) {
super(userAgent);
public IFRenderer() {
}

/** {@inheritDoc} */
Expand Down
10 changes: 6 additions & 4 deletions src/java/org/apache/fop/render/java2d/Java2DRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem
private GeneralPath currentPath = null;

/** Default constructor */
public Java2DRenderer(FOUserAgent userAgent) {
super(userAgent);
public Java2DRenderer() {
}

// MH: necessary? the caller has access to FOUserAgent
/** {@inheritDoc} */
public void setUserAgent(FOUserAgent foUserAgent) {
super.setUserAgent(foUserAgent);
userAgent.setRendererOverride(this); // for document regeneration

String s = (String) userAgent.getRendererOptions().get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND);
String s = (String)userAgent.getRendererOptions().get(JAVA2D_TRANSPARENT_PAGE_BACKGROUND);
if (s != null) {
this.transparentPageBackground = "true".equalsIgnoreCase(s);
}
Expand Down
15 changes: 10 additions & 5 deletions src/java/org/apache/fop/render/print/PageableRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,23 @@ public class PageableRenderer extends Java2DRenderer implements Pageable {
/**
* Creates a new PageableRenderer.
*/
public PageableRenderer(FOUserAgent userAgent) {
super(userAgent);
Map rendererOptions = getUserAgent().getRendererOptions();
processOptions(rendererOptions);
this.pageFilter = new DefaultPageFilter();
public PageableRenderer() {
}

/** {@inheritDoc} */
public String getMimeType() {
return MimeConstants.MIME_FOP_PRINT;
}

/** {@inheritDoc} */
public void setUserAgent(FOUserAgent agent) {
super.setUserAgent(agent);

Map rendererOptions = agent.getRendererOptions();
processOptions(rendererOptions);
this.pageFilter = new DefaultPageFilter();
}

private void processOptions(Map rendererOptions) {
Object o = rendererOptions.get(PageableRenderer.PAGES_MODE);
if (o != null) {
Expand Down
Loading

0 comments on commit bfd20ff

Please sign in to comment.