From 68d9473ba8b5673a05ca055101c6024c31d93469 Mon Sep 17 00:00:00 2001 From: fotis Date: Sat, 2 Dec 2000 22:04:06 +0000 Subject: [PATCH] oops: added further files for rule-style git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193856 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 6 +- docs/bugtests/build.xml | 1 + docs/examples/fo/leader.fo | 55 ++++-- .../apache/fop/render/pdf/PDFRenderer.java | 171 ++++++++++-------- 4 files changed, 144 insertions(+), 89 deletions(-) diff --git a/STATUS b/STATUS index 015a903e2..3b7563938 100644 --- a/STATUS +++ b/STATUS @@ -29,6 +29,7 @@ Jon Smirl Done since 0.15 release - added: FopImage class that uses JAI [Eric Schaeffer] and JAI compile target [Kelly Campbell] +- added: support for rule-style [Fotis Jannidis] - updated: svg stuff for the latest java bindings [Keiron Liddle] - fixed: enhanced error messages for page layout (region names, master) [Norm Walsh] - fixed: infinite looping bug when TableCell or TableRow is larger than a page [Hani Elabed] @@ -221,8 +222,9 @@ extended - colour not continued onto subsequent pages if coloured block goes over page - keep-next doesn't work and doubles the text lines which should be moved to the next page - border width in fo:table is added to the start position of the next block or - table (see page 6 in table.fo for a test case) - + table (see page 6 in examples/fo/table.fo for a test case) +- if a block, which is positioned with space-before, doesn't fit on the current page, + it gets lost. (see space-before.fo in bugtests/fo for a test case) SVG diff --git a/docs/bugtests/build.xml b/docs/bugtests/build.xml index 9307e1ab7..806569520 100644 --- a/docs/bugtests/build.xml +++ b/docs/bugtests/build.xml @@ -72,6 +72,7 @@ + diff --git a/docs/examples/fo/leader.fo b/docs/examples/fo/leader.fo index 2ba7ff964..1e147f9b9 100644 --- a/docs/examples/fo/leader.fo +++ b/docs/examples/fo/leader.fo @@ -375,37 +375,68 @@ space-before.optimum="5pt" space-after.optimum="3pt" text-align="start"> - Here are 3 fo:leader with the property rule and no text + Here are some fo:leader with the property rule and different rule styles + (solid, dashed, dotted, double, groove, ridge the last one with colored backgrounds + to the effect) - - + + leader-length="6cm" + rule-thickness="1pt" + rule-style="dashed"/> - - + leader-length="6cm" + rule-style="dotted" + rule-thickness="1pt"/> + + + + + + + + + + + + diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 59c585832..293e3cf0b 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -148,20 +148,20 @@ public class PDFRenderer implements Renderer { } /** - * set the PDF document's producer - * - * @param producer string indicating application producing PDF - */ + * set the PDF document's producer + * + * @param producer string indicating application producing PDF + */ public void setProducer(String producer) { this.pdfDoc.setProducer(producer); } /** - * render the areas into PDF - * - * @param areaTree the laid-out area tree - * @param writer the PrintWriter to write the PDF with - */ + * render the areas into PDF + * + * @param areaTree the laid-out area tree + * @param writer the PrintWriter to write the PDF with + */ public void render(AreaTree areaTree, PrintWriter writer) throws IOException, FOPException { MessageHandler.logln("rendering areas to PDF"); @@ -184,6 +184,26 @@ public class PDFRenderer implements Renderer { this.pdfDoc.output(writer); } + /** + * add a line to the current stream + * + * @param x1 the start x location in millipoints + * @param y1 the start y location in millipoints + * @param x2 the end x location in millipoints + * @param y2 the end y location in millipoints + * @param th the thickness in millipoints + * @param r the red component + * @param g the green component + * @param b the blue component + */ + protected void addLine(int x1, int y1, int x2, int y2, int th, + PDFPathPaint stroke) { + currentStream.add("ET\nq\n" + stroke.getColorSpaceOut(false) + + (x1 / 1000f) + " "+ (y1 / 1000f) + " m " + + (x2 / 1000f) + " "+ (y2 / 1000f) + " l " + + (th / 1000f) + " w S\n" + "Q\nBT\n"); + } + /** * add a line to the current stream * @@ -192,27 +212,28 @@ public class PDFRenderer implements Renderer { * @param x2 the end x location in millipoints * @param y2 the end y location in millipoints * @param th the thickness in millipoints + * @param rs the rule style as String containing dashArray + dashPhase * @param r the red component * @param g the green component * @param b the blue component */ protected void addLine(int x1, int y1, int x2, int y2, int th, - PDFPathPaint stroke) { + String rs, PDFPathPaint stroke) { currentStream.add("ET\nq\n" + stroke.getColorSpaceOut(false) + - (x1 / 1000f) + " "+ (y1 / 1000f) + " m " + + rs + (x1 / 1000f) + " "+ (y1 / 1000f) + " m " + (x2 / 1000f) + " "+ (y2 / 1000f) + " l " + (th / 1000f) + " w S\n" + "Q\nBT\n"); } /** - * add a rectangle to the current stream - * - * @param x the x position of left edge in millipoints - * @param y the y position of top edge in millipoints - * @param w the width in millipoints - * @param h the height in millipoints - * @param stroke the stroke color/gradient - */ + * add a rectangle to the current stream + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param stroke the stroke color/gradient + */ protected void addRect(int x, int y, int w, int h, PDFPathPaint stroke) { currentStream.add("ET\nq\n" + stroke.getColorSpaceOut(false) + @@ -221,15 +242,15 @@ public class PDFRenderer implements Renderer { } /** - * add a filled rectangle to the current stream - * - * @param x the x position of left edge in millipoints - * @param y the y position of top edge in millipoints - * @param w the width in millipoints - * @param h the height in millipoints - * @param fill the fill color/gradient - * @param stroke the stroke color/gradient - */ + * add a filled rectangle to the current stream + * + * @param x the x position of left edge in millipoints + * @param y the y position of top edge in millipoints + * @param w the width in millipoints + * @param h the height in millipoints + * @param fill the fill color/gradient + * @param stroke the stroke color/gradient + */ protected void addRect(int x, int y, int w, int h, PDFPathPaint stroke, PDFPathPaint fill) { currentStream.add("ET\nq\n" + fill.getColorSpaceOut(true) + @@ -239,10 +260,10 @@ public class PDFRenderer implements Renderer { } /** - * render area container to PDF - * - * @param area the area container to render - */ + * render area container to PDF + * + * @param area the area container to render + */ public void renderAreaContainer(AreaContainer area) { int saveY = this.currentYPosition; @@ -322,10 +343,10 @@ public class PDFRenderer implements Renderer { /** - * render block area to PDF - * - * @param area the block area to render - */ + * render block area to PDF + * + * @param area the block area to render + */ public void renderBlockArea(BlockArea area) { doFrame(area); Enumeration e = area.getChildren().elements(); @@ -336,20 +357,20 @@ public class PDFRenderer implements Renderer { } /** - * render display space to PDF - * - * @param space the display space to render - */ + * render display space to PDF + * + * @param space the display space to render + */ public void renderDisplaySpace(DisplaySpace space) { int d = space.getSize(); this.currentYPosition -= d; } /** - * render image area to PDF - * - * @param area the image area to render - */ + * render image area to PDF + * + * @param area the image area to render + */ public void renderImageArea(ImageArea area) { // adapted from contribution by BoBoGi int x = this.currentAreaContainerXPosition + area.getXOffset(); @@ -444,10 +465,10 @@ public class PDFRenderer implements Renderer { } /** - * render SVG area to PDF - * - * @param area the SVG area to render - */ + * render SVG area to PDF + * + * @param area the SVG area to render + */ public void renderSVGArea(SVGArea area) { int x = this.currentXPosition; int y = this.currentYPosition; @@ -486,10 +507,10 @@ public class PDFRenderer implements Renderer { } /** - * render inline area to PDF - * - * @param area inline area to render - */ + * render inline area to PDF + * + * @param area inline area to render + */ public void renderInlineArea(InlineArea area) { char ch; StringBuffer pdf = new StringBuffer(); @@ -566,19 +587,19 @@ public class PDFRenderer implements Renderer { } /** - * render inline space to PDF - * - * @param space space to render - */ + * render inline space to PDF + * + * @param space space to render + */ public void renderInlineSpace(InlineSpace space) { this.currentXPosition += space.getSize(); } /** - * render line area to PDF - * - * @param area area to render - */ + * render line area to PDF + * + * @param area area to render + */ public void renderLineArea(LineArea area) { int rx = this.currentAreaContainerXPosition + area.getStartIndent(); int ry = this.currentYPosition; @@ -602,10 +623,10 @@ public class PDFRenderer implements Renderer { } /** - * render page into PDF - * - * @param page page to render - */ + * render page into PDF + * + * @param page page to render + */ public void renderPage(Page page) { AreaContainer body, before, after; @@ -661,10 +682,10 @@ public class PDFRenderer implements Renderer { } /** - * render leader area into PDF - * - * @param area area to render - */ + * render leader area into PDF + * + * @param area area to render + */ public void renderLeaderArea(LeaderArea area) { int rx = this.currentXPosition; ; @@ -674,7 +695,7 @@ public class PDFRenderer implements Renderer { int th = area.getRuleThickness(); int st = area.getRuleStyle(); String rs = setRuleStylePattern(st); - //checks whether thickness is = 0, because of bug in pdf (or where?), + //checks whether thickness is = 0, because of bug in pdf (or where?), //a line with thickness 0 is still displayed if (th != 0) { switch (st) { @@ -713,18 +734,18 @@ public class PDFRenderer implements Renderer { } /** - * set up the font info - * - * @param fontInfo font info to set up - */ + * set up the font info + * + * @param fontInfo font info to set up + */ public void setupFontInfo(FontInfo fontInfo) { FontSetup.setup(fontInfo); FontSetup.addToResources(this.pdfDoc, fontInfo); } /** - * defines a string containing dashArray and dashPhase for the rule style - */ + * defines a string containing dashArray and dashPhase for the rule style + */ private String setRuleStylePattern (int style) { String rs = ""; switch (style) { -- 2.39.5