From 1b337a72e1929f27fb9220d12f00a619ea54d122 Mon Sep 17 00:00:00 2001 From: Peter Bernard West Date: Thu, 15 Apr 2004 07:45:08 +0000 Subject: [PATCH] Generate and return a GraphicsEnvironment git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197501 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/AbstractRenderer.java | 512 +----------------- 1 file changed, 5 insertions(+), 507 deletions(-) diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 6d3dfc484..b14b1ce18 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -18,6 +18,7 @@ package org.apache.fop.render; +import java.awt.GraphicsEnvironment; import java.io.OutputStream; import java.util.HashMap; import java.util.Map; @@ -47,27 +48,6 @@ public abstract class AbstractRenderer /** renderer configuration */ protected Map options = new HashMap(); -// /** block progression position */ -// protected int currentBPPosition = 0; -// -// /** inline progression position */ -// protected int currentIPPosition = 0; -// -// /** current inline progression position in block */ -// protected int currentBlockIPPosition = 0; -// -// /** -// * the block progression position of the containing block used for -// * absolutely positioned blocks -// */ -// protected int containingBPPosition = 0; -// -// /** -// * the inline progression position of the containing block used for -// * absolutely positioned blocks -// */ -// protected int containingIPPosition = 0; - protected Logger log = Logger.getLogger(Fop.fopPackage); @@ -80,15 +60,14 @@ public abstract class AbstractRenderer public void run() { } + public GraphicsEnvironment getGraphicsEnvironment() { + return null; + } + public synchronized void setOutputStream(OutputStream output) { this.output = output; } -// /** -// * @see org.apache.fop.render.Renderer -// */ -// public abstract void setupFontInfo(FOTreeControl foTreeControl); - /** @see org.apache.fop.render.Renderer */ public synchronized void setUserAgent(FOUserAgent agent) { userAgent = agent; @@ -110,12 +89,6 @@ public abstract class AbstractRenderer return false; } -// /** -// * @param ext (todo) Description of the Parameter -// * @see org.apache.fop.render.Renderer -// */ -// public void renderExtension(TreeExt ext) { } - /** * Prepare a page for rendering. This is called if the renderer supports * out of order rendering. The renderer should prepare the page so that a @@ -127,110 +100,6 @@ public abstract class AbstractRenderer */ public void preparePage(PageViewport page) { } -// /** -// * Utility method to convert a page sequence title to a string. Some -// * renderers may only be able to use a string title. A title is a sequence -// * of inline areas that this method attempts to convert to an equivalent -// * string. -// * -// * @param title The Title to convert -// * @return An expanded string representing the title -// */ -// protected String convertTitleToString(Title title) { -// List children = title.getInlineAreas(); -// String str = convertToString(children); -// return str.trim(); -// } -// -// private String convertToString(List children) { -// StringBuffer sb = new StringBuffer(); -// for (int count = 0; count < children.size(); count++) { -// InlineArea inline = (InlineArea) children.get(count); -// if (inline instanceof Character) { -// sb.append(((Character) inline).getChar()); -// } else if (inline instanceof TextArea) { -// sb.append(((TextArea) inline).getTextArea()); -// } else if (inline instanceof InlineParent) { -// sb.append(convertToString( -// ((InlineParent) inline).getChildAreas())); -// } else { -// sb.append(" "); -// } -// } -// return sb.toString(); -// } -// -// /** @see org.apache.fop.render.Renderer */ -// public void startPageSequence(Title seqTitle) { -// //do nothing -// } - - // normally this would be overriden to create a page in the - // output -// /** @see org.apache.fop.render.Renderer */ -// public void renderPage(PageViewport page) -// throws IOException, FOPException { -// -// Page p = page.getPage(); -// renderPageAreas(p); -// } - -// /** -// * Renders page areas. -// * -// * @param page The page whos page areas are to be rendered -// */ -// protected void renderPageAreas(Page page) { -// /* Spec does not appear to specify whether fo:region-body should -// appear above or below side regions in cases of overlap. FOP -// decision is to have fo:region-body on top, hence it is rendered -// last here. */ -// RegionViewport viewport; -// viewport = page.getRegionViewport(Region.BEFORE_CODE); -// renderRegionViewport(viewport); -// viewport = page.getRegionViewport(Region.START_CODE); -// renderRegionViewport(viewport); -// viewport = page.getRegionViewport(Region.END_CODE); -// renderRegionViewport(viewport); -// viewport = page.getRegionViewport(Region.AFTER_CODE); -// renderRegionViewport(viewport); -// viewport = page.getRegionViewport(Region.BODY_CODE); -// renderRegionViewport(viewport); -// } - -// /** -// * Renders a region viewport.

-// * -// * The region may clip the area and it establishes a position from where -// * the region is placed.

-// * -// * @param port The region viewport to be rendered -// */ -// protected void renderRegionViewport(RegionViewport port) { -// if (port != null) { -// Rectangle2D view = port.getViewArea(); -// // The CoordTransformer will transform coordinates relative to -// // this region-reference area into page coords, so -// // set origin for the region to 0,0. -// currentBPPosition = 0; -// currentIPPosition = 0; -// currentBlockIPPosition = currentIPPosition; -// -// RegionReference region = port.getRegion(); -// handleRegionTraits(port); -// -// // shouldn't the viewport have the CoordTransformer -// startVParea(region.getCoordTransformer()); -// // do after starting viewport area -// if (region.getRegionClass() == Region.BODY_CODE) { -// renderBodyRegion((BodyRegion) region); -// } else { -// renderRegion(region); -// } -// endVParea(); -// } -// } - /** * (todo) Description of the Method * @@ -253,377 +122,6 @@ public abstract class AbstractRenderer */ protected void endVParea() { } -// /** -// * Renders a region reference area. -// * -// * @param region The region reference area -// */ -// protected void renderRegion(RegionReference region) { -// List blocks = region.getBlocks(); -// -// renderBlocks(null, blocks); -// -// } - -// /** -// * Renders a body region area. -// * -// * @param region The body region -// */ -// protected void renderBodyRegion(BodyRegion region) { -// BeforeFloat bf = region.getBeforeFloat(); -// if (bf != null) { -// renderBeforeFloat(bf); -// } -// MainReference mr = region.getMainReference(); -// if (mr != null) { -// renderMainReference(mr); -// } -// Footnote foot = region.getFootnote(); -// if (foot != null) { -// renderFootnote(foot); -// } -// } - -// /** -// * Renders a before float area. -// * -// * @param bf The before float area -// */ -// protected void renderBeforeFloat(BeforeFloat bf) { -// List blocks = bf.getChildAreas(); -// if (blocks != null) { -// renderBlocks(null, blocks); -// Block sep = bf.getSeparator(); -// if (sep != null) { -// renderBlock(sep); -// } -// } -// } - -// /** -// * Renders a footnote -// * -// * @param footnote The footnote -// */ -// protected void renderFootnote(Footnote footnote) { -// List blocks = footnote.getChildAreas(); -// if (blocks != null) { -// Block sep = footnote.getSeparator(); -// if (sep != null) { -// renderBlock(sep); -// } -// renderBlocks(null, blocks); -// } -// } - -// /** -// * Renders the main reference area. -// *

-// * The main reference area contains a list of spans that are -// * stacked on the page. -// * The spans contain a list of normal flow reference areas -// * that are positioned into columns. -// *

-// * -// * @param mr The main reference area -// */ -// protected void renderMainReference(MainReference mr) { -// int saveIPPos = currentIPPosition; -// -// Span span = null; -// List spans = mr.getSpans(); -// for (int count = 0; count < spans.size(); count++) { -// span = (Span) spans.get(count); -// int offset = (mr.getWidth() -// - (span.getColumnCount() - 1) * mr.getColumnGap()) -// / span.getColumnCount() + mr.getColumnGap(); -// for (int c = 0; c < span.getColumnCount(); c++) { -// Flow flow = (Flow) span.getFlow(c); -// -// renderFlow(flow); -// currentIPPosition += offset; -// } -// currentIPPosition = saveIPPos; -// currentBPPosition += span.getHeight(); -// } -// } - -// /** -// * Renders a flow reference area. -// * -// * @param flow The flow reference area -// */ -// protected void renderFlow(Flow flow) { -// // the normal flow reference area contains stacked blocks -// List blocks = flow.getChildAreas(); -// if (blocks != null) { -// renderBlocks(null, blocks); -// } -// } - -// /** -// * Handle block traits. -// * This method is called when the correct ip and bp posiiton is -// * set. This should be overridden to draw border and background -// * traits for the block area. -// * -// * @param block the block area -// */ -// protected void handleBlockTraits(Block block) { -// // draw border and background -// } - -// /** -// * Renders a block viewport. -// * -// * @param bv The block viewport -// * @param children The children to render within the block viewport -// */ -// protected void renderBlockViewport(BlockViewport bv, List children) { -// // clip and position viewport if necessary -// if (bv.getPositioning() == Block.ABSOLUTE) { -// // save positions -// int saveIP = currentIPPosition; -// int saveBP = currentBPPosition; -// -// CoordTransformer ctm = bv.getCoordTransformer(); -// currentIPPosition = 0; -// currentBPPosition = 0; -// -// startVParea(ctm); -// handleBlockTraits(bv); -// renderBlocks(bv, children); -// endVParea(); -// -// // clip if necessary -// -// currentIPPosition = saveIP; -// currentBPPosition = saveBP; -// } else { -// // save position and offset -// int saveIP = currentIPPosition; -// int saveBP = currentBPPosition; -// -// handleBlockTraits(bv); -// renderBlocks(bv, children); -// -// currentIPPosition = saveIP; -// currentBPPosition = saveBP + bv.getHeight(); -// } -// } - -// /** -// * Renders a list of block areas. -// * -// * @param parent the parent block if the parent is a block, otherwise -// * a null value. -// * @param blocks The block areas -// */ -// protected void renderBlocks(Block parent, List blocks) { -// // the position of the containing block is used for -// // absolutely positioned areas -// int contBP = currentBPPosition; -// int contIP = currentIPPosition; -// containingBPPosition = contBP; -// containingIPPosition = contIP; -// -// for (int count = 0; count < blocks.size(); count++) { -// Object obj = blocks.get(count); -// if (obj instanceof Block) { -// containingBPPosition = contBP; -// containingIPPosition = contIP; -// renderBlock((Block) obj); -// containingBPPosition = contBP; -// containingIPPosition = contIP; -// } else { -// // a line area is rendered from the top left position -// // of the line, each inline object is offset from there -// LineArea line = (LineArea) obj; -// currentBlockIPPosition = -// currentIPPosition + line.getStartIndent(); -// renderLineArea(line); -// currentBPPosition += line.getHeight(); -// } -// } -// } -// -// /** -// * Renders a block area. -// * -// * @param block The block area -// */ -// protected void renderBlock(Block block) { -// List children = block.getChildAreas(); -// if (children == null) { -// handleBlockTraits(block); -// // simply move position -// currentBPPosition += block.getHeight(); -// } else if (block instanceof BlockViewport) { -// renderBlockViewport((BlockViewport) block, children); -// } else { -// // save position and offset -// int saveIP = currentIPPosition; -// int saveBP = currentBPPosition; -// -// if (block.getPositioning() == Block.ABSOLUTE) { -// currentIPPosition = containingIPPosition + block.getXOffset(); -// currentBPPosition = containingBPPosition + block.getYOffset(); -// -// handleBlockTraits(block); -// -// renderBlocks(block, children); -// -// // absolute blocks do not effect the layout -// currentBPPosition = saveBP; -// } else { -// // relative blocks are offset -// currentIPPosition += block.getXOffset(); -// currentBPPosition += block.getYOffset(); -// -// handleBlockTraits(block); -// -// renderBlocks(block, children); -// -// // stacked and relative blocks effect stacking -// currentBPPosition = saveBP + block.getHeight(); -// } -// currentIPPosition = saveIP; -// } -// } -// -// /** -// * Renders a line area.

-// * -// * A line area may have grouped styling for its children such as underline, -// * background.

-// * -// * @param line The line area -// */ -// protected void renderLineArea(LineArea line) { -// List children = line.getInlineAreas(); -// -// for (int count = 0; count < children.size(); count++) { -// InlineArea inline = (InlineArea) children.get(count); -// renderInlineArea(inline); -// } -// } -// -// protected void renderInlineArea(InlineArea inlineArea) { -// if (inlineArea instanceof TextArea) { -// renderText((TextArea) inlineArea); -// } else if (inlineArea instanceof InlineParent) { -// renderInlineParent((InlineParent) inlineArea); -// } else if (inlineArea instanceof Space) { -// renderInlineSpace((Space) inlineArea); -// } else if (inlineArea instanceof Character) { -// renderCharacter((Character) inlineArea); -// } else if (inlineArea instanceof Viewport) { -// renderViewport((Viewport) inlineArea); -// } else if (inlineArea instanceof Leader) { -// renderLeader((Leader) inlineArea); -// } -// } -// -// -// /** @see org.apache.fop.render.Renderer */ -// protected void renderCharacter(Character ch) { -// currentBlockIPPosition += ch.getWidth(); -// } -// -// /** @see org.apache.fop.render.Renderer */ -// protected void renderInlineSpace(Space space) { -// // an inline space moves the inline progression position -// // for the current block by the width or height of the space -// // it may also have styling (only on this object) that needs -// // handling -// currentBlockIPPosition += space.getWidth(); -// } -// -// /** @see org.apache.fop.render.Renderer */ -// protected void renderLeader(Leader area) { -// currentBlockIPPosition += area.getWidth(); -// } -// -// /** @see org.apache.fop.render.Renderer */ -// protected void renderText(TextArea text) { -// currentBlockIPPosition += text.getWidth(); -// } -// -// /** @see org.apache.fop.render.Renderer */ -// protected void renderInlineParent(InlineParent ip) { -// int saveIP = currentBlockIPPosition; -// Iterator iter = ip.getChildAreas().iterator(); -// while (iter.hasNext()) { -// renderInlineArea((InlineArea) iter.next()); -// } -// currentBlockIPPosition = saveIP + ip.getWidth(); -// } -// -// /** @see org.apache.fop.render.Renderer */ -// protected void renderViewport(Viewport viewport) { -// Area content = viewport.getContent(); -// int saveBP = currentBPPosition; -// currentBPPosition += viewport.getOffset(); -// Rectangle2D contpos = viewport.getContentPosition(); -// if (content instanceof Image) { -// renderImage((Image) content, contpos); -// } else if (content instanceof Container) { -// renderContainer((Container) content); -// } else if (content instanceof ForeignObject) { -// renderForeignObject((ForeignObject) content, contpos); -// } -// currentBlockIPPosition += viewport.getWidth(); -// currentBPPosition = saveBP; -// } -// -// /** -// * Renders an image area. -// * -// * @param image The image -// * @param pos The target position of the image -// * (todo) Make renderImage() protected -// */ -// public void renderImage(Image image, Rectangle2D pos) { -// // Default: do nothing. -// // Some renderers (ex. Text) don't support images. -// } -// -// /** @see org.apache.fop.render.Renderer */ -// public void renderContainer(Container cont) { -// int saveIP = currentIPPosition; -// currentIPPosition = currentBlockIPPosition; -// int saveBlockIP = currentBlockIPPosition; -// int saveBP = currentBPPosition; -// -// List blocks = cont.getBlocks(); -// renderBlocks(null, blocks); -// currentIPPosition = saveIP; -// currentBlockIPPosition = saveBlockIP; -// currentBPPosition = saveBP; -// } -// -// /** -// * Renders a foreign object area. -// * -// * @param fo The foreign object area -// * @param pos The target position of the foreign object -// * (todo) Make renderForeignObject() protected -// */ -// public void renderForeignObject(ForeignObject fo, Rectangle2D pos) { -// // Default: do nothing. -// // Some renderers (ex. Text) don't support foreign objects. -// } -// -// /** -// * Set the default xml handler for the given mime type. -// * @param mime MIME type -// * @param handler XMLHandler to use -// */ -// public void setDefaultXMLHandler(FOUserAgent foua, String mime, -// XMLHandler handler) { -// foua.defaults.put(mime, handler); -// } /** * Add an xml handler for the given mime type and xml namespace. -- 2.39.5