foray-commit Mailing List for FOray (Page 263)
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <vic...@us...> - 2006-05-29 21:49:29
|
Revision: 7311 Author: victormote Date: 2006-05-29 14:49:18 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7311&view=rev Log Message: ----------- Handle axsl changes regarding cursor positioning methods. Modified Paths: -------------- trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java Modified: trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java 2006-05-29 19:57:56 UTC (rev 7310) +++ trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java 2006-05-29 21:49:18 UTC (rev 7311) @@ -119,7 +119,7 @@ * @return The Y position that should be used for the underline stroke. */ protected int getUnderlineYPosition(GeneralInlineArea area) { - return area.alignmentPointY() - (area.traitFontSize() / 10); + return area.baselineY() - (area.traitFontSize() / 10); } /** @@ -128,7 +128,7 @@ * @return The Y position that should be used for the overline stroke. */ protected int getOverlineYPosition(GeneralInlineArea area) { - return area.alignmentPointY() + area.getFontAscender() + return area.baselineY() + area.getFontAscender() + (area.traitFontSize() / 10); } @@ -138,7 +138,7 @@ * @return The Y position that should be used for the through stroke. */ protected int getThroughYPosition(GeneralInlineArea area) { - return area.alignmentPointY() + (area.getFontAscender() * 3 / 8); + return area.baselineY() + (area.getFontAscender() * 3 / 8); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-05-29 19:57:56 UTC (rev 7310) +++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-05-29 21:49:18 UTC (rev 7311) @@ -288,10 +288,8 @@ getContentStream().setCharacterSpacing(letterspacing); /* Position the cursor. */ - float originX = area.rrOriginX() / 1000f; - float originY = (area.rrOriginY() - - area.ancestorLineAreaOut().alignmentPointOffset()) - / 1000f; + float originX = area.baselineX() / 1000f; + float originY = area.baselineY() / 1000f; getContentStream().setCursor(originX, originY); FontUse primaryFont = area.getPrimaryFont(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 19:58:05
|
Revision: 7310 Author: victormote Date: 2006-05-29 12:57:56 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7310&view=rev Log Message: ----------- When creating a new TextArea, set initial values of letter-spacing and word-spacing to their optimum values. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-05-29 19:56:56 UTC (rev 7309) +++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-05-29 19:57:56 UTC (rev 7310) @@ -810,9 +810,12 @@ if (parent instanceof FObjMixed) { FObjMixed mixed = (FObjMixed) foText.parentFO(); int sequence = mixed.getChildren().indexOf(foText); + int initialWordSpacing = this.traitWordSpacingOpt(); + int initialLetterSpacing = this.traitLetterSpacingOpt(); return new TextArea(mixed, parentArea, sequence, - startOffset, sizeInChars, ipd, 0, 0, - hasDiscretionaryHyphen, hasFauxSmallCaps); + startOffset, sizeInChars, ipd, initialLetterSpacing, + initialWordSpacing, hasDiscretionaryHyphen, + hasFauxSmallCaps); } if (parent instanceof Character) { return new TextArea((Character) parent, parentArea, ipd, 0, 0, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 19:57:04
|
Revision: 7309 Author: victormote Date: 2006-05-29 12:56:56 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7309&view=rev Log Message: ----------- Rename constructor variable for clarity. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2006-05-29 19:35:02 UTC (rev 7308) +++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2006-05-29 19:56:56 UTC (rev 7309) @@ -109,15 +109,15 @@ public TextArea(FObjMixed generatedBy, Area parentArea, int backingSequence, int backingOffset, int backingSize, - int progressionDimensionUsed, int resolvedLetterSpacing, - int resolvedWordSpacing, boolean hasDiscretionaryHyphen, + int progressionDimensionUsed, int initialLetterSpacing, + int initialWordSpacing, boolean hasDiscretionaryHyphen, boolean hasFauxSmallCaps) { super(generatedBy, parentArea); this.backingSequence = backingSequence; this.backingOffset = backingOffset; this.backingSize = backingSize; - this.resolvedLetterSpacing = resolvedLetterSpacing; - this.resolvedWordSpacing = resolvedWordSpacing; + this.resolvedLetterSpacing = initialLetterSpacing; + this.resolvedWordSpacing = initialWordSpacing; this.hasDiscretionaryHyphen = hasDiscretionaryHyphen; this.hasFauxSmallCaps = hasFauxSmallCaps; setProgressionDimension(progressionDimensionUsed); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 19:35:09
|
Revision: 7308 Author: victormote Date: 2006-05-29 12:35:02 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7308&view=rev Log Message: ----------- Make PDFTextString subclass PDFObject directly, instead of PDFString. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFTextString.java Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2006-05-29 19:13:45 UTC (rev 7307) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFString.java 2006-05-29 19:35:02 UTC (rev 7308) @@ -32,6 +32,10 @@ /** * A PDF String Object, as defined in PDF Reference, 2nd edition, Section 3.2.3. + * PDF string objects are used in content streams, and are specifically + * distinguished from PDF text strings, which are used for such things as + * bookmark titles, annotations, etc. + * @see PDFTextString */ public class PDFString extends PDFObject { Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFTextString.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFTextString.java 2006-05-29 19:13:45 UTC (rev 7307) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFTextString.java 2006-05-29 19:35:02 UTC (rev 7308) @@ -25,11 +25,13 @@ package org.foray.pdf.object; /** - * A subclass of PDFString modelling a PDF Text String, as defined in PDF - * Reference, 2nd Edition, Section 3.8.1. + * A PDF Text String, as defined in PDF Reference, 2nd Edition, Section 3.8.1. + * Text-strings are used in such PDF concepts as bookmarks, text annotations, + * etc., which do not have control over fonts, layout, etc. + * For string objects used in PDF content streams, see {@link PDFString}. * @see PDFString */ -public class PDFTextString extends PDFString { +public class PDFTextString extends PDFObject { /** * This char is returned when a Unicode character cannot be encoded using @@ -37,8 +39,12 @@ */ public static final char INVALID_PDF_DOC_ENCODING = 0xffff; + /** The encapsulated String. */ + protected String theString; + public PDFTextString(PDFDocument doc, String string) { - super(doc, string, null); + super(doc); + this.theString = string; } /** @@ -129,4 +135,14 @@ return INVALID_PDF_DOC_ENCODING; } + public boolean isEmpty() { + if (this.theString == null) { + return true; + } + if (this.theString.equals("")) { + return true; + } + return false; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 19:13:52
|
Revision: 7307 Author: victormote Date: 2006-05-29 12:13:45 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7307&view=rev Log Message: ----------- Clean up unneeded comments. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:55:44 UTC (rev 7306) +++ trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 19:13:45 UTC (rev 7307) @@ -44,9 +44,6 @@ private int dimensionFootnoteRA; private int dimensionBeforeFloatRA; - // keeps track of footnote state for multiple layouts -// private int footnoteState = 0; - public RegionRABody(RegionBody generatedBy, PageRA parentArea, int xPosition, int yPosition) { super(generatedBy, parentArea); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 18:55:59
|
Revision: 7306 Author: victormote Date: 2006-05-29 11:55:44 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7306&view=rev Log Message: ----------- Conform to axsl changes. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java 2006-05-29 18:42:45 UTC (rev 7305) +++ trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java 2006-05-29 18:55:44 UTC (rev 7306) @@ -31,7 +31,8 @@ * Manages the before-float-reference-area. Its parent should always be an * instance of RegionRABody. */ -public class BeforeFloatRA extends AreaFixed { +public class BeforeFloatRA extends AreaFixed + implements org.axsl.areaW.BeforeFloatRA { public BeforeFloatRA(FObj generatedBy, RegionRABody parentArea) { super(generatedBy, parentArea); Modified: trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:42:45 UTC (rev 7305) +++ trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:55:44 UTC (rev 7306) @@ -69,14 +69,10 @@ return mainReferenceArea; } - public BeforeFloatRA getBeforeFloatReferenceArea() { - return beforeFloatReferenceArea; + public org.axsl.areaW.BeforeFloatRA getWritableBeforeFloatRA() { + return this.beforeFloatReferenceArea; } - public FootnoteRA getFootnoteReferenceArea() { - return footnoteReferenceArea; - } - public org.axsl.areaW.FootnoteRA getWritableFootnoteReferenceArea() { return footnoteReferenceArea; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 18:42:52
|
Revision: 7305 Author: victormote Date: 2006-05-29 11:42:45 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7305&view=rev Log Message: ----------- Conform to axsl area-tree changes. Keep track of footnote layout status in the layout system, not in the area tree. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/FootnoteRA.java trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/FootnoteRA.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/FootnoteRA.java 2006-05-29 18:42:37 UTC (rev 7304) +++ trunk/foray/foray-areatree/src/java/org/foray/area/FootnoteRA.java 2006-05-29 18:42:45 UTC (rev 7305) @@ -28,8 +28,7 @@ import org.axsl.foR.FObj; /** - * Manages the main-reference-area. Its parent should always be an instance of - * RegionRABody. + * Manages the footnote reference area for a page. */ public class FootnoteRA extends AreaFixed implements org.axsl.areaW.FootnoteRA { Modified: trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:42:37 UTC (rev 7304) +++ trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:42:45 UTC (rev 7305) @@ -45,7 +45,7 @@ private int dimensionBeforeFloatRA; // keeps track of footnote state for multiple layouts - private int footnoteState = 0; +// private int footnoteState = 0; public RegionRABody(RegionBody generatedBy, PageRA parentArea, int xPosition, int yPosition) { @@ -81,24 +81,6 @@ return footnoteReferenceArea; } - public int getFootnoteState() { - return footnoteState; - } - - public boolean needsFootnoteAdjusting() { - int footnoteYPosition = footnoteReferenceArea.crOriginY(); - switch (footnoteState) { - case 0: - if (footnoteReferenceArea.crBPD() > 0 - && mainReferenceArea.crBPD() > footnoteYPosition) { - return true; - } - case 1: - break; - } - return false; - } - protected static void resetMaxHeight(Area ar, int change) { List childs = ar.getChildren(); for (int i = 0; i < childs.size(); i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 18:42:45
|
Revision: 7304 Author: victormote Date: 2006-05-29 11:42:37 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7304&view=rev Log Message: ----------- Conform to axsl area-tree changes. Keep track of footnote layout status in the layout system, not in the area tree. Modified Paths: -------------- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java 2006-05-29 18:33:48 UTC (rev 7303) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java 2006-05-29 18:42:37 UTC (rev 7304) @@ -87,10 +87,8 @@ = (StaticContentPL) getLayoutProxy(separator); staticPL.layout(footArea); int diff = footArea.crBPD() - oldHeight; - if (bac.getFootnoteState() == 0) { - Area ar = bac.getWritableMainRA(); - decreaseMaxHeight(ar, diff); - } + Area ar = bac.getWritableMainRA(); + decreaseMaxHeight(ar, diff); oldHeight = footArea.crBPD(); } } @@ -99,10 +97,8 @@ // add as a pending footnote return false; } - if (bac.getFootnoteState() == 0) { - Area ar = bac.getWritableMainRA(); - decreaseMaxHeight(ar, footArea.crBPD() - oldHeight); - } + Area ar = bac.getWritableMainRA(); + decreaseMaxHeight(ar, footArea.crBPD() - oldHeight); } catch (AreaWException exception) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 18:33:57
|
Revision: 7303 Author: victormote Date: 2006-05-29 11:33:48 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7303&view=rev Log Message: ----------- Remove unneeded instance variables. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:30:34 UTC (rev 7302) +++ trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:33:48 UTC (rev 7303) @@ -44,10 +44,6 @@ private int dimensionFootnoteRA; private int dimensionBeforeFloatRA; - // reference area yPositions - private int mainYPosition; - private int footnoteYPosition; - // keeps track of footnote state for multiple layouts private int footnoteState = 0; @@ -90,12 +86,11 @@ } public boolean needsFootnoteAdjusting() { - footnoteYPosition = footnoteReferenceArea.crOriginY(); + int footnoteYPosition = footnoteReferenceArea.crOriginY(); switch (footnoteState) { case 0: if (footnoteReferenceArea.crBPD() > 0 - && mainYPosition + mainReferenceArea.crBPD() - > footnoteYPosition) { + && mainReferenceArea.crBPD() > footnoteYPosition) { return true; } case 1: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 18:30:40
|
Revision: 7302 Author: victormote Date: 2006-05-29 11:30:34 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7302&view=rev Log Message: ----------- Force the parent of BeforeFloatRA to be a RegionRABody. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java 2006-05-29 18:27:35 UTC (rev 7301) +++ trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java 2006-05-29 18:30:34 UTC (rev 7302) @@ -33,7 +33,7 @@ */ public class BeforeFloatRA extends AreaFixed { - public BeforeFloatRA(FObj generatedBy, Area parentArea) { + public BeforeFloatRA(FObj generatedBy, RegionRABody parentArea) { super(generatedBy, parentArea); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 18:27:47
|
Revision: 7301 Author: victormote Date: 2006-05-29 11:27:35 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7301&view=rev Log Message: ----------- Remove some unused methods and instance variables. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java 2006-05-29 18:17:42 UTC (rev 7300) +++ trunk/foray/foray-areatree/src/java/org/foray/area/BeforeFloatRA.java 2006-05-29 18:27:35 UTC (rev 7301) @@ -41,18 +41,6 @@ return AreaNode.AREATYPE_BEFORE_FLOAT_RA; } - public int getXPosition() { - // x-position is the same as the parent's - RegionRABody parent = (RegionRABody) getParent(); - return parent.getXPosition(); - } - - public int getYPosition() { - // y-position is the same as the parent's - RegionRABody parent = (RegionRABody) getParent(); - return parent.getYPosition(); - } - public int crBPD() { return ((RegionRABody) getParentArea()).getDimensionBeforeFloatRA(); } Modified: trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:17:42 UTC (rev 7300) +++ trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2006-05-29 18:27:35 UTC (rev 7301) @@ -36,10 +36,6 @@ public class RegionRABody extends AreaFixed implements RegionBodyArea, org.axsl.areaW.RegionRABody { - // dimensions for the 'region-reference-area' - private int xPosition; - private int yPosition; - // the 3 primary reference areas private MainRA mainReferenceArea; private BeforeFloatRA beforeFloatReferenceArea; @@ -58,8 +54,6 @@ public RegionRABody(RegionBody generatedBy, PageRA parentArea, int xPosition, int yPosition) { super(generatedBy, parentArea); - this.xPosition = xPosition; - this.yPosition = yPosition; // create the primary reference areas beforeFloatReferenceArea = new BeforeFloatRA(generatedBy, this); @@ -67,14 +61,6 @@ footnoteReferenceArea = new FootnoteRA(generatedBy, this); } - public int getXPosition() { - return xPosition + getPaddingLeft() + getBorderLeftWidth(); - } - - public int getYPosition() { - return yPosition + getPaddingTop() + getBorderTopWidth(); - } - public MainReferenceArea getMainReferenceArea() { return mainReferenceArea; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 18:17:48
|
Revision: 7300 Author: victormote Date: 2006-05-29 11:17:42 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7300&view=rev Log Message: ----------- Correct computation of remaining space in area. Was double-counting the space already used. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java 2006-05-29 17:51:49 UTC (rev 7299) +++ trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java 2006-05-29 18:17:42 UTC (rev 7300) @@ -105,11 +105,12 @@ */ public org.axsl.areaW.LineArea createNextLineArea() { /* The size of the next line does not need to consider the half-leading - * that follows the line. */ + * that follows the line. That half-leading will be automatically + * handled if the line is actually created, but can safely be ignored + * for purposes of deciding whether the line will fit. */ int sizeNextLineArea = this.traitFontSize() + this.traitHalfLeadingOpt(); - if (this.getProgressionDimension() - + sizeNextLineArea + if (sizeNextLineArea > this.progressionDimensionAvailable()) { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 17:52:10
|
Revision: 7299 Author: victormote Date: 2006-05-29 10:51:49 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7299&view=rev Log Message: ----------- Make space-before and space-after traits of line-areas zero. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/Area.java trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/Area.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2006-05-29 16:32:23 UTC (rev 7298) +++ trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2006-05-29 17:51:49 UTC (rev 7299) @@ -773,14 +773,30 @@ return traitGeneratedBy().traitPaddingAfter(traitIsLast()); } + public int traitSpaceBeforeMinimum() { + return traitGeneratedBy().traitSpaceBeforeMinimum(); + } + public int traitSpaceBeforeOptimum() { return traitGeneratedBy().traitSpaceBeforeOptimum(); } + public int traitSpaceBeforeMaximum() { + return traitGeneratedBy().traitSpaceBeforeMaximum(); + } + + public int traitSpaceAfterMinumum() { + return traitGeneratedBy().traitSpaceAfterMinimum(); + } + public int traitSpaceAfterOptimum() { return traitGeneratedBy().traitSpaceAfterOptimum(); } + public int traitSpaceAfterMaximum() { + return traitGeneratedBy().traitSpaceAfterMaximum(); + } + public int traitSpaceStartOptimum() { Area ancestor = this.ancestorBlockAreaNotALineArea(); return traitGeneratedBy().traitSpaceStartOptimum(ancestor.crIPD()); Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-05-29 16:32:23 UTC (rev 7298) +++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-05-29 17:51:49 UTC (rev 7299) @@ -848,4 +848,40 @@ return this; } + public int traitSpaceBeforeMinimum() { + /* space-before applies to the parent normal block area, but not to the + * line-area.*/ + return 0; + } + + public int traitSpaceBeforeOptimum() { + /* space-before applies to the parent normal block area, but not to the + * line-area.*/ + return 0; + } + + public int traitSpaceBeforeMaximum() { + /* space-before applies to the parent normal block area, but not to the + * line-area.*/ + return 0; + } + + public int traitSpaceAfterMinumum() { + /* space-after applies to the parent normal block area, but not to the + * line-area.*/ + return 0; + } + + public int traitSpaceAfterOptimum() { + /* space-after applies to the parent normal block area, but not to the + * line-area.*/ + return 0; + } + + public int traitSpaceAfterMaximum() { + /* space-after applies to the parent normal block area, but not to the + * line-area.*/ + return 0; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 17:12:10
|
Revision: 7298 Author: victormote Date: 2006-05-29 09:32:23 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7298&view=rev Log Message: ----------- Correct the process of checking the existence of a previous line in the block Area, so that the half-leading between lines is computed properly. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-05-29 16:12:53 UTC (rev 7297) +++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-05-29 16:32:23 UTC (rev 7298) @@ -56,7 +56,7 @@ /* The progression dimension used is exactly equal to the size of the * em-box, i.e. exactly equal to the font-size. */ this.setProgressionDimension(this.traitFontSize()); - LineArea prevLineArea = (LineArea) this.getPreviousChildOfGeneratedBy(); + LineArea prevLineArea = parentArea.getPreviousLineArea(this); if (prevLineArea == null) { this.setAnteriorSpace(traitHalfLeadingOpt()); } else { Modified: trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java 2006-05-29 16:12:53 UTC (rev 7297) +++ trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java 2006-05-29 16:32:23 UTC (rev 7298) @@ -235,4 +235,19 @@ this.pendingFootnotes = new ArrayList(newFootnotes); } + public LineArea getPreviousLineArea(LineArea lineArea) { + if (this.children == null) { + return null; + } + int index = children.indexOf(lineArea); + if (index <= 0) { + return null; + } + Object previousObject = children.get(index - 1); + if (previousObject instanceof LineArea) { + return (LineArea) previousObject; + } + return null; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 15:51:37
|
Revision: 7296 Author: victormote Date: 2006-05-29 08:51:25 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7296&view=rev Log Message: ----------- Conform to axsl changes regarding removal of line-height traits, using half-leading traits instead. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/Area.java trunk/foray/foray-areatree/src/java/org/foray/area/AreaFlexible.java trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java trunk/foray/foray-areatree/src/java/org/foray/area/SpanRA.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/Area.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2006-05-29 15:51:15 UTC (rev 7295) +++ trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2006-05-29 15:51:25 UTC (rev 7296) @@ -1150,10 +1150,6 @@ return true; } - public int traitLineHeight() { - return this.traitGeneratedBy().traitLineHeightOpt(); - } - public org.axsl.areaW.TableBodyContainer makeTableBodyContainer( TableBody tableBody) { return new org.foray.area.TableBodyContainer(tableBody, this); Modified: trunk/foray/foray-areatree/src/java/org/foray/area/AreaFlexible.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/AreaFlexible.java 2006-05-29 15:51:15 UTC (rev 7295) +++ trunk/foray/foray-areatree/src/java/org/foray/area/AreaFlexible.java 2006-05-29 15:51:25 UTC (rev 7296) @@ -130,17 +130,7 @@ } /** - * <p>Returns the actual total value of the size of this area (not counting - * space-before, etc.) in its progression direction. - * This value does <em>not</em> include space-before, etc., but - * <em>does</em> include borders and padding. - * For block areas, the progression dimension is the - * block-progression-dimension. - * For inline areas, it is the inline-progression-dimension. - * The Area stores this size, but the Layout system is responsible to - * compute and set it. - * Every AreaFlexible starts out with a progressionDimension of zero.</p> - * @return The progressionDimension. + * {@inheritDoc} */ public int getProgressionDimension() { return this.progressionDimension; Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-05-29 15:51:15 UTC (rev 7295) +++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-05-29 15:51:25 UTC (rev 7296) @@ -53,12 +53,9 @@ public LineArea(FObj generatedBy, NormalBlockArea parentArea) { super(generatedBy, parentArea); - if (getAscender() < 1 - || getDescender() > -1) { - this.setProgressionDimension(this.traitLineHeight()); - } else { - this.setProgressionDimension(getAscender() - getDescender()); - } + /* The progression dimension used is exactly equal to the size of the + * em-box, i.e. exactly equal to the font-size. */ + this.setProgressionDimension(this.traitFontSize()); LineArea prevLineArea = (LineArea) this.getPreviousChildOfGeneratedBy(); if (prevLineArea == null) { this.setAnteriorSpace(traitHalfLeadingOpt()); Modified: trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java 2006-05-29 15:51:15 UTC (rev 7295) +++ trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java 2006-05-29 15:51:25 UTC (rev 7296) @@ -49,8 +49,10 @@ implements org.axsl.areaR.NormalBlockArea, org.axsl.areaW.NormalBlockArea { + /* TODO: This is a layout concept and should not be in AreaTree? */ private LineArea currentLineArea; + /* TODO: This is a layout concept and should not be in AreaTree? */ private ArrayList pendingFootnotes = null; public NormalBlockArea(FObj parentFObj, Area parentArea) { @@ -102,8 +104,12 @@ * @return the new current line area, which will be empty. */ public org.axsl.areaW.LineArea createNextLineArea() { + /* The size of the next line does not need to consider the half-leading + * that follows the line. */ + int sizeNextLineArea = this.traitFontSize() + + this.traitHalfLeadingOpt(); if (this.getProgressionDimension() - + traitGeneratedBy().traitLineHeightOpt() + + sizeNextLineArea > this.progressionDimensionAvailable()) { return null; } Modified: trunk/foray/foray-areatree/src/java/org/foray/area/SpanRA.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/SpanRA.java 2006-05-29 15:51:15 UTC (rev 7295) +++ trunk/foray/foray-areatree/src/java/org/foray/area/SpanRA.java 2006-05-29 15:51:25 UTC (rev 7296) @@ -237,8 +237,10 @@ public boolean canAddLineArea(NormalBlockArea blockArea) { for (int i = 0; i < getChildren().size(); i++) { NormalFlowRA nf = (NormalFlowRA) getChildren().get(i); + int sizeNextLine = blockArea.traitFontSize() + + blockArea.traitGeneratedBy().traitHalfLeadingOpt(); if (nf.bpdUsedByChildren() - + blockArea.traitGeneratedBy().traitLineHeightOpt() + + sizeNextLine <= this.progressionDimensionAvailable()) { return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-29 15:51:23
|
Revision: 7295 Author: victormote Date: 2006-05-29 08:51:15 -0700 (Mon, 29 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7295&view=rev Log Message: ----------- Conform to axsl changes regarding removal of line-height traits, using half-leading traits instead. Modified Paths: -------------- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java =================================================================== --- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2006-05-27 19:14:38 UTC (rev 7294) +++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2006-05-29 15:51:15 UTC (rev 7295) @@ -896,41 +896,6 @@ /** * {@inheritDoc} */ - public int traitLineHeightMin() { - return propertyList.traitLineHeight(Property.MINIMUM); - } - - /** - * {@inheritDoc} - */ - public int traitLineHeightOpt() { - return propertyList.traitLineHeight(Property.OPTIMUM); - } - - /** - * {@inheritDoc} - */ - public int traitLineHeightMax() { - return propertyList.traitLineHeight(Property.MAXIMUM); - } - - /** - * {@inheritDoc} - */ - public short traitLineHeightConditionality() { - return propertyList.traitLineHeightConditionality(); - } - - /** - * {@inheritDoc} - */ - public int traitLineHeightPrecedence() { - return propertyList.traitLineHeightPrecedence(); - } - - /** - * {@inheritDoc} - */ public int traitEndIndent(int ipdContainingRA) { return propertyList.getIndent(Constants.DIRECTION_END, ipdContainingRA); Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java =================================================================== --- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java 2006-05-27 19:14:38 UTC (rev 7294) +++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java 2006-05-29 15:51:15 UTC (rev 7295) @@ -224,7 +224,7 @@ public static int getPrecedenceNoInstance(FObj fobj) { FObj parent = fobj.getFObjParent(); if (parent != null) { - return parent.traitLineHeightPrecedence(); + return parent.traitHalfLeadingPrecedence(); } return DtSpace.PRECEDENCE_FORCE; } @@ -240,7 +240,7 @@ public static short getConditionalityNoInstance(FObj fobj) { FObj parent = fobj.getFObjParent(); if (parent != null) { - return parent.traitLineHeightConditionality(); + return parent.traitHalfLeadingConditionality(); } return Constants.FOVAL_RETAIN; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-27 19:14:53
|
Revision: 7294 Author: victormote Date: 2006-05-27 12:14:38 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7294&view=rev Log Message: ----------- Convert use of other FOraySession constructors to use of the factory method instead. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java Modified: trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -103,8 +103,7 @@ resource.setMissingEmphasized(false); SessionConfig configuration = this.options.getSessionConfig(); - session = new FOraySession(null, configuration, null, null, null, null, - null, null); + FOraySession session = FOraySpecific.makeFOraySession(configuration); // init parser parser = inputHandler.getParser(); Modified: trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -24,7 +24,6 @@ package org.foray.app; -import org.foray.common.Logging; import org.foray.core.FOrayException; import org.foray.core.FOraySession; import org.foray.core.SessionConfig; @@ -56,10 +55,9 @@ } public void run() throws FOrayException { - Log logger = Logging.makeDefaultLogger(); SessionConfig configuration = this.options.getSessionConfig(); - FOraySession session = new FOraySession(logger, configuration, null, - null, null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession( + configuration); PrinterJob pj = PrinterJob.getPrinterJob(); if(System.getProperty("dialog") != null) { Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -24,6 +24,7 @@ package org.foray.app.ant; +import org.foray.app.FOraySpecific; import org.foray.app.Options; import org.foray.app.OutputTargetFactory; import org.foray.app.Starter; @@ -263,8 +264,8 @@ } try { - FOraySession session = new FOraySession(this.getLogger(), - sessionConfig, null, null, null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession( + sessionConfig); FOrayDocument document = new FOrayDocument(session, inputHandler.getInputSource(), parser); Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -24,6 +24,7 @@ package org.foray.app.test; +import org.foray.app.FOraySpecific; import org.foray.app.OutputTargetFactory; import org.foray.common.Logging; import org.foray.core.FOInputHandler; @@ -270,8 +271,8 @@ + xsl)); } - FOraySession session = new FOraySession(log, configuration, null, - null, null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession( + configuration); XMLReader parser = inputHandler.getParser(); setParserFeatures(parser); Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -34,6 +34,7 @@ import javax.xml.transform.TransformerException; +import org.foray.app.FOraySpecific; import org.foray.core.Application; import org.foray.core.FOInputHandler; import org.foray.core.FOrayDocument; @@ -41,7 +42,6 @@ import org.foray.core.FOraySession; import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; -import org.foray.core.SessionConfig; import org.foray.render.awt.AWTRenderer; import org.foray.render.awt.viewer.PreviewDialog; import org.foray.render.awt.viewer.SecureResourceBundle; @@ -111,9 +111,7 @@ // TODO: userMessage doesn't seem to be used anywhere. //Setup FOraySession - SessionConfig config = new SessionConfig(getLogger()); - FOraySession session = new FOraySession(logger, config, null, null, - null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession(null); //Setup FOrayDocument InputHandler inputHandler = new FOInputHandler(getLogger(), fo); Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -24,6 +24,7 @@ package org.foray.demo.embed; +import org.foray.app.FOraySpecific; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; import org.foray.core.FOInputHandler; @@ -32,7 +33,6 @@ import org.foray.core.FOraySession; import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; -import org.foray.core.SessionConfig; import org.axsl.output.OutputTarget; @@ -50,9 +50,7 @@ FOrayException { // Setup FOraySession - SessionConfig config = new SessionConfig(getLogger()); - FOraySession session = new FOraySession(getLogger(), config, null, null, - null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession(null); // Setup FOrayDocument InputHandler inputHandler = new FOInputHandler(getLogger(), fo); Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -24,13 +24,13 @@ package org.foray.demo.embed; +import org.foray.app.FOraySpecific; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; import org.foray.core.FOraySession; import org.foray.core.FOrayTarget; -import org.foray.core.SessionConfig; import org.foray.demo.embed.model.ProjectTeam; import org.axsl.output.OutputTarget; @@ -56,9 +56,7 @@ throws IOException, FOrayException, TransformerException { // Setup FOraySession - SessionConfig config = new SessionConfig(getLogger()); - FOraySession session = new FOraySession(getLogger(), config, null, null, - null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession(null); // Setup FOrayDocument // Setup JAXP transformation Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -24,6 +24,7 @@ package org.foray.demo.embed; +import org.foray.app.FOraySpecific; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; import org.foray.core.FOrayDocument; @@ -56,8 +57,7 @@ // Setup FOraySession SessionConfig config = new SessionConfig(getLogger()); - FOraySession session = new FOraySession(getLogger(), config, null, null, - null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession(config); // Setup FOrayDocument // Setup JAXP transformation Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-27 16:54:33 UTC (rev 7293) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-27 19:14:38 UTC (rev 7294) @@ -24,6 +24,7 @@ package org.foray.demo.servlet; +import org.foray.app.FOraySpecific; import org.foray.app.OutputTargetFactory; import org.foray.common.Logging; import org.foray.core.FOInputHandler; @@ -32,7 +33,6 @@ import org.foray.core.FOraySession; import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; -import org.foray.core.SessionConfig; import org.axsl.output.OutputTarget; @@ -110,9 +110,7 @@ throws FOrayException { response.setContentType(getContentType()); // Setup FOraySession - SessionConfig configuration = new SessionConfig(logger); - FOraySession session = new FOraySession(logger, configuration, null, - null, null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession(null); return session; } @@ -198,9 +196,7 @@ response.setContentType("application/pdf"); // Setup FOraySession - SessionConfig configuration = new SessionConfig(logger); - FOraySession session = new FOraySession(logger, configuration, null, - null, null, null, null, null); + FOraySession session = FOraySpecific.makeFOraySession(null); // Setup FOrayDocument TransformerFactory factory = TransformerFactory.newInstance(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-27 16:54:43
|
Revision: 7293 Author: victormote Date: 2006-05-27 09:54:33 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7293&view=rev Log Message: ----------- Don't remove empty blocks if they are empty on purpose. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java 2006-05-26 22:46:24 UTC (rev 7292) +++ trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java 2006-05-27 16:54:33 UTC (rev 7293) @@ -313,11 +313,20 @@ purgeEmptyNodes((Area) object); } } - if (area instanceof LineArea && ! area.hasChildren()) { + + /* Remove empty line areas. */ + if (area instanceof LineArea + && ! area.hasChildren()) { area.remove(); getLogger().debug("Removing empty line-area."); } - if (area instanceof NormalBlockArea && ! area.hasChildren()) { + + /* Remove empty block areas only if they are generated by FONodes that + * actually have children. If the FONode has no children, then an empty + * area is needed in the area tree. */ + if (area instanceof NormalBlockArea + && ! area.hasChildren() + && area.generatedBy.getFONode().hasChildren()) { area.remove(); getLogger().debug("Removing empty normal block-area."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 23:47:03
|
Revision: 7292 Author: victormote Date: 2006-05-26 15:46:24 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7292&view=rev Log Message: ----------- Move more bootstrapping logic to FOraySpecific. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:36:59 UTC (rev 7291) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:46:24 UTC (rev 7292) @@ -33,13 +33,7 @@ import org.foray.output.OutputConfig; import org.foray.pioneer.PioneerLS; -import org.axsl.areaW.AreaTreeFactory; -import org.axsl.foR.FOTreeFactory; -import org.axsl.fontR.FontServer; -import org.axsl.graphicR.GraphicServer; -import org.axsl.layout.LayoutFactory; import org.axsl.output.OutputTarget; -import org.axsl.text.TextServer; import org.apache.commons.logging.Log; @@ -78,32 +72,9 @@ * who wish to embed FOray in other applications. */ - /* - * Instantiate and configure the FOraySession. - * All parameters (Logger, SessionConfig, FontServer, TextServer, - * GraphicServer, and FOTreeServer) are optional. - * Each one that is passed as null in the constructor will be created - * by the FOraySession. - * However, if an instance <em>is</em> passed here, it needs to already - * be fully configured and ready to go. - */ - /* Set Logger to null so that new one will be created at the right - * verbosity level. */ + /* Instantiate the FOraySession. */ SessionConfig sessionConfig = this.options.getSessionConfig(); - Log logger = FOraySpecific.makeLogger(sessionConfig); - FontServer fontServer = FOraySpecific.makeFontServer(logger, - sessionConfig); - TextServer textServer = FOraySpecific.makeTextServer(logger, - sessionConfig); - GraphicServer graphicServer = FOraySpecific.makeGraphicServer(logger); - FOTreeFactory foTreeServer = FOraySpecific.makeFOTreeFactory(logger, - sessionConfig, graphicServer, textServer); - AreaTreeFactory areaTreeFactory = FOraySpecific.makeAreaTreeFactory( - logger, textServer); - LayoutFactory layoutFactory = FOraySpecific.makeLayoutFactory(logger); - FOraySession session = new FOraySession(logger, sessionConfig, - fontServer, textServer, graphicServer, foTreeServer, - areaTreeFactory, layoutFactory); + FOraySession session = FOraySpecific.makeFOraySession(sessionConfig); /* * Instantiate and configure the FOrayDocument(s). The constructor Modified: trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:36:59 UTC (rev 7291) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySpecific.java 2006-05-26 22:46:24 UTC (rev 7292) @@ -28,6 +28,7 @@ import org.foray.common.Logging; import org.foray.common.XMLParser; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; import org.foray.core.SessionConfig; import org.foray.font.FOrayFontServer; import org.foray.fotree.FOrayFOTreeServer; @@ -65,6 +66,31 @@ private FOraySpecific() { } + /** + * @return A new FOraySession instance configured with default servers and + * factories. + * @throws FOrayException For errors in creating the server and factories, + * or in instantiating the FOraySession. + */ + public static FOraySession makeFOraySession(SessionConfig sessionConfig) + throws FOrayException { + Log logger = FOraySpecific.makeLogger(sessionConfig); + FontServer fontServer = FOraySpecific.makeFontServer(logger, + sessionConfig); + TextServer textServer = FOraySpecific.makeTextServer(logger, + sessionConfig); + GraphicServer graphicServer = FOraySpecific.makeGraphicServer(logger); + FOTreeFactory foTreeServer = FOraySpecific.makeFOTreeFactory(logger, + sessionConfig, graphicServer, textServer); + AreaTreeFactory areaTreeFactory = FOraySpecific.makeAreaTreeFactory( + logger, textServer); + LayoutFactory layoutFactory = FOraySpecific.makeLayoutFactory(logger); + FOraySession session = new FOraySession(logger, sessionConfig, + fontServer, textServer, graphicServer, foTreeServer, + areaTreeFactory, layoutFactory); + return session; + } + public static Log makeLogger(SessionConfig configuration) { if (configuration.optionVerbosity().equals("debug")) { return Logging.makeDebugLogger(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:37:09
|
Revision: 7291 Author: victormote Date: 2006-05-26 15:36:59 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7291&view=rev Log Message: ----------- Clean up build problem. aXSL is not supposed to have access to any logging. Modified Paths: -------------- trunk/foray/foray-output/src/java/org/foray/output/Converter.java trunk/foray/foray-output/src/java/org/foray/output/MIFConverter.java trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java Modified: trunk/foray/foray-output/src/java/org/foray/output/Converter.java =================================================================== --- trunk/foray/foray-output/src/java/org/foray/output/Converter.java 2006-05-26 22:36:47 UTC (rev 7290) +++ trunk/foray/foray-output/src/java/org/foray/output/Converter.java 2006-05-26 22:36:59 UTC (rev 7291) @@ -24,6 +24,8 @@ package org.foray.output; +import org.apache.commons.logging.Log; + /** * Abstract superclass for all output targets that do no layout, instead * converting directly from the FO Tree. @@ -33,8 +35,8 @@ /** * */ - public Converter(OutputConfig outputConfig) { - super(outputConfig); + public Converter(Log logger, OutputConfig outputConfig) { + super(logger, outputConfig); } } Modified: trunk/foray/foray-output/src/java/org/foray/output/MIFConverter.java =================================================================== --- trunk/foray/foray-output/src/java/org/foray/output/MIFConverter.java 2006-05-26 22:36:47 UTC (rev 7290) +++ trunk/foray/foray-output/src/java/org/foray/output/MIFConverter.java 2006-05-26 22:36:59 UTC (rev 7291) @@ -34,6 +34,8 @@ import org.axsl.foR.fo.TableRow; import org.axsl.fontR.FontConsumer; +import org.apache.commons.logging.Log; + import java.awt.Color; import java.io.IOException; @@ -71,8 +73,8 @@ /** * create the MIF renderer */ - public MIFConverter(OutputConfig outputConfig) { - super(outputConfig); + public MIFConverter(Log logger, OutputConfig outputConfig) { + super(logger, outputConfig); } public void convert(Table table) { Modified: trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java =================================================================== --- trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java 2006-05-26 22:36:47 UTC (rev 7290) +++ trunk/foray/foray-output/src/java/org/foray/output/OutputTarget.java 2006-05-26 22:36:59 UTC (rev 7291) @@ -49,7 +49,8 @@ /** * */ - public OutputTarget(OutputConfig outputConfig) { + public OutputTarget(Log logger, OutputConfig outputConfig) { + this.logger = logger; this.options = outputConfig; } @@ -156,13 +157,6 @@ } /** - * {@inheritDoc} - */ - public void setLogger(Log logger) { - this.logger = logger; - } - - /** * @param fontConsumer The fontConsumer to set. */ public void setFontConsumer(FontConsumer fontConsumer) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:36:57
|
Revision: 7290 Author: victormote Date: 2006-05-26 15:36:47 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7290&view=rev Log Message: ----------- Clean up build problem. aXSL is not supposed to have access to any logging. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java Modified: trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 22:36:29 UTC (rev 7289) +++ trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 22:36:47 UTC (rev 7290) @@ -119,7 +119,7 @@ } OutputConfig renderOptions = commandLineOptions.getRendererOptions(); - this.renderer = new AWTRenderer(renderOptions); + this.renderer = new AWTRenderer(this.getLogger(), renderOptions); frame = createPreviewDialog(renderer, resource); renderer.setProgressListener(frame); renderer.setComponent(frame); Modified: trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java 2006-05-26 22:36:29 UTC (rev 7289) +++ trunk/foray/foray-app/src/java/org/foray/app/OutputTargetFactory.java 2006-05-26 22:36:47 UTC (rev 7290) @@ -102,7 +102,7 @@ OutputTarget renderer = null; switch (rendererType) { case RENDER_AWT: { - renderer = new AWTRenderer(outputOptions); + renderer = new AWTRenderer(logger, outputOptions); break; } case RENDER_PRINT: { @@ -110,32 +110,32 @@ + "from the standard method."); } case RENDER_PCL: { - renderer = new PCLRenderer(outputOptions); + renderer = new PCLRenderer(logger, outputOptions); break; } case RENDER_PS: { - renderer = new PSRenderer(outputOptions); + renderer = new PSRenderer(logger, outputOptions); break; } case RENDER_TXT: { - renderer = new TXTRenderer(outputOptions); + renderer = new TXTRenderer(logger, outputOptions); break; } case RENDER_MIF: { - renderer = new MIFConverter(outputOptions); + renderer = new MIFConverter(logger, outputOptions); break; } case RENDER_XML: { - renderer = new XMLRenderer(outputOptions); + renderer = new XMLRenderer(logger, outputOptions); break; } case RENDER_SVG: { - renderer = new SVGRenderer(outputOptions); + renderer = new SVGRenderer(logger, outputOptions); break; } default: { PDFDocument document = new org.foray.pdf.object.PDFDocument(logger); - renderer = new PDFRenderer(outputOptions, document); + renderer = new PDFRenderer(logger, outputOptions, document); break; } } Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 22:36:29 UTC (rev 7289) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 22:36:47 UTC (rev 7290) @@ -121,7 +121,7 @@ inputHandler.getInputSource(), inputHandler.getParser()); //Setup renderer - AWTRenderer renderer = new AWTRenderer(null); + AWTRenderer renderer = new AWTRenderer(this.logger, null); //Setup FOrayTarget new FOrayTarget(document, renderer, null, null); Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 22:36:29 UTC (rev 7289) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 22:36:47 UTC (rev 7290) @@ -115,7 +115,7 @@ // Setup the Renderer PrinterJob pj = PrinterJob.getPrinterJob(); pj.setCopies(1); - AWTPrintRenderer renderer = new AWTPrintRenderer(null, pj); + AWTPrintRenderer renderer = new AWTPrintRenderer(this.logger, null, pj); // Setup FOrayTarget FOrayTarget target = new FOrayTarget(document, renderer, null, null); return target; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:36:44
|
Revision: 7289 Author: victormote Date: 2006-05-26 15:36:29 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7289&view=rev Log Message: ----------- Clean up build problem. aXSL is not supposed to have access to any logging. Modified Paths: -------------- trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java trunk/foray/foray-render/src/java/org/foray/render/Renderer.java trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java Modified: trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/PrintRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -33,6 +33,8 @@ import org.axsl.common.Constants; import org.axsl.fontR.FontConsumer; +import org.apache.commons.logging.Log; + import java.awt.Color; /** @@ -40,8 +42,8 @@ */ public abstract class PrintRenderer extends Renderer { - public PrintRenderer(OutputConfig renderConfig) { - super(renderConfig); + public PrintRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/Renderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -69,6 +69,7 @@ import org.axsl.graphicR.GraphicException; import org.apache.batik.bridge.BridgeContext; +import org.apache.commons.logging.Log; import java.awt.Color; import java.awt.Rectangle; @@ -89,8 +90,8 @@ /** * Constructor. */ - public Renderer(OutputConfig renderConfig) { - super(renderConfig); + public Renderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } public void setAreaTree(AreaTree areaTree) { Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTPrintRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -28,6 +28,8 @@ import org.axsl.areaR.PageArea; +import org.apache.commons.logging.Log; + import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.IOException; @@ -44,8 +46,9 @@ private int mode = EVEN_AND_ALL; private PrinterJob printerJob; - public AWTPrintRenderer(OutputConfig renderConfig, PrinterJob printerJob) { - super(renderConfig); + public AWTPrintRenderer(Log logger, OutputConfig renderConfig, + PrinterJob printerJob) { + super(logger, renderConfig); this.printerJob = printerJob; startNumber = getIntProperty("start", 1) - 1; Modified: trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/awt/AWTRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -49,6 +49,7 @@ import org.apache.batik.bridge.GVTBuilder; import org.apache.batik.bridge.ViewBox; import org.apache.batik.gvt.GraphicsNode; +import org.apache.commons.logging.Log; import org.w3c.dom.Document; import org.w3c.dom.svg.SVGDocument; @@ -147,8 +148,8 @@ */ protected Component parent; - public AWTRenderer(OutputConfig renderConfig) { - super(renderConfig); + public AWTRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/pcl/PCLRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -48,6 +48,8 @@ import org.axsl.graphicR.Graphic; import org.axsl.graphicR.GraphicException; +import org.apache.commons.logging.Log; + import java.awt.Color; import java.awt.Rectangle; import java.awt.color.ColorSpace; @@ -80,8 +82,8 @@ /** * Create the PCL renderer */ - public PCLRenderer(OutputConfig renderConfig) { - super(renderConfig); + public PCLRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -61,6 +61,8 @@ import org.axsl.pdfW.PDFPathPaint; import org.axsl.pdfW.PDFUtility; +import org.apache.commons.logging.Log; + import java.awt.Color; import java.awt.Rectangle; import java.awt.geom.Line2D; @@ -83,8 +85,9 @@ /** * Create a PDF renderer. */ - public PDFRenderer(OutputConfig renderConfig, PDFDocument document) { - super(renderConfig); + public PDFRenderer(Log logger, OutputConfig renderConfig, + PDFDocument document) { + super(logger, renderConfig); this.pdfDoc = document; } Modified: trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/ps/PSRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -58,6 +58,7 @@ import org.apache.batik.bridge.ViewBox; import org.apache.batik.ext.awt.g2d.GraphicContext; import org.apache.batik.gvt.GraphicsNode; +import org.apache.commons.logging.Log; import org.w3c.dom.Document; import org.w3c.dom.svg.SVGDocument; @@ -156,8 +157,8 @@ */ private HashMap fontMap = new HashMap(); - public PSRenderer(OutputConfig renderConfig) { - super(renderConfig); + public PSRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/svg/SVGRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -49,6 +49,7 @@ import org.apache.batik.transcoder.TranscoderInput; import org.apache.batik.transcoder.TranscoderOutput; import org.apache.batik.transcoder.svg2svg.SVGTranscoder; +import org.apache.commons.logging.Log; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; @@ -101,8 +102,8 @@ protected float currentGreen = 0; protected float currentBlue = 0; - public SVGRenderer(OutputConfig renderConfig) { - super(renderConfig); + public SVGRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } /** Modified: trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/txt/TXTRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -39,6 +39,8 @@ import org.axsl.graphicR.Graphic; import org.axsl.graphicR.GraphicException; +import org.apache.commons.logging.Log; + import org.w3c.dom.svg.SVGSVGElement; import java.awt.Color; @@ -95,8 +97,8 @@ public boolean suppressGraphics = false; boolean firstPage = false; - public TXTRenderer(OutputConfig renderConfig) { - super(renderConfig); + public TXTRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } void addStr(int row, int col, String str, boolean ischar) { Modified: trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java =================================================================== --- trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2006-05-26 22:36:22 UTC (rev 7288) +++ trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2006-05-26 22:36:29 UTC (rev 7289) @@ -57,6 +57,8 @@ import org.axsl.fontR.FontConsumer; import org.axsl.graphicR.Graphic; +import org.apache.commons.logging.Log; + import java.awt.Color; import java.awt.Rectangle; import java.io.IOException; @@ -82,8 +84,8 @@ */ protected PrintWriter writer; - public XMLRenderer(OutputConfig renderConfig) { - super(renderConfig); + public XMLRenderer(Log logger, OutputConfig renderConfig) { + super(logger, renderConfig); } public void render(PageArea page) throws IOException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:36:26
|
Revision: 7288 Author: victormote Date: 2006-05-26 15:36:22 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7288&view=rev Log Message: ----------- Clean up build problem. aXSL is not supposed to have access to any logging. Modified Paths: -------------- trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java Modified: trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2006-05-26 22:23:53 UTC (rev 7287) +++ trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2006-05-26 22:36:22 UTC (rev 7288) @@ -160,7 +160,6 @@ Application.getDeveloperURLShort()); this.outputTarget.setStrokeSVGText(getConfiguration() .optionStrokeSVGText()); - this.outputTarget.setLogger(this.getLogger()); this.outputTarget.setFontConsumer(this.getFontConsumer()); // Start the renderer. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:24:14
|
Revision: 7287 Author: victormote Date: 2006-05-26 15:23:53 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7287&view=rev Log Message: ----------- Move remaining core files from the app module to the core module. Modified Paths: -------------- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java Removed Paths: ------------- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java Modified: trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/AWTStarter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -31,7 +31,9 @@ * Modified to use streaming API by Mark Lillywhite, mar...@in... */ +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; import org.foray.render.awt.AWTRenderer; Modified: trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/CommandLineStarter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,7 +24,10 @@ package org.foray.app; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.SessionConfig; import org.foray.layout.LayoutStrategy; import org.foray.output.OutputConfig; Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -1,328 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.foray.common.XMLParser; -import org.foray.core.DocumentInputSource; -import org.foray.core.DocumentReader; -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; - -import org.axsl.areaW.AreaTreeFactory; -import org.axsl.fontR.FontConsumer; -import org.axsl.fontR.FontServer; -import org.axsl.graphicR.GraphicServer; -import org.axsl.layout.LayoutFactory; -import org.axsl.text.TextServer; - -import org.apache.commons.logging.Log; - -import org.w3c.dom.Document; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; - -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerException; -import javax.xml.transform.sax.SAXResult; - -/** - * This class manages the process of parsing an input FO document and creating - * an FOTree. - */ -public class FOrayDocument { - - /** The "parent" FOraySession. */ - private FOraySession session; - - /** - * The SAX InputSource that encapsulates the document to be parsed. - * Should be null if the JAXP constructor was used. - */ - private InputSource inputSource; - - /** - * The JAXP Transformer that should be used to handle an XSLT transformation - * on the input. - * Should be null if the SAX constructor was used. - */ - private Transformer jaxpTransformer; - - /** - * The JAXP Source that encapsulates the document to be parsed. - * Should be null if the SAX constructor was used. - */ - private Source jaxpSource; - - /** - * The JAXP Result encapsulating our FOTreeBuilder. - * Should be null if the SAX constructor was used. - */ - private SAXResult jaxpResult; - - /** The collection of FOrayTarget "children". */ - private ArrayList targetList = new ArrayList(); - - /** The FO tree builder, which handles the SAX events. */ - private org.axsl.foR.FOTree treeBuilder; - - private FOrayTarget currentTarget; - - /** Array of bytes listing unsupported FO objects. */ - protected byte[] unsupportedObjects; - - /** Array of shorts listing unsupported FO properties. */ - protected short[] unsupportedProperties; - - /** The SAX parser. */ - private XMLReader parser; - - /** - * Private constructor used only by the other constructors. - * @param session The parent FOraySession. - */ - private FOrayDocument(FOraySession session) { - this.session = session; - session.registerDocument(this); - treeBuilder = this.session.getFOTreeServer().makeFOTree(); - } - - /** - * Standard constructor. Accepts a SAX InputSource as input. - * @param session The parent FOraySession. - * @param inputSource A SAX InputSource. - * @param parser A SAX parser. - */ - public FOrayDocument(FOraySession session, InputSource inputSource, - XMLReader parser) { - this(session); - this.inputSource = inputSource; - this.parser = parser; - this.parser.setContentHandler(treeBuilder); - } - - /** - * Constructor for processing a DOM Document. It creates its own parser. - * @param session The parent FOraySession. - * @param domDocument A DOM Document. - */ - public FOrayDocument (FOraySession session, Document domDocument) - throws FOrayException { - this(session); - this.inputSource = new DocumentInputSource(domDocument); - this.parser = new DocumentReader(); - this.parser.setContentHandler(treeBuilder); - } - - /** - * Constructor for processing a JAXP Transformer. - * @param session The parent FOraySession. - * @param jaxpTransformer A JAXP Transformer. - */ - public FOrayDocument (FOraySession session, Transformer jaxpTransformer, - Source jaxpSource) throws FOrayException { - this(session); - this.jaxpTransformer = jaxpTransformer; - this.jaxpSource = jaxpSource; - this.jaxpResult = new SAXResult(this.treeBuilder); - } - - /** - * Registers a FOrayTarget instance that this FOrayDocument should process. - * @param target The FOrayTarget instance that should be processed. - */ - protected void registerTarget(FOrayTarget target) { - if (target == null) { - return; - } - this.targetList.add(target); - } - - /** - * Returns the tree builder (a SAX ContentHandler). - * - * Used in situations where SAX is used but not via a FOray-invoked - * SAX parser, i.e. where some upstream process wishes to be in control - * of the parsing and event-firing, usually because there is a pipeline of - * processes that are both SAX consumers and producers. Cocoon is one - * example of such a system. - */ - public ContentHandler getContentHandler() { - return this.treeBuilder; - } - - /** - * Returns the JAXP SAXResult (which encapsulates a SAX ContentHandler). - * - * See {@link #getContentHandler()} for the use-case. - */ - public SAXResult getJAXPResult() { - return this.jaxpResult; - } - - public void setTarget(FOrayTarget target) throws FOrayException { - if (target.getDocument() != this) { - throw new FOrayException("FOrayTarget not a child of this " - + "FOrayDocument."); - } - this.currentTarget = target; - } - - public synchronized void process() throws FOrayException { - // Get the FOrayTarget to process. - FOrayTarget target = (FOrayTarget) targetList.get(0); - processTarget(target); - } - - /** - * Build the formatting object tree from the input. - */ - public synchronized void processTarget(FOrayTarget target) - throws FOrayException { - this.setTarget(target); - this.treeBuilder.setFontConsumer(this.getFontConsumer()); - try { - if (this.jaxpTransformer == null) { - // Regular SAX Input - parser.parse(this.inputSource); - } else { - // SAX Events generated by a JAXP Transformer - jaxpTransformer.transform(this.jaxpSource, jaxpResult); - } - } catch (SAXException e) { - if (e.getException() instanceof FOrayException) { - throw (FOrayException)e.getException(); - } - throw new FOrayException(e); - } catch (TransformerException e) { - if (e.getException() instanceof FOrayException) { - throw (FOrayException)e.getException(); - } - throw new FOrayException(e); - } catch (IOException e) { - throw new FOrayException(e); - } finally { - cleanup(currentTarget); - } - } - - public void cleanup(FOrayTarget target) { - } - - /** - * Dumps an error - */ - public void dumpError(Exception e) { - if (! this.getConfiguration().optionVerbosity().equals("debug")) { - return; - } - Log log = getLogger(); - if (e instanceof SAXException) { - log.error(e.getMessage()); - if (((SAXException)e).getException() != null) { - log.error(((SAXException)e).getException().getMessage()); - } - } else if (e instanceof FOrayException) { - e.printStackTrace(); - if (((FOrayException)e).getException() != null) { - log.error(((FOrayException)e).getException().getMessage()); - } - } else { - log.error(e.getMessage()); - } - } - - /** - * Runs the formatting and renderering process using the previously set - * inputsource and outputstream - */ - public synchronized void run() - throws IOException, FOrayException { - if (this.inputSource == null) { - throw new FOrayException("InputSource is not set."); - } - - if (this.parser == null) { - throw new FOrayException("Invalid Parser."); - } - process(); - } - - public Log getLogger() { - return this.session.getLogger(); - } - - public FontServer getFontServer() { - return this.session.getFontServer(); - } - - public String getParserClassName() { - return XMLParser.getParserClassName(); - } - - /** - * Required by FOTreeControl interface. - * @return The base URL that should be used for finding external files, like - * graphical images, etc. - */ - public URL getBaseURL() { - return getConfiguration().optionBaseDirectory(); - } - - public FontConsumer getFontConsumer() { - return this.currentTarget.getFontConsumer(); - } - - public TextServer getTextServer() { - return session.getTextServer(); - } - - public GraphicServer getGraphicServer() { - return session.getGraphicServer(); - } - - public SessionConfig getConfiguration() { - return session.getConfiguration(); - } - - public org.axsl.foR.FOTree getFOTreeBuilder() { - return this.treeBuilder; - } - - public AreaTreeFactory getAreaTreeFactory() { - return this.session.getAreaTreeFactory(); - } - - public LayoutFactory getLayoutFactory() { - return this.session.getLayoutFactory(); - } - -} Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -1,268 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.foray.core.Application; -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; - -import org.axsl.areaW.AreaTreeFactory; -import org.axsl.foR.FOTreeFactory; -import org.axsl.fontR.FontServer; -import org.axsl.graphicR.GraphicServer; -import org.axsl.layout.LayoutFactory; -import org.axsl.text.TextServer; - -import org.apache.commons.logging.Log; - -import org.xml.sax.EntityResolver; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * The ancestor class for all FOray processing. All classes that start - * FOray processing need to create a FOraySession, one or more FOrayDocument - * instances, and one or more FOrayTarget instances for each FOrayDocument, - * then run the FOraySession process() method. - * This process is illustrated and documented in the source code for - * the CommandLineStarter.run() method. - * - * After instantiating FOraySession, additional Namespace instances can - * be registered with the session through the addNamespace method. Custom - * Namespaces can also be added to the system resources, and these are - * automatically registered at runtime. - * - * The input document is identified to the FOrayDocument as it is instantiated. - * There are two constructors, one for SAX input, and the other for DOM input. - * The Renderer, LayoutStrategy, and output document are identified to the - * FOrayTarget as it is instantiated. - */ -public class FOraySession { - - /** The collection of FOrayDocument instances that will be processed. */ - private ArrayList documentList = new ArrayList(); - - /** An logger to be used for this session. */ - private Log log; - - /** A FontServer instance to be used for this session. */ - private FontServer fontServer; - - /** A TextServer instance to be used for this session. */ - private TextServer textServer; - - /** A GraphicServer instance to be used for this session. */ - private GraphicServer graphicServer; - - /** */ - private FOTreeFactory foTreeFactory; - - private AreaTreeFactory areaTreeFactory; - - private LayoutFactory layoutFactory; - - /** A SessionConfig instance to be used for this session. */ - private SessionConfig configuration; - - /** The EntityResolver to be used when parsing XML (resolves XML catalogs, - * etc. */ - private EntityResolver entityResolver; - - /** - * Constructor. - * @param logger The (optional) logger that should be used for this - * session. If null is passed, a default Logger will be created. - * @param configuration The Configuration instance that should be used - * with this session. - * @param fontServer The (optional) FontServer instance that should be used - * for this session. If null is passed, then a FontServer instance will be - * created by this FOraySession. If an instance is passed, it needs to be - * fully configured and ready to be used. - * @param textServer The (optional) TextServer instance that should be used - * for this session. If null is passed, then a TextServer instance will be - * created by this FOraySession. If an instance is passed, it needs to be - * fully configured and ready to be used. - * @param graphicServer The (optional) GraphicServer instance that should - * be used for this session. If null is passed, then a GraphicServer - * instance will be created by this FOray Session. If an instance is passed, - * it needs to be fully configured and ready to be used. - */ - public FOraySession(Log logger, SessionConfig configuration, - FontServer fontServer, TextServer textServer, - GraphicServer graphicServer, FOTreeFactory foTreeFactory, - AreaTreeFactory areaTreeFactory, LayoutFactory layoutFactory) - throws FOrayException { - /* Validate Logger. */ - if (logger == null) { - throw new FOrayException("Logger required for FOraySession."); - } - this.log = logger; - log.info(Application.getVersion()); - - /* Validate Configuration. */ - this.configuration = configuration; - if (this.configuration == null) { - this.configuration = new SessionConfig(logger); - } - - /* Validate FontServer. */ - if (fontServer == null) { - throw new FOrayException("FontServer required for FOraySession."); - } - this.fontServer = fontServer; - setupFontServer(); - - /* Validate TextServer. */ - if (textServer == null) { - throw new FOrayException("TextServer required for FOraySession."); - } - this.textServer = textServer; - - /* Validate GraphicServer. */ - if (graphicServer == null) { - throw new FOrayException("GraphicServer required for " - + "FOraySession."); - } - this.graphicServer = graphicServer; - - /* Validate FOTreeFactory. */ - if (foTreeFactory == null) { - throw new FOrayException("FOTreeFactory required for " - + "FOraySession."); - } - this.foTreeFactory = foTreeFactory; - - /* Validate AreaTreeFactory. */ - if (areaTreeFactory == null) { - throw new FOrayException("AreaTreeFactory required for " - + "FOraySession."); - } - this.areaTreeFactory = areaTreeFactory; - - /* Validate LayoutFactory. */ - if (layoutFactory == null) { - throw new FOrayException("LayoutFactory required for " - + "FOraySession."); - } - this.layoutFactory = layoutFactory; - } - - public Log getLogger() { - return log; - } - - /** - * Registers a FOrayDocument instance that this FOraySession should process. - * @param document The FOrayDocument instance that should be processed. - */ - protected void registerDocument(FOrayDocument document) { - if (document == null) { - return; - } - this.documentList.add(document); - } - - /** - * Sets up a FontServer instance if there is not one already. - */ - private void setupFontServer() { - if (log.isDebugEnabled()) { - String[] systemFontFamilies = fontServer.getSystemFontFamilyList(); - if (systemFontFamilies != null) { - log.debug("Java font family names:"); - for (int i = 0; i < systemFontFamilies.length; i++) { - log.debug(" " + systemFontFamilies[i]); - } - } - java.awt.Font[] systemFonts = fontServer.getSystemFontList(); - if (systemFonts != null) { - log.debug("Java font names:"); - for (int i = 0; i < systemFonts.length; i++) { - log.debug(" " + systemFonts[i].getFontName()); - } - } - } - } - - /** - * @return The FontServer instance that is being used in this session. - */ - public FontServer getFontServer() { - return this.fontServer; - } - - public TextServer getTextServer() { - return this.textServer; - } - - public GraphicServer getGraphicServer() { - return this.graphicServer; - } - - public SessionConfig getConfiguration() { - return this.configuration; - } - - /** - * Iterates through the collection of FOrayDocuments to be processed, and - * processes each one. - */ - public void process() throws FOrayException { - Iterator iter = documentList.iterator(); - while (iter.hasNext()) { - FOrayDocument document = (FOrayDocument) iter.next(); - document.process(); - } - } - - public FOTreeFactory getFOTreeServer() { - return this.foTreeFactory; - } - - /** - * Sets the EntityResolver that should be used to resolve XML entities. - * @param entityResolver The EntityResolver that should be set. - */ - public void setEntityResolver(EntityResolver entityResolver) { - this.entityResolver = entityResolver; - } - - /** - * @return The EntityResolver that should be used to resolve XML entities. - */ - public EntityResolver getEntityResolver() { - return this.entityResolver; - } - - public AreaTreeFactory getAreaTreeFactory() { - return this.areaTreeFactory; - } - - public LayoutFactory getLayoutFactory() { - return this.layoutFactory; - } - -} Deleted: trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -1,462 +0,0 @@ -/* - * Copyright 2004 The FOray Project. - * http://www.foray.org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This work is in part derived from the following work(s), used with the - * permission of the licensor: - * Apache FOP, licensed by the Apache Software Foundation - * - */ - -/* $Id$ */ - -package org.foray.app; - -import org.foray.core.Application; -import org.foray.core.FOrayException; -import org.foray.core.SessionConfig; -import org.axsl.output.OutputTarget; -import org.axsl.output.Renderer; - -import org.axsl.areaR.AreaRException; -import org.axsl.areaR.PageArea; -import org.axsl.areaW.AreaTreeEvent; -import org.axsl.areaW.AreaTreeFactory; -import org.axsl.areaW.AreaTreeListener; -import org.axsl.areaW.AreaWException; -import org.axsl.foR.FOTreeEvent; -import org.axsl.foR.FOTreeListener; -import org.axsl.foR.fo.PageSequence; -import org.axsl.fontR.FontConsumer; -import org.axsl.fontR.FontServer; -import org.axsl.layout.Layout; -import org.axsl.layout.LayoutException; -import org.axsl.layout.LayoutFactory; -import org.axsl.text.TextServer; - -import org.apache.commons.logging.Log; - -import org.xml.sax.SAXException; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; - -/** - This class acts as a bridge between the XML:FO parser - and the formatting/rendering classes. It will queue - PageSequences up until all the IDs required by them - are satisfied, at which time it will render the - pages.<P> - - StreamRenderer is created by Driver and called from - FOTreeBuilder when a PageSequence is created, - and AreaTree when a Page is formatted.<P> -*/ -public class FOrayTarget implements FOTreeListener, AreaTreeListener { - private static final boolean MEM_PROFILE_WITH_GC = false; - - /** The "parent" FOrayDocument instance. */ - private FOrayDocument document; - - /** This will provide some statistics. */ - private Runtime runtime = Runtime.getRuntime(); - - /** Keep track of the number of pages rendered. */ - int pageCount = 0; - - /** Keep track of heap memory allocated, for statistical purposes. */ - private long initialMemory; - - /** Keep track of time used by renderer. */ - private long startTime; - - /** - * The stream to which this rendering is to be written. <B>Note</B> that - * some renderers do not render to a stream, and that this member can - * therefore be null. - */ - private OutputStream outputStream; - - /** The renderer being used. */ - private OutputTarget outputTarget; - - /** - * The list of pages waiting to be renderered. In general, pages waiting - * to be rendered are doing so because they have unresolved "ref-id" items - * on them. - */ - private ArrayList renderQueue = new ArrayList(); - - /** - * Keeps track of how many page-sequence objects have been processed. - * Used in messages to the users. - */ - private int pageSequenceCount; - - /** The LayoutStrategy implementation to be used for this target. */ - private Layout layout; - - private org.axsl.areaW.AreaTree areaTree; - - private FontConsumer fontConsumer; - - public FOrayTarget(FOrayDocument document, OutputTarget outputTarget, - Layout layout, OutputStream outputStream) - throws FOrayException { - // Validate the FOrayDocument. - this.document = document; - if (this.document == null) { - throw new FOrayException("A FOrayDocument is required to create" - + "a FOrayTarget"); - } - document.registerTarget(this); - - // Register this FOrayTarget as a listener for FO Tree events. - document.getFOTreeBuilder().registerListener(this); - - // Validate the OutputTarget. - this.outputTarget = outputTarget; - if (this.outputTarget == null) { - throw new FOrayException("OutputTarget has not been set."); - } - - // Validate the LayoutStrategy. If null, create a default one. - this.layout = layout; - if (this.layout == null) { - this.layout = this.getLayoutFactory().makeLayout(); - } - - // Validate the OutputStream. - this.outputStream = outputStream; - if (this.outputTarget.outputStreamRequired() - && outputStream == null) { - throw new FOrayException("OutputStream is required."); - } - - /* Obtain a FontConsumer instance. */ - FontServer server = getFontServer(); - this.fontConsumer = server.makeFontConsumer(); - this.fontConsumer.setFontSources(this.getOutputTarget() - .getFontSources()); - - /* Finish configuring the OutputTarget. */ - this.outputTarget.setOutputStream(this.getOutputStream()); - this.outputTarget.setApplicationName( - Application.getApplicationName()); - this.outputTarget.setApplicationNameShort( - Application.getApplicationNameShort()); - this.outputTarget.setApplicationVersion(Application.getVersion()); - this.outputTarget.setDeveloperURLShort( - Application.getDeveloperURLShort()); - this.outputTarget.setStrokeSVGText(getConfiguration() - .optionStrokeSVGText()); - this.outputTarget.setLogger(this.getLogger()); - this.outputTarget.setFontConsumer(this.getFontConsumer()); - - // Start the renderer. - startRenderer(); - } - - public void startRenderer() throws FOrayException { - pageCount = 0; - - if (MEM_PROFILE_WITH_GC) { - System.gc(); // This takes time but gives better results - } - - initialMemory = runtime.totalMemory() - runtime.freeMemory(); - startTime = System.currentTimeMillis(); - try { - outputTarget.startOutput(); - } catch (IOException e) { - throw new FOrayException(e); - } - } - - public void stopRenderer() throws SAXException { - /* - Force the processing of any more queue elements, - even if they are not resolved. - */ - try { - processQueue(true); - outputTarget.stopOutput(); - } catch (AreaRException e) { - throw new SAXException(e); - } - catch (IOException e) { - throw new SAXException(e); - } - - if (MEM_PROFILE_WITH_GC) { - System.gc(); // This takes time but gives better results - } - - long memoryNow = runtime.totalMemory() - runtime.freeMemory(); - long memoryUsed = (memoryNow - initialMemory) / 1024L; - - getLogger().debug("Initial heap size: " + (initialMemory/1024L) + "Kb"); - getLogger().debug("Current heap size: " + (memoryNow/1024L) + "Kb"); - getLogger().debug("Total memory used: " + memoryUsed + "Kb"); - - if (!MEM_PROFILE_WITH_GC) { - getLogger().debug(" Memory use is indicative; no GC was " - + "performed"); - getLogger().debug(" These figures should not be used " - + "comparatively"); - } - - long timeUsed = System.currentTimeMillis() - startTime; - - getLogger().debug("Total time used: " + timeUsed + "ms"); - getLogger().debug("Pages rendered: " + pageCount); - if (pageCount != 0) { - getLogger().debug("Avg render time: " + (timeUsed / pageCount) - + "ms/page"); - } - } - - /** - Format the PageSequence. The PageSequence - formats Pages and adds them to the AreaTree, - which subsequently calls the StreamRenderer - instance (this) again to render the page. - At this time the page might be printed - or it might be queued. A page might not - be renderable immediately if the IDReferences - are not all valid. In this case we defer - the rendering until they are all valid. - */ - public void render(PageSequence pageSequence) throws FOrayException { - pageSequenceCount ++; - getLogger().info("Starting layout of page-sequence " - + pageSequenceCount + "."); - if (this.outputTarget instanceof Renderer) { - Renderer renderer = (Renderer) this.outputTarget; - org.axsl.areaR.AreaTree areaTreeR = getRenderedAreaTree(); - renderer.setAreaTree(areaTreeR); - org.axsl.areaW.PageCollection pageCollection = - areaTree.makePageCollection(pageSequence); - try { - layout.formatPageSequence(pageCollection); - } catch (AreaWException e) { - throw new FOrayException(e); - } catch (LayoutException e) { - throw new FOrayException(e); - } - try { - processQueue(false); - } catch (AreaRException e1) { - throw new FOrayException(e1); - } catch (IOException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - getLogger().info("Ending page-sequence " + pageSequenceCount + ": " - + pageCollection.getPageCount() + " pages produced."); - } - } - - private org.axsl.areaW.AreaTree getCreatedAreaTree() { - if (this.areaTree == null) { - this.areaTree = this.getAreaTreeFactory().makeAreaTree( - this.document.getFOTreeBuilder().getRootFObj()); - this.areaTree.registerListener(this); - } - return this.areaTree; - } - - private org.axsl.areaR.AreaTree getRenderedAreaTree() - throws FOrayException { - org.axsl.areaW.AreaTree areaTreeW = getCreatedAreaTree(); - if (! (areaTreeW instanceof org.axsl.areaR.AreaTree)) { - throw new FOrayException("Area Tree cannot be rendered."); - } - return (org.axsl.areaR.AreaTree) areaTreeW; - } - - public void pageComplete(AreaTreeEvent event) { - org.axsl.areaW.PageArea page = event.getPage(); - org.axsl.areaR.PageArea pageToRender = (PageArea) page; - try { - queuePage(pageToRender); - } catch (AreaWException e) { - /* TODO: Do something better with this. */ - e.printStackTrace(); - } - } - - public synchronized void queuePage(PageArea page) throws AreaWException { - /* - * We run the pages through a queue because any page page that contains - * an unresolved ref-id prevents subsequent pages from being rendered. - * So, first we add them to the queue. Then, we check to see if - * anything in the queue can be processed. - */ -// try { - renderQueue.add(page); - /* - The just-added entry could (possibly) resolve the - waiting entries, so we try to process the queue - now to see. - */ -// processQueue(false); -// } catch (IOException e) { -// throw new FOrayException(e); -// } - pageCount++; - } - - /** - Try to process the queue from the first entry forward. - If an entry can't be processed, then the queue can't - move forward, so return. - */ - private synchronized void processQueue(boolean force) - throws AreaRException, IOException { - if (! (this.outputTarget instanceof Renderer)) { - return; - } - Renderer renderer = (Renderer) this.outputTarget; - while (renderQueue.size() > 0) { - PageArea page = (PageArea) renderQueue.get(0); - if (force || page.firstUnresolvedRefId() == null) { - renderer.render(page); - renderQueue.remove(0); - } else { - return; - } - } - } - - /** - * Return the logger to be used. (Required by the FontConsumer interface). - */ - public Log getLogger() { - return document.getLogger(); - } - - /** - * Required by the FOTreeListener interface. It handles an - * FOTreeEvent that is fired when an FObj object has been completed. We - * do not need to do anything with it, so we ignore it. - * @param event The FOTreeEvent that was fired. - */ - public void foFObjComplete(FOTreeEvent event) { - } - - /** - * Required by the FOTreeListener interface. It handles an - * FOTreeEvent that is fired when a PageSequence object has been completed. - * @param event the FOTreeEvent that was fired - */ - public void foPageSequenceComplete(FOTreeEvent event) { - try { - boolean shouldRender = this.getConfiguration().isModeRender(); - if (shouldRender) { - render(event.getPageSequence()); - } - } catch (FOrayException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * Required by the FOTreeListener interface. It handles an FOTreeEvent that - * is fired when the Document has been completely parsed. - * @param event the FOTreeEvent that was fired - */ - public void foDocumentComplete(FOTreeEvent event) { - org.axsl.foR.fo.Root rootFObj = document.getFOTreeBuilder() - .getRootFObj(); - try { - getCreatedAreaTree().layoutDocumentNodes(rootFObj); - } catch (AreaWException e1) { - getLogger().error("Error in layout of Document nodes."); - e1.printStackTrace(); - } - try { - stopRenderer(); - } catch (SAXException e) { - e.printStackTrace(); - } - } - - /** - * Tell FOTreeBuilder that we don't want the FObj-complete events. - */ - public boolean wantsFObjCompleteEvents() { - return false; - } - - public FontConsumer getFontConsumer() { - return this.fontConsumer; - } - - public FontServer getFontServer() { - return this.document.getFontServer(); - } - - public TextServer getTextServer() { - return document.getTextServer(); - } - - public OutputStream getOutputStream() { - return this.outputStream; - } - - public OutputTarget getOutputTarget() { - return this.outputTarget; - } - - public SessionConfig getConfiguration() { - return document.getConfiguration(); - } - - public Layout getLayoutStrategy() { - return this.layout; - } - - /** - * Closes the OutputStream, if any. - * This method is part of the external API, and should <em>not</em> be - * run automatically, because the OutputStream may be under the control of - * an external process that wishes to leave it open and do some more - * processing to it. - */ - public void cleanup() { - if (this.outputStream != null) { - try { - this.outputStream.close(); - } catch (Exception e) { - } - } - } - - public FOrayDocument getDocument() { - return this.document; - } - - public AreaTreeFactory getAreaTreeFactory() { - return this.document.getAreaTreeFactory(); - } - - public LayoutFactory getLayoutFactory() { - return this.document.getLayoutFactory(); - } - -} Modified: trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/PrintStarter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -26,6 +26,7 @@ import org.foray.common.Logging; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; Modified: trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/ant/FOrayAntTaskStarter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,14 +24,14 @@ package org.foray.app.ant; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.Options; import org.foray.app.OutputTargetFactory; import org.foray.app.Starter; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.output.OutputConfig; Modified: trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/app/test/TestConverter.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,13 +24,13 @@ package org.foray.app.test; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.common.Logging; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.core.TraxInputHandler; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoAWTViewer.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -34,12 +34,12 @@ import javax.xml.transform.TransformerException; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.core.Application; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; import org.foray.render.awt.AWTRenderer; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoFO2PDF.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,13 +24,13 @@ package org.foray.demo.embed; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoObj2PDF.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,12 +24,12 @@ package org.foray.demo.embed; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.SessionConfig; import org.foray.demo.embed.model.ProjectTeam; Modified: trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/embed/DemoXML2PDF.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,12 +24,12 @@ package org.foray.demo.embed; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.core.Application; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.SessionConfig; import org.axsl.output.OutputTarget; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/AbstractDemoServlet.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,13 +24,13 @@ package org.foray.demo.servlet; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; import org.foray.common.Logging; import org.foray.core.FOInputHandler; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.core.SessionConfig; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoPrintServlet.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,11 +24,11 @@ package org.foray.demo.servlet; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.foray.render.awt.AWTPrintRenderer; Modified: trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java =================================================================== --- trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 22:23:35 UTC (rev 7286) +++ trunk/foray/foray-app/src/java/org/foray/demo/servlet/DemoServlet.java 2006-05-26 22:23:53 UTC (rev 7287) @@ -24,11 +24,11 @@ package org.foray.demo.servlet; -import org.foray.app.FOrayDocument; -import org.foray.app.FOraySession; -import org.foray.app.FOrayTarget; import org.foray.app.OutputTargetFactory; +import org.foray.core.FOrayDocument; import org.foray.core.FOrayException; +import org.foray.core.FOraySession; +import org.foray.core.FOrayTarget; import org.foray.core.InputHandler; import org.axsl.output.OutputTarget; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-05-26 22:23:51
|
Revision: 7286 Author: victormote Date: 2006-05-26 15:23:35 -0700 (Fri, 26 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7286&view=rev Log Message: ----------- Move remaining core files from the app module to the core module. Modified Paths: -------------- trunk/foray/foray-core/.classpath Added Paths: ----------- trunk/foray/foray-core/src/java/org/foray/core/FOrayDocument.java trunk/foray/foray-core/src/java/org/foray/core/FOraySession.java trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java Modified: trunk/foray/foray-core/.classpath =================================================================== --- trunk/foray/foray-core/.classpath 2006-05-26 22:18:04 UTC (rev 7285) +++ trunk/foray/foray-core/.classpath 2006-05-26 22:23:35 UTC (rev 7286) @@ -4,5 +4,14 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/FOrayCommon"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslArea-W"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslFont-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslFO-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslGraphic-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslLayout"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslText"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslArea-R"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslOutput"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslCommon"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Copied: trunk/foray/foray-core/src/java/org/foray/core/FOrayDocument.java (from rev 7278, trunk/foray/foray-app/src/java/org/foray/app/FOrayDocument.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOrayDocument.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/FOrayDocument.java 2006-05-26 22:23:35 UTC (rev 7286) @@ -0,0 +1,324 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.foray.common.XMLParser; + +import org.axsl.areaW.AreaTreeFactory; +import org.axsl.fontR.FontConsumer; +import org.axsl.fontR.FontServer; +import org.axsl.graphicR.GraphicServer; +import org.axsl.layout.LayoutFactory; +import org.axsl.text.TextServer; + +import org.apache.commons.logging.Log; + +import org.w3c.dom.Document; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; + +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.sax.SAXResult; + +/** + * This class manages the process of parsing an input FO document and creating + * an FOTree. + */ +public class FOrayDocument { + + /** The "parent" FOraySession. */ + private FOraySession session; + + /** + * The SAX InputSource that encapsulates the document to be parsed. + * Should be null if the JAXP constructor was used. + */ + private InputSource inputSource; + + /** + * The JAXP Transformer that should be used to handle an XSLT transformation + * on the input. + * Should be null if the SAX constructor was used. + */ + private Transformer jaxpTransformer; + + /** + * The JAXP Source that encapsulates the document to be parsed. + * Should be null if the SAX constructor was used. + */ + private Source jaxpSource; + + /** + * The JAXP Result encapsulating our FOTreeBuilder. + * Should be null if the SAX constructor was used. + */ + private SAXResult jaxpResult; + + /** The collection of FOrayTarget "children". */ + private ArrayList targetList = new ArrayList(); + + /** The FO tree builder, which handles the SAX events. */ + private org.axsl.foR.FOTree treeBuilder; + + private FOrayTarget currentTarget; + + /** Array of bytes listing unsupported FO objects. */ + protected byte[] unsupportedObjects; + + /** Array of shorts listing unsupported FO properties. */ + protected short[] unsupportedProperties; + + /** The SAX parser. */ + private XMLReader parser; + + /** + * Private constructor used only by the other constructors. + * @param session The parent FOraySession. + */ + private FOrayDocument(FOraySession session) { + this.session = session; + session.registerDocument(this); + treeBuilder = this.session.getFOTreeServer().makeFOTree(); + } + + /** + * Standard constructor. Accepts a SAX InputSource as input. + * @param session The parent FOraySession. + * @param inputSource A SAX InputSource. + * @param parser A SAX parser. + */ + public FOrayDocument(FOraySession session, InputSource inputSource, + XMLReader parser) { + this(session); + this.inputSource = inputSource; + this.parser = parser; + this.parser.setContentHandler(treeBuilder); + } + + /** + * Constructor for processing a DOM Document. It creates its own parser. + * @param session The parent FOraySession. + * @param domDocument A DOM Document. + */ + public FOrayDocument (FOraySession session, Document domDocument) + throws FOrayException { + this(session); + this.inputSource = new DocumentInputSource(domDocument); + this.parser = new DocumentReader(); + this.parser.setContentHandler(treeBuilder); + } + + /** + * Constructor for processing a JAXP Transformer. + * @param session The parent FOraySession. + * @param jaxpTransformer A JAXP Transformer. + */ + public FOrayDocument (FOraySession session, Transformer jaxpTransformer, + Source jaxpSource) throws FOrayException { + this(session); + this.jaxpTransformer = jaxpTransformer; + this.jaxpSource = jaxpSource; + this.jaxpResult = new SAXResult(this.treeBuilder); + } + + /** + * Registers a FOrayTarget instance that this FOrayDocument should process. + * @param target The FOrayTarget instance that should be processed. + */ + protected void registerTarget(FOrayTarget target) { + if (target == null) { + return; + } + this.targetList.add(target); + } + + /** + * Returns the tree builder (a SAX ContentHandler). + * + * Used in situations where SAX is used but not via a FOray-invoked + * SAX parser, i.e. where some upstream process wishes to be in control + * of the parsing and event-firing, usually because there is a pipeline of + * processes that are both SAX consumers and producers. Cocoon is one + * example of such a system. + */ + public ContentHandler getContentHandler() { + return this.treeBuilder; + } + + /** + * Returns the JAXP SAXResult (which encapsulates a SAX ContentHandler). + * + * See {@link #getContentHandler()} for the use-case. + */ + public SAXResult getJAXPResult() { + return this.jaxpResult; + } + + public void setTarget(FOrayTarget target) throws FOrayException { + if (target.getDocument() != this) { + throw new FOrayException("FOrayTarget not a child of this " + + "FOrayDocument."); + } + this.currentTarget = target; + } + + public synchronized void process() throws FOrayException { + // Get the FOrayTarget to process. + FOrayTarget target = (FOrayTarget) targetList.get(0); + processTarget(target); + } + + /** + * Build the formatting object tree from the input. + */ + public synchronized void processTarget(FOrayTarget target) + throws FOrayException { + this.setTarget(target); + this.treeBuilder.setFontConsumer(this.getFontConsumer()); + try { + if (this.jaxpTransformer == null) { + // Regular SAX Input + parser.parse(this.inputSource); + } else { + // SAX Events generated by a JAXP Transformer + jaxpTransformer.transform(this.jaxpSource, jaxpResult); + } + } catch (SAXException e) { + if (e.getException() instanceof FOrayException) { + throw (FOrayException)e.getException(); + } + throw new FOrayException(e); + } catch (TransformerException e) { + if (e.getException() instanceof FOrayException) { + throw (FOrayException)e.getException(); + } + throw new FOrayException(e); + } catch (IOException e) { + throw new FOrayException(e); + } finally { + cleanup(currentTarget); + } + } + + public void cleanup(FOrayTarget target) { + } + + /** + * Dumps an error + */ + public void dumpError(Exception e) { + if (! this.getConfiguration().optionVerbosity().equals("debug")) { + return; + } + Log log = getLogger(); + if (e instanceof SAXException) { + log.error(e.getMessage()); + if (((SAXException)e).getException() != null) { + log.error(((SAXException)e).getException().getMessage()); + } + } else if (e instanceof FOrayException) { + e.printStackTrace(); + if (((FOrayException)e).getException() != null) { + log.error(((FOrayException)e).getException().getMessage()); + } + } else { + log.error(e.getMessage()); + } + } + + /** + * Runs the formatting and renderering process using the previously set + * inputsource and outputstream + */ + public synchronized void run() + throws IOException, FOrayException { + if (this.inputSource == null) { + throw new FOrayException("InputSource is not set."); + } + + if (this.parser == null) { + throw new FOrayException("Invalid Parser."); + } + process(); + } + + public Log getLogger() { + return this.session.getLogger(); + } + + public FontServer getFontServer() { + return this.session.getFontServer(); + } + + public String getParserClassName() { + return XMLParser.getParserClassName(); + } + + /** + * Required by FOTreeControl interface. + * @return The base URL that should be used for finding external files, like + * graphical images, etc. + */ + public URL getBaseURL() { + return getConfiguration().optionBaseDirectory(); + } + + public FontConsumer getFontConsumer() { + return this.currentTarget.getFontConsumer(); + } + + public TextServer getTextServer() { + return session.getTextServer(); + } + + public GraphicServer getGraphicServer() { + return session.getGraphicServer(); + } + + public SessionConfig getConfiguration() { + return session.getConfiguration(); + } + + public org.axsl.foR.FOTree getFOTreeBuilder() { + return this.treeBuilder; + } + + public AreaTreeFactory getAreaTreeFactory() { + return this.session.getAreaTreeFactory(); + } + + public LayoutFactory getLayoutFactory() { + return this.session.getLayoutFactory(); + } + +} Copied: trunk/foray/foray-core/src/java/org/foray/core/FOraySession.java (from rev 7285, trunk/foray/foray-app/src/java/org/foray/app/FOraySession.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOraySession.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/FOraySession.java 2006-05-26 22:23:35 UTC (rev 7286) @@ -0,0 +1,265 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + + +import org.axsl.areaW.AreaTreeFactory; +import org.axsl.foR.FOTreeFactory; +import org.axsl.fontR.FontServer; +import org.axsl.graphicR.GraphicServer; +import org.axsl.layout.LayoutFactory; +import org.axsl.text.TextServer; + +import org.apache.commons.logging.Log; + +import org.xml.sax.EntityResolver; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * The ancestor class for all FOray processing. All classes that start + * FOray processing need to create a FOraySession, one or more FOrayDocument + * instances, and one or more FOrayTarget instances for each FOrayDocument, + * then run the FOraySession process() method. + * This process is illustrated and documented in the source code for + * the CommandLineStarter.run() method. + * + * After instantiating FOraySession, additional Namespace instances can + * be registered with the session through the addNamespace method. Custom + * Namespaces can also be added to the system resources, and these are + * automatically registered at runtime. + * + * The input document is identified to the FOrayDocument as it is instantiated. + * There are two constructors, one for SAX input, and the other for DOM input. + * The Renderer, LayoutStrategy, and output document are identified to the + * FOrayTarget as it is instantiated. + */ +public class FOraySession { + + /** The collection of FOrayDocument instances that will be processed. */ + private ArrayList documentList = new ArrayList(); + + /** An logger to be used for this session. */ + private Log log; + + /** A FontServer instance to be used for this session. */ + private FontServer fontServer; + + /** A TextServer instance to be used for this session. */ + private TextServer textServer; + + /** A GraphicServer instance to be used for this session. */ + private GraphicServer graphicServer; + + /** */ + private FOTreeFactory foTreeFactory; + + private AreaTreeFactory areaTreeFactory; + + private LayoutFactory layoutFactory; + + /** A SessionConfig instance to be used for this session. */ + private SessionConfig configuration; + + /** The EntityResolver to be used when parsing XML (resolves XML catalogs, + * etc. */ + private EntityResolver entityResolver; + + /** + * Constructor. + * @param logger The (optional) logger that should be used for this + * session. If null is passed, a default Logger will be created. + * @param configuration The Configuration instance that should be used + * with this session. + * @param fontServer The (optional) FontServer instance that should be used + * for this session. If null is passed, then a FontServer instance will be + * created by this FOraySession. If an instance is passed, it needs to be + * fully configured and ready to be used. + * @param textServer The (optional) TextServer instance that should be used + * for this session. If null is passed, then a TextServer instance will be + * created by this FOraySession. If an instance is passed, it needs to be + * fully configured and ready to be used. + * @param graphicServer The (optional) GraphicServer instance that should + * be used for this session. If null is passed, then a GraphicServer + * instance will be created by this FOray Session. If an instance is passed, + * it needs to be fully configured and ready to be used. + */ + public FOraySession(Log logger, SessionConfig configuration, + FontServer fontServer, TextServer textServer, + GraphicServer graphicServer, FOTreeFactory foTreeFactory, + AreaTreeFactory areaTreeFactory, LayoutFactory layoutFactory) + throws FOrayException { + /* Validate Logger. */ + if (logger == null) { + throw new FOrayException("Logger required for FOraySession."); + } + this.log = logger; + log.info(Application.getVersion()); + + /* Validate Configuration. */ + this.configuration = configuration; + if (this.configuration == null) { + this.configuration = new SessionConfig(logger); + } + + /* Validate FontServer. */ + if (fontServer == null) { + throw new FOrayException("FontServer required for FOraySession."); + } + this.fontServer = fontServer; + setupFontServer(); + + /* Validate TextServer. */ + if (textServer == null) { + throw new FOrayException("TextServer required for FOraySession."); + } + this.textServer = textServer; + + /* Validate GraphicServer. */ + if (graphicServer == null) { + throw new FOrayException("GraphicServer required for " + + "FOraySession."); + } + this.graphicServer = graphicServer; + + /* Validate FOTreeFactory. */ + if (foTreeFactory == null) { + throw new FOrayException("FOTreeFactory required for " + + "FOraySession."); + } + this.foTreeFactory = foTreeFactory; + + /* Validate AreaTreeFactory. */ + if (areaTreeFactory == null) { + throw new FOrayException("AreaTreeFactory required for " + + "FOraySession."); + } + this.areaTreeFactory = areaTreeFactory; + + /* Validate LayoutFactory. */ + if (layoutFactory == null) { + throw new FOrayException("LayoutFactory required for " + + "FOraySession."); + } + this.layoutFactory = layoutFactory; + } + + public Log getLogger() { + return log; + } + + /** + * Registers a FOrayDocument instance that this FOraySession should process. + * @param document The FOrayDocument instance that should be processed. + */ + protected void registerDocument(FOrayDocument document) { + if (document == null) { + return; + } + this.documentList.add(document); + } + + /** + * Sets up a FontServer instance if there is not one already. + */ + private void setupFontServer() { + if (log.isDebugEnabled()) { + String[] systemFontFamilies = fontServer.getSystemFontFamilyList(); + if (systemFontFamilies != null) { + log.debug("Java font family names:"); + for (int i = 0; i < systemFontFamilies.length; i++) { + log.debug(" " + systemFontFamilies[i]); + } + } + java.awt.Font[] systemFonts = fontServer.getSystemFontList(); + if (systemFonts != null) { + log.debug("Java font names:"); + for (int i = 0; i < systemFonts.length; i++) { + log.debug(" " + systemFonts[i].getFontName()); + } + } + } + } + + /** + * @return The FontServer instance that is being used in this session. + */ + public FontServer getFontServer() { + return this.fontServer; + } + + public TextServer getTextServer() { + return this.textServer; + } + + public GraphicServer getGraphicServer() { + return this.graphicServer; + } + + public SessionConfig getConfiguration() { + return this.configuration; + } + + /** + * Iterates through the collection of FOrayDocuments to be processed, and + * processes each one. + */ + public void process() throws FOrayException { + Iterator iter = documentList.iterator(); + while (iter.hasNext()) { + FOrayDocument document = (FOrayDocument) iter.next(); + document.process(); + } + } + + public FOTreeFactory getFOTreeServer() { + return this.foTreeFactory; + } + + /** + * Sets the EntityResolver that should be used to resolve XML entities. + * @param entityResolver The EntityResolver that should be set. + */ + public void setEntityResolver(EntityResolver entityResolver) { + this.entityResolver = entityResolver; + } + + /** + * @return The EntityResolver that should be used to resolve XML entities. + */ + public EntityResolver getEntityResolver() { + return this.entityResolver; + } + + public AreaTreeFactory getAreaTreeFactory() { + return this.areaTreeFactory; + } + + public LayoutFactory getLayoutFactory() { + return this.layoutFactory; + } + +} Copied: trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java (from rev 7279, trunk/foray/foray-app/src/java/org/foray/app/FOrayTarget.java) =================================================================== --- trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java (rev 0) +++ trunk/foray/foray-core/src/java/org/foray/core/FOrayTarget.java 2006-05-26 22:23:35 UTC (rev 7286) @@ -0,0 +1,459 @@ +/* + * Copyright 2004 The FOray Project. + * http://www.foray.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This work is in part derived from the following work(s), used with the + * permission of the licensor: + * Apache FOP, licensed by the Apache Software Foundation + * + */ + +/* $Id$ */ + +package org.foray.core; + +import org.axsl.output.OutputTarget; +import org.axsl.output.Renderer; + +import org.axsl.areaR.AreaRException; +import org.axsl.areaR.PageArea; +import org.axsl.areaW.AreaTreeEvent; +import org.axsl.areaW.AreaTreeFactory; +import org.axsl.areaW.AreaTreeListener; +import org.axsl.areaW.AreaWException; +import org.axsl.foR.FOTreeEvent; +import org.axsl.foR.FOTreeListener; +import org.axsl.foR.fo.PageSequence; +import org.axsl.fontR.FontConsumer; +import org.axsl.fontR.FontServer; +import org.axsl.layout.Layout; +import org.axsl.layout.LayoutException; +import org.axsl.layout.LayoutFactory; +import org.axsl.text.TextServer; + +import org.apache.commons.logging.Log; + +import org.xml.sax.SAXException; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; + +/** + This class acts as a bridge between the XML:FO parser + and the formatting/rendering classes. It will queue + PageSequences up until all the IDs required by them + are satisfied, at which time it will render the + pages.<P> + + StreamRenderer is created by Driver and called from + FOTreeBuilder when a PageSequence is created, + and AreaTree when a Page is formatted.<P> +*/ +public class FOrayTarget implements FOTreeListener, AreaTreeListener { + private static final boolean MEM_PROFILE_WITH_GC = false; + + /** The "parent" FOrayDocument instance. */ + private FOrayDocument document; + + /** This will provide some statistics. */ + private Runtime runtime = Runtime.getRuntime(); + + /** Keep track of the number of pages rendered. */ + int pageCount = 0; + + /** Keep track of heap memory allocated, for statistical purposes. */ + private long initialMemory; + + /** Keep track of time used by renderer. */ + private long startTime; + + /** + * The stream to which this rendering is to be written. <B>Note</B> that + * some renderers do not render to a stream, and that this member can + * therefore be null. + */ + private OutputStream outputStream; + + /** The renderer being used. */ + private OutputTarget outputTarget; + + /** + * The list of pages waiting to be renderered. In general, pages waiting + * to be rendered are doing so because they have unresolved "ref-id" items + * on them. + */ + private ArrayList renderQueue = new ArrayList(); + + /** + * Keeps track of how many page-sequence objects have been processed. + * Used in messages to the users. + */ + private int pageSequenceCount; + + /** The LayoutStrategy implementation to be used for this target. */ + private Layout layout; + + private org.axsl.areaW.AreaTree areaTree; + + private FontConsumer fontConsumer; + + public FOrayTarget(FOrayDocument document, OutputTarget outputTarget, + Layout layout, OutputStream outputStream) + throws FOrayException { + // Validate the FOrayDocument. + this.document = document; + if (this.document == null) { + throw new FOrayException("A FOrayDocument is required to create" + + "a FOrayTarget"); + } + document.registerTarget(this); + + // Register this FOrayTarget as a listener for FO Tree events. + document.getFOTreeBuilder().registerListener(this); + + // Validate the OutputTarget. + this.outputTarget = outputTarget; + if (this.outputTarget == null) { + throw new FOrayException("OutputTarget has not been set."); + } + + // Validate the LayoutStrategy. If null, create a default one. + this.layout = layout; + if (this.layout == null) { + this.layout = this.getLayoutFactory().makeLayout(); + } + + // Validate the OutputStream. + this.outputStream = outputStream; + if (this.outputTarget.outputStreamRequired() + && outputStream == null) { + throw new FOrayException("OutputStream is required."); + } + + /* Obtain a FontConsumer instance. */ + FontServer server = getFontServer(); + this.fontConsumer = server.makeFontConsumer(); + this.fontConsumer.setFontSources(this.getOutputTarget() + .getFontSources()); + + /* Finish configuring the OutputTarget. */ + this.outputTarget.setOutputStream(this.getOutputStream()); + this.outputTarget.setApplicationName( + Application.getApplicationName()); + this.outputTarget.setApplicationNameShort( + Application.getApplicationNameShort()); + this.outputTarget.setApplicationVersion(Application.getVersion()); + this.outputTarget.setDeveloperURLShort( + Application.getDeveloperURLShort()); + this.outputTarget.setStrokeSVGText(getConfiguration() + .optionStrokeSVGText()); + this.outputTarget.setLogger(this.getLogger()); + this.outputTarget.setFontConsumer(this.getFontConsumer()); + + // Start the renderer. + startRenderer(); + } + + public void startRenderer() throws FOrayException { + pageCount = 0; + + if (MEM_PROFILE_WITH_GC) { + System.gc(); // This takes time but gives better results + } + + initialMemory = runtime.totalMemory() - runtime.freeMemory(); + startTime = System.currentTimeMillis(); + try { + outputTarget.startOutput(); + } catch (IOException e) { + throw new FOrayException(e); + } + } + + public void stopRenderer() throws SAXException { + /* + Force the processing of any more queue elements, + even if they are not resolved. + */ + try { + processQueue(true); + outputTarget.stopOutput(); + } catch (AreaRException e) { + throw new SAXException(e); + } + catch (IOException e) { + throw new SAXException(e); + } + + if (MEM_PROFILE_WITH_GC) { + System.gc(); // This takes time but gives better results + } + + long memoryNow = runtime.totalMemory() - runtime.freeMemory(); + long memoryUsed = (memoryNow - initialMemory) / 1024L; + + getLogger().debug("Initial heap size: " + (initialMemory/1024L) + "Kb"); + getLogger().debug("Current heap size: " + (memoryNow/1024L) + "Kb"); + getLogger().debug("Total memory used: " + memoryUsed + "Kb"); + + if (!MEM_PROFILE_WITH_GC) { + getLogger().debug(" Memory use is indicative; no GC was " + + "performed"); + getLogger().debug(" These figures should not be used " + + "comparatively"); + } + + long timeUsed = System.currentTimeMillis() - startTime; + + getLogger().debug("Total time used: " + timeUsed + "ms"); + getLogger().debug("Pages rendered: " + pageCount); + if (pageCount != 0) { + getLogger().debug("Avg render time: " + (timeUsed / pageCount) + + "ms/page"); + } + } + + /** + Format the PageSequence. The PageSequence + formats Pages and adds them to the AreaTree, + which subsequently calls the StreamRenderer + instance (this) again to render the page. + At this time the page might be printed + or it might be queued. A page might not + be renderable immediately if the IDReferences + are not all valid. In this case we defer + the rendering until they are all valid. + */ + public void render(PageSequence pageSequence) throws FOrayException { + pageSequenceCount ++; + getLogger().info("Starting layout of page-sequence " + + pageSequenceCount + "."); + if (this.outputTarget instanceof Renderer) { + Renderer renderer = (Renderer) this.outputTarget; + org.axsl.areaR.AreaTree areaTreeR = getRenderedAreaTree(); + renderer.setAreaTree(areaTreeR); + org.axsl.areaW.PageCollection pageCollection = + areaTree.makePageCollection(pageSequence); + try { + layout.formatPageSequence(pageCollection); + } catch (AreaWException e) { + throw new FOrayException(e); + } catch (LayoutException e) { + throw new FOrayException(e); + } + try { + processQueue(false); + } catch (AreaRException e1) { + throw new FOrayException(e1); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + getLogger().info("Ending page-sequence " + pageSequenceCount + ": " + + pageCollection.getPageCount() + " pages produced."); + } + } + + private org.axsl.areaW.AreaTree getCreatedAreaTree() { + if (this.areaTree == null) { + this.areaTree = this.getAreaTreeFactory().makeAreaTree( + this.document.getFOTreeBuilder().getRootFObj()); + this.areaTree.registerListener(this); + } + return this.areaTree; + } + + private org.axsl.areaR.AreaTree getRenderedAreaTree() + throws FOrayException { + org.axsl.areaW.AreaTree areaTreeW = getCreatedAreaTree(); + if (! (areaTreeW instanceof org.axsl.areaR.AreaTree)) { + throw new FOrayException("Area Tree cannot be rendered."); + } + return (org.axsl.areaR.AreaTree) areaTreeW; + } + + public void pageComplete(AreaTreeEvent event) { + org.axsl.areaW.PageArea page = event.getPage(); + org.axsl.areaR.PageArea pageToRender = (PageArea) page; + try { + queuePage(pageToRender); + } catch (AreaWException e) { + /* TODO: Do something better with this. */ + e.printStackTrace(); + } + } + + public synchronized void queuePage(PageArea page) throws AreaWException { + /* + * We run the pages through a queue because any page page that contains + * an unresolved ref-id prevents subsequent pages from being rendered. + * So, first we add them to the queue. Then, we check to see if + * anything in the queue can be processed. + */ +// try { + renderQueue.add(page); + /* + The just-added entry could (possibly) resolve the + waiting entries, so we try to process the queue + now to see. + */ +// processQueue(false); +// } catch (IOException e) { +// throw new FOrayException(e); +// } + pageCount++; + } + + /** + Try to process the queue from the first entry forward. + If an entry can't be processed, then the queue can't + move forward, so return. + */ + private synchronized void processQueue(boolean force) + throws AreaRException, IOException { + if (! (this.outputTarget instanceof Renderer)) { + return; + } + Renderer renderer = (Renderer) this.outputTarget; + while (renderQueue.size() > 0) { + PageArea page = (PageArea) renderQueue.get(0); + if (force || page.firstUnresolvedRefId() == null) { + renderer.render(page); + renderQueue.remove(0); + } else { + return; + } + } + } + + /** + * Return the logger to be used. (Required by the FontConsumer interface). + */ + public Log getLogger() { + return document.getLogger(); + } + + /** + * Required by the FOTreeListener interface. It handles an + * FOTreeEvent that is fired when an FObj object has been completed. We + * do not need to do anything with it, so we ignore it. + * @param event The FOTreeEvent that was fired. + */ + public void foFObjComplete(FOTreeEvent event) { + } + + /** + * Required by the FOTreeListener interface. It handles an + * FOTreeEvent that is fired when a PageSequence object has been completed. + * @param event the FOTreeEvent that was fired + */ + public void foPageSequenceComplete(FOTreeEvent event) { + try { + boolean shouldRender = this.getConfiguration().isModeRender(); + if (shouldRender) { + render(event.getPageSequence()); + } + } catch (FOrayException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * Required by the FOTreeListener interface. It handles an FOTreeEvent that + * is fired when the Document has been completely parsed. + * @param event the FOTreeEvent that was fired + */ + public void foDocumentComplete(FOTreeEvent event) { + org.axsl.foR.fo.Root rootFObj = document.getFOTreeBuilder() + .getRootFObj(); + try { + getCreatedAreaTree().layoutDocumentNodes(rootFObj); + } catch (AreaWException e1) { + getLogger().error("Error in layout of Document nodes."); + e1.printStackTrace(); + } + try { + stopRenderer(); + } catch (SAXException e) { + e.printStackTrace(); + } + } + + /** + * Tell FOTreeBuilder that we don't want the FObj-complete events. + */ + public boolean wantsFObjCompleteEvents() { + return false; + } + + public FontConsumer getFontConsumer() { + return this.fontConsumer; + } + + public FontServer getFontServer() { + return this.document.getFontServer(); + } + + public TextServer getTextServer() { + return document.getTextServer(); + } + + public OutputStream getOutputStream() { + return this.outputStream; + } + + public OutputTarget getOutputTarget() { + return this.outputTarget; + } + + public SessionConfig getConfiguration() { + return document.getConfiguration(); + } + + public Layout getLayoutStrategy() { + return this.layout; + } + + /** + * Closes the OutputStream, if any. + * This method is part of the external API, and should <em>not</em> be + * run automatically, because the OutputStream may be under the control of + * an external process that wishes to leave it open and do some more + * processing to it. + */ + public void cleanup() { + if (this.outputStream != null) { + try { + this.outputStream.close(); + } catch (Exception e) { + } + } + } + + public FOrayDocument getDocument() { + return this.document; + } + + public AreaTreeFactory getAreaTreeFactory() { + return this.document.getAreaTreeFactory(); + } + + public LayoutFactory getLayoutFactory() { + return this.document.getLayoutFactory(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |