set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\serializer-2.7.0.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\batik-all-1.6.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\avalon-framework-4.2.0.jar
-set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-1.0.jar
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-1.1.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-logging-1.0.3.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jimi-1.0.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_core.jar
http://jakarta.apache.org/commons/io/
(I/O routines)
- Apache License v1.1
+ Apache License v2.0
- Apache Jakarta Commons Logging
-/*
- * ====================================================================
- *
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Commons", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
--- /dev/null
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
// load page from cache
String name = (String)pageMap.get(p);
File temp = new File(name);
- System.out.println("page serialized to: " + temp.length());
+ log.debug("page serialized to: " + temp.length());
ObjectInputStream in = new ObjectInputStream(
new BufferedInputStream(
new FileInputStream(temp)));
temp.delete();
pageMap.remove(p);
} catch (Exception e) {
- e.printStackTrace();
+ log.error(e);
}
}
}
} catch (Exception e) {
// use error handler to handle this FOP or IO Exception
- e.printStackTrace();
+ log.error(e);
}
p.clear();
iter.remove();
tempstream.close();
pageMap.put(page, fname);
} catch (Exception e) {
- e.printStackTrace();
+ log.error(e);
}
}
}
renderer.renderPage(page);
} catch (Exception e) {
// use error handler to handle this FOP or IO Exception
- e.printStackTrace();
+ log.error(e);
}
page.clear();
} else {
}
} catch (Exception e) {
// use error handler to handle this FOP or IO Exception
- e.printStackTrace();
+ log.error(e);
}
p.clear();
iter.remove();
package org.apache.fop.area;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.Constants;
import org.apache.fop.image.FopImage;
* This class represents an area trait that specifies a value for rendering.
*/
public class Trait implements Serializable {
+
+ /** Logger instance */
+ private static Log log = LogFactory.getLog(Trait.class);
+
/**
* Id reference line, not resolved.
* not sure if this is needed.
Object o = tclass.newInstance();
//return o.fromString(sTraitValue);
} catch (IllegalAccessException e1) {
- System.err.println("Can't create instance of "
+ log.error("Can't create instance of "
+ tclass.getName());
return null;
} catch (InstantiationException e2) {
- System.err.println("Can't create instance of "
+ log.error("Can't create instance of "
+ tclass.getName());
return null;
}
public boolean hasNext() {
if (curIndex == 0) {
-// System.out.println("->" + new String(ca) + "<-");
+// log.debug("->" + new String(ca) + "<-");
}
return (curIndex < endIndex);
}
if (curIndex < endIndex && nextCharCalled < 2) {
startIndex++;
nextCharCalled = 0;
-// System.out.println("removeA: " + new String(ca, startIndex, endIndex - startIndex));
+// log.debug("removeA: " + new String(ca, startIndex, endIndex - startIndex));
} else if (curIndex < endIndex) {
// copy from curIndex to end to curIndex-1
System.arraycopy(ca, curIndex, ca, curIndex - 1,
endIndex - curIndex);
endIndex--;
curIndex--;
-// System.out.println("removeB: " + new String(ca, startIndex, endIndex - startIndex));
+// log.debug("removeB: " + new String(ca, startIndex, endIndex - startIndex));
} else if (curIndex == endIndex) {
-// System.out.println("removeC: " + new String(ca, startIndex, endIndex - startIndex));
+// log.debug("removeC: " + new String(ca, startIndex, endIndex - startIndex));
endIndex--;
curIndex--;
}
}
ElementMapping.Maker fobjMaker = findFOMaker(namespaceURI, localName);
-// System.out.println("found a " + fobjMaker.toString());
+// log.debug("found a " + fobjMaker.toString());
try {
foNode = fobjMaker.make(currentFObj);
element = doc.getDocumentElement();
buildTopLevel(doc, element);
} catch (Exception e) {
- e.printStackTrace();
+ log.error("Error while trying to instantiate a DOM Document", e);
}
return doc;
}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
/**
* Base class for all property makers
- * @author unascribed
*/
public class PropertyMaker implements Cloneable {
+
+ /** Logger instance */
+ private static Log log = LogFactory.getLog(PropertyMaker.class);
+
+ /** the property ID */
protected int propId;
private boolean inherited = true;
private Map enums = null;
private Map keywords = null;
+ /** the default value for the maker */
protected String defaultValue = null;
+ /** Indicates whether the property is context-dependant and therefore can't be cached. */
protected boolean contextDep = false;
+ /** Indicates whether the property is set through a shorthand. */
protected boolean setByShorthand = false;
private int percentBase = -1;
private PropertyMaker[] shorthands = null;
protected Property defaultProperty;
protected CorrespondingPropertyMaker corresponding;
- private static Log log = LogFactory.getLog(PropertyMaker.class);
-
/**
* @return the name of the property for this Maker
*/
/**
* Set the inherited flag.
- * @param inherited
+ * @param inherited true if this is an inherited property
*/
public void setInherited(boolean inherited) {
this.inherited = inherited;
/**
* Add a keyword-equiv to the maker.
- * @param keyword
- * @param value
+ * @param keyword the keyword
+ * @param value the value to be used when the keyword is specified
*/
public void addKeyword(String keyword, String value) {
if (keywords == null) {
/**
* Add a enum constant.
- * @param constant
- * @param value
+ * @param constant the enum constant
+ * @param value the Property value to use when the constant is specified
*/
public void addEnum(String constant, Property value) {
if (enums == null) {
/**
* Add a subproperty to this maker.
- * @param subproperty
+ * @param subproperty the PropertyMaker for the subproperty
*/
public void addSubpropMaker(PropertyMaker subproperty) {
throw new RuntimeException("Unable to add subproperties " + getClass());
/**
* Set the default value for this maker.
- * @param defaultValue
+ * @param defaultValue the default value
* @param contextDep true when the value context dependent and
* must not be cached.
*/
/**
* Set the percent base identifier for this maker.
- * @param percentBase
+ * @param percentBase the percent base (ex. LengthBase.FONTSIZE)
*/
public void setPercentBase(int percentBase) {
this.percentBase = percentBase;
* makers. It should be true for the subproperties which must be
* assigned a value when the base property is assigned a attribute
* value directly.
- * @param setByShorthand
+ * @param setByShorthand true if this subproperty must be set when the base property is set
*/
public void setByShorthand(boolean setByShorthand) {
this.setByShorthand = setByShorthand;
return null;
}
- /*
+ /**
* If the property is a relative property with a corresponding absolute
* value specified, the absolute value is used. This is also true of
* the inheritance priority (I think...)
* If the property is an "absolute" property and it isn't specified, then
* we try to compute it from the corresponding relative property: this
* happens in computeProperty.
+ * @param propertyList the applicable property list
+ * @param tryInherit true if inherited properties should be examined.
+ * @return the property value
+ * @throws PropertyException if there is a problem evaluating the property
*/
public Property findProperty(PropertyList propertyList,
boolean tryInherit)
- throws PropertyException
- {
+ throws PropertyException {
Property p = null;
if (log.isTraceEnabled()) {
* Is 0 when retriving a base property.
* @param propertyList The PropertyList object being built for this FO.
* @param tryInherit true if inherited properties should be examined.
- * @param tryDefault true if the default value should be returned.
+ * @param tryDefault true if the default value should be returned.
+ * @return the property value
+ * @throws PropertyException if there is a problem evaluating the property
*/
public Property get(int subpropertyId, PropertyList propertyList,
boolean tryInherit, boolean tryDefault)
- throws PropertyException
- {
+ throws PropertyException {
Property p = findProperty(propertyList, tryInherit);
if (p == null && tryDefault) { // default value for this FO!
* @param pl the PropertyList containing the property. (TODO: explain
* what this is used for, or remove it from the signature.)
* @return an object implementing the PercentBase interface.
+ * @throws PropertyException if there is a problem while evaluating the base property
*/
public PercentBase getPercentBase(FObj fo, PropertyList pl) throws PropertyException {
- if (percentBase == -1)
+ if (percentBase == -1) {
return null;
- return new LengthBase(fo, pl, percentBase);
+ } else {
+ return new LengthBase(fo, pl, percentBase);
+ }
}
/**
newProp = convertProperty(newProp, propertyList, fo);
}
if (newProp == null) {
- throw new org.apache.fop.fo.expr.PropertyException("No conversion defined " + pvalue);
+ throw new org.apache.fop.fo.expr.PropertyException(
+ "No conversion defined " + pvalue);
}
return newProp;
} catch (PropertyException propEx) {
public Property convertShorthandProperty(PropertyList propertyList,
Property prop, FObj fo)
- throws PropertyException
- {
+ throws PropertyException {
Property pret = convertProperty(prop, propertyList, fo);
if (pret == null) {
// If value is a name token, may be keyword or Enum
String sval = prop.getNCname();
if (sval != null) {
- // System.err.println("Convert shorthand ncname " + sval);
+ //log.debug("Convert shorthand ncname " + sval);
pret = checkEnumValues(sval);
if (pret == null) {
/* Check for keyword shorthand values to be substituted. */
String pvalue = checkValueKeywords(sval);
if (!pvalue.equals(sval)) {
- // System.err.println("Convert shorthand keyword" + pvalue);
+ // log.debug("Convert shorthand keyword" + pvalue);
// Substituted a value: must parse it
- Property p =
- PropertyParser.parse(pvalue,
+ Property p = PropertyParser.parse(pvalue,
new PropertyInfo(this,
propertyList,
fo));
}
if (pret != null) {
/*
- * System.err.println("Return shorthand value " + pret.getString() +
+ * log.debug("Return shorthand value " + pret.getString() +
* " for " + getPropName());
*/
}
* return an appropriate border-right-width Property object.
* @param propertyList the collection of properties to be considered
* @return the Property, if found, the correspons, otherwise, null
+ * @throws PropertyException if there is a problem while evaluating the shorthand
*/
public Property getShorthand(PropertyList propertyList)
- throws PropertyException
- {
+ throws PropertyException {
if (shorthands == null) {
return null;
}
return null;
}
+ /** @return the name of the property this maker is used for. */
public String getName() {
return FOPropertyMapping.getPropertyName(propId);
}
/**
* Return a clone of the makers. Used by useGeneric() to clone the
* subproperty makers of the generic compound makers.
+ * @see java.lang.Object#clone()
*/
public Object clone() {
try {
if (value.charAt(vlen) == q1) {
return new StringProperty(value.substring(1, vlen));
}
- System.err.println("Warning String-valued property starts with quote"
+ log.warn("String-valued property starts with quote"
+ " but doesn't end with quote: "
+ value);
// fall through and use the entire value, including first quote
*/
public StringProperty(String str) {
this.str = str;
- // System.err.println("Set StringProperty: " + str);
+ // log.debug("Set StringProperty: " + str);
}
/**
* @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
*/
public void startElement(String uri, String localName, String qName,
- Attributes attributes) {
+ Attributes attributes) throws SAXException {
if (localName.equals("font-metrics")) {
if ("TYPE0".equals(attributes.getValue("type"))) {
multiFont = new MultiByteFont();
singleFont.setWidth(Integer.parseInt(attributes.getValue("idx")),
Integer.parseInt(attributes.getValue("wdt")));
} catch (NumberFormatException ne) {
- System.out.println("Malformed width in metric file: "
- + ne.getMessage());
+ throw new SAXException("Malformed width in metric file: "
+ + ne.getMessage(), ne);
}
} else if ("pair".equals(localName)) {
currentKerning.put(new Integer(attributes.getValue("kpx2")),
}
}
- private int getInt(String str) {
+ private int getInt(String str) throws SAXException {
int ret = 0;
try {
ret = Integer.parseInt(str);
} catch (Exception e) {
- /**@todo log this exception */
+ throw new SAXException("Error while parsing integer value: " + str, e);
}
return ret;
}
/**
* @see org.xml.sax.ContentHandler#endElement(String, String, String)
*/
- public void endElement(String uri, String localName, String qName) {
+ public void endElement(String uri, String localName, String qName) throws SAXException {
String content = text.toString().trim();
if ("font-name".equals(localName)) {
returnFont.setFontName(content);
FontTriplet triplet = (FontTriplet) triplets.get(c);
int weight = FontUtil.parseCSS2FontWeight(triplet.getWeight());
- //System.out.println("Registering: "+triplet+" weight="+weight);
+ if (log.isDebugEnabled()) {
+ log.debug("Registering: " + triplet + " weight=" + weight);
+ }
fontInfo.addFontProperties(internalName,
triplet.getName(),
triplet.getStyle(),
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.apache.fop.fonts;
-//Java
import java.util.Map;
-//FOP
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class is used to defer the loading of a font until it is really used.
*/
public class LazyFont extends Typeface implements FontDescriptor {
+ private static Log log = LogFactory.getLog(LazyFont.class);
+
private String metricsFileName = null;
private String fontEmbedPath = null;
private boolean useKerning = false;
if (realFont instanceof FontDescriptor) {
realFontDescriptor = (FontDescriptor) realFont;
}
- // System.out.println("Metrics " + metricsFileName + " loaded.");
+ // log.debug("Metrics " + metricsFileName + " loaded.");
} catch (Exception ex) {
- ex.printStackTrace();
- /**@todo Log this exception */
- //log.error("Failed to read font metrics file "
- // + metricsFileName
- // + " : " + ex.getMessage());
+ log.error("Failed to read font metrics file "
+ + metricsFileName, ex);
}
}
}
usedGlyphsIndex.put(new Integer(usedGlyphsCount),
new Integer(retIdx));
retIdx = usedGlyphsCount;
- // System.out.println(c+"("+(int)c+") = "+retIdx);
usedGlyphsCount++;
} else {
retIdx = newIdx.intValue();
offset = in.readTTFULong();
length = in.readTTFULong();
String tagStr = new String(tag, "ISO-8859-1");
- // System.err.println("tag='" + tagStr + "'");
- //System.out.println(this.toString());
return tagStr;
}
case LengthBase.CONTAINING_REFAREA_WIDTH:
return getReferenceAreaIPD();
default:
- log.error("Unknown base type for LengthBase:" + lengthBase);
- new Exception().printStackTrace();
+ log.error(new Exception("Unknown base type for LengthBase:" + lengthBase));
return 0;
}
} else {
ElementListObserver.observe(elementList, "breaker", null);
}
+ /**
+ * Starts the page breaking process.
+ * @param flowBPD the constant available block-progression-dimension (used for every part)
+ */
public void doLayout(int flowBPD) {
LayoutContext childLC = createLayoutContext();
childLC.setStackLimit(new MinOptMax(flowBPD));
- //System.err.println("Vertical alignment: " +
- // currentSimplePageMaster.getRegion(FO_REGION_BODY).getDisplayAlign());
if (getCurrentDisplayAlign() == Constants.EN_X_FILL) {
//EN_FILL is non-standard (by LF)
alignment = Constants.EN_JUSTIFY;
private int optimizeLineLength(KnuthSequence effectiveList, int startElementIndex, int endElementIndex) {
ListIterator effectiveListIterator;
// optimize line length
- //System.out.println(" ");
int boxCount = 0;
int accumulatedLineLength = 0;
int greatestMinimumLength = 0;
int averageLineLength = 0;
if (accumulatedLineLength > 0 && boxCount > 0) {
averageLineLength = (int) (accumulatedLineLength / boxCount);
- //System.out.println("PSLM> lunghezza media = " + averageLineLength);
+ log.debug("Average line length = " + averageLineLength);
if (averageLineLength < greatestMinimumLength) {
averageLineLength = greatestMinimumLength;
- //System.out.println(" correzione, ora e' = " + averageLineLength);
+ log.debug(" Correction to: " + averageLineLength);
}
}
return averageLineLength;
Position lastPos = null;
while (parentIter.hasNext()) {
pos = (Position) parentIter.next();
- //System.out.println("pos = " + pos.getClass().getName());
if (pos.getIndex() >= 0) {
if (firstPos == null) {
firstPos = pos;
// pos was created by this BlockLM and was inside a penalty
// allowing or forbidding a page break
// nothing to do
- /* LF *///System.out.println(" penalty");
} else {
// innerPosition was created by another LM
positionList.add(innerPosition);
lastLM = innerPosition.getLM();
- /* LF *///System.out.println(" " +
- // innerPosition.getClass().getName());
}
}
// // the last item inside positionList is a LeafPosition
// // (a LineBreakPosition, more precisely); this means that
// // the whole paragraph is on the same page
- // System.out.println("paragrafo intero");
// childPosIter = new KnuthPossPosIter(storedList, 0,
// storedList.size());
//} else {
lastLM = element.getLayoutManager();
}
}
- //System.out.println("addAreas riferito a storedList da " +
- // iFirst + " a " + iLast);
- //System.out.println("splitLength= " + splitLength
- // + " (" + neededUnits(splitLength) + " unita') "
- // + (neededUnits(splitLength) * bpUnit - splitLength) + " spazi");
+ //log.debug("Adding areas from " + iFirst + " to " + iLast);
+ //log.debug("splitLength= " + splitLength
+ // + " (" + neededUnits(splitLength) + " units') "
+ // + (neededUnits(splitLength) * bpUnit - splitLength)
+ // + " spacing");
// add space before and / or after the paragraph
// to reach a multiple of bpUnit
if (bSpaceBefore && bSpaceAfter) {
+ foBlockSpaceAfter.min)
* bpUnit - splitLength;
}
- //System.out.println("spazio prima = " + adjustedSpaceBefore
- // + " spazio dopo = " + adjustedSpaceAfter + " totale = " +
+ //log.debug("space before = " + adjustedSpaceBefore
+ // + " space after = " + adjustedSpaceAfter + " total = " +
// (adjustedSpaceBefore + adjustedSpaceAfter + splitLength));
childPosIter = new KnuthPossPosIter(splitList, 0, splitList
.size());
*/
public void addAreas(PositionIterator parentIter,
LayoutContext layoutContext) {
- //System.out.println(" BLM.addAreas>");
getParentArea(null);
// if this will create the first block area in a page
// // the last item inside positionList is a LeafPosition
// // (a LineBreakPosition, more precisely); this means that
// // the whole paragraph is on the same page
- // System.out.println("paragrafo intero");
// childPosIter = new KnuthPossPosIter(storedList, 0,
// storedList.size());
//} else {
lastLM = element.getLayoutManager();
}
}
- //System.out.println("addAreas riferito a storedList da " +
- // iFirst + " a " + iLast);
- //System.out.println("splitLength= " + splitLength
- // + " (" + neededUnits(splitLength) + " unita') "
- // + (neededUnits(splitLength) * bpUnit - splitLength) + " spazi");
+ //log.debug("Adding areas from " + iFirst + " to " + iLast);
+ //log.debug("splitLength= " + splitLength
+ // + " (" + neededUnits(splitLength) + " units') "
+ // + (neededUnits(splitLength) * bpUnit - splitLength)
+ // + " spacing");
// add space before and / or after the paragraph
// to reach a multiple of bpUnit
if (bSpaceBefore && bSpaceAfter) {
+ foSpaceAfter.min)
* bpUnit - splitLength;
}
- //System.out.println("spazio prima = " + adjustedSpaceBefore
+ //log.debug("spazio prima = " + adjustedSpaceBefore
// + " spazio dopo = " + adjustedSpaceAfter + " totale = " +
// (adjustedSpaceBefore + adjustedSpaceAfter + splitLength));
childPosIter = new KnuthPossPosIter(splitList, 0, splitList
* @see LayoutManager#getNextKnuthElements(LayoutContext, int)
*/
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
- /* LF *///System.err.println("BLM.getNextKnuthElements> keep-together = "
+ //log.debug("BLM.getNextKnuthElements> keep-together = "
// + layoutProps.keepTogether.getType());
- /* LF *///System.err.println(" keep-with-previous = " +
+ //log.debug(" keep-with-previous = " +
// layoutProps.keepWithPrevious.getType());
- /* LF *///System.err.println(" keep-with-next = " +
+ //log.debug(" keep-with-next = " +
// layoutProps.keepWithNext.getType());
BlockLevelLayoutManager curLM; // currently active LM
BlockLevelLayoutManager prevLM = null; // previously active LM
* @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement)
*/
public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) {
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> " + adj);
-/*LF*/ //System.out.println(" lastElement e' " + (lastElement.isPenalty()
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> " + adj);
+/*LF*/ //log.debug(" lastElement e' " + (lastElement.isPenalty()
// ? "penalty" : (lastElement.isGlue() ? "glue" : "box" )));
-/*LF*/ //System.out.println(" position e' " + lastElement.getPosition().getClass().getName());
-/*LF*/ //System.out.println(" " + (bpUnit > 0 ? "unit" : ""));
+/*LF*/ //log.debug(" position e' " + lastElement.getPosition().getClass().getName());
+/*LF*/ //log.debug(" " + (bpUnit > 0 ? "unit" : ""));
Position innerPosition = ((NonLeafPosition) lastElement.getPosition()).getPosition();
if (innerPosition == null && lastElement.isGlue()) {
if (((KnuthGlue) lastElement).getAdjustmentClass() == SPACE_BEFORE_ADJUSTMENT) {
// this adjustment applies to space-before
adjustedSpaceBefore += adj;
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> spazio prima: " + adj);
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> spazio prima: " + adj);
} else {
// this adjustment applies to space-after
adjustedSpaceAfter += adj;
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> spazio dopo: " + adj);
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> spazio dopo: " + adj);
}
return adj;
} else if (innerPosition instanceof MappingPosition) {
MappingPosition mappingPos = (MappingPosition)innerPosition;
if (lastElement.isGlue()) {
// lastElement is a glue
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> bpunit con glue");
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> bpunit con glue");
ListIterator storedListIterator = storedList.listIterator(
mappingPos.getFirstIndex());
int newAdjustment = 0;
newAdjustment += ((BlockLevelLayoutManager)storedElement
.getLayoutManager()).negotiateBPDAdjustment(
adj - newAdjustment, storedElement);
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> (progressivo) righe: "
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> (progressivo) righe: "
// + newAdjustment);
}
}
// lastElement is a penalty: this means that the paragraph
// has been split between consecutive pages:
// this may involve a change in the number of lines
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> bpunit con penalty");
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> bpunit con penalty");
KnuthPenalty storedPenalty = (KnuthPenalty)
storedList.get(mappingPos.getLastIndex());
if (storedPenalty.getW() > 0) {
// the original penalty has width > 0
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> chiamata passata");
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> chiamata passata");
return ((BlockLevelLayoutManager)storedPenalty.getLayoutManager())
.negotiateBPDAdjustment(storedPenalty.getW(),
(KnuthElement)storedPenalty);
} else {
// the original penalty has width = 0
// the adjustment involves only the spaces before and after
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> chiamata gestita");
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> chiamata gestita");
return adj;
}
}
int returnValue = ((BlockLevelLayoutManager)lastElement.getLayoutManager())
.negotiateBPDAdjustment(adj, lastElement);
lastElement.setPosition(savedPos);
-/*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> righe: " + returnValue);
+/*LF*/ //log.debug(" BLM.negotiateBPDAdjustment> righe: " + returnValue);
return returnValue;
} else {
// this should never happen
* @see BlockLevelLayoutManager#discardSpace(KnuthGlue)
*/
public void discardSpace(KnuthGlue spaceGlue) {
- //System.out.println(" BLM.discardSpace> " + spaceGlue.getPosition().getClass().getName());
+ //log.debug(" BLM.discardSpace> " + spaceGlue.getPosition().getClass().getName());
Position innerPosition = ((NonLeafPosition) spaceGlue.getPosition()).getPosition();
if (innerPosition == null || innerPosition.getLM() == this) {
* @see LayoutManager#getChangedKnuthElements(List, int)
*/
public LinkedList getChangedKnuthElements(List oldList, int alignment) {
-/*LF*/ //System.out.println("");
-/*LF*/ //System.out.println(" BLM.getChangedKnuthElements> inizio: oldList.size() = "
+/*LF*/ //log.debug("");
+/*LF*/ //log.debug(" BLM.getChangedKnuthElements> inizio: oldList.size() = "
// + oldList.size());
ListIterator oldListIterator = oldList.listIterator();
KnuthElement returnedElement;
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement)oldListIterator.next();
Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition();
- //System.out.println(" BLM> unwrapping: "
+ //log.debug(" BLM> unwrapping: "
// + (oldElement.isBox() ? "box " : (oldElement.isGlue() ? "glue " : "penalty"))
// + " creato da " + oldElement.getLayoutManager().getClass().getName());
- //System.out.println(" BLM> unwrapping: "
+ //log.debug(" BLM> unwrapping: "
// + oldElement.getPosition().getClass().getName());
if (innerPosition != null) {
// oldElement was created by a descendant of this BlockLM
}
int iLast = ((MappingPosition) el.getPosition()).getLastIndex();
- //System.out.println(" si usa storedList da " + iFirst + " a " + iLast
+ //log-debug(" si usa storedList da " + iFirst + " a " + iLast
// + " compresi su " + storedList.size() + " elementi totali");
workList = storedList.subList(iFirst, iLast + 1);
}
ListIterator workListIterator = workList.listIterator();
- //System.out.println("");
- //System.out.println(" BLM.getChangedKnuthElements> workList.size() = "
+ //log.debug(" BLM.getChangedKnuthElements> workList.size() = "
// + workList.size() + " da 0 a " + (workList.size() - 1));
while (workListIterator.hasNext()) {
currElement = (KnuthElement) workListIterator.next();
- //System.out.println("elemento n. " + workListIterator.previousIndex()
+ //log.debug("elemento n. " + workListIterator.previousIndex()
// + " nella workList");
if (prevElement != null
&& prevElement.getLayoutManager() != currElement.getLayoutManager()) {
currElement.getLayoutManager();
boolean bSomethingAdded = false;
if (prevLM != this) {
- //System.out.println(" BLM.getChangedKnuthElements> chiamata da "
+ //log.debug(" BLM.getChangedKnuthElements> chiamata da "
// + fromIndex + " a " + workListIterator.previousIndex() + " su "
// + prevLM.getClass().getName());
returnedList.addAll(prevLM.getChangedKnuthElements(workList.subList(
} else {
// prevLM == this
// do nothing
- //System.out.println(" BLM.getChangedKnuthElements> elementi propri, "
+ //log.debug(" BLM.getChangedKnuthElements> elementi propri, "
// + "ignorati, da " + fromIndex + " a " + workListIterator.previousIndex()
// + " su " + prevLM.getClass().getName());
}
BlockLevelLayoutManager currLM = (BlockLevelLayoutManager)
currElement.getLayoutManager();
if (currLM != this) {
- //System.out.println(" BLM.getChangedKnuthElements> chiamata da " + fromIndex
+ //log.debug(" BLM.getChangedKnuthElements> chiamata da " + fromIndex
// + " a " + oldList.size() + " su " + currLM.getClass().getName());
returnedList.addAll(currLM.getChangedKnuthElements(
workList.subList(fromIndex, workList.size()), alignment));
if (returnedList.size() > 0) {
returnedList.removeLast();
}
- //System.out.println(" BLM.getChangedKnuthElements> elementi propri, ignorati, da "
+ //log.debug(" BLM.getChangedKnuthElements> elementi propri, ignorati, da "
// + fromIndex + " a " + workList.size());
}
}
}
}
- //System.out.println(" BLM.getChangedKnuthElements> intermedio: returnedList.size() = "
+ //log.debug(" BLM.getChangedKnuthElements> intermedio: returnedList.size() = "
// + returnedList.size());
/* estensione: conversione complessiva */
}
}
- //System.out.println(" BLM.getChangedKnuthElements> finished: returnList.size() = "
+ //log.debug(" BLM.getChangedKnuthElements> finished: returnList.size() = "
// + returnList.size());
return returnList;
}
CommonBorderPaddingBackground.BEFORE),
RelSide.BEFORE, isFirst, false, this));
}
- //TODO Handle conditionality
- /*
- int bpBefore = borderAndPadding.getBorderBeforeWidth(false)
- + borderAndPadding.getPaddingBefore(false, this);
- if (bpBefore > 0) {
- returnList.add(new KnuthBox(bpBefore, getAuxiliaryPosition(), true));
- }*/
}
}
.getWidth(),
RelSide.AFTER, false, isLast, this));
}
- //TODO Handle conditionality
- /*
- int bpAfter = borderAndPadding.getBorderAfterWidth(false)
- + borderAndPadding.getPaddingAfter(false, this);
- if (bpAfter > 0) {
- returnList.add(new KnuthBox(bpAfter, getAuxiliaryPosition(), true));
- }*/
}
}
}
protected LinkedList createUnitElements(LinkedList oldList) {
- //System.out.println(" ");
- //System.out.println("Start conversion: " + oldList.size()
+ //log.debug("Start conversion: " + oldList.size()
// + " elements, space-before.min=" + layoutProps.spaceBefore.getSpace().min
// + " space-after.min=" + layoutProps.spaceAfter.getSpace().min);
// add elements at the beginning and at the end of oldList
MinOptMax totalUnits = new MinOptMax(0);
LinkedList newList = new LinkedList();
- //System.out.println(" ");
- //System.out.println(" Prima scansione");
+ //log.debug(" Prima scansione");
// scan the list once to compute total min, opt and max length
ListIterator oldListIterator = oldList.listIterator();
while (oldListIterator.hasNext()) {
KnuthElement element = (KnuthElement) oldListIterator.next();
if (element.isBox()) {
totalLength.add(new MinOptMax(element.getW()));
- //System.out.println("box " + element.getW());
+ //log.debug("box " + element.getW());
} else if (element.isGlue()) {
totalLength.min -= ((KnuthGlue) element).getZ();
totalLength.max += ((KnuthGlue) element).getY();
//leafValue = ((LeafPosition) element.getPosition()).getLeafPos();
- //System.out.println("glue " + element.getW() + " + "
+ //log.debug("glue " + element.getW() + " + "
// + ((KnuthGlue) element).getY() + " - " + ((KnuthGlue) element).getZ());
} else {
- //System.out.println((((KnuthPenalty)element).getP() == KnuthElement.INFINITE
+ //log.debug((((KnuthPenalty)element).getP() == KnuthElement.INFINITE
// ? "PENALTY " : "penalty ") + element.getW());
}
}
totalUnits = new MinOptMax(neededUnits(totalLength.min),
neededUnits(totalLength.opt),
neededUnits(totalLength.max));
- //System.out.println(" totalLength= " + totalLength);
- //System.out.println(" unita'= " + totalUnits);
+ //log.debug(" totalLength= " + totalLength);
+ //log.debug(" unita'= " + totalUnits);
- //System.out.println(" ");
- //System.out.println(" Seconda scansione");
+ //log.debug(" Seconda scansione");
// scan the list once more, stopping at every breaking point
// in order to compute partial min, opt and max length
// and create the new elements
int uNewShrink = (unitsBeforeBreak.opt - unitsBeforeBreak.min)
- (unsuppressibleUnits.opt - unsuppressibleUnits.min);
- //System.out.println("("
+ //log.debug("("
// + unsuppressibleUnits.min + "-" + unsuppressibleUnits.opt + "-"
// + unsuppressibleUnits.max + ") "
// + " -> " + unitsBeforeBreak.min + "-" + unitsBeforeBreak.opt + "-"
mappingPos,
false));
unsuppressibleUnits.add(new MinOptMax(uNewNormal - uLengthChange));
- //System.out.println(" box " + (uNewNormal - uLengthChange));
+ //log.debug(" box " + (uNewNormal - uLengthChange));
// new infinite penalty, glue and box, if necessary
if (uNewStretch - uStretchChange > 0
LINE_NUMBER_ADJUSTMENT,
mappingPos,
false));
- //System.out.println(" PENALTY");
- //System.out.println(" glue 0 " + iStretchUnits + " " + iShrinkUnits);
+ //log.debug(" PENALTY");
+ //log.debug(" glue 0 " + iStretchUnits + " " + iShrinkUnits);
unsuppressibleUnits.max += iStretchUnits;
unsuppressibleUnits.min -= iShrinkUnits;
if (!oldListIterator.hasNext()) {
newList.add(new KnuthBox(0,
mappingPos,
false));
- //System.out.println(" box 0");
+ //log.debug(" box 0");
}
}
LINE_NUMBER_ADJUSTMENT,
mappingPos,
false));
- //System.out.println(" PENALTY");
- //System.out.println(" glue 0 " + uStretchChange + " " + uShrinkChange);
- //System.out.println(" penalty " + uLengthChange + " * unit");
- //System.out.println(" glue 0 " + (- uStretchChange) + " "
+ //log.debug(" PENALTY");
+ //log.debug(" glue 0 " + uStretchChange + " " + uShrinkChange);
+ //log.debug(" penalty " + uLengthChange + " * unit");
+ //log.debug(" glue 0 " + (- uStretchChange) + " "
// + (- uShrinkChange));
} else if (oldListIterator.hasNext()) {
// new penalty
0, false,
mappingPos,
false));
- //System.out.println(" penalty " + uLengthChange + " * unit");
+ //log.debug(" penalty " + uLengthChange + " * unit");
}
// update firstIndex
firstIndex = lastIndex + 1;
wrongBox.getPosition(), false));
newList.addFirst(new KnuthGlue(decreasedLength, 0, 0, SPACE_BEFORE_ADJUSTMENT,
wrongBox.getPosition(), false));
- //System.out.println(" rimosso box " + neededUnits(wrongBox.getW()));
- //System.out.println(" aggiunto glue " + neededUnits(decreasedLength) + " 0 0");
- //System.out.println(" aggiunto box " + neededUnits(
+ //log.debug(" rimosso box " + neededUnits(wrongBox.getW()));
+ //log.debug(" aggiunto glue " + neededUnits(decreasedLength) + " 0 0");
+ //log.debug(" aggiunto box " + neededUnits(
// wrongBox.getW() - decreasedLength));
}
// insert the correct glue
newList.addLast(new KnuthGlue(decreasedLength, 0, 0, SPACE_AFTER_ADJUSTMENT,
wrongBox.getPosition(), false));
- //System.out.println(" rimosso box " + neededUnits(wrongBox.getW()));
- //System.out.println(" aggiunto box " + neededUnits(
+ //log.debug(" rimosso box " + neededUnits(wrongBox.getW()));
+ //log.debug(" aggiunto box " + neededUnits(
// wrongBox.getW() - decreasedLength));
- //System.out.println(" aggiunto glue " + neededUnits(decreasedLength) + " 0 0");
+ //log.debug(" aggiunto glue " + neededUnits(decreasedLength) + " 0 0");
}
return newList;
if (bHasNext) {
Object retObj = getPos(nextObj);
lookAhead();
- //System.out.println(retObj);
return retObj;
} else {
throw new NoSuchElementException("PosIter");
// get elements from curLM
returnedList = curLM.getNextKnuthElements(childLC, alignment);
- //System.out.println("FLM.getNextKnuthElements> returnedList.size() = "
+ //log.debug("FLM.getNextKnuthElements> returnedList.size() = "
// + returnedList.size());
// "wrap" the Position inside each element
&& ((KnuthPenalty)returnedList.getLast()).getP()
== -KnuthElement.INFINITE) {
// a descendant of this flow has break-after
-/*LF*/ //System.out.println("FLM - break after!!");
+/*LF*/ //log.debug("FLM - break after!!");
return returnList;
}
/*LF*/ }
if (addedPositions == lineLayouts.getLineCount(activePossibility)) {
activePossibility++;
addedPositions = 0;
- //System.out.println(" ");
}
- //System.out.println("LLM> (" + (lineLayouts.getLineNumber(activePossibility) - addedPositions) + ") difference = " + difference + " ratio = " + ratio);
+ //log.debug("LLM> (" + (lineLayouts.getLineNumber(activePossibility) - addedPositions) + ") difference = " + difference + " ratio = " + ratio);
lineLayouts.addBreakPosition(makeLineBreakPosition(par,
(bestActiveNode.line > 1 ? bestActiveNode.previous.position + 1: 0),
bestActiveNode.position,
if (pageAlignment == EN_JUSTIFY) {
// leave all active nodes and find the optimum line number
- //System.out.println("LBA.filterActiveNodes> " + activeNodeCount + " layouts");
+ //log.debug("LBA.filterActiveNodes> " + activeNodeCount + " layouts");
for (int i = startLine; i < endLine; i++) {
for (KnuthNode node = getNode(i); node != null; node = node.next) {
- //System.out.println(" + lines = " + node.line + " demerits = " + node.totalDemerits);
+ //log.debug(" + lines = " + node.line + " demerits = " + node.totalDemerits);
bestActiveNode = compareNodes(bestActiveNode, node);
}
}
// scan the node set once again and remove some nodes
- //System.out.println("LBA.filterActiveList> layout selection");
+ //log.debug("LBA.filterActiveList> layout selection");
for (int i = startLine; i < endLine; i++) {
for (KnuthNode node = getNode(i); node != null; node = node.next) {
//if (Math.abs(node.line - bestActiveNode.line) > maxDiff) {
//if (false) {
if (node.line != bestActiveNode.line
&& node.totalDemerits > MAX_DEMERITS) {
- //System.out.println(" XXX lines = " + node.line + " demerits = " + node.totalDemerits);
+ //log.debug(" XXX lines = " + node.line + " demerits = " + node.totalDemerits);
removeNode(i, node);
} else {
- //System.out.println(" ok lines = " + node.line + " demerits = " + node.totalDemerits);
+ //log.debug(" ok lines = " + node.line + " demerits = " + node.totalDemerits);
}
}
}
shorter or longer lines */
//TODO This code snippet is disabled. Reenable?
if (false && alignment == EN_JUSTIFY && textAlignment == EN_JUSTIFY) {
- //System.out.println("LLM.getNextKnuthElements> layouts with more lines? " + lineLayouts.canUseMoreLines());
- //System.out.println(" layouts with fewer lines? " + lineLayouts.canUseLessLines());
+ //log.debug("LLM.getNextKnuthElements> layouts with more lines? " + lineLayouts.canUseMoreLines());
+ //log.debug(" layouts with fewer lines? " + lineLayouts.canUseLessLines());
if (!lineLayouts.canUseMoreLines()) {
alg.resetAlgorithm();
lineLayouts.savePossibilities(true);
lineLayouts.restorePossibilities();
iLineWidth = savedLineWidth;
}
- //System.out.println("LLM.getNextKnuthElements> now, layouts with more lines? " + lineLayouts.canUseMoreLines());
- //System.out.println(" now, layouts with fewer lines? " + lineLayouts.canUseLessLines());
+ //log.debug("LLM.getNextKnuthElements> now, layouts with more lines? " + lineLayouts.canUseMoreLines());
+ //log.debug(" now, layouts with fewer lines? " + lineLayouts.canUseLessLines());
}
}
return lineLayouts;
breaker.add(new KnuthPenalty(0, 0, false, elementPosition, false));
}
- //System.out.println("first=" + nFirstLines + " inner=" + nInnerLines
+ //log.debug("first=" + nFirstLines + " inner=" + nInnerLines
// + " optional=" + nOptionalLines + " eliminable=" + nEliminableLines
// + " last=" + nLastLines
// + " (condOpt=" + nConditionalOptionalLines + " condEl=" + nConditionalEliminableLines + ")");
//}
//int lineNumberDifference = (int)((double) totalAdj / constantLineHeight);
int lineNumberDifference = (int) Math.round((double) totalAdj / constantLineHeight + (adj > 0 ? - 0.4 : 0.4));
- //System.out.println(" LLM> variazione calcolata = " + ((double) totalAdj / constantLineHeight) + " variazione applicata = " + lineNumberDifference);
+ //log.debug(" LLM> variazione calcolata = " + ((double) totalAdj / constantLineHeight) + " variazione applicata = " + lineNumberDifference);
lineLayouts = (LineLayoutPossibilities)lineLayoutsList.get(pos.getLeafPos());
lineNumberDifference = lineLayouts.applyLineCountAdjustment(lineNumberDifference);
return lineNumberDifference * constantLineHeight;
LinkedList returnList = new LinkedList();
for (int p = 0; p < knuthParagraphs.size(); p++) {
lineLayouts = (LineLayoutPossibilities)lineLayoutsList.get(p);
- //System.out.println("demerits of the chosen layout: " + lineLayouts.getChosenDemerits());
+ //log.debug("demerits of the chosen layout: " + lineLayouts.getChosenDemerits());
for (int i = 0; i < lineLayouts.getChosenLineCount(); i++) {
if (!((BlockLevelLayoutManager) parentLM).mustKeepTogether()
&& i >= fobj.getOrphans()
returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false));
}
LineBreakPosition lbp = (LineBreakPosition) lineLayouts.getChosenPosition(i);
- //System.out.println("LLM.getChangedKnuthElements> lineWidth= " + lbp.lineWidth + " difference= " + lbp.difference);
- //System.out.println(" shrink= " + lbp.availableShrink + " stretch= " + lbp.availableStretch);
+ //log.debug("LLM.getChangedKnuthElements> lineWidth= " + lbp.lineWidth + " difference= " + lbp.difference);
+ //log.debug(" shrink= " + lbp.availableShrink + " stretch= " + lbp.availableStretch);
- //System.out.println("linewidth= " + lbp.lineWidth + " difference= " + lbp.difference + " indent= " + lbp.startIndent);
+ //log.debug("linewidth= " + lbp.lineWidth + " difference= " + lbp.difference + " indent= " + lbp.startIndent);
MinOptMax contentIPD;
if (alignment == EN_JUSTIFY) {
contentIPD = new MinOptMax(
updatedRatio = (float) updatedDifference / lbp.availableShrink;
}
lc.setIPDAdjust(updatedRatio);
- //System.out.println("LLM.addAreas> old difference = " + lbp.difference + " new difference = " + updatedDifference);
- //System.out.println(" old ratio = " + lbp.ipdAdjust + " new ratio = " + updatedRatio);
+ //log.debug("LLM.addAreas> old difference = " + lbp.difference + " new difference = " + updatedDifference);
+ //log.debug(" old ratio = " + lbp.ipdAdjust + " new ratio = " + updatedRatio);
} else if (false && textAlignment == EN_CENTER) {
// re-compute indent
int updatedIndent = lbp.startIndent
chosenIndex = optimumIndex;
}
}
-/*LF*/ //System.out.println(">> minLineCount = " + getMinLineCount() + " optLineCount = " + getOptLineCount() + " maxLineCount() = " + getMaxLineCount());
+ //log.debug(">> minLineCount = " + getMinLineCount()
+ // + " optLineCount = " + getOptLineCount() + " maxLineCount() = " + getMaxLineCount());
}
public void addBreakPosition(Position pos, int i) {
while (oldListIterator.hasNext()) {
oldElement = (KnuthElement)oldListIterator.next();
Position innerPosition = ((NonLeafPosition) oldElement.getPosition()).getPosition();
- //System.out.println(" BLM> unwrapping: " + (oldElement.isBox()
+ //log.debug(" BLM> unwrapping: " + (oldElement.isBox()
// ? "box " : (oldElement.isGlue() ? "glue " : "penalty"))
// + " creato da " + oldElement.getLayoutManager().getClass().getName());
- //System.out.println(" BLM> unwrapping: "
+ //log.debug(" BLM> unwrapping: "
// + oldElement.getPosition().getClass().getName());
if (innerPosition != null) {
// oldElement was created by a descendant of this BlockLM
TableBody body = null;
while (iterator.hasNext()) {
Position pos = (Position)iterator.next();
- //System.out.println(pos);
if (pos instanceof TableContentPosition) {
TableContentPosition tcpos = (TableContentPosition)pos;
lst.add(tcpos);
- //System.out.println(tcpos.row);
GridUnitPart part = (GridUnitPart)tcpos.gridUnitParts.get(0);
if (body == null) {
body = part.pgu.getBody();
}
if (tcpos.getFlag(TableContentPosition.FIRST_IN_ROWGROUP)
&& tcpos.row.getFlag(EffRow.FIRST_IN_BODY)) {
- //System.out.println("pgu is first in body");
firstPos = true;
}
if (tcpos.getFlag(TableContentPosition.LAST_IN_ROWGROUP)
&& tcpos.row.getFlag(EffRow.LAST_IN_BODY)) {
- //System.out.println("pgu is last in body");
lastPos = true;
getTableLM().getCurrentPV().addMarkers(body.getMarkers(),
true, firstPos, lastPos);
//Add object to list
this.objects.add(obj);
- //System.out.println("Registering: "+obj);
-
//Add object to special lists where necessary
if (obj instanceof PDFFunction) {
this.functions.add(obj);
return (PDFEncryption)obj;
} catch (ClassNotFoundException e) {
if (checkAvailableAlgorithms()) {
- System.out.println("JCE and algorithms available, but the "
+ log.warn("JCE and algorithms available, but the "
+ "implementation class unavailable. Please do a full "
+ "rebuild.");
}
return null;
} catch (NoSuchMethodException e) {
- e.printStackTrace();
+ log.error(e);
return null;
} catch (IllegalAccessException e) {
- e.printStackTrace();
+ log.error(e);
return null;
} catch (InvocationTargetException e) {
- e.printStackTrace();
+ log.error(e);
return null;
}
}
*/
public boolean setColor(Color col) {
if (!col.equals(getData().color)) {
- //System.out.println("old: " + getData().color + ", new: " + col);
getData().color = col;
return true;
} else {
try {
data = StreamCacheFactory.getInstance().createStreamCache();
} catch (IOException ex) {
- /**@todo Log with Logger */
+ //TODO throw the exception and catch it elsewhere
ex.printStackTrace();
}
}
try {
data.getOutputStream().write(s.getBytes());
} catch (IOException ex) {
- /**@todo Log with Logger */
+ //TODO throw the exception and catch it elsewhere
ex.printStackTrace();
}
try {
return data.getSize();
} catch (Exception e) {
+ //TODO throw the exception and catch it elsewhere
e.printStackTrace();
return 0;
}
import java.io.File;
//Commons
-import org.apache.commons.io.CopyUtils;
+import org.apache.commons.io.IOUtils;
/**
* StreamCache implementation that uses temporary files rather than heap.
output.close();
output = null;
- // don't need a buffer because streamCopy is buffered
+ // don't need a buffer because copy() is buffered
InputStream input = new java.io.FileInputStream(tempFile);
- final long bytesCopied = CopyUtils.copy(input, out);
- input.close();
- return (int)bytesCopied;
+ try {
+ return IOUtils.copy(input, out);
+ } finally {
+ IOUtils.closeQuietly(input);
+ }
}
/**
try {
pageImage = getPageImage(current++);
} catch (FOPException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ log.error(e);
+ return null;
}
switch (renderParams.getCompression()) {
renderPageAreas(viewport.getPage());
return PAGE_EXISTS;
} catch (FOPException e) {
- e.printStackTrace();
+ log.error(e);
return NO_SUCH_PAGE;
} finally {
oldState = state;
int rx = currentIPPosition + ch.getBorderAndPaddingWidthStart();
int bl = currentBPPosition + ch.getOffset() + ch.getBaselineOffset();
-/* System.out.println("Text = " + ch.getTextArea() +
+/* log.debug("Text = " + ch.getTextArea() +
"; text width: " + ch.getWidth() +
"; BlockIP Position: " + currentBlockIPPosition +
"; currentBPPosition: " + currentBPPosition +
int rx = currentIPPosition + text.getBorderAndPaddingWidthStart();
int bl = currentBPPosition + text.getOffset() + text.getBaselineOffset();
-/* System.out.println("Text = " + text.getTextArea() +
+/* log.debug("Text = " + text.getTextArea() +
"; text width: " + text.getWidth() +
"; BlockIP Position: " + currentBlockIPPosition +
"; currentBPPosition: " + currentBPPosition +
try {
printerJob.print();
} catch (PrinterException e) {
- e.printStackTrace();
+ log.error(e);
throw new IOException("Unable to print: " + e.getClass().getName()
+ ": " + e.getMessage());
}
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
-import org.apache.commons.io.CopyUtils;
import org.apache.commons.io.EndianUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.fop.fonts.CustomFont;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontType;
gen.writeln("end");
gen.writeln("/" + fm.getFontName() + " exch definefont pop");
} else {
- System.out.println("Only WinAnsiEncoding is supported. Font '"
+ gen.commentln("%WARNING: Only WinAnsiEncoding is supported. Font '"
+ fm.getFontName() + "' asks for: " + fm.getEncoding());
}
}
SubInputStream sin = new SubInputStream(in, dataSegLen);
ASCIIHexOutputStream hexOut = new ASCIIHexOutputStream(gen.getOutputStream());
- CopyUtils.copy(sin, hexOut);
+ IOUtils.copy(sin, hexOut);
gen.newLine();
break;
case 3: //EOF
* @param ioe IOException to handle
*/
protected void handleIOException(IOException ioe) {
+ //TODO Surely, there's a better way to do this.
ioe.printStackTrace();
}
* (todo) use drawString(AttributedCharacterIterator iterator...) for some
*
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
- * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
* @version $Id: PSTextPainter.java,v 1.15 2003/01/08 14:03:55 jeremias Exp $
*/
public class PSTextPainter implements TextPainter {
* @param g2d the Graphics2D to use
*/
public void paint(TextNode node, Graphics2D g2d) {
- // System.out.println("PSText paint");
String txt = node.getText();
Point2D loc = node.getLocation();
* @return new current location
*/
protected Point2D paintACI(AttributedCharacterIterator aci, Graphics2D g2d, Point2D loc) {
- //System.out.println("==============================================");
//ACIUtils.dumpAttrs(aci);
aci.first();
* @return null
*/
public Mark getMark(TextNode node, int pos, boolean all) {
- System.out.println("PSText getMark");
return null;
}
* @return null
*/
public Mark selectAt(double x, double y, TextNode node) {
- System.out.println("PSText selectAt");
return null;
}
* @return null
*/
public Mark selectTo(double x, double y, Mark beginMark) {
- System.out.println("PSText selectTo");
return null;
}
* @return null
*/
public Mark selectFirst(TextNode node) {
- System.out.println("PSText selectFirst");
return null;
}
* @return null
*/
public Mark selectLast(TextNode node) {
- System.out.println("PSText selectLast");
return null;
}
* @return null
*/
public int[] getSelected(Mark start, Mark finish) {
- System.out.println("PSText getSelected");
return null;
}
* @return null
*/
public Shape getHighlightShape(Mark beginMark, Mark endMark) {
- System.out.println("PSText getHighlightShape");
return null;
}
package org.apache.fop.render.xml;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.fop.render.XMLHandler;
import org.apache.fop.render.RendererContext;
/** Key for getting the TransformerHandler from the RendererContext */
public static final String HANDLER = "handler";
+ /** Logging instance */
+ private static Log log = LogFactory.getLog(XMLXMLHandler.class);
+
private AttributesImpl atts = new AttributesImpl();
/** @see org.apache.fop.render.XMLHandler */
handler.endCDATA();
break;
case Node.ENTITY_REFERENCE_NODE:
- System.out.println("Ignoring ENTITY_REFERENCE_NODE. NYI");
+ log.warn("Ignoring ENTITY_REFERENCE_NODE. NYI");
/*
writer.write("&");
writer.write();
}
}
} catch (Exception e) {
+ //TODO Move this to setDestination() and throw an IllegalArgumentException
e.printStackTrace();
}
Rectangle2D destRect = new Rectangle2D.Float(x, y, width, height);
* @param ioe IOException to handle
*/
protected void handleIOException(IOException ioe) {
+ //TODO Surely, there's a better way to do this.
ioe.printStackTrace();
}
public boolean drawImage(Image img, int x, int y,
ImageObserver observer) {
preparePainting();
- // System.err.println("drawImage:x, y");
int width = img.getWidth(observer);
int height = img.getHeight(observer);
public boolean drawImage(Image img, int x, int y, int width, int height,
ImageObserver observer) {
preparePainting();
- //System.out.println("drawImage x=" + x + " y=" + y
- //+ " width=" + width + " height=" + height + " image=" + img.toString());
// first we look to see if we've already added this image to
// the pdf document. If so, we just reuse the reference;
// otherwise we have to build a FopImage and add it to the pdf
* @see java.awt.Graphics#create
*/
public void dispose() {
- // System.out.println("dispose");
pdfDoc = null;
fontInfo = null;
currentStream = null;
*/
public void draw(Shape s) {
preparePainting();
- // System.out.println("draw(Shape)");
//Transparency shortcut
Color c;
//PDFColor currentColour = new PDFColor(blackMagenta[0], blackMagenta[1]);
//currentStream.write(currentColour.getColorSpaceOut(fill));
} else {
- System.err.println("Color Space not supported by PDFGraphics2D");
+ throw new UnsupportedOperationException(
+ "Color Space not supported by PDFGraphics2D");
}
}
* @see #setClip
*/
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
- //System.out.println("drawRenderedImage");
+ //NYI
}
/**
*/
public void drawRenderableImage(RenderableImage img,
AffineTransform xform) {
- //System.out.println("drawRenderableImage");
+ //NYI
}
/**
*/
public void drawString(String s, float x, float y) {
preparePainting();
- // System.out.println("drawString(String)");
Font fontState;
if (ovFontState == null) {
public void drawString(AttributedCharacterIterator iterator, float x,
float y) {
preparePainting();
- System.err.println("drawString(AttributedCharacterIterator)");
Font fontState = null;
*/
public void fill(Shape s) {
preparePainting();
- // System.err.println("fill");
//Transparency shortcut
Color c;
* @param c1 the XOR alternation color
*/
public void setXORMode(Color c1) {
- //System.out.println("setXORMode");
+ //NYI
}
*/
public void copyArea(int x, int y, int width, int height, int dx,
int dy) {
- //System.out.println("copyArea");
+ //NYI
}
}
}
/**
- * FIXX ME: This should return the page bounds in Pts,
+ * TODO: This should return the page bounds in Pts,
* I couldn't figure out how to get this for the current
* page from the PDFDocument (this still works for now,
* but it should be fixed...).
* @return the bounds of the PDF document page
*/
public Rectangle getBounds() {
- System.out.println("getting getBounds");
return null;
}
* @return the default transform for the configuration
*/
public AffineTransform getDefaultTransform() {
- System.out.println("getting getDefaultTransform");
return new AffineTransform();
}
* @return the normalizing transform for the configuration
*/
public AffineTransform getNormalizingTransform() {
- System.out.println("getting getNormalizingTransform");
return new AffineTransform(2, 0, 0, 2, 0, 0);
}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.apache.batik.bridge.SVGImageElementBridge;
-import org.apache.fop.image.JpegImage;
-import org.apache.fop.image.FopImage;
-import org.apache.fop.image.analyser.ImageReaderFactory;
-
import java.awt.Shape;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import org.w3c.dom.Element;
-import org.apache.commons.logging.impl.SimpleLog;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.gvt.AbstractGraphicsNode;
import org.apache.batik.gvt.GraphicsNode;
import org.apache.batik.util.ParsedURL;
+import org.apache.fop.image.JpegImage;
+import org.apache.fop.image.FopImage;
+import org.apache.fop.image.analyser.ImageReaderFactory;
+
/**
* Bridge class for the <image> element when jpeg images.
*
* THis checks if it is a jpeg file and creates a jpeg node
* so the jpeg can be inserted directly into the pdf document.
* @param ctx the bridge context
- * @param e the svg element for the image
+ * @param imageElement the svg element for the image
* @param purl the parsed url for the image resource
* @return a new graphics node
*/
protected GraphicsNode createImageGraphicsNode
- (BridgeContext ctx, Element e, ParsedURL purl) {
+ (BridgeContext ctx, Element imageElement, ParsedURL purl) {
try {
InputStream is = purl.openStream();
if (!is.markSupported()) {
byte [] data = new byte[3];
is.read(data);
is.reset();
- if ((data[0] == (byte)0xFF) && (data[1] == (byte)0xD8) &&
- (data[2] == (byte)0xFF)) {
- FopImage.ImageInfo ii = ImageReaderFactory.make
- (purl.toString(), is, null);
+ if ((data[0] == (byte)0xFF)
+ && (data[1] == (byte)0xD8)
+ && (data[2] == (byte)0xFF)) {
+ FopImage.ImageInfo ii = ImageReaderFactory.make
+ (purl.toString(), is, null);
JpegImage jpeg = new JpegImage(ii);
- SimpleLog logger = new SimpleLog("FOP/SVG");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
jpeg.load(FopImage.ORIGINAL_DATA);
PDFJpegNode node = new PDFJpegNode(jpeg, ctx, e, purl);
-
+
Rectangle2D imgBounds = getImageBounds(ctx, e);
- Rectangle2D bounds = node.getPrimitiveBounds();
- float [] vb = new float[4];
- vb[0] = 0; // x
- vb[1] = 0; // y
- vb[2] = (float) bounds.getWidth(); // width
- vb[3] = (float) bounds.getHeight(); // height
-
+ Rectangle2D bounds = node.getPrimitiveBounds();
+ float [] vb = new float[4];
+ vb[0] = 0; // x
+ vb[1] = 0; // y
+ vb[2] = (float) bounds.getWidth(); // width
+ vb[3] = (float) bounds.getHeight(); // height
+
// handles the 'preserveAspectRatio', 'overflow' and 'clip'
// and sets the appropriate AffineTransform to the image node
initializeViewport(ctx, e, node, vb, imgBounds);
- return node;
+ return node;
}
} catch (Exception ex) {
+ //TODO Handle this exception
}
return superCreateGraphicsNode(ctx, e, purl);
}
+ /**
+ * @see org.apache.batik.bridge.SVGImageElementBridge
+ */
protected GraphicsNode superCreateGraphicsNode
- (BridgeContext ctx, Element e, ParsedURL purl) {
- return super.createImageGraphicsNode(ctx, e, purl);
+ (BridgeContext ctx, Element imageElement, ParsedURL purl) {
+ return super.createImageGraphicsNode(ctx, imageElement, purl);
}
* the PDFGraphics2D.
*/
public class PDFJpegNode extends AbstractGraphicsNode {
+
private JpegImage jpeg;
private BridgeContext ctx;
- private Element e;
+ private Element imageElement;
private ParsedURL purl;
- private GraphicsNode origGraphicsNode=null;
+ private GraphicsNode origGraphicsNode = null;
+
/**
* Create a new pdf jpeg node for drawing jpeg images
* into pdf graphics.
* @param j the jpeg image
+ * @param ctx the bridge context
+ * @param imageElement the SVG image element
+ * @param purl the URL to the image
*/
public PDFJpegNode(JpegImage j, BridgeContext ctx,
- Element e, ParsedURL purl) {
+ Element imageElement, ParsedURL purl) {
this.jpeg = j;
this.ctx = ctx;
- this.e = e;
+ this.imageElement = imageElement;
this.purl = purl;
}
float height = jpeg.getHeight();
pdfg.addJpegImage(jpeg, x, y, width, height);
} catch (Exception e) {
+ //TODO Handle this exception properly
e.printStackTrace();
}
} else {
if (origGraphicsNode == null) {
// Haven't constructed baseclass Graphics Node,
// so do so now.
- origGraphicsNode =
- PDFImageElementBridge.this.superCreateGraphicsNode
- (ctx, e, purl);
+ origGraphicsNode
+ = PDFImageElementBridge.this.superCreateGraphicsNode
+ (ctx, imageElement, purl);
}
origGraphicsNode.primitivePaint(g2d);
}
return new Rectangle2D.Double(0, 0, jpeg.getWidth(),
jpeg.getHeight());
} catch (Exception e) {
+ //TODO Handle this exception properly
e.printStackTrace();
}
return null;
* @param g2d the Graphics2D to use
*/
public void paint(TextNode node, Graphics2D g2d) {
- // System.out.println("PDFText paint");
String txt = node.getText();
Point2D loc = node.getLocation();
* @return null
*/
public Mark getMark(TextNode node, int pos, boolean all) {
- System.out.println("PDFText getMark");
return null;
}
* @return null
*/
public Mark selectAt(double x, double y, TextNode node) {
- System.out.println("PDFText selectAt");
return null;
}
* @return null
*/
public Mark selectTo(double x, double y, Mark beginMark) {
- System.out.println("PDFText selectTo");
return null;
}
* @return null
*/
public Mark selectFirst(TextNode node) {
- System.out.println("PDFText selectFirst");
return null;
}
* @return null
*/
public Mark selectLast(TextNode node) {
- System.out.println("PDFText selectLast");
return null;
}
* @return null
*/
public int[] getSelected(Mark start, Mark finish) {
- System.out.println("PDFText getSelected");
return null;
}
* @return null
*/
public Shape getHighlightShape(Mark beginMark, Mark endMark) {
- System.out.println("PDFText getHighlightShape");
return null;
}
* The filter is described in chapter 3.13.3 of the PostScript Language
* Reference (third edition).
*
- * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
* @version $Id$
*/
public class ASCII85InputStream extends InputStream
} else {
int cIndex = 0;
tuple = (buf - START) * POW85[cIndex];
- //System.out.println(cIndex + ": " + Long.toHexString(tuple));
cIndex++;
while (cIndex < 5) {
buf = filteredRead();
throw new IOException("Illegal 'z' within tuple");
} else {
tuple += (buf - START) * POW85[cIndex];
- //System.out.println(cIndex + ": " + Long.toHexString(tuple));
cIndex++;
}
}
/**
* This class applies a ASCII85 encoding to the stream.
*
- * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
* @version $Id$
*/
public class ASCII85OutputStream extends FilterOutputStream
* @see java.io.OutputStream#close()
*/
public void close() throws IOException {
- //System.out.println("Not sending close() to " + out);
try {
flush();
} catch (IOException ioe) {
try {
fontcode = Integer.parseInt(name.substring(1));
} catch (Exception e) {
- e.printStackTrace();
+ log.error(e);
}
}
switch (fontcode) {
try {
out.write(buff);
} catch (IOException e) {
- // e.printStackTrace();
- // e.printStackTrace(System.out);
throw new RuntimeException(e.toString());
}
}
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.io.IOException;
import java.io.InputStream;
-import org.apache.commons.io.CopyUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.fop.pdf.PDFText;
* ATTENTION: Some of the tests here depend on the correct behaviour of
* ASCII85OutputStream. If something fails here make sure
* ASCII85OutputStreamTestCase runs!
- *
- * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
*/
public class ASCII85InputStreamTestCase extends TestCase {
byte[] ascii85 = text.getBytes("US-ASCII");
InputStream in = new ByteArrayInputStream(ascii85);
InputStream decoder = new ASCII85InputStream(in);
- ByteArrayOutputStream baout = new ByteArrayOutputStream();
- CopyUtils.copy(decoder, baout);
- baout.close();
- return baout.toByteArray();
+ return IOUtils.toByteArray(decoder);
}
private byte[] getChunk(int count) {