keiron 2002/09/18 07:12:42 Modified: src/org/apache/fop/render AbstractRenderer.java src/org/apache/fop/render/pdf PDFRenderer.java Log: updated for area tree and prepare for block border and back Revision Changes Path 1.25 +24 -6 xml-fop/src/org/apache/fop/render/AbstractRenderer.java Index: AbstractRenderer.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/AbstractRenderer.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- AbstractRenderer.java 13 Sep 2002 08:21:55 -0000 1.24 +++ AbstractRenderer.java 18 Sep 2002 14:12:42 -0000 1.25 @@ -278,7 +278,7 @@ * @param bf The before float area */ protected void renderBeforeFloat(BeforeFloat bf) { - List blocks = bf.getBlocks(); + List blocks = bf.getChildAreas(); if (blocks != null) { renderBlocks(blocks); Block sep = bf.getSeparator(); @@ -294,7 +294,7 @@ * @param footnote The footnote */ protected void renderFootnote(Footnote footnote) { - List blocks = footnote.getBlocks(); + List blocks = footnote.getChildAreas(); if (blocks != null) { Block sep = footnote.getSeparator(); if (sep != null) { @@ -343,7 +343,7 @@ */ protected void renderFlow(Flow flow) { // the normal flow reference area contains stacked blocks - List blocks = flow.getBlocks(); + List blocks = flow.getChildAreas(); renderBlocks(blocks); } @@ -356,6 +356,7 @@ 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) { @@ -366,8 +367,10 @@ int saveBP = currentBPPosition; if (block.getPositioning() == Block.ABSOLUTE) { - currentIPPosition += block.getXOffset(); - currentBPPosition += block.getYOffset(); + currentIPPosition = containingIPPosition + block.getXOffset(); + currentBPPosition = containingBPPosition + block.getYOffset(); + + handleBlockTraits(block); renderBlocks(children); @@ -378,6 +381,8 @@ currentIPPosition += block.getXOffset(); currentBPPosition += block.getYOffset(); + handleBlockTraits(block); + renderBlocks(children); // stacked and relative blocks effect stacking @@ -388,6 +393,18 @@ } /** + * 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 @@ -405,6 +422,7 @@ currentBPPosition = 0; startVParea(ctm); + handleBlockTraits(bv); renderBlocks(children); endVParea(); 1.124 +49 -14 xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java Index: PDFRenderer.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/render/pdf/PDFRenderer.java,v retrieving revision 1.123 retrieving revision 1.124 diff -u -r1.123 -r1.124 --- PDFRenderer.java 13 Sep 2002 08:21:55 -0000 1.123 +++ PDFRenderer.java 18 Sep 2002 14:12:42 -0000 1.124 @@ -17,7 +17,6 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.apps.Version; import org.apache.fop.fo.properties.RuleStyle; -//import org.apache.fop.datatypes.*; import org.apache.fop.pdf.PDFStream; import org.apache.fop.pdf.PDFDocument; import org.apache.fop.pdf.PDFInfo; @@ -50,6 +49,7 @@ import org.apache.fop.area.inline.InlineParent; import org.apache.fop.layout.FontState; import org.apache.fop.layout.FontMetric; +import org.apache.fop.traits.BorderProps; import org.w3c.dom.Document; @@ -117,47 +117,47 @@ /** * the current stream to add PDF commands to */ - PDFStream currentStream; + protected PDFStream currentStream; /** * the current annotation list to add annotations to */ - PDFAnnotList currentAnnotList; + protected PDFAnnotList currentAnnotList; /** * the current page to add annotations to */ - PDFPage currentPage; + protected PDFPage currentPage; // drawing state - PDFState currentState = null; + protected PDFState currentState = null; - PDFColor currentColor; - String currentFontName = ""; - int currentFontSize = 0; - int pageHeight; + protected PDFColor currentColor; + protected String currentFontName = ""; + protected int currentFontSize = 0; + protected int pageHeight; /** * true if a TJ command is left to be written */ - boolean textOpen = false; + protected boolean textOpen = false; /** * the previous Y coordinate of the last word written. * Used to decide if we can draw the next word on the same line. */ - int prevWordY = 0; + protected int prevWordY = 0; /** * the previous X coordinate of the last word written. * used to calculate how much space between two words */ - int prevWordX = 0; + protected int prevWordX = 0; /** * The width of the previous word. Used to calculate space between */ - int prevWordWidth = 0; + protected int prevWordWidth = 0; /** * reusable word area string buffer to reduce memory usage @@ -341,12 +341,44 @@ super.renderRegion(region); } + protected void handleBlockTraits(Block block) { + // draw border and background + BorderProps bps = (BorderProps)block.getTrait(Trait.BORDER_BEFORE); + if(bps != null) { + float startx = ((float) currentBlockIPPosition) / 1000f; + float starty = (currentBPPosition / 1000f); + float endx = (currentBlockIPPosition + block.getWidth()) / 1000f; + + currentStream.add("ET\n"); + currentStream.add("q\n"); + + currentStream.add(bps.width / 1000f + " w\n"); + + currentStream.add(startx + " " + starty + " m\n"); + currentStream.add(endx + " " + starty + " l\n"); + currentStream.add("S\n"); + + currentStream.add("Q\n"); + currentStream.add("BT\n"); + } + bps = (BorderProps)block.getTrait(Trait.BORDER_START); + if(bps != null) { + } + bps = (BorderProps)block.getTrait(Trait.BORDER_AFTER); + if(bps != null) { + } + bps = (BorderProps)block.getTrait(Trait.BORDER_END); + if(bps != null) { + } + } + protected void renderBlockViewport(BlockViewport bv, List children) { // clip and position viewport if necessary // save positions int saveIP = currentIPPosition; int saveBP = currentBPPosition; + String saveFontName = currentFontName; CTM ctm = bv.getCTM(); @@ -372,6 +404,7 @@ ctm = tempctm.multiply(ctm); startVParea(ctm); + handleBlockTraits(bv); renderBlocks(children); endVParea(); @@ -415,6 +448,7 @@ if (ctm != null) { startVParea(ctm); } + handleBlockTraits(bv); renderBlocks(children); if (ctm != null) { endVParea(); @@ -433,6 +467,7 @@ currentBPPosition = saveBP; currentBPPosition += (int)(bv.getHeight()); } + currentFontName = saveFontName; } /**
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]