foray-commit Mailing List for FOray (Page 278)
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-03-13 20:35:20
|
Revision: 6935 Author: victormote Date: 2006-03-13 12:35:14 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6935&view=rev Log Message: ----------- Add PDFFactory implementation. Added Paths: ----------- trunk/foray/foray-pdf/src/java/org/foray/pdf/FOrayPDFFactory.java Added: trunk/foray/foray-pdf/src/java/org/foray/pdf/FOrayPDFFactory.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/FOrayPDFFactory.java (rev 0) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/FOrayPDFFactory.java 2006-03-13 20:35:14 UTC (rev 6935) @@ -0,0 +1,60 @@ +/* + * Copyright 2006 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.pdf; + +import org.axsl.pdf.PDFDocument; +import org.axsl.pdf.PDFEncryption; +import org.axsl.pdf.PDFException; +import org.axsl.pdf.PDFFactory; + +public class FOrayPDFFactory implements PDFFactory { + + public FOrayPDFFactory() { + } + + public PDFDocument createPDFDocument() { + // TODO Auto-generated method stub + return null; + } + + private org.foray.pdf.object.PDFDocument getFOrayPDFDocument( + PDFDocument document) throws PDFException { + if (document instanceof org.foray.pdf.object.PDFDocument) { + return (org.foray.pdf.object.PDFDocument) document; + } + throw new PDFException("Unsupported PDFDocument implementation."); + } + + /** + * {@inheritDoc} + */ + public PDFEncryption createPDFEncryption(PDFDocument document) + throws PDFException { + org.foray.pdf.object.PDFDocument forayPDFDocument + = getFOrayPDFDocument(document); + return new org.foray.pdf.object.PDFEncryption(forayPDFDocument); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-13 20:02:47
|
Revision: 6934 Author: victormote Date: 2006-03-13 12:02:25 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6934&view=rev Log Message: ----------- Remove FOray class PDFException in favor of axsl class with the same purpose. Modified Paths: -------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontDescriptor.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontFileStream.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTranscoder.java trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java Removed Paths: ------------- trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFException.java Deleted: trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFException.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFException.java 2006-03-13 19:25:08 UTC (rev 6933) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFException.java 2006-03-13 20:02:25 UTC (rev 6934) @@ -1,37 +0,0 @@ -/* - * Copyright 2005 The aXSL Project. - * http://www.axsl.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. - * - */ - -/* $Id$ */ - -package org.foray.pdf; - -/** - * Exception thrown there is a problem creating the PDF. - */ -public class PDFException extends Exception { - static final long serialVersionUID = 386745769201835454L; - - /** - * Create a new PDFException - * @param message Descriptive message. - */ - public PDFException(String message) { - super(message); - } - -} Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2006-03-13 19:25:08 UTC (rev 6933) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2006-03-13 20:02:25 UTC (rev 6934) @@ -32,12 +32,12 @@ package org.foray.pdf.object; -import org.foray.pdf.PDFException; import org.foray.pdf.PDFGraphicsState; import org.axsl.font.Font; import org.axsl.font.FontConsumer; import org.axsl.font.FontUse; +import org.axsl.pdf.PDFException; import org.axsl.ps.Encoding; import org.apache.commons.logging.Log; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java 2006-03-13 19:25:08 UTC (rev 6933) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java 2006-03-13 20:02:25 UTC (rev 6934) @@ -24,11 +24,10 @@ package org.foray.pdf.object; -import org.foray.pdf.PDFException; - import org.axsl.font.Font; import org.axsl.font.FontUse; import org.axsl.font.output.FontPDF; +import org.axsl.pdf.PDFException; import org.axsl.ps.Encoding; import org.axsl.ps.EncodingVector; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontDescriptor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontDescriptor.java 2006-03-13 19:25:08 UTC (rev 6933) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontDescriptor.java 2006-03-13 20:02:25 UTC (rev 6934) @@ -24,10 +24,9 @@ package org.foray.pdf.object; -import org.foray.pdf.PDFException; - import org.axsl.font.Font; import org.axsl.font.output.FontPDF; +import org.axsl.pdf.PDFException; /** * Class representing a PDF Font Descriptor. Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontFileStream.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontFileStream.java 2006-03-13 19:25:08 UTC (rev 6933) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFontFileStream.java 2006-03-13 20:02:25 UTC (rev 6934) @@ -24,10 +24,9 @@ package org.foray.pdf.object; -import org.foray.pdf.PDFException; - import org.axsl.font.FontUse; import org.axsl.font.output.FontPDF; +import org.axsl.pdf.PDFException; import java.io.IOException; import java.io.OutputStream; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java 2006-03-13 19:25:08 UTC (rev 6933) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFDocumentGraphics2D.java 2006-03-13 20:02:25 UTC (rev 6934) @@ -24,7 +24,6 @@ package org.foray.pdf.svg.batik; -import org.foray.pdf.PDFException; import org.foray.pdf.object.PDFColor; import org.foray.pdf.object.PDFDocument; import org.foray.pdf.object.PDFNumber; @@ -32,6 +31,7 @@ import org.foray.pdf.object.PDFResources; import org.axsl.font.FontException; +import org.axsl.pdf.PDFException; import org.apache.batik.ext.awt.g2d.GraphicContext; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTranscoder.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTranscoder.java 2006-03-13 19:25:08 UTC (rev 6933) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/svg/batik/PDFTranscoder.java 2006-03-13 20:02:25 UTC (rev 6934) @@ -24,9 +24,8 @@ package org.foray.pdf.svg.batik; -import org.foray.pdf.PDFException; - import org.axsl.font.FontUse; +import org.axsl.pdf.PDFException; import org.apache.batik.bridge.BridgeContext; import org.apache.batik.bridge.BridgeException; 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-03-13 19:25:08 UTC (rev 6933) +++ trunk/foray/foray-render/src/java/org/foray/render/pdf/PDFRenderer.java 2006-03-13 20:02:25 UTC (rev 6934) @@ -32,7 +32,6 @@ import org.foray.common.FOrayException; import org.foray.common.StringUtilPre5; import org.foray.output.OutputConfig; -import org.foray.pdf.PDFException; import org.foray.pdf.PDFGraphicsState; import org.foray.pdf.object.PDFColor; import org.foray.pdf.object.PDFContentStream; @@ -61,6 +60,7 @@ import org.axsl.common.Constants; import org.axsl.font.FontUse; import org.axsl.graphic.Graphic; +import org.axsl.pdf.PDFException; import java.awt.Color; import java.awt.Rectangle; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-13 19:25:26
|
Revision: 6933 Author: victormote Date: 2006-03-13 11:25:08 -0800 (Mon, 13 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6933&view=rev Log Message: ----------- 1. Implement the new (empty) axsl PDF interfaces. 2. Add Eclipse classpath dependencies for axsl-pdf. Modified Paths: -------------- trunk/foray/foray-pdf/.classpath trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFEncryption.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFExplicitDestination.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNamedDestination.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineItem.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineParent.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPathPaint.java trunk/foray/foray-render/.classpath Modified: trunk/foray/foray-pdf/.classpath =================================================================== --- trunk/foray/foray-pdf/.classpath 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/.classpath 2006-03-13 19:25:08 UTC (rev 6933) @@ -12,5 +12,6 @@ <classpathentry sourcepath="ECLIPSE_HOME/plugins/org.eclipse.jdt.source_3.0.0/src/org.junit_3.8.1/junitsrc.zip" kind="var" path="JUNIT_HOME/junit.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/batik.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslPDF"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/PDFGraphicsState.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -34,7 +34,7 @@ * it allows us to avoid writing operators that change the Graphics State * unnecessarily. */ -public class PDFGraphicsState { +public class PDFGraphicsState implements org.axsl.pdf.PDFGraphicsState { private PDFColor strokeColor; /** The "non-stroke" or "other" color. */ Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFColor.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -28,7 +28,7 @@ import java.awt.Color; import java.util.ArrayList; -public class PDFColor extends PDFPathPaint { +public class PDFColor extends PDFPathPaint implements org.axsl.pdf.PDFColor { protected static double blackFactor = 2.0; // could be 3.0 as well. protected double red = -1.0; protected double green = -1.0; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFContentStream.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -53,7 +53,8 @@ * Specialized version of PDFStream with methods useful in creating PDF content * streams. */ -public class PDFContentStream extends PDFStream { +public class PDFContentStream extends PDFStream + implements org.axsl.pdf.PDFContentStream { boolean textObjectOpen = false; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFDocument.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -65,7 +65,7 @@ * keep track of the character position of each object. The document * also keeps direct track of the /Root, /Info and /Resources objects. */ -public class PDFDocument { +public class PDFDocument implements org.axsl.pdf.PDFDocument { /** Name of the CharSet that should be used when converting Strings to * bytes. */ Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFEncryption.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFEncryption.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFEncryption.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -41,7 +41,8 @@ * class representing a /Filter /Standard object. * */ -public class PDFEncryption extends PDFObject { +public class PDFEncryption extends PDFObject + implements org.axsl.pdf.PDFEncryption { private class EncryptionFilter extends PSFilter { PDFEncryption encryption; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFExplicitDestination.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFExplicitDestination.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFExplicitDestination.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -36,7 +36,8 @@ * See PDF Reference, 2nd Edition, Section 7.2.1 for more information about * PDF Destinations in general, and Explicit Destinations in particular. */ -public class PDFExplicitDestination extends PDFDestination { +public class PDFExplicitDestination extends PDFDestination + implements org.axsl.pdf.PDFExplicitDestination { /** The page to which this Destination goes. */ protected PDFPage page; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFFont.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -41,7 +41,7 @@ * * Fonts are specified on page 198 and onwards of the PDF 1.3 spec. */ -public class PDFFont extends PDFObject { +public class PDFFont extends PDFObject implements org.axsl.pdf.PDFFont { /** Font subtype indicating a composite font. */ public static final byte TYPE0 = 0; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNamedDestination.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNamedDestination.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFNamedDestination.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -30,7 +30,8 @@ * See PDF Reference, 2nd Edition, Section 7.2.1 for more information about * PDF Destinations in general, and Named Destinations in particular. */ -public class PDFNamedDestination extends PDFDestination { +public class PDFNamedDestination extends PDFDestination + implements org.axsl.pdf.PDFNamedDestination { /** The name that is used as the key to the destination. */ private String name; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineItem.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineItem.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineItem.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -35,7 +35,8 @@ * An Outline Item Dictionary in PDF. */ -public class PDFOutlineItem extends PDFOutlineParent { +public class PDFOutlineItem extends PDFOutlineParent + implements org.axsl.pdf.PDFOutlineItem { /** The parent object. */ private PDFOutlineParent parent; Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineParent.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineParent.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFOutlineParent.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -32,7 +32,8 @@ * object. This includes the classes PDFOutline and PDFOutlineItem. */ -public abstract class PDFOutlineParent extends PDFObject { +public abstract class PDFOutlineParent extends PDFObject + implements org.axsl.pdf.PDFOutlineParent { /** Collection of child PDFOutline objects. */ private ArrayList children = new ArrayList(); Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPage.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -34,7 +34,7 @@ * object, a contents stream and the page's parent in the page * hierarchy. */ -public class PDFPage extends PDFObject { +public class PDFPage extends PDFObject implements org.axsl.pdf.PDFPage { /** * the page's parent, a PDF reference object Modified: trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPathPaint.java =================================================================== --- trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPathPaint.java 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-pdf/src/java/org/foray/pdf/object/PDFPathPaint.java 2006-03-13 19:25:08 UTC (rev 6933) @@ -26,7 +26,8 @@ import java.awt.color.ColorSpace; -public abstract class PDFPathPaint extends PDFObject { +public abstract class PDFPathPaint extends PDFObject + implements org.axsl.pdf.PDFPathPaint { // protected int colorspace = 0; //default is 0:RGB, not 1:CMYK protected ColorSpace colorSpace; Modified: trunk/foray/foray-render/.classpath =================================================================== --- trunk/foray/foray-render/.classpath 2006-03-11 18:16:48 UTC (rev 6932) +++ trunk/foray/foray-render/.classpath 2006-03-13 19:25:08 UTC (rev 6933) @@ -15,5 +15,6 @@ <classpathentry kind="src" path="/axslText"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/batik.jar"/> <classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/> + <classpathentry combineaccessrules="false" kind="src" path="/axslPDF"/> <classpathentry kind="output" path="build/eclipse"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-11 18:16:53
|
Revision: 6932 Author: victormote Date: 2006-03-11 10:16:48 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6932&view=rev Log Message: ----------- Add setter methods for the configuration parameters. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-11 17:42:25 UTC (rev 6931) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-11 18:16:48 UTC (rev 6932) @@ -100,14 +100,13 @@ /* End state variables. */ - /* Begin configuration variables. TODO: These need to be externalized and - * exposed with setters. */ + /* Begin configuration variables. */ + private String outputEncoding = "UTF-8"; private String xmlDeclaration = "<?xml version=\"1.0\" " - + "encoding=\"UTF-8\"?>"; + + "encoding=\"" + outputEncoding + "\"?>"; /** The line terminator that should be used in the output. */ private String lineTerminator = "\n"; - private String outputEncoding = "UTF-8"; private String preRootText = null; private String postRootText = "\n"; /** @@ -927,4 +926,88 @@ } } + /** + * Set this configuration parameter to true if whitespace within PCDATA can + * be interchanged. Specifically, if this parameter is set, tabs will be + * normalized to spaces, duplicate spaces will be removed, and spaces and + * new-lines will be treated as interchangeable. The default value is true. + */ + public void setBreakPCDATA(boolean breakPCDATA) { + this.breakPCDATA = breakPCDATA; + } + + /** + * Use this configuration parameter to set the value of the XML Declaration + * at the beginning of the pretty-printed document. The default value is + * <code><?xml version="1.0" encoding="UTF-8"?></code> + */ + public void setXmlDeclaration(String xmlDeclaration) { + this.xmlDeclaration = xmlDeclaration; + } + + /** + * Use this configuration parameter to set the text that should be used + * to delimit lines in the pretty-printed document. The default is + * platform-specific. On Unix, for example, it is "\n". On Windows, it is + * "\r\n". + */ + public void setLineTerminator(String lineTerminator) { + this.lineTerminator = lineTerminator; + } + + /** + * Use this configuration parameter to set the output encoding for the + * pretty-printed document. The default value is "UTF-8". + */ + public void setOutputEncoding(String outputEncoding) { + this.outputEncoding = outputEncoding; + } + + /** + * Use this configuration parameter to control the text that is written + * right before the root element. + * Any text between the DTD and the root element in the source document is + * considered to be insignificant and is therefore stripped out. + * The default value is null. + */ + public void setPreRootText(String preRootText) { + this.preRootText = preRootText; + } + + /** + * Use this configuration parameter to control the text that is written + * right after the close of the root element. + * Any text after the root element in the source document is considered to + * be insignificant and is therefore stripped out. + * The default value is "\n" (one line-feed). + */ + public void setPostRootText(String postRootText) { + this.postRootText = postRootText; + } + + /** + * Use this configuration parameter to set the number of spaces that each + * successive block level of the document should be indented. The default + * is 2. + */ + public void setIndent(int indent) { + this.indent = indent; + } + + /** + * Use this configuration parameter to set the desired maximum line length, + * in characters, for the pretty-printed document. The default is 80. + */ + public void setDesiredLineLength(int desiredLineLength) { + this.desiredLineLength = desiredLineLength; + } + + /** + * Set this configuration parameter to true if blocks that are inside of + * mixed content should be indented. The default is "false". + */ + public void setIndentBlocksInsideMixedContent(boolean indent) { + this.indentBlocksInsideMixedContent = indent; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-11 17:42:29
|
Revision: 6931 Author: victormote Date: 2006-03-11 09:42:25 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6931&view=rev Log Message: ----------- Fix NPEs. Modified Paths: -------------- trunk/foray/foray-font/src/java/org/foray/font/format/TTFTableCMAP.java Modified: trunk/foray/foray-font/src/java/org/foray/font/format/TTFTableCMAP.java =================================================================== --- trunk/foray/foray-font/src/java/org/foray/font/format/TTFTableCMAP.java 2006-03-11 17:28:10 UTC (rev 6930) +++ trunk/foray/foray-font/src/java/org/foray/font/format/TTFTableCMAP.java 2006-03-11 17:42:25 UTC (rev 6931) @@ -227,10 +227,16 @@ } public int encodeCharacter(int codePoint) { + if (this.unicodeCMap == null) { + return -1; + } return this.unicodeCMap.encodeCharacter(codePoint); } public int decodeCharacter(int glyphIndex) { + if (this.unicodeCMap == null) { + return -1; + } return this.unicodeCMap.decodeCharacter(glyphIndex); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-11 17:28:17
|
Revision: 6930 Author: victormote Date: 2006-03-11 09:28:10 -0800 (Sat, 11 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6930&view=rev Log Message: ----------- Start work on a class to diff two XML documents. Added Paths: ----------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java Added: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java (rev 0) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-03-11 17:28:10 UTC (rev 6930) @@ -0,0 +1,382 @@ +/* + * Copyright 2006 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: FOrayPretty.java 6929 2006-03-10 23:21:21Z victormote $ */ + +package org.foray.pretty; + +import org.foray.pretty.dtd.DTD; +import org.foray.pretty.dtd.DTDElement; +import org.foray.pretty.dtd.ElementStack; + +import org.apache.xerces.util.XMLCatalogResolver; + +import org.xml.sax.Attributes; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.XMLReader; +import org.xml.sax.ext.DefaultHandler2; +import org.xml.sax.helpers.AttributesImpl; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; + +/** + * Command-line application that reads two XML files and finds the first + * difference (if any) between them. + * This is not intended to be a general-purpose XML diff and compare tool. + * It is suitable in situations where some tranformation (like a pretty-print) + * has taken place and we wish to make sure that no significant changes were + * made to the document. + */ +public class FOrayXDiff extends DefaultHandler2 { + + /** The base document to be compared. */ + private XDiffDocument doc1; + + /** The second document to be compared. */ + private XDiffDocument doc2; + + /* Begin configuration variables. TODO: These need to be externalized and + * exposed with setters. */ + + /** + * Set this to true if PCDATA content can have space characters replaced + * by line terminators and vice versa. + */ + private boolean breakPCDATA = true; + + /* End configuration variables. */ + + /** + * Constructor. + */ + public FOrayXDiff(InputSource inputSource1, InputSource inputSource2, + String catalog) { + this.doc1 = new XDiffDocument(inputSource1, catalog); + this.doc2 = new XDiffDocument(inputSource2, catalog); + } + + public void start() { + try { + this.doc1.start(); + } catch (Exception e) { + this.logError("Unable to parse:\n " + doc1.input); + } + try { + this.doc2.start(); + } catch (Exception e) { + this.logError("Unable to parse:\n " + doc2.input); + } + } + + private void cleanup() { + } + + /** + * Replaces all occurrences of a given String with a different Strings. + */ + private static void convertString(StringBuffer buffer, String oldString, + String newString) { + boolean anyChanges = true; + while (anyChanges) { + anyChanges = false; + int index = buffer.indexOf(oldString); + if (index > -1) { + buffer.replace(index, index + oldString.length(), newString); + anyChanges = true; + } + } + } + + public EntityResolver getEntityResolver(String catalog) { + if (catalog == null) { + return null; + } + String [] catalogs = {catalog}; + XMLCatalogResolver resolver = new XMLCatalogResolver(); + resolver.setPreferPublic(true); + resolver.setCatalogList(catalogs); + return resolver; + } + + private void logError(String message) { + Locator locator1 = this.doc1.getDocumentLocator(); + Locator locator2 = this.doc2.getDocumentLocator(); + if (locator1 != null) { + System.out.println(locator1.getSystemId() + ":" + + locator1.getLineNumber() + ":" + + locator1.getColumnNumber()); + } + if (locator2 != null) { + System.out.println(locator2.getSystemId() + ":" + + locator2.getLineNumber() + ":" + + locator2.getColumnNumber()); + } + System.out.println(message); + } + + /** + * Private inner class representing an XML document that is part of the + * comparison. + */ + private class XDiffDocument extends DefaultHandler2 { + + InputSource input; + + private Locator locator; + + private ElementStack elementStack = new ElementStack(); + + private DTD dtd = new DTD(); + + private StringBuffer charBuffer = new StringBuffer(); + + private EntityResolver entityResolver; + + /* Begin state variables. */ + + /** State variable tracking whether we are currently inside the DTD or + * not. */ + private boolean inDTD = false; + + /** State variable tracking whether we are currently inside an entity + * expansion or not. */ + private boolean inEntity = false; + + /* End state variables. */ + + XDiffDocument(InputSource input, String catalog) { + this.input = input; + this.entityResolver = getEntityResolver(catalog); + } + + /** + * Intantiates parser and starts parsing of input. + */ + public void start() throws IOException, SAXException, + ParserConfigurationException { + XMLReader parser = createParser(); + + /* Bind the LexicalHandler to the XMLReader if possible. */ + try { + parser.setProperty("http://xml.org/sax/properties/lexical-handler", + this); + } catch (SAXNotSupportedException e1) { + logError("Parser does not support LexicalHandler."); + } + + /* Bind the DeclHandler to the XMLReader if possible. */ + try { + parser.setProperty("http://xml.org/sax/properties/declaration-handler", + this); + } catch (SAXNotSupportedException e) { + logError("Parser does not support Declaration Handler."); + } + + /* Turn on validation if it is available. */ + try { + parser.setFeature("http://xml.org/sax/features/validation", true); + } catch (SAXNotRecognizedException e1) { + logError("Parser does not recognize validation."); + } catch (SAXNotSupportedException e1) { + logError("Parser unable to validate."); + } + parser.setContentHandler(this); + parser.parse(this.input); + cleanup(); + } + + /** + * creates a SAX parser + * + * @return the created SAX parser + */ + public XMLReader createParser() throws SAXException, + ParserConfigurationException { + SAXParserFactory spf = + javax.xml.parsers.SAXParserFactory.newInstance(); + spf.setNamespaceAware(true); + XMLReader xmlReader = spf.newSAXParser().getXMLReader(); + if (this.entityResolver != null) { + xmlReader.setEntityResolver(this.entityResolver); + } + return xmlReader; + } + + public void setDocumentLocator(Locator locator) { + this.locator = locator; + } + + public Locator getDocumentLocator() { + return this.locator; + } + + public void startDocument() { + } + + public void endDocument() { + } + + public void startElement(String uri, String local, String qName, + Attributes attributes) { + flushCharacters(); + /* Must copy the attributes as they are reset on each callback. */ + Attributes attributesCache = new AttributesImpl(attributes); + if (attributesCache == null) { + attributesCache = null; + } + DTDElement element = this.dtd.getElement(local); + this.elementStack.push(element); + } + + public void endElement(String uri, String local, String qName) { + flushCharacters(); + } + + public void characters(char[] buffer, int offset, int length) { + if (this.inEntity) { + /* Skip these characters. We are writing the unexpanded entity + * elsewhere. We do not want to also write the expanded version. */ + return; + } + this.charBuffer.append(buffer, offset, length); + } + + public void processingInstruction(String target, String data) { + } + + public void ignorableWhitespace(char[] buffer, int offset, int length) { + /* Ignorable white space is just ignored. */ + } + + public void comment(char[] buffer, int offset, int length) { + if (this.inDTD) { + return; + } + } + + public void startDTD(String name, String publicId, String systemId) { + this.inDTD = true; + } + + public void endDTD() { + this.inDTD = false; + } + + public void startEntity(String name) { + if (this.inDTD) { + return; + } + /* Assumes for now that all are general entities. */ + this.charBuffer.append("&"); + this.charBuffer.append(name); + this.charBuffer.append(";"); + this.inEntity = true; + } + + public void endEntity(String name) { + this.inEntity = false; + } + + public void elementDecl(String name, String model) { + DTDElement dtdElement = new DTDElement(name, model); + this.dtd.addElement(dtdElement); + } + + private void flushCharacters() { + if (this.charBuffer.length() < 1) { + return; + } + if (breakPCDATA) { + /* Note: SAX input has linefeeds normalized to \n. */ + normalizeWhitespace(); + } + this.charBuffer.setLength(0); + } + + private void normalizeWhitespace() { + /* Convert all line-feeds to spaces. */ + convertString(this.charBuffer, "\n", " "); + /* Convert all tabs to spaces. */ + convertString(this.charBuffer, "\t", " "); + /* Remove extra spaces. */ + convertString(this.charBuffer, " ", " "); + } + + } + + public static void main(String[] args) { + if (args == null + || args.length < 2 + || args.length > 3) { + System.out.print("Wrong number of arguments."); + System.exit(1); + } + String input1 = args[0]; + String input2 = args[1]; + String catalog = null; + if (args.length > 2) { + catalog = args[2]; + } + InputStream inputStream = null; + try { + FileInputStream fis = null; + fis = new FileInputStream(input1); + inputStream = new BufferedInputStream(fis); + } catch (FileNotFoundException e) { + System.err.println("File not found: " + input1); + System.exit(1); + } + InputSource inputSource1 = new InputSource(inputStream); + + try { + FileInputStream fis = null; + fis = new FileInputStream(input2); + inputStream = new BufferedInputStream(fis); + } catch (FileNotFoundException e) { + System.err.println("File not found: " + input2); + System.exit(1); + } + InputSource inputSource2 = new InputSource(inputStream); + + FOrayXDiff processor = new FOrayXDiff(inputSource1, inputSource2, + catalog); + try { + processor.start(); + } catch (Exception e) { + System.out.print("Error parsing input."); + e.printStackTrace(); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-10 23:21:26
|
Revision: 6929 Author: victormote Date: 2006-03-10 15:21:21 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6929&view=rev Log Message: ----------- Make better fix for situation where the content is too long to fit on a line. Specifically, prevent the same break opportunity from being selected more than once. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 23:10:47 UTC (rev 6928) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 23:21:21 UTC (rev 6929) @@ -630,7 +630,14 @@ int firstChunkToConsider = this.getLastBreakChosen(); sizeIfAccepted += this.chunkSize(firstChunkToConsider, i); if (sizeIfAccepted > desiredLineLength) { - this.breaksChosen.add(new Integer(i - 1)); + int breakSelected = i - 1; + if (breakSelected <= this.getLastBreakChosen()) { + /* Don't let the same break get chosen again. If the + * content is too long, we still need to write it + * once. */ + breakSelected = this.getLastBreakChosen() + 1; + } + this.breaksChosen.add(new Integer(breakSelected)); } } } @@ -835,10 +842,7 @@ startItem = this.breakOpportunityItems[startOpportunity]; startItemIndex = this.breakOpportunityIndexes[startOpportunity]; } - if (endOpportunity < 0) { - /* This was no break recorded. */ - return; - } else if (endOpportunity >= this.breakOpportunityIndexes.length) { + if (endOpportunity >= this.breakOpportunityIndexes.length) { int lastItem = this.toWriteQueue.size() - 1; endItem = lastItem; endItemIndex = this.getLastItem().length() - 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-10 23:10:56
|
Revision: 6928 Author: victormote Date: 2006-03-10 15:10:47 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6928&view=rev Log Message: ----------- Remove erroneous incrementation of size. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 22:59:33 UTC (rev 6927) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 23:10:47 UTC (rev 6928) @@ -629,9 +629,6 @@ } int firstChunkToConsider = this.getLastBreakChosen(); sizeIfAccepted += this.chunkSize(firstChunkToConsider, i); - /* Add one for the first break opportunity, which is outside the - * computation above. */ - sizeIfAccepted ++; if (sizeIfAccepted > desiredLineLength) { this.breaksChosen.add(new Integer(i - 1)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-10 22:59:38
|
Revision: 6927 Author: victormote Date: 2006-03-10 14:59:33 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6927&view=rev Log Message: ----------- Fix problem with chunks that have no valid break in them. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 21:58:48 UTC (rev 6926) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 22:59:33 UTC (rev 6927) @@ -701,12 +701,11 @@ } for (int i = 0; i < this.breaksChosen.size(); i++) { - this.writeChunk(i); - write(newLine()); + this.writeChunk(i, true); } /* Write the last chunk. Don't write a new-line after it. That will * be controlled at a higher level. */ - this.writeChunk(Integer.MAX_VALUE); + this.writeChunk(Integer.MAX_VALUE, false); } private int getBreakChosen(int index) { @@ -808,7 +807,13 @@ return count; } - private void writeChunk(int breakSelected) { + /** + * Write one of the chunks selected. + * @param breakSelected The break selection that should be written. + * @param newLine Set to true if a new-line should be written after + * the text of the line. + */ + private void writeChunk(int breakSelected, boolean newLine) { int startOpportunity; int endOpportunity; if (breakSelected == 0) { @@ -833,7 +838,10 @@ startItem = this.breakOpportunityItems[startOpportunity]; startItemIndex = this.breakOpportunityIndexes[startOpportunity]; } - if (endOpportunity >= this.breakOpportunityIndexes.length) { + if (endOpportunity < 0) { + /* This was no break recorded. */ + return; + } else if (endOpportunity >= this.breakOpportunityIndexes.length) { int lastItem = this.toWriteQueue.size() - 1; endItem = lastItem; endItemIndex = this.getLastItem().length() - 1; @@ -862,6 +870,9 @@ } write(string.substring(startIndex, endIndex + 1)); } + if (newLine) { + write(newLine()); + } } private String getLastItem() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-10 21:58:52
|
Revision: 6926 Author: victormote Date: 2006-03-10 13:58:48 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6926&view=rev Log Message: ----------- Must consider queued items before the first break opportunity. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 21:20:59 UTC (rev 6925) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 21:58:48 UTC (rev 6926) @@ -628,9 +628,6 @@ sizeIfAccepted += lastColumnWritten; } int firstChunkToConsider = this.getLastBreakChosen(); - if (firstChunkToConsider < 0) { - firstChunkToConsider = 0; - } sizeIfAccepted += this.chunkSize(firstChunkToConsider, i); /* Add one for the first break opportunity, which is outside the * computation above. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-10 21:21:10
|
Revision: 6925 Author: victormote Date: 2006-03-10 13:20:59 -0800 (Fri, 10 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6925&view=rev Log Message: ----------- 1. Don't count the last chunk twice when computing the sizes. 2. Remove count variables as they are no longer used. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 01:15:31 UTC (rev 6924) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 21:20:59 UTC (rev 6925) @@ -594,12 +594,6 @@ * in that queue item. */ private int[] breakOpportunityItems; private int[] breakOpportunityIndexes; - /* chunkSizes[n] = the size in chars of the chunk ending at - * breakOpportunityItems[n], breakOpportunityIndex[n]. */ - private int[] chunkSizes; - /* If there are n break opportunities, there are n + 1 chunks. This - * stores the size of the last chunk. */ - private int lastChunkSize; /* List of Integer indexes into the breakOpportunity arrays that * indicate which opportunities have actually been chosen. */ @@ -673,8 +667,6 @@ private void reset() { this.breakOpportunityItems = null; this.breakOpportunityIndexes = null; - this.chunkSizes = null; - this.lastChunkSize = -1; this.toWriteQueue.clear(); this.breaksChosen.clear(); } @@ -740,7 +732,6 @@ int count = countBreakOpportunities(); this.breakOpportunityItems = new int[count]; this.breakOpportunityIndexes = new int[count]; - this.chunkSizes = new int[count]; if (count == 0) { return; } @@ -752,14 +743,11 @@ if (c == ' ') { this.breakOpportunityItems[count] = i; this.breakOpportunityIndexes[count] = j; - int chunkSize = chunkSize(count - 1, count); - this.chunkSizes[count] = chunkSize; count ++; } } } count = this.breakOpportunityItems.length; - this.lastChunkSize = chunkSize(count - 1, count); } private int chunkSize(int startOpportunity, int endOpportunity) { @@ -806,11 +794,6 @@ size ++; } } - /* If the parameters go past the end of the opportunities, it means - * they want the length of the last chunk included. */ - if (endOpportunity > lastOpportunity) { - size += this.lastChunkSize + 1; - } return size; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-10 01:15:37
|
Revision: 6924 Author: victormote Date: 2006-03-09 17:15:31 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6924&view=rev Log Message: ----------- Improvements to line-breaking logic. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 00:58:50 UTC (rev 6923) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 01:15:31 UTC (rev 6924) @@ -642,11 +642,7 @@ * computation above. */ sizeIfAccepted ++; if (sizeIfAccepted > desiredLineLength) { - if (i == 0) { - this.breaksChosen.add(new Integer(i)); - } else { - this.breaksChosen.add(new Integer(i - 1)); - } + this.breaksChosen.add(new Integer(i - 1)); } } } @@ -783,7 +779,7 @@ } int lastOpportunity = this.breakOpportunityItems.length - 1; if (endOpportunity > lastOpportunity) { - endItem = this.breakOpportunityItems[lastOpportunity]; + endItem = this.toWriteQueue.size() - 1; String string = this.get(endItem); endItemIndex = string.length(); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-10 00:58:54
|
Revision: 6923 Author: victormote Date: 2006-03-09 16:58:50 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6923&view=rev Log Message: ----------- More improvements to line writing. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 00:15:01 UTC (rev 6922) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 00:58:50 UTC (rev 6923) @@ -715,22 +715,13 @@ return; } - int activeBreak; - int previousBreak; for (int i = 0; i < this.breaksChosen.size(); i++) { - activeBreak = this.getBreakChosen(i); - if (i == 0) { - previousBreak = 0; - } else { - previousBreak = this.getBreakChosen(i - 1); - } - this.writeChunk(previousBreak, activeBreak); + this.writeChunk(i); write(newLine()); } /* Write the last chunk. Don't write a new-line after it. That will * be controlled at a higher level. */ - activeBreak = this.getBreakChosen(this.breaksChosen.size() - 1); - this.writeChunk(activeBreak, Integer.MAX_VALUE); + this.writeChunk(Integer.MAX_VALUE); } private int getBreakChosen(int index) { @@ -841,7 +832,20 @@ return count; } - private void writeChunk(int startOpportunity, int endOpportunity) { + private void writeChunk(int breakSelected) { + int startOpportunity; + int endOpportunity; + if (breakSelected == 0) { + startOpportunity = Integer.MIN_VALUE; + endOpportunity = this.getBreakChosen(breakSelected); + } else if (breakSelected > this.breaksChosen.size() - 1) { + startOpportunity = this.getLastBreakChosen(); + endOpportunity = Integer.MAX_VALUE; + } else { + startOpportunity = this.getBreakChosen(breakSelected - 1); + endOpportunity = this.getBreakChosen(breakSelected); + } + int startItem; int startItemIndex; int endItem; @@ -866,17 +870,21 @@ int startIndex = 0; if (i == startItem) { startIndex = startItemIndex; + /* If the first character on a line is a space, don't write + * it. */ + if (string.charAt(startIndex) == ' ' + && lastColumnWritten == 0) { + startIndex ++; + } } int endIndex = string.length() - 1; if (i == endItem) { endIndex = endItemIndex; + if (string.charAt(endIndex) == ' ') { + endIndex --; + } } - if (startIndex == 0 - && endIndex == string.length() - 1) { - write(string); - } else { - write(string.substring(startIndex, endIndex + 1)); - } + write(string.substring(startIndex, endIndex + 1)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-10 00:15:07
|
Revision: 6922 Author: victormote Date: 2006-03-09 16:15:01 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6922&view=rev Log Message: ----------- Simplify the writing of a chunk. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 23:07:36 UTC (rev 6921) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-10 00:15:01 UTC (rev 6922) @@ -715,53 +715,22 @@ return; } - int startItem = 0; - int startIndex = 0; - int endItem = 0; - int endIndex = 0; - + int activeBreak; + int previousBreak; for (int i = 0; i < this.breaksChosen.size(); i++) { - int activeBreak = this.getBreakChosen(i); - /* Adjust starting items for the items after the first. */ - if (i != 0) { - int previousBreak = this.getBreakChosen(i - 1); - startItem = this.breakOpportunityItems[previousBreak]; - startIndex = this.breakOpportunityIndexes[previousBreak]; + activeBreak = this.getBreakChosen(i); + if (i == 0) { + previousBreak = 0; + } else { + previousBreak = this.getBreakChosen(i - 1); } - - /* Set the ending items. */ - endItem = this.breakOpportunityItems[activeBreak]; - endIndex = this.breakOpportunityIndexes[activeBreak]; - - /* Start writing one past the break, and stop one before. */ - startIndex ++; - endIndex --; - - /* Write the chunk. */ - writeChunk(startItem, startIndex, endItem, endIndex); + this.writeChunk(previousBreak, activeBreak); write(newLine()); } - - /* Write the final chunk, the portion from the last break chosen - * to the end of the data items. */ - int lastChosen = this.getBreakChosen(this.breaksChosen.size() - 1); - if (lastChosen < 0) { - startItem = 0; - startIndex = -1; - } else { - startItem = this.breakOpportunityItems[lastChosen]; - startIndex = this.breakOpportunityIndexes[lastChosen]; - } - endItem = this.toWriteQueue.size() - 1; - endIndex = this.getLastItem().length() - 1; - - /* Start writing one past the break. The ending index is already - * adjusted. */ - startIndex ++; - - writeChunk(startItem, startIndex, endItem, endIndex); - /* Do not write a new line here. This will be controlled at a - * higher level. */ + /* Write the last chunk. Don't write a new-line after it. That will + * be controlled at a higher level. */ + activeBreak = this.getBreakChosen(this.breaksChosen.size() - 1); + this.writeChunk(activeBreak, Integer.MAX_VALUE); } private int getBreakChosen(int index) { @@ -872,8 +841,26 @@ return count; } - private void writeChunk(int startItem, int startItemIndex, int endItem, - int endItemIndex) { + private void writeChunk(int startOpportunity, int endOpportunity) { + int startItem; + int startItemIndex; + int endItem; + int endItemIndex; + if (startOpportunity < 0) { + startItem = 0; + startItemIndex = 0; + } else { + startItem = this.breakOpportunityItems[startOpportunity]; + startItemIndex = this.breakOpportunityIndexes[startOpportunity]; + } + if (endOpportunity >= this.breakOpportunityIndexes.length) { + int lastItem = this.toWriteQueue.size() - 1; + endItem = lastItem; + endItemIndex = this.getLastItem().length() - 1; + } else { + endItem = this.breakOpportunityItems[endOpportunity]; + endItemIndex = this.breakOpportunityIndexes[endOpportunity]; + } for (int i = startItem; i <= endItem; i++) { String string = this.get(i); int startIndex = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-09 23:07:41
|
Revision: 6921 Author: victormote Date: 2006-03-09 15:07:36 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6921&view=rev Log Message: ----------- Improvements to line-breaking. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 22:34:42 UTC (rev 6920) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 23:07:36 UTC (rev 6921) @@ -619,16 +619,14 @@ } private void chooseBreaks() { - /* Make these arrays as big as the opportunity arrays to avoid - * resizing. */ - int arraySize = this.breakOpportunityIndexes.length; this.breaksChosen.clear(); - if (arraySize < 1) { + if (this.breakOpportunityIndexes.length < 1) { return; } - for (int i = 0; i < arraySize; i++) { + /* Loop one extra time to catch the last chunk. */ + for (int i = 0; i <= this.breakOpportunityIndexes.length; i++) { int sizeIfAccepted = 0; /* If it is the first item, we must consider what has already * been written on the line. */ @@ -639,14 +637,10 @@ if (firstChunkToConsider < 0) { firstChunkToConsider = 0; } - for (int j = firstChunkToConsider; j <= i; j++) { - sizeIfAccepted += this.chunkSizes[j]; - if (j != firstChunkToConsider) { - /* For all but the first item, we must consider the - * space between the items. */ - sizeIfAccepted ++; - } - } + sizeIfAccepted += this.chunkSize(firstChunkToConsider, i); + /* Add one for the first break opportunity, which is outside the + * computation above. */ + sizeIfAccepted ++; if (sizeIfAccepted > desiredLineLength) { if (i == 0) { this.breaksChosen.add(new Integer(i)); @@ -813,6 +807,9 @@ } private int chunkSize(int startOpportunity, int endOpportunity) { + if (startOpportunity == endOpportunity) { + return 0; + } int startItem; int startItemIndex; int endItem; @@ -853,6 +850,11 @@ size ++; } } + /* If the parameters go past the end of the opportunities, it means + * they want the length of the last chunk included. */ + if (endOpportunity > lastOpportunity) { + size += this.lastChunkSize + 1; + } return size; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-09 22:34:47
|
Revision: 6920 Author: victormote Date: 2006-03-09 14:34:42 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6920&view=rev Log Message: ----------- More simplification. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 21:04:33 UTC (rev 6919) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 22:34:42 UTC (rev 6920) @@ -628,16 +628,15 @@ return; } - int lastIndexChosen = -1; for (int i = 0; i < arraySize; i++) { int sizeIfAccepted = 0; /* If it is the first item, we must consider what has already * been written on the line. */ - if (lastIndexChosen < 0) { + if (this.breaksChosen.size() < 1) { sizeIfAccepted += lastColumnWritten; } - int firstChunkToConsider = lastIndexChosen; - if (lastIndexChosen < 0) { + int firstChunkToConsider = this.getLastBreakChosen(); + if (firstChunkToConsider < 0) { firstChunkToConsider = 0; } for (int j = firstChunkToConsider; j <= i; j++) { @@ -650,10 +649,8 @@ } if (sizeIfAccepted > desiredLineLength) { if (i == 0) { - lastIndexChosen = i; this.breaksChosen.add(new Integer(i)); } else { - lastIndexChosen = i - 1; this.breaksChosen.add(new Integer(i - 1)); } } @@ -784,6 +781,11 @@ return integer.intValue(); } + private int getLastBreakChosen() { + int lastIndex = this.breaksChosen.size() - 1; + return getBreakChosen(lastIndex); + } + private void listBreakOpportunities() { int count = countBreakOpportunities(); this.breakOpportunityItems = new int[count]; @@ -800,36 +802,37 @@ if (c == ' ') { this.breakOpportunityItems[count] = i; this.breakOpportunityIndexes[count] = j; - int startItem = 0; - /* Must pretend there is a break right before the first - * index of the first item. */ - int startIndex = -1; - if (count > 0) { - startItem = this.breakOpportunityItems[count - 1]; - startIndex = this.breakOpportunityIndexes[count - 1]; - } - int endItem = i; - int endIndex = j; - int chunkSize = chunkSize(startItem, startIndex, - endItem, endIndex); + int chunkSize = chunkSize(count - 1, count); this.chunkSizes[count] = chunkSize; count ++; } } } count = this.breakOpportunityItems.length; - this.lastChunkSize = chunkSize( - this.breakOpportunityItems[count - 1], - this.breakOpportunityIndexes[count - 1], - this.toWriteQueue.size() - 1, - /* Don't subtract 1 here. We must pretend there is a break - * opportunity immediately after the last index of the last - * item. */ - this.getLastItem().length()); + this.lastChunkSize = chunkSize(count - 1, count); } - private int chunkSize(int startItem, int startItemIndex, int endItem, - int endItemIndex) { + private int chunkSize(int startOpportunity, int endOpportunity) { + int startItem; + int startItemIndex; + int endItem; + int endItemIndex; + if (startOpportunity < 0) { + startItem = 0; + startItemIndex = -1; + } else { + startItem = this.breakOpportunityItems[startOpportunity]; + startItemIndex = this.breakOpportunityIndexes[startOpportunity]; + } + int lastOpportunity = this.breakOpportunityItems.length - 1; + if (endOpportunity > lastOpportunity) { + endItem = this.breakOpportunityItems[lastOpportunity]; + String string = this.get(endItem); + endItemIndex = string.length(); + } else { + endItem = this.breakOpportunityItems[endOpportunity]; + endItemIndex = this.breakOpportunityIndexes[endOpportunity]; + } int size = 0; for (int i = startItem; i <= endItem; i++) { int startIndex = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-09 21:04:38
|
Revision: 6919 Author: victormote Date: 2006-03-09 13:04:33 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6919&view=rev Log Message: ----------- Just keep track of which indexes were selected instead of copying them around. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 19:54:45 UTC (rev 6918) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 21:04:33 UTC (rev 6919) @@ -601,17 +601,10 @@ * stores the size of the last chunk. */ private int lastChunkSize; - /* The following items are similar to breakOpportunityItems and - * breakOpportunityIndexes, except they represent breaks actually - * chosen. */ - private int[] breakChosenItems; - private int[] breakChosenIndexes; + /* List of Integer indexes into the breakOpportunity arrays that + * indicate which opportunities have actually been chosen. */ + private ArrayList breaksChosen = new ArrayList(); - /* The last index used in the "breakChosen" variables. Those items are - * sized to generally be larger than they need to be, so this is needed - * to keep track of the amount actually used. */ - private int breakChosenIndex = -1; - Queue() { } @@ -629,9 +622,7 @@ /* Make these arrays as big as the opportunity arrays to avoid * resizing. */ int arraySize = this.breakOpportunityIndexes.length; - this.breakChosenItems = new int[arraySize]; - this.breakChosenIndexes = new int[arraySize]; - this.breakChosenIndex = -1; + this.breaksChosen.clear(); if (arraySize < 1) { return; @@ -660,23 +651,15 @@ if (sizeIfAccepted > desiredLineLength) { if (i == 0) { lastIndexChosen = i; - markBreak(this.breakOpportunityItems[i], - this.breakOpportunityIndexes[i]); + this.breaksChosen.add(new Integer(i)); } else { lastIndexChosen = i - 1; - markBreak(this.breakOpportunityItems[i - 1], - this.breakOpportunityIndexes[i - 1]); + this.breaksChosen.add(new Integer(i - 1)); } } } } - private void markBreak(int item, int itemIndex) { - this.breakChosenIndex ++; - this.breakChosenItems[this.breakChosenIndex] = item; - this.breakChosenIndexes[this.breakChosenIndex] = itemIndex; - } - /** * If everything can be written on the current line, do it. Otherwise, * do nothing. @@ -701,14 +684,12 @@ } private void reset() { - this.breakChosenIndex = -1; - this.breakChosenItems = null; - this.breakChosenIndexes = null; this.breakOpportunityItems = null; this.breakOpportunityIndexes = null; this.chunkSizes = null; this.lastChunkSize = -1; this.toWriteQueue.clear(); + this.breaksChosen.clear(); } protected int size() { @@ -738,30 +719,28 @@ private void writeChosenChunks() { /* If there are no breaks, there is nothing to do but write the * whole thing.*/ - if (this.breakChosenIndex < 0) { + if (this.breaksChosen.size() < 0) { this.writeAll(); return; } - /* Usable size of the arrays is 1 greater than the last index. */ - int chosenSize = this.breakChosenIndex + 1; int startItem = 0; int startIndex = 0; int endItem = 0; int endIndex = 0; - /* Notice that if there are n breaks, we loop through n + 1 - * times, so that the last chunk gets written. */ - for (int i = 0; i < chosenSize; i++) { - + + for (int i = 0; i < this.breaksChosen.size(); i++) { + int activeBreak = this.getBreakChosen(i); /* Adjust starting items for the items after the first. */ if (i != 0) { - startItem = this.breakChosenItems[i - 1]; - startIndex = this.breakChosenIndexes[i - 1]; + int previousBreak = this.getBreakChosen(i - 1); + startItem = this.breakOpportunityItems[previousBreak]; + startIndex = this.breakOpportunityIndexes[previousBreak]; } /* Set the ending items. */ - endItem = this.breakChosenItems[i]; - endIndex = this.breakChosenIndexes[i]; + endItem = this.breakOpportunityItems[activeBreak]; + endIndex = this.breakOpportunityIndexes[activeBreak]; /* Start writing one past the break, and stop one before. */ startIndex ++; @@ -774,8 +753,14 @@ /* Write the final chunk, the portion from the last break chosen * to the end of the data items. */ - startItem = this.breakChosenItems[this.breakChosenIndex]; - startIndex = this.breakChosenIndexes[this.breakChosenIndex]; + int lastChosen = this.getBreakChosen(this.breaksChosen.size() - 1); + if (lastChosen < 0) { + startItem = 0; + startIndex = -1; + } else { + startItem = this.breakOpportunityItems[lastChosen]; + startIndex = this.breakOpportunityIndexes[lastChosen]; + } endItem = this.toWriteQueue.size() - 1; endIndex = this.getLastItem().length() - 1; @@ -788,6 +773,17 @@ * higher level. */ } + private int getBreakChosen(int index) { + if (this.breaksChosen == null + || index < 0 + || index >= this.breaksChosen.size()) { + return -1; + } + Object object = this.breaksChosen.get(index); + Integer integer = (Integer) object; + return integer.intValue(); + } + private void listBreakOpportunities() { int count = countBreakOpportunities(); this.breakOpportunityItems = new int[count]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-09 19:54:50
|
Revision: 6918 Author: victormote Date: 2006-03-09 11:54:45 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6918&view=rev Log Message: ----------- Select the correct break opportunity. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 19:32:58 UTC (rev 6917) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 19:54:45 UTC (rev 6918) @@ -651,16 +651,21 @@ } for (int j = firstChunkToConsider; j <= i; j++) { sizeIfAccepted += this.chunkSizes[j]; + if (j != firstChunkToConsider) { + /* For all but the first item, we must consider the + * space between the items. */ + sizeIfAccepted ++; + } } if (sizeIfAccepted > desiredLineLength) { if (i == 0) { lastIndexChosen = i; - markBreak(this.breakChosenItems[i], - this.breakChosenIndexes[i]); + markBreak(this.breakOpportunityItems[i], + this.breakOpportunityIndexes[i]); } else { lastIndexChosen = i - 1; - markBreak(this.breakChosenItems[i - 1], - this.breakChosenIndexes[i - 1]); + markBreak(this.breakOpportunityItems[i - 1], + this.breakOpportunityIndexes[i - 1]); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-09 19:33:13
|
Revision: 6917 Author: victormote Date: 2006-03-09 11:32:58 -0800 (Thu, 09 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6917&view=rev Log Message: ----------- Fix problems in the way sizes of chunks were computed. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 02:38:25 UTC (rev 6916) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 19:32:58 UTC (rev 6917) @@ -800,7 +800,9 @@ this.breakOpportunityItems[count] = i; this.breakOpportunityIndexes[count] = j; int startItem = 0; - int startIndex = 0; + /* Must pretend there is a break right before the first + * index of the first item. */ + int startIndex = -1; if (count > 0) { startItem = this.breakOpportunityItems[count - 1]; startIndex = this.breakOpportunityIndexes[count - 1]; @@ -819,7 +821,10 @@ this.breakOpportunityItems[count - 1], this.breakOpportunityIndexes[count - 1], this.toWriteQueue.size() - 1, - this.getLastItem().length() - 1); + /* Don't subtract 1 here. We must pretend there is a break + * opportunity immediately after the last index of the last + * item. */ + this.getLastItem().length()); } private int chunkSize(int startItem, int startItemIndex, int endItem, @@ -837,7 +842,12 @@ String item = this.get(i); endIndex = item.length() - 1; } - size += endIndex - startIndex + 1; + size += endIndex - startIndex; + if (i != startItem) { + /* For all but the first item, we must add the space that + * separates the chunks in order to get the complete size.*/ + size ++; + } } return size; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-09 02:38:33
|
Revision: 6916 Author: victormote Date: 2006-03-08 18:38:25 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6916&view=rev Log Message: ----------- 1. Add logic to compute size of chunks. 2. Fill in some of the logic for selecting line breaks. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 00:08:55 UTC (rev 6915) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 02:38:25 UTC (rev 6916) @@ -631,21 +631,45 @@ int arraySize = this.breakOpportunityIndexes.length; this.breakChosenItems = new int[arraySize]; this.breakChosenIndexes = new int[arraySize]; + this.breakChosenIndex = -1; if (arraySize < 1) { return; } - /* For now, just choose the last opportunity. */ + int lastIndexChosen = -1; + for (int i = 0; i < arraySize; i++) { + int sizeIfAccepted = 0; + /* If it is the first item, we must consider what has already + * been written on the line. */ + if (lastIndexChosen < 0) { + sizeIfAccepted += lastColumnWritten; + } + int firstChunkToConsider = lastIndexChosen; + if (lastIndexChosen < 0) { + firstChunkToConsider = 0; + } + for (int j = firstChunkToConsider; j <= i; j++) { + sizeIfAccepted += this.chunkSizes[j]; + } + if (sizeIfAccepted > desiredLineLength) { + if (i == 0) { + lastIndexChosen = i; + markBreak(this.breakChosenItems[i], + this.breakChosenIndexes[i]); + } else { + lastIndexChosen = i - 1; + markBreak(this.breakChosenItems[i - 1], + this.breakChosenIndexes[i - 1]); + } + } + } + } + + private void markBreak(int item, int itemIndex) { this.breakChosenIndex ++; - this.breakChosenItems[this.breakChosenIndex] - = this.breakOpportunityItems[arraySize - 1]; - this.breakChosenIndexes[this.breakChosenIndex] - = this.breakOpportunityIndexes[arraySize - 1]; - - /* The main thing to watch out for here is that the last line is not - * too long. */ -// if (this.lastChunkSize >) + this.breakChosenItems[this.breakChosenIndex] = item; + this.breakChosenIndexes[this.breakChosenIndex] = itemIndex; } /** @@ -800,7 +824,22 @@ private int chunkSize(int startItem, int startItemIndex, int endItem, int endItemIndex) { - return 0; + int size = 0; + for (int i = startItem; i <= endItem; i++) { + int startIndex = 0; + int endIndex = 0; + if (i == startItem) { + startIndex = startItemIndex; + } + if (i == endItem) { + endIndex = endItemIndex - 1; + } else { + String item = this.get(i); + endIndex = item.length() - 1; + } + size += endIndex - startIndex + 1; + } + return size; } private int countBreakOpportunities() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-09 00:09:04
|
Revision: 6915 Author: victormote Date: 2006-03-08 16:08:55 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6915&view=rev Log Message: ----------- Fix some problems related to getting the choices written. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 23:46:14 UTC (rev 6914) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-09 00:08:55 UTC (rev 6915) @@ -713,13 +713,16 @@ this.writeAll(); return; } + /* Usable size of the arrays is 1 greater than the last index. */ + int chosenSize = this.breakChosenIndex + 1; + + int startItem = 0; + int startIndex = 0; + int endItem = 0; + int endIndex = 0; /* Notice that if there are n breaks, we loop through n + 1 * times, so that the last chunk gets written. */ - for (int i = 0; i <= this.breakChosenIndex; i++) { - int startItem = 0; - int startIndex = 0; - int endItem = 0; - int endIndex = 0; + for (int i = 0; i < chosenSize; i++) { /* Adjust starting items for the items after the first. */ if (i != 0) { @@ -728,20 +731,32 @@ } /* Set the ending items. */ - if (i == this.breakChosenIndex) { - endItem = this.toWriteQueue.size() - 1; - endIndex = this.getLastItem().length() - 1; - } else { - endItem = this.breakChosenItems[i]; - endItem = this.breakChosenIndexes[i]; - } + endItem = this.breakChosenItems[i]; + endIndex = this.breakChosenIndexes[i]; + /* Start writing one past the break, and stop one before. */ + startIndex ++; + endIndex --; + /* Write the chunk. */ writeChunk(startItem, startIndex, endItem, endIndex); - if (i != this.breakChosenIndex) { - write(newLine()); - } + write(newLine()); } + + /* Write the final chunk, the portion from the last break chosen + * to the end of the data items. */ + startItem = this.breakChosenItems[this.breakChosenIndex]; + startIndex = this.breakChosenIndexes[this.breakChosenIndex]; + endItem = this.toWriteQueue.size() - 1; + endIndex = this.getLastItem().length() - 1; + + /* Start writing one past the break. The ending index is already + * adjusted. */ + startIndex ++; + + writeChunk(startItem, startIndex, endItem, endIndex); + /* Do not write a new line here. This will be controlled at a + * higher level. */ } private void listBreakOpportunities() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-08 23:46:18
|
Revision: 6914 Author: victormote Date: 2006-03-08 15:46:14 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6914&view=rev Log Message: ----------- Fix some problems related to getting the choices written. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 23:31:27 UTC (rev 6913) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 23:46:14 UTC (rev 6914) @@ -326,15 +326,13 @@ flushCharacters(); if (this.topElementWritten) { - if (this.elementStack.topIsBlockElement()) { + if (endTagOnNewLine()) { this.queue.flush(); - } - if (endTagOnNewLine()) { write(newLine()); write(indent()); } addToQueue("</" + local + ">"); - if (this.elementStack.topIsBlockElement()) { + if (endTagOnNewLine()) { this.queue.flush(); } } else { @@ -711,7 +709,7 @@ private void writeChosenChunks() { /* If there are no breaks, there is nothing to do but write the * whole thing.*/ - if (this.breakChosenIndex < 1) { + if (this.breakChosenIndex < 0) { this.writeAll(); return; } @@ -740,7 +738,9 @@ /* Write the chunk. */ writeChunk(startItem, startIndex, endItem, endIndex); - write(newLine()); + if (i != this.breakChosenIndex) { + write(newLine()); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-08 23:31:33
|
Revision: 6913 Author: victormote Date: 2006-03-08 15:31:27 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6913&view=rev Log Message: ----------- Add logic for writing multiple break opportunities. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 22:25:15 UTC (rev 6912) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 23:31:27 UTC (rev 6913) @@ -596,7 +596,24 @@ * in that queue item. */ private int[] breakOpportunityItems; private int[] breakOpportunityIndexes; + /* chunkSizes[n] = the size in chars of the chunk ending at + * breakOpportunityItems[n], breakOpportunityIndex[n]. */ + private int[] chunkSizes; + /* If there are n break opportunities, there are n + 1 chunks. This + * stores the size of the last chunk. */ + private int lastChunkSize; + /* The following items are similar to breakOpportunityItems and + * breakOpportunityIndexes, except they represent breaks actually + * chosen. */ + private int[] breakChosenItems; + private int[] breakChosenIndexes; + + /* The last index used in the "breakChosen" variables. Those items are + * sized to generally be larger than they need to be, so this is needed + * to keep track of the amount actually used. */ + private int breakChosenIndex = -1; + Queue() { } @@ -604,11 +621,35 @@ if (attemptWriteAll()) { return; } - breakAtLastOpportunity(); - /* Otherwise, search backwards through the items in the queue looking - * for the last break opportunity*/ + this.listBreakOpportunities(); + this.chooseBreaks(); + this.writeChosenChunks(); + this.reset(); } + private void chooseBreaks() { + /* Make these arrays as big as the opportunity arrays to avoid + * resizing. */ + int arraySize = this.breakOpportunityIndexes.length; + this.breakChosenItems = new int[arraySize]; + this.breakChosenIndexes = new int[arraySize]; + + if (arraySize < 1) { + return; + } + + /* For now, just choose the last opportunity. */ + this.breakChosenIndex ++; + this.breakChosenItems[this.breakChosenIndex] + = this.breakOpportunityItems[arraySize - 1]; + this.breakChosenIndexes[this.breakChosenIndex] + = this.breakOpportunityIndexes[arraySize - 1]; + + /* The main thing to watch out for here is that the last line is not + * too long. */ +// if (this.lastChunkSize >) + } + /** * If everything can be written on the current line, do it. Otherwise, * do nothing. @@ -629,8 +670,20 @@ writeRawPCDATA(returnItem); this.toWriteQueue.remove(0); } + reset(); } + private void reset() { + this.breakChosenIndex = -1; + this.breakChosenItems = null; + this.breakChosenIndexes = null; + this.breakOpportunityItems = null; + this.breakOpportunityIndexes = null; + this.chunkSizes = null; + this.lastChunkSize = -1; + this.toWriteQueue.clear(); + } + protected int size() { return toWriteQueue.size(); } @@ -655,33 +708,50 @@ return charCount; } - private void breakAtLastOpportunity() { - this.listBreakOpportunities(); - /* If there is no break, there is nothing to do but write the whole - * thing.*/ - if (this.breakOpportunityItems.length < 1) { + private void writeChosenChunks() { + /* If there are no breaks, there is nothing to do but write the + * whole thing.*/ + if (this.breakChosenIndex < 1) { this.writeAll(); return; } - /* Otherwise, split into two chunks. */ - /* Write the first chunk. */ - int lastIndex = this.breakOpportunityItems.length - 1; - int lastBreakItem = this.breakOpportunityItems[lastIndex]; - int lastBreakIndex = this.breakOpportunityIndexes[lastIndex]; - writeChunk(0, 0, lastBreakItem, lastBreakIndex); - write(newLine()); - /* Write the second chunk. */ - writeChunk(lastBreakItem, lastBreakIndex + 1, - this.toWriteQueue.size() - 1, - this.getLastItem().length() - 1); - /* Clear the queue contents. */ - this.toWriteQueue.clear(); + /* Notice that if there are n breaks, we loop through n + 1 + * times, so that the last chunk gets written. */ + for (int i = 0; i <= this.breakChosenIndex; i++) { + int startItem = 0; + int startIndex = 0; + int endItem = 0; + int endIndex = 0; + + /* Adjust starting items for the items after the first. */ + if (i != 0) { + startItem = this.breakChosenItems[i - 1]; + startIndex = this.breakChosenIndexes[i - 1]; + } + + /* Set the ending items. */ + if (i == this.breakChosenIndex) { + endItem = this.toWriteQueue.size() - 1; + endIndex = this.getLastItem().length() - 1; + } else { + endItem = this.breakChosenItems[i]; + endItem = this.breakChosenIndexes[i]; + } + + /* Write the chunk. */ + writeChunk(startItem, startIndex, endItem, endIndex); + write(newLine()); + } } private void listBreakOpportunities() { int count = countBreakOpportunities(); this.breakOpportunityItems = new int[count]; this.breakOpportunityIndexes = new int[count]; + this.chunkSizes = new int[count]; + if (count == 0) { + return; + } count = 0; for (int i = 0; i < this.toWriteQueue.size(); i++) { String string = this.get(i); @@ -690,12 +760,34 @@ if (c == ' ') { this.breakOpportunityItems[count] = i; this.breakOpportunityIndexes[count] = j; + int startItem = 0; + int startIndex = 0; + if (count > 0) { + startItem = this.breakOpportunityItems[count - 1]; + startIndex = this.breakOpportunityIndexes[count - 1]; + } + int endItem = i; + int endIndex = j; + int chunkSize = chunkSize(startItem, startIndex, + endItem, endIndex); + this.chunkSizes[count] = chunkSize; count ++; } } } + count = this.breakOpportunityItems.length; + this.lastChunkSize = chunkSize( + this.breakOpportunityItems[count - 1], + this.breakOpportunityIndexes[count - 1], + this.toWriteQueue.size() - 1, + this.getLastItem().length() - 1); } + private int chunkSize(int startItem, int startItemIndex, int endItem, + int endItemIndex) { + return 0; + } + private int countBreakOpportunities() { int count = 0; for (int i = 0; i < this.toWriteQueue.size(); i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-08 22:25:19
|
Revision: 6912 Author: victormote Date: 2006-03-08 14:25:15 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6912&view=rev Log Message: ----------- Only write the tag if it starts a new line. Otherwise queue it up. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 21:49:04 UTC (rev 6911) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 22:25:15 UTC (rev 6912) @@ -256,17 +256,11 @@ write(this.preRootText); } - if (this.startTagOnNewLine()) { - write(newLine()); - if (this.shouldIndent()) { - write(indent()); - } - } + /* Accumulate the tag opener. */ + StringBuffer tagOpenBuffer = new StringBuffer(); + tagOpenBuffer.append("<"); + tagOpenBuffer.append(local); - /* Always write the tag opener and the element name itself. */ - write("<"); - write(local); - /* Accumulate the attributes. */ StringBuffer attributesBuffer = new StringBuffer(); for (int i = 0; i < attributes.getLength(); i++) { @@ -284,15 +278,23 @@ } else { tagCloseBuffer.append(">"); } - - /* If there are attributes, they must be queued up for output.*/ - if (attributes.getLength() > 0) { - this.queue.add(attributesBuffer.toString() - + tagCloseBuffer.toString()); + + /* If starting on new line, write the tag open buffer. */ + if (this.startTagOnNewLine()) { + this.queue.flush(); + write(newLine()); + if (this.shouldIndent()) { + write(indent()); + } + write(tagOpenBuffer.toString()); } else { - /* Otherwise write the tag closer now. */ - write(tagCloseBuffer.toString()); + /* Otherwise queue it up. */ + this.queue.add(tagOpenBuffer.toString()); } + + /* Queue up the attributes and tag close. */ + this.queue.add(attributesBuffer.toString() + + tagCloseBuffer.toString()); } private boolean shouldIndent() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
|
From: <vic...@us...> - 2006-03-08 21:49:09
|
Revision: 6911 Author: victormote Date: 2006-03-08 13:49:04 -0800 (Wed, 08 Mar 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=6911&view=rev Log Message: ----------- Use new break opportunity logic to compute last break opportunity. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 21:19:19 UTC (rev 6910) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-03-08 21:49:04 UTC (rev 6911) @@ -583,9 +583,17 @@ private class Queue { /** Collection of Strings that need to be written as soon as we know * enough of what comes after them to choose line breaks. This is needed - * for PCDATA and inline tags that must stay on the current line. */ + * for PCDATA and inline tags that must stay on the current line. + * It is tempting to turn this all into one long StringBuffer, but we + * need to handle attributes differently from PCDATA. */ private ArrayList toWriteQueue = new ArrayList(); + /* After running listBreakOpportunities, these two arrays hold a list of + * break opportunities. The "Items" element points to the item in + * toWriteQueue. The "Indexes" element points to a specific character + * in that queue item. */ + private int[] breakOpportunityItems; + private int[] breakOpportunityIndexes; Queue() { } @@ -646,45 +654,60 @@ } private void breakAtLastOpportunity() { - if (this.size() < 1) { - return; - } - int lastBreakItem = -1; - int lastBreakItemIndex = -1; - for (int i = this.toWriteQueue.size() - 1; - i >= 0 && lastBreakItem < 0; i--) { - String string = this.get(i); - for (int j = string.length() - 1; j >= 0 && lastBreakItem < 0; - j--) { - char c = string.charAt(j); - switch (c) { - case ' ': - case '\t': - case '\n': { - lastBreakItem = i; - lastBreakItemIndex = j; - } - } - } - } + this.listBreakOpportunities(); /* If there is no break, there is nothing to do but write the whole * thing.*/ - if (lastBreakItem < 0) { + if (this.breakOpportunityItems.length < 1) { this.writeAll(); return; } /* Otherwise, split into two chunks. */ /* Write the first chunk. */ - writeChunk(0, 0, lastBreakItem, lastBreakItemIndex - 1); + int lastIndex = this.breakOpportunityItems.length - 1; + int lastBreakItem = this.breakOpportunityItems[lastIndex]; + int lastBreakIndex = this.breakOpportunityIndexes[lastIndex]; + writeChunk(0, 0, lastBreakItem, lastBreakIndex); write(newLine()); /* Write the second chunk. */ - writeChunk(lastBreakItem, lastBreakItemIndex + 1, + writeChunk(lastBreakItem, lastBreakIndex + 1, this.toWriteQueue.size() - 1, this.getLastItem().length() - 1); /* Clear the queue contents. */ this.toWriteQueue.clear(); } + private void listBreakOpportunities() { + int count = countBreakOpportunities(); + this.breakOpportunityItems = new int[count]; + this.breakOpportunityIndexes = new int[count]; + count = 0; + for (int i = 0; i < this.toWriteQueue.size(); i++) { + String string = this.get(i); + for (int j = 0; j < string.length(); j++) { + char c = string.charAt(j); + if (c == ' ') { + this.breakOpportunityItems[count] = i; + this.breakOpportunityIndexes[count] = j; + count ++; + } + } + } + } + + private int countBreakOpportunities() { + int count = 0; + for (int i = 0; i < this.toWriteQueue.size(); i++) { + String string = this.get(i); + for (int j = 0; j < string.length(); j++) { + char c = string.charAt(j); + if (c == ' ') { + count ++; + } + } + } + return count; + } + private void writeChunk(int startItem, int startItemIndex, int endItem, int endItemIndex) { for (int i = startItem; i <= endItem; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |