/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// center window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
- if (frameSize.height > screenSize.height)
+ if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
- if (frameSize.width > screenSize.width)
+ }
+ if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
+ }
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
private FOUserAgent getUserAgent() {
- if(userAgent == null) {
+ if (userAgent == null) {
userAgent = new FOUserAgent();
userAgent.enableLogging(getLogger());
userAgent.setBaseURL("file:/.");
protected Logger getLogger() {
- if(this.log == null) {
+ if (this.log == null) {
this.log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
this.log.error("Logger not set. Using ConsoleLogger as default.");
}
*/
public ContentHandler getContentHandler() {
// TODO - do this stuff in a better way
- if(_renderer != null) {
+ if (_renderer != null) {
structHandler = new LayoutHandler(_stream, _renderer, true);
} else {
structHandler = new org.apache.fop.mif.MIFHandler(_stream);
public static synchronized Enumeration providers(Class cls) {
ClassLoader cl = cls.getClassLoader();
// null if loaded by bootstrap class loader
- if(cl == null) {
+ if (cl == null) {
cl = ClassLoader.getSystemClassLoader();
}
String serviceFile = "META-INF/services/" + cls.getName();
// getLogger().debug("File: " + serviceFile);
Vector v = (Vector)providerMap.get(serviceFile);
- if (v != null)
+ if (v != null) {
return v.elements();
+ }
v = new Vector();
providerMap.put(serviceFile, v);
try {
// First strip any comment...
int idx = line.indexOf('#');
- if (idx != -1)
+ if (idx != -1) {
line = line.substring(0, idx);
+ }
// Trim whitespace.
line = line.trim();
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
* Manages input if it is an xsl:fo file
*/
public class FOInputHandler extends InputHandler {
-
File fofile = null;
URL foURL = null;
+
public FOInputHandler (File fofile) {
this.fofile = fofile;
}
}
public InputSource getInputSource () {
- if (fofile != null)
+ if (fofile != null) {
return super.fileInputSource(fofile);
+ }
return super.urlInputSource(foURL);
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
import java.net.URL;
import java.io.File;
-abstract public class InputHandler {
+public abstract class InputHandler {
- abstract public InputSource getInputSource();
- abstract public XMLReader getParser() throws FOPException;
+ public abstract InputSource getInputSource();
+ public abstract XMLReader getParser() throws FOPException;
- static public InputSource urlInputSource(URL url) {
+ public static InputSource urlInputSource(URL url) {
return new InputSource(url.toString());
}
* @param file the File
* @return the InputSource created
*/
- static public InputSource fileInputSource(File file) {
+ public static InputSource fileInputSource(File file) {
/* this code adapted from James Clark's in XT */
String path = file.getAbsolutePath();
String fSep = System.getProperty("file.separator");
- if (fSep != null && fSep.length() == 1)
+ if (fSep != null && fSep.length() == 1) {
path = path.replace(fSep.charAt(0), '/');
- if (path.length() > 0 && path.charAt(0) != '/')
+ }
+ if (path.length() > 0 && path.charAt(0) != '/') {
path = '/' + path;
+ }
try {
return new InputSource(new URL("file", null, path).toString());
} catch (java.net.MalformedURLException e) {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public void startDocument() throws SAXException {
pageCount = 0;
- if (MEM_PROFILE_WITH_GC)
+ if (MEM_PROFILE_WITH_GC) {
System.gc(); // This takes time but gives better results
+ }
initialMemory = runtime.totalMemory() - runtime.freeMemory();
startTime = System.currentTimeMillis();
throw new SAXException(e);
}
- if (MEM_PROFILE_WITH_GC)
+ if (MEM_PROFILE_WITH_GC) {
System.gc(); // This takes time but gives better results
+ }
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
long memoryUsed = (memoryNow - initialMemory) / 1024L;
public void startPageSequence(PageSequence pageSeq, org.apache.fop.fo.Title seqTitle, LayoutMasterSet lms) {
Title title = null;
- if(seqTitle != null) {
+ if (seqTitle != null) {
title = seqTitle.getTitleArea();
}
areaTree.startPageSequence(title);
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
setParserFeatures(parser);
PrinterJob pj = PrinterJob.getPrinterJob();
- if(System.getProperty("dialog") != null)
- if(!pj.printDialog())
+ if (System.getProperty("dialog") != null) {
+ if (!pj.printDialog()) {
throw new FOPException("Printing cancelled by operator");
+ }
+ }
PrintRenderer renderer = new PrintRenderer(pj);
int copies = getIntProperty("copies", 1);
}
int getIntProperty(String name, int def) {
String propValue = System.getProperty(name);
- if(propValue != null) {
+ if (propValue != null) {
try {
return Integer.parseInt(propValue);
} catch (Exception e) {
throws IOException {
super.stopRenderer();
- if(endNumber == -1)
+ if (endNumber == -1) {
endNumber = getPageCount();
+ }
Vector numbers = getInvalidPageNumbers();
for (int i = numbers.size() - 1; i > -1; i--) {
if (i < startNumber || i > endNumber) {
isValid = false;
} else if (mode != EVEN_AND_ALL) {
- if (mode == EVEN && ((i + 1) % 2 != 0))
+ if (mode == EVEN && ((i + 1) % 2 != 0)) {
isValid = false;
- else if (mode == ODD && ((i + 1) % 2 != 1))
+ } else if (mode == ODD && ((i + 1) % 2 != 1)) {
isValid = false;
+ }
}
- if (!isValid)
+ if (!isValid) {
vec.add(i + "");
+ }
}
return vec;
this.inputHandler = inputHandler;
}
- abstract public void run() throws FOPException;
+ public abstract void run() throws FOPException;
// setting the parser features
public void setParserFeatures(XMLReader parser) throws FOPException {
* @param child the child area to add
*/
public void addChild(Area child) {
-System.out.println("mmmm");
-(new Exception()).printStackTrace();
}
/**
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
* The matrix encodes translations, scaling and rotations of the coordinate
* system used to render pages.
*/
-
public class CTM implements Serializable {
private double a, b, c, d, e, f;
* @param bpd The block-progression dimension of the reference area whose
* CTM is being set.
*/
- static public CTM getWMctm(int wm, int ipd, int bpd) {
+ public static CTM getWMctm(int wm, int ipd, int bpd) {
CTM wmctm;
switch (wm) {
case WritingMode.LR_TB:
return new double[]{a, b, c, d, e, f};
}
}
+
*/
protected ArrayList inlines = new ArrayList();
+ /**
+ * An inline parent is a reference area somay have clipping
+ */
+ protected boolean clip = false;
+
/**
* Create a new inline parent to add areas to.
*/
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
}
public String toString() {
- StringBuffer sbuf = new StringBuffer(8);
- sbuf.append('#');
- String s = Integer.toHexString((int)(red * 255.0));
- if (s.length() == 1) sbuf.append('0');
- sbuf.append(s);
- s = Integer.toHexString((int)(green * 255.0));
- if (s.length() == 1) sbuf.append('0');
- sbuf.append(s);
- s = Integer.toHexString((int)(blue * 255.0));
- if (s.length() == 1) sbuf.append('0');
- sbuf.append(s);
- return sbuf.toString();
+ StringBuffer sbuf = new StringBuffer(8);
+ sbuf.append('#');
+ String s = Integer.toHexString((int)(red * 255.0));
+ if (s.length() == 1) {
+ sbuf.append('0');
+ }
+ sbuf.append(s);
+ s = Integer.toHexString((int)(green * 255.0));
+ if (s.length() == 1) {
+ sbuf.append('0');
+ }
+ sbuf.append(s);
+ s = Integer.toHexString((int)(blue * 255.0));
+ if (s.length() == 1) {
+ sbuf.append('0');
+ }
+ sbuf.append(s);
+ return sbuf.toString();
}
- final static String[] names = {
+ protected static final String[] names = {
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral",
"whitesmoke", "yellow", "yellowgreen"
};
- final static int[][] vals = {
+ protected static final int[][] vals = {
{
240, 248, 255
}, {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// From CompoundDatatype
public void setComponent(String sCmpnName, Property cmpnValue,
boolean bIsDefault) {
- if (sCmpnName.equals("length"))
+ if (sCmpnName.equals("length")) {
length = cmpnValue;
- else if (sCmpnName.equals("conditionality"))
+ } else if (sCmpnName.equals("conditionality")) {
conditionality = cmpnValue;
+ }
}
public Property getComponent(String sCmpnName) {
- if (sCmpnName.equals("length"))
+ if (sCmpnName.equals("length")) {
return length;
- else if (sCmpnName.equals("conditionality"))
+ } else if (sCmpnName.equals("conditionality")) {
return conditionality;
- else
+ } else {
return null;
+ }
}
public Property getConditionality() {
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public FODimension(int ipd, int bpd) {
- this.ipd = ipd;
- this.bpd = bpd;
+ this.ipd = ipd;
+ this.bpd = bpd;
}
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
int assumed_resolution = 1; // points/pixel
- if (unit.equals("in"))
+ if (unit.equals("in")) {
dvalue = dvalue * 72;
- else if (unit.equals("cm"))
+ } else if (unit.equals("cm")) {
dvalue = dvalue * 28.3464567;
- else if (unit.equals("mm"))
+ } else if (unit.equals("mm")) {
dvalue = dvalue * 2.83464567;
- else if (unit.equals("pt"))
+ } else if (unit.equals("pt")) {
dvalue = dvalue;
- else if (unit.equals("pc"))
+ } else if (unit.equals("pc")) {
dvalue = dvalue * 12;
/*
- * else if (unit.equals("em"))
+ * } else if (unit.equals("em")) {
* dvalue = dvalue * fontsize;
*/
- else if (unit.equals("px"))
+ } else if (unit.equals("px")) {
dvalue = dvalue * assumed_resolution;
- else {
+ } else {
dvalue = 0;
//log.error("unknown length unit '" + unit
// + "'");
}
public Numeric asNumeric() {
- return new Numeric(this);
+ return new Numeric(this);
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// From CompoundDatatype
public void setComponent(String sCmpnName, Property cmpnValue,
boolean bIsDefault) {
- if (sCmpnName.equals("within-line"))
+ if (sCmpnName.equals("within-line")) {
setWithinLine(cmpnValue, bIsDefault);
- else if (sCmpnName.equals("within-column"))
+ } else if (sCmpnName.equals("within-column")) {
setWithinColumn(cmpnValue, bIsDefault);
- else if (sCmpnName.equals("within-page"))
+ } else if (sCmpnName.equals("within-page")) {
setWithinPage(cmpnValue, bIsDefault);
+ }
}
// From CompoundDatatype
public Property getComponent(String sCmpnName) {
- if (sCmpnName.equals("within-line"))
+ if (sCmpnName.equals("within-line")) {
return getWithinLine();
- else if (sCmpnName.equals("within-column"))
+ } else if (sCmpnName.equals("within-column")) {
return getWithinColumn();
- else if (sCmpnName.equals("within-page"))
+ } else if (sCmpnName.equals("within-page")) {
return getWithinPage();
- else
+ } else {
return null;
+ }
}
public void setWithinLine(Property withinLine, boolean bIsDefault) {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public int mvalue() {
if (!bIsComputed) {
computeValue();
- }
+ }
return millipoints;
}
protected void setComputedValue(int millipoints) {
- setComputedValue(millipoints, true);
+ setComputedValue(millipoints, true);
}
protected void setComputedValue(int millipoints, boolean bSetComputed) {
}
public boolean isComputed() {
- return this.bIsComputed;
+ return this.bIsComputed;
}
/**
}
public Numeric asNumeric() {
- return null;
+ return null;
}
public String toString() {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// From CompoundDatatype
public void setComponent(String sCmpnName, Property cmpnValue,
boolean bIsDefault) {
- if (sCmpnName.equals("block-progression-direction"))
+ if (sCmpnName.equals("block-progression-direction")) {
bpd = cmpnValue;
- else if (sCmpnName.equals("inline-progression-direction"))
+ } else if (sCmpnName.equals("inline-progression-direction")) {
ipd = cmpnValue;
+ }
}
// From CompoundDatatype
public Property getComponent(String sCmpnName) {
- if (sCmpnName.equals("block-progression-direction"))
+ if (sCmpnName.equals("block-progression-direction")) {
return getBPD();
- else if (sCmpnName.equals("inline-progression-direction"))
+ } else if (sCmpnName.equals("inline-progression-direction")) {
return getIPD();
- else
+ } else {
return null; // SHOULDN'T HAPPEN
+ }
}
public Property getIPD() {
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// From CompoundDatatype
public void setComponent(String sCmpnName, Property cmpnValue,
boolean bIsDefault) {
- if (sCmpnName.equals("minimum"))
+ if (sCmpnName.equals("minimum")) {
setMinimum(cmpnValue, bIsDefault);
- else if (sCmpnName.equals("optimum"))
+ } else if (sCmpnName.equals("optimum")) {
setOptimum(cmpnValue, bIsDefault);
- else if (sCmpnName.equals("maximum"))
+ } else if (sCmpnName.equals("maximum")) {
setMaximum(cmpnValue, bIsDefault);
+ }
}
// From CompoundDatatype
public Property getComponent(String sCmpnName) {
- if (sCmpnName.equals("minimum"))
+ if (sCmpnName.equals("minimum")) {
return getMinimum();
- else if (sCmpnName.equals("optimum"))
+ } else if (sCmpnName.equals("optimum")) {
return getOptimum();
- else if (sCmpnName.equals("maximum"))
+ } else if (sCmpnName.equals("maximum")) {
return getMaximum();
- else
+ } else {
return null; // SHOULDN'T HAPPEN
+ }
}
/**
*/
protected void setMinimum(Property minimum, boolean bIsDefault) {
this.minimum = minimum;
- if (!bIsDefault)
+ if (!bIsDefault) {
bfSet |= MINSET;
+ }
}
*/
protected void setMaximum(Property max, boolean bIsDefault) {
maximum = max;
- if (!bIsDefault)
+ if (!bIsDefault) {
bfSet |= MAXSET;
+ }
}
*/
protected void setOptimum(Property opt, boolean bIsDefault) {
optimum = opt;
- if (!bIsDefault)
+ if (!bIsDefault) {
bfSet |= OPTSET;
+ }
}
// Minimum is prioritaire, if explicit
private void checkConsistency() {
- if (bChecked)
+ if (bChecked) {
return;
+ }
// Make sure max >= min
// Must also control if have any allowed enum values!
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
private Vector lengths ;
public MixedLength(Vector lengths) {
- this.lengths = lengths;
+ this.lengths = lengths;
}
protected void computeValue() {
- int computedValue =0;
- boolean bAllComputed = true;
- Enumeration e = lengths.elements();
- while (e.hasMoreElements()) {
- Length l = (Length)e.nextElement();
- computedValue += l.mvalue();
- if (! l.isComputed()) {
- bAllComputed = false;
- }
+ int computedValue = 0;
+ boolean bAllComputed = true;
+ Enumeration e = lengths.elements();
+ while (e.hasMoreElements()) {
+ Length l = (Length) e.nextElement();
+ computedValue += l.mvalue();
+ if (! l.isComputed()) {
+ bAllComputed = false;
+ }
}
setComputedValue(computedValue, bAllComputed);
}
public double getTableUnits() {
- double tableUnits = 0.0;
- Enumeration e = lengths.elements();
- while (e.hasMoreElements()) {
- tableUnits += ((Length)e.nextElement()).getTableUnits();
+ double tableUnits = 0.0;
+ Enumeration e = lengths.elements();
+ while (e.hasMoreElements()) {
+ tableUnits += ((Length) e.nextElement()).getTableUnits();
}
return tableUnits;
}
public void resolveTableUnit(double dTableUnit) {
- Enumeration e = lengths.elements();
- while (e.hasMoreElements()) {
- ((Length)e.nextElement()).resolveTableUnit(dTableUnit);
+ Enumeration e = lengths.elements();
+ while (e.hasMoreElements()) {
+ ((Length) e.nextElement()).resolveTableUnit(dTableUnit);
}
}
public String toString() {
StringBuffer sbuf = new StringBuffer();
- Enumeration e = lengths.elements();
- while (e.hasMoreElements()) {
- if (sbuf.length()>0) {
- sbuf.append('+');
- }
- sbuf.append(e.nextElement().toString());
+ Enumeration e = lengths.elements();
+ while (e.hasMoreElements()) {
+ if (sbuf.length() > 0) {
+ sbuf.append('+');
+ }
+ sbuf.append(e.nextElement().toString());
}
- return sbuf.toString();
+ return sbuf.toString();
}
public Numeric asNumeric() {
- Numeric numeric = null;
- for (Enumeration e = lengths.elements(); e.hasMoreElements();) {
- Length l = (Length)e.nextElement();
- if (numeric == null) {
- numeric = l.asNumeric();
- }
- else {
- try {
- Numeric sum = numeric.add(l.asNumeric());
- numeric = sum;
- } catch (PropertyException pe) {
- System.err.println("Can't convert MixedLength to Numeric: " +
- pe);
- }
- }
- }
- return numeric;
+ Numeric numeric = null;
+ for (Enumeration e = lengths.elements(); e.hasMoreElements();) {
+ Length l = (Length) e.nextElement();
+ if (numeric == null) {
+ numeric = l.asNumeric();
+ } else {
+ try {
+ Numeric sum = numeric.add(l.asNumeric());
+ numeric = sum;
+ } catch (PropertyException pe) {
+ System.err.println(
+ "Can't convert MixedLength to Numeric: " + pe);
+ }
+ }
+ }
+ return numeric;
}
-
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
}
public Numeric asNumeric() {
- return new Numeric(this);
+ return new Numeric(this);
}
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// From CompoundDatatype
public void setComponent(String sCmpnName, Property cmpnValue,
boolean bIsDefault) {
- if (sCmpnName.equals("precedence"))
+ if (sCmpnName.equals("precedence")) {
setPrecedence(cmpnValue, bIsDefault);
- else if (sCmpnName.equals("conditionality"))
+ } else if (sCmpnName.equals("conditionality")) {
setConditionality(cmpnValue, bIsDefault);
- else
+ } else {
super.setComponent(sCmpnName, cmpnValue, bIsDefault);
+ }
}
// From CompoundDatatype
public Property getComponent(String sCmpnName) {
- if (sCmpnName.equals("precedence"))
+ if (sCmpnName.equals("precedence")) {
return getPrecedence();
- else if (sCmpnName.equals("conditionality"))
+ } else if (sCmpnName.equals("conditionality")) {
return getConditionality();
- else
+ } else {
return super.getComponent(sCmpnName);
+ }
}
protected void setPrecedence(Property precedence, boolean bIsDefault) {
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
this.tcolUnits = tcolUnits;
}
-
-
/**
* Override the method in Length to return the number of specified
* proportional table-column units.
* Calculate the number of millipoints and set it.
*/
public void resolveTableUnit(double mpointsPerUnit) {
- setComputedValue((int)(tcolUnits * mpointsPerUnit));
+ setComputedValue((int)(tcolUnits * mpointsPerUnit));
}
-// If the table-unit can be resolved, set the computed value
-// protected void computeValue() {
-// if (tblUnitBase.canResolveUnit()) {
-// rslt += (int)(tcolUnits * (double)tblUnitBase.getUnitValue());
-// setComputedValue(rslt);
-// }
-// }
-
+ //If the table-unit can be resolved, set the computed value
+ /*protected void computeValue() {
+ if (tblUnitBase.canResolveUnit()) {
+ rslt += (int)(tcolUnits * (double)tblUnitBase.getUnitValue());
+ setComputedValue(rslt);
+ }
+ }*/
public String toString() {
return (Double.toString(tcolUnits) + " table-column-units");
}
public Numeric asNumeric() {
- return new Numeric(this);
+ return new Numeric(this);
}
}
+
/*
* $Id$ --
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public Property convertProperty(Property p,
PropertyList propertyList, FObj fo) {
- if (p instanceof ToBeImplementedProperty)
+ if (p instanceof ToBeImplementedProperty) {
return p;
+ }
ToBeImplementedProperty val =
- new ToBeImplementedProperty(getPropName());
+ new ToBeImplementedProperty(getPropName());
return val;
}
-
}
public ToBeImplementedProperty(String propName) {
- // XXX: (mjg@recalldesign.com) This is a bit of a kluge, perhaps an
- // UnimplementedPropertyException or something similar should
- // get thrown here instead.
- //
- // This was solved on the maintenance branch by using
- // MessageHandler, btu that doesn't exist on the trunk
+ //XXX: (mjg@recalldesign.com) This is a bit of a kluge, perhaps an
+ //UnimplementedPropertyException or something similar should
+ //get thrown here instead.
// Logger log = Hierarchy.getDefaultHierarchy().getLoggerFor("fop");
// log.warn("property - \"" + propName
// + "\" is not implemented yet.");
}
-
}
+
public abstract class AbstractCharIterator implements CharIterator, Cloneable {
- abstract public boolean hasNext();
+ public abstract boolean hasNext();
- abstract public char nextChar() throws NoSuchElementException ;
+ public abstract char nextChar() throws NoSuchElementException ;
public Object next() throws NoSuchElementException {
- return new Character(nextChar());
+ return new Character(nextChar());
}
public void remove() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException();
}
}
public Object clone() {
- try {
- return super.clone();
- } catch (CloneNotSupportedException ex) {
- return null;
- }
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException ex) {
+ return null;
+ }
}
-};
+}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public Property convertProperty(Property p,
PropertyList propertyList, FObj fo) {
- if (p instanceof ColorTypeProperty)
+ if (p instanceof ColorTypeProperty) {
return p;
+ }
ColorType val = p.getColorType();
- if (val != null)
+ if (val != null) {
return new ColorTypeProperty(val);
+ }
return convertPropertyDatatype(p, propertyList, fo);
}
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
super(propName);
}
-
/**
* Called by subclass if no match found.
*/
public Property convertProperty(Property p,
PropertyList propertyList,
FObj fo) throws FOPException {
- if (p instanceof EnumProperty)
+ if (p instanceof EnumProperty) {
return p;
- else
+ } else {
return null;
+ }
}
-
}
private int value;
}
}
+
* base class for nodes in the XML tree
*
*/
-abstract public class FONode {
+public abstract class FONode {
protected FOUserAgent userAgent;
protected FONode parent;
protected String name;
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources."
*/
public void addLayoutManager(List list) {
// if nothing left (length=0)?
- if(length == 0) return;
+ if(length == 0) { return; }
if (length < ca.length) {
char[] tmp = ca;
if (curIndex < length) {
// Just a char class? Don't actually care about the value!
return ca[curIndex++];
- } else
+ } else {
throw new NoSuchElementException();
+ }
}
public void remove() {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
/**
* value of marker before layout begins
*/
- public final static int START = -1000;
+ public static final int START = -1000;
/**
* value of marker after break-after
*/
- public final static int BREAK_AFTER = -1001;
+ public static final int BREAK_AFTER = -1001;
/**
* where the layout was up to.
public FObj(FONode parent) {
super(parent);
markers = new HashMap();
- if (parent instanceof FObj)
+ if (parent instanceof FObj) {
this.areaClass = ((FObj) parent).areaClass;
+ }
}
public void setName(String str) {
protected void setupID() {
Property prop = this.properties.get("id");
- if(prop != null) {
+ if (prop != null) {
String str = prop.getString();
- if(str != null && !str.equals("")) {
+ if (str != null && !str.equals("")) {
HashSet idrefs = structHandler.getIDReferences();
- if(!idrefs.contains(str)) {
+ if (!idrefs.contains(str)) {
id = str;
idrefs.add(id);
} else {
FONode parent;
for (p = this; !p.generatesReferenceAreas() &&
(parent = p.getParent()) != null &&
- (parent instanceof FObj); p = (FObj) parent)
- ;
+ (parent instanceof FObj); p = (FObj) parent) {
+ }
this.properties.setWritingMode(
p.getProperty("writing-mode").getEnum());
}
* @return A ListIterator.
*/
public ListIterator getChildren() {
- if(children != null) {
+ if (children != null) {
return children.listIterator();
}
return null;
int i = children.indexOf(childNode);
if (i >= 0) {
return children.listIterator(i);
- } else
+ } else {
return null;
+ }
}
public void setIsInTableCell() {
snapshot.add(new Integer(this.marker));
// terminate if no kids or child not yet accessed
- if (this.marker < 0)
+ if (this.marker < 0) {
return snapshot;
- else if (children.isEmpty())
+ } else if (children.isEmpty()) {
return snapshot;
- else
+ } else {
return ( (FObj) children.get(this.marker)).getMarkerSnapshot(
snapshot);
+ }
}
/**
// make sure all the children of this FO are also reset
resetMarker();
return;
- } else if ((this.marker == -1) || children.isEmpty())
+ } else if ((this.marker == -1) || children.isEmpty()) {
return;
+ }
int numChildren = this.children.size();
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
}
protected Property getElement(int index) {
- if (list.size() > index)
+ if (list.size() > index) {
return (Property)list.elementAt(index);
- else
+ } else {
return null;
+ }
}
protected int count() {
}
}
+
+/*
+ * $Id$
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
package org.apache.fop.fo;
import org.apache.fop.layout.BorderAndPadding;
public class InlineCharIterator extends RecursiveCharIterator {
- private boolean bStartBoundary=false;
- private boolean bEndBoundary=false;
+ private boolean bStartBoundary = false;
+ private boolean bEndBoundary = false;
public InlineCharIterator(FObj fobj, BorderAndPadding bap) {
- super(fobj);
- checkBoundaries(bap);
+ super(fobj);
+ checkBoundaries(bap);
}
private void checkBoundaries(BorderAndPadding bap) {
- // TODO! use start and end in BAP!!
- bStartBoundary = (bap.getBorderLeftWidth(false)>0 ||
- bap.getPaddingLeft(false)>0);
- bEndBoundary = (bap.getBorderRightWidth(false)>0 ||
- bap.getPaddingRight(false)>0);
+ // TODO! use start and end in BAP!!
+ bStartBoundary = (bap.getBorderLeftWidth(false) > 0 ||
+ bap.getPaddingLeft(false) > 0);
+ bEndBoundary = (bap.getBorderRightWidth(false) > 0 ||
+ bap.getPaddingRight(false) > 0);
}
public boolean hasNext() {
- if (bStartBoundary) return true;
- return (super.hasNext() || bEndBoundary);
- /* If super.hasNext() returns false,
- * we return true if we are going to return a "boundary" signal
- * else false.
- */
+ if (bStartBoundary)
+ return true;
+ return (super.hasNext() || bEndBoundary);
+ /* If super.hasNext() returns false,
+ * we return true if we are going to return a "boundary" signal
+ * else false.
+ */
}
public char nextChar() throws NoSuchElementException {
- if (bStartBoundary) {
- bStartBoundary=false;
- return CharUtilities.CODE_EOT;
- }
- try {
- return super.nextChar();
- }
- catch (NoSuchElementException e) {
- // Underlying has nothing more to return
- // Check end boundary char
- if (bEndBoundary) {
- bEndBoundary=false;
- return CharUtilities.CODE_EOT;
- }
- else throw e;
- }
+ if (bStartBoundary) {
+ bStartBoundary = false;
+ return CharUtilities.CODE_EOT;
+ }
+ try {
+ return super.nextChar();
+ } catch (NoSuchElementException e) {
+ // Underlying has nothing more to return
+ // Check end boundary char
+ if (bEndBoundary) {
+ bEndBoundary = false;
+ return CharUtilities.CODE_EOT;
+ } else
+ throw e;
+ }
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
FObj fo) throws FOPException {
if (isAutoLengthAllowed()) {
String pval = p.getString();
- if (pval != null && pval.equals("auto"))
+ if (pval != null && pval.equals("auto")) {
return new LengthProperty(new AutoLength());
+ }
}
- if (p instanceof LengthProperty)
+ if (p instanceof LengthProperty) {
return p;
+ }
Length val = p.getLength();
- if (val != null)
+ if (val != null) {
return new LengthProperty(val);
+ }
return convertPropertyDatatype(p, propertyList, fo);
}
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
private char charCode;
public OneCharIterator(char c) {
- this.charCode = c;
+ this.charCode = c;
}
public boolean hasNext() {
- return bFirst;
+ return bFirst;
}
public char nextChar() throws NoSuchElementException {
- if (bFirst) {
- bFirst=false;
- return charCode;
- }
- else throw new NoSuchElementException();
+ if (bFirst) {
+ bFirst = false;
+ return charCode;
+ } else {
+ throw new NoSuchElementException();
+ }
}
}
+
"inline-progression-dimension"
};
- static private final HashMap wmtables = new HashMap(4);
+ private static final HashMap wmtables = new HashMap(4);
{
wmtables.put(new Integer(WritingMode.LR_TB), /* lr-tb */
new byte[] {
+/*
+ * $Id$
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
package org.apache.fop.fo;
import java.util.Iterator;
private FONode curChild;
public RecursiveCharIterator(FObj fobj) {
- // Set up first child iterator
- this.fobj = fobj;
- this.childIter = fobj.getChildren();
- getNextCharIter();
+ // Set up first child iterator
+ this.fobj = fobj;
+ this.childIter = fobj.getChildren();
+ getNextCharIter();
}
public RecursiveCharIterator(FObj fobj, FONode child) {
- // Set up first child iterator
- this.fobj = fobj;
- this.childIter = fobj.getChildren(child);
- getNextCharIter();
+ // Set up first child iterator
+ this.fobj = fobj;
+ this.childIter = fobj.getChildren(child);
+ getNextCharIter();
}
public CharIterator mark() {
- return (CharIterator) this.clone();
+ return (CharIterator) this.clone();
}
public Object clone() {
- RecursiveCharIterator ci = (RecursiveCharIterator)super.clone();
- ci.childIter = fobj.getChildren(ci.curChild);
- // Need to advance to the next child, else we get the same one!!!
- ci.childIter.next();
- ci.curCharIter = (CharIterator)curCharIter.clone();
- return ci;
+ RecursiveCharIterator ci = (RecursiveCharIterator) super.clone();
+ ci.childIter = fobj.getChildren(ci.curChild);
+ // Need to advance to the next child, else we get the same one!!!
+ ci.childIter.next();
+ ci.curCharIter = (CharIterator) curCharIter.clone();
+ return ci;
}
public void replaceChar(char c) {
- if (curCharIter != null) {
- curCharIter.replaceChar(c);
- }
+ if (curCharIter != null) {
+ curCharIter.replaceChar(c);
+ }
}
private void getNextCharIter() {
- if (childIter.hasNext()) {
- this.curChild = (FONode)childIter.next();
- this.curCharIter = curChild.charIterator();
- }
- else {
- curChild = null;
- curCharIter = null;
- }
+ if (childIter.hasNext()) {
+ this.curChild = (FONode) childIter.next();
+ this.curCharIter = curChild.charIterator();
+ } else {
+ curChild = null;
+ curCharIter = null;
+ }
}
public boolean hasNext() {
- while (curCharIter != null) {
- if (curCharIter.hasNext()==false) {
- getNextCharIter();
- }
- else return true;
- }
- return false;
+ while (curCharIter != null) {
+ if (curCharIter.hasNext() == false) {
+ getNextCharIter();
+ } else
+ return true;
+ }
+ return false;
}
public char nextChar() throws NoSuchElementException {
- if (curCharIter != null) {
- return curCharIter.nextChar();
- }
- else throw new NoSuchElementException();
+ if (curCharIter != null) {
+ return curCharIter.nextChar();
+ } else
+ throw new NoSuchElementException();
}
public void remove() {
- if (curCharIter != null) {
- curCharIter.remove();
- }
+ if (curCharIter != null) {
+ curCharIter.remove();
+ }
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
- * LICENSE file included with these sources."
+ * LICENSE file included with these sources.
*/
package org.apache.fop.fo;
/**
* Collection of properties used in
*/
- public class TextInfo {
- public FontState fs;
- public ColorType color;
- public int wrapOption;
- public boolean bWrap ; // True if wrap-option = WRAP
- public int whiteSpaceCollapse;
- public int verticalAlign;
- public int lineHeight;
+public class TextInfo {
+ public FontState fs;
+ public ColorType color;
+ public int wrapOption;
+ public boolean bWrap ; // True if wrap-option = WRAP
+ public int whiteSpaceCollapse;
+ public int verticalAlign;
+ public int lineHeight;
- // Props used for calculating inline-progression-dimension
- public SpaceVal wordSpacing;
- public SpaceVal letterSpacing;
+ // Props used for calculating inline-progression-dimension
+ public SpaceVal wordSpacing;
+ public SpaceVal letterSpacing;
- // Add hyphenation props too
- public boolean bCanHyphenate=true;
+ // Add hyphenation props too
+ public boolean bCanHyphenate=true;
- // Textdecoration
- public boolean underlined = false;
- public boolean overlined = false;
- public boolean lineThrough = false;
- }
+ // Textdecoration
+ public boolean underlined = false;
+ public boolean overlined = false;
+ public boolean lineThrough = false;
+}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public Property eval(Property[] args,
PropertyInfo propInfo) throws PropertyException {
Numeric num = args[0].getNumeric();
- if (num == null)
+ if (num == null) {
throw new PropertyException("Non numeric operand to abs function");
- // What if has relative composants (percent, table-col units)?
+ }
+ // What if has relative composants (percent, table-col units)?
return new NumericProperty(num.abs());
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public Property eval(Property[] args,
PropertyInfo pInfo) throws PropertyException {
Number dbl = args[0].getNumber();
- if (dbl == null)
+ if (dbl == null) {
throw new PropertyException("Non number operand to ceiling function");
+ }
return new NumberProperty(Math.ceil(dbl.doubleValue()));
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public Property eval(Property[] args,
PropertyInfo pInfo) throws PropertyException {
Number dbl = args[0].getNumber();
- if (dbl == null)
+ if (dbl == null) {
throw new PropertyException("Non number operand to floor function");
+ }
return new NumberProperty(Math.floor(dbl.doubleValue()));
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
PropertyInfo pInfo) throws PropertyException {
Numeric n1 = args[0].getNumeric();
Numeric n2 = args[1].getNumeric();
- if (n1 == null || n2 == null)
+ if (n1 == null || n2 == null) {
throw new PropertyException("Non numeric operands to max function");
+ }
return new NumericProperty(n1.max(n2));
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
PropertyInfo pInfo) throws PropertyException {
Numeric n1 = args[0].getNumeric();
Numeric n2 = args[1].getNumeric();
- if (n1 == null || n2 == null)
+ if (n1 == null || n2 == null) {
throw new PropertyException("Non numeric operands to min function");
+ }
return new NumericProperty(n1.min(n2));
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
*/
public Length asLength() {
if (dim == 1) {
- Vector len = new Vector(3);
+ Vector len = new Vector(3);
if ((valType & ABS_LENGTH) != 0) {
len.add(new FixedLength((int)absValue));
}
if ((valType & TCOL_LENGTH) != 0) {
len.add(new TableColLength(tcolValue));
}
- if (len.size() == 1) {
- return (Length)len.elementAt(0);
- }
- else {
- return new MixedLength(len);
- }
+ if (len.size() == 1) {
+ return (Length)len.elementAt(0);
+ } else {
+ return new MixedLength(len);
+ }
} else {
// or throw exception???
// can't make Length if dimension != 1
private boolean isMixedType() {
int ntype = 0;
for (int t = valType; t != 0; t = t >> 1) {
- if ((t & 1) != 0)
+ if ((t & 1) != 0) {
++ntype;
+ }
}
return ntype > 1;
}
double rslt = 0.0;
// Only compare if have same dimension and value type!
if (dim == op.dim && valType == op.valType &&!isMixedType()) {
- if (valType == ABS_LENGTH)
+ if (valType == ABS_LENGTH) {
rslt = absValue - op.absValue;
- else if (valType == PC_LENGTH)
+ } else if (valType == PC_LENGTH) {
rslt = pcValue - op.pcValue;
- else if (valType == TCOL_LENGTH)
+ } else if (valType == TCOL_LENGTH) {
rslt = tcolValue - op.tcolValue;
- if (rslt > 0.0)
+ }
+ if (rslt > 0.0) {
return this;
- else
+ } else {
return op;
+ }
}
throw new PropertyException("Arguments to max() must have same dimension and value type.");
}
double rslt = 0.0;
// Only compare if have same dimension and value type!
if (dim == op.dim && valType == op.valType &&!isMixedType()) {
- if (valType == ABS_LENGTH)
+ if (valType == ABS_LENGTH) {
rslt = absValue - op.absValue;
- else if (valType == PC_LENGTH)
+ } else if (valType == PC_LENGTH) {
rslt = pcValue - op.pcValue;
- else if (valType == TCOL_LENGTH)
+ } else if (valType == TCOL_LENGTH) {
rslt = tcolValue - op.tcolValue;
- if (rslt > 0.0)
+ }
+ if (rslt > 0.0) {
return op;
- else
+ } else {
return this;
+ }
}
throw new PropertyException("Arguments to min() must have same dimension and value type.");
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
}
public void popFunction() {
- if (stkFunction != null)
+ if (stkFunction != null) {
stkFunction.pop();
+ }
}
private PercentBase getFunctionPercentBase() {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public class PropertyParser extends PropertyTokenizer {
private PropertyInfo propInfo; // Maker and propertyList related info
- static private final String RELUNIT = "em";
- static private final Numeric negOne = new Numeric(new Double(-1.0));
- static final private HashMap functionTable = new HashMap();
+ private static final String RELUNIT = "em";
+ private static final Numeric negOne = new Numeric(new Double(-1.0));
+ private static final HashMap functionTable = new HashMap();
static {
// Initialize the HashMap of XSL-defined functions
if (propList != null) {
propList.addProperty(prop);
return propList;
- } else
+ } else {
return prop;
+ }
} else {
if (propList == null) {
propList = new ListProperty(prop);
// Evaluate and put result on the operand stack
Property prop = parseMultiplicativeExpr();
loop:
- for (; ; ) {
+ for (; ;) {
switch (currentToken) {
case TOK_PLUS:
next();
private Property parseMultiplicativeExpr() throws PropertyException {
Property prop = parseUnaryExpr();
loop:
- for (; ; ) {
+ for (; ;) {
switch (currentToken) {
case TOK_DIV:
next();
* and throws an exception if this isn't the case.
*/
private final void expectRpar() throws PropertyException {
- if (currentToken != TOK_RPAR)
+ if (currentToken != TOK_RPAR) {
throw new PropertyException("expected )");
+ }
next();
}
if (unitPart.equals(RELUNIT)) {
length = new FixedLength(numPart.doubleValue(),
propInfo.currentFontSize());
- } else
+ } else {
length = new FixedLength(numPart.doubleValue(), unitPart);
+ }
if (length == null) {
throw new PropertyException("unrecognized unit name: "
+ currentTokenValue);
- } else
+ } else {
prop = new LengthProperty(length);
+ }
break;
case TOK_COLORSPEC:
args[i++] = prop;
}
// ignore extra args
- if (currentToken != TOK_COMMA)
+ if (currentToken != TOK_COMMA) {
break;
+ }
next();
}
expectRpar();
*/
private Property evalAddition(Numeric op1,
Numeric op2) throws PropertyException {
- if (op1 == null || op2 == null)
+ if (op1 == null || op2 == null) {
throw new PropertyException("Non numeric operand in addition");
+ }
return new NumericProperty(op1.add(op2));
}
*/
private Property evalSubtraction(Numeric op1,
Numeric op2) throws PropertyException {
- if (op1 == null || op2 == null)
+ if (op1 == null || op2 == null) {
throw new PropertyException("Non numeric operand in subtraction");
+ }
return new NumericProperty(op1.subtract(op2));
}
* @throws PropertyException If the operand is null.
*/
private Property evalNegate(Numeric op) throws PropertyException {
- if (op == null)
+ if (op == null) {
throw new PropertyException("Non numeric operand to unary minus");
+ }
return new NumericProperty(op.multiply(negOne));
}
*/
private Property evalMultiply(Numeric op1,
Numeric op2) throws PropertyException {
- if (op1 == null || op2 == null)
+ if (op1 == null || op2 == null) {
throw new PropertyException("Non numeric operand in multiplication");
+ }
return new NumericProperty(op1.multiply(op2));
}
*/
private Property evalDivide(Numeric op1,
Numeric op2) throws PropertyException {
- if (op1 == null || op2 == null)
+ if (op1 == null || op2 == null) {
throw new PropertyException("Non numeric operand in division");
+ }
return new NumericProperty(op1.divide(op2));
}
*/
private Property evalModulo(Number op1,
Number op2) throws PropertyException {
- if (op1 == null || op2 == null)
+ if (op1 == null || op2 == null) {
throw new PropertyException("Non number operand to modulo");
+ }
return new NumberProperty(op1.doubleValue() % op2.doubleValue());
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
boolean currentMaybeOperator = recognizeOperator;
boolean bSawDecimal;
recognizeOperator = true;
- for (; ; ) {
+ for (; ;) {
if (exprIndex >= exprLength) {
currentToken = TOK_EOF;
return;
exprIndex++;
scanDigits();
}
- } else
+ } else {
bSawDecimal = false;
+ }
if (exprIndex < exprLength && expr.charAt(exprIndex) == '%') {
exprIndex++;
currentToken = TOK_PERCENT;
exprIndex);
// Probably should have some multiple of 3 for length!
return;
- } else
+ } else {
throw new PropertyException("illegal character '#'");
+ }
default:
--exprIndex;
scanName();
- if (exprIndex == currentTokenStartIndex)
+ if (exprIndex == currentTokenStartIndex) {
throw new PropertyException("illegal character");
+ }
currentTokenValue = expr.substring(currentTokenStartIndex,
exprIndex);
// if (currentMaybeOperator) {
* Attempt to recognize a valid NAME token in the input expression.
*/
private void scanName() {
- if (exprIndex < exprLength && isNameStartChar(expr.charAt(exprIndex)))
+ if (exprIndex < exprLength && isNameStartChar(expr.charAt(exprIndex))) {
while (++exprIndex < exprLength
- && isNameChar(expr.charAt(exprIndex)));
+ && isNameChar(expr.charAt(exprIndex))) { }
+ }
}
/**
* input expression.
*/
private void scanDigits() {
- while (exprIndex < exprLength && isDigit(expr.charAt(exprIndex)))
+ while (exprIndex < exprLength && isDigit(expr.charAt(exprIndex))) {
exprIndex++;
+ }
}
/**
* input expression.
*/
private void scanHexDigits() {
- while (exprIndex < exprLength && isHexDigit(expr.charAt(exprIndex)))
+ while (exprIndex < exprLength && isHexDigit(expr.charAt(exprIndex))) {
exprIndex++;
+ }
}
/**
}
- static private final String nameStartChars =
+ private static final String nameStartChars =
"_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- static private final String nameChars = ".-0123456789";
- static private final String digits = "0123456789";
- static private final String hexchars = digits + "abcdefABCDEF";
+ private static final String nameChars = ".-0123456789";
+ private static final String digits = "0123456789";
+ private static final String hexchars = digits + "abcdefABCDEF";
/**
* Return a boolean value indicating whether the argument is a
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public Property eval(Property[] args,
PropertyInfo pInfo) throws PropertyException {
Number dbl = args[0].getNumber();
- if (dbl == null)
+ if (dbl == null) {
throw new PropertyException("Non number operand to round function");
+ }
double n = dbl.doubleValue();
double r = Math.floor(n + 0.5);
- if (r == 0.0 && n < 0.0)
+ if (r == 0.0 && n < 0.0) {
r = -r; // round(-0.2) returns -0 not 0
+ }
return new NumberProperty(r);
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// only if bWScollapse=true
charIter.remove();
} else {
- if (bWScollapse)
+ if (bWScollapse) {
bInWS = true;
+ }
charIter.replaceChar('\u0020');
}
break;
*
*/
public class Character extends FObj {
- public final static int OK = 0;
- public final static int DOESNOT_FIT = 1;
+ public static final int OK = 0;
+ public static final int DOESNOT_FIT = 1;
private char characterValue;
/*
- * -- $Id$ --
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * $Id$
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// Depends on all cells starting in row
bRelativeAlign = true;
verticalAlign = this.properties.get("relative-align").getEnum();
- } else
+ } else {
bRelativeAlign = false; // Align on a per-cell basis
+ }
this.minCellHeight =
this.properties.get("height").getLength().mvalue();
this.beforeOffset = m_borderSeparation / 2
+ bp.getBorderTopWidth(false)
+ bp.getPaddingTop(false);
- // bp.getBorderBeforeWidth(false) + bp.getPaddingBefore(false);
+ // bp.getBorderBeforeWidth(false) + bp.getPaddingBefore(false);
} else {
// System.err.println("Collapse borders");
}
}
-
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// this.properties.get("number-columns-spanned");
// this.properties.get("visibility");
- this.iColumnNumber =
- this.properties.get("column-number").getNumber().intValue();
+ iColumnNumber = properties.get("column-number").getNumber().intValue();
- this.numColumnsRepeated =
- this.properties.get("number-columns-repeated").getNumber().intValue();
+ numColumnsRepeated =
+ properties.get("number-columns-repeated").getNumber().intValue();
this.backgroundColor =
this.properties.get("background-color").getColorType();
- this.columnWidthPropVal =
- this.properties.get("column-width").getLength();
- // This won't include resolved table-units or % values yet.
- this.columnWidth = columnWidthPropVal.mvalue();
+ Property prop = this.properties.get("column-width");
+ if(prop != null) {
+ columnWidthPropVal = properties.get("column-width").getLength();
+
+ // This won't include resolved table-units or % values yet.
+ columnWidth = columnWidthPropVal.mvalue();
+ } else {
+ columnWidth = 300000;
+ }
// initialize id
setupID();
/*
- * -- $Id$ --
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * $Id$
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
private KeepValue getKeepValue(String sPropName) {
Property p = this.properties.get(sPropName);
Number n = p.getNumber();
- if (n != null)
+ if (n != null) {
return new KeepValue(KeepValue.KEEP_WITH_VALUE, n.intValue());
+ }
switch (p.getEnum()) {
case Constants.ALWAYS:
return new KeepValue(KeepValue.KEEP_WITH_ALWAYS, 0);
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
minPadding = 0;
}
} else {
- // only accepted token is '0+1'at this stage. Because of the
+ // only accepted token is '0+1'at this stage. Because of the
// wonderful regular expression support in Java, we will resort to a
// loop
for (int i = 0; i < fmtLen - 1; i++) {
pageLM.run();
// Thread layoutThread = new Thread(pageLM);
-// layoutThread.start();
-// log.debug("Layout thread started");
-
-// // wait on both managers
-// try {
-// layoutThread.join();
-// log.debug("Layout thread done");
-// } catch (InterruptedException ie) {
-// log.error("PageSequence.format() interrupted waiting on layout");
-// }
+// layoutThread.start();
+// log.debug("Layout thread started");
+
+// // wait on both managers
+// try {
+// layoutThread.join();
+// log.debug("Layout thread done");
+// } catch (InterruptedException ie) {
+// log.error("PageSequence.format() interrupted waiting on layout");
+// }
// Tell the root the last page number we created.
this.root.setRunningPageNumberCounter(this.currentPageNumber);
}
// String formattedPageNumber =
// pageNumberGenerator.makeFormattedPageNumber(this.currentPageNumber);
// currentPage.setFormattedNumber(formattedPageNumber);
-// this.currentPageNumber++;
+// this.currentPageNumber++;
// //this.root.setRunningPageNumberCounter(this.currentPageNumber);
// BodyAreaContainer bodyArea = currentPage.getBody();
public abstract class Region extends FObj {
public static final String PROP_REGION_NAME = "region-name";
- public final static String BEFORE = "before";
- public final static String START = "start";
- public final static String END = "end";
- public final static String AFTER = "after";
- public final static String BODY = "body";
+ public static final String BEFORE = "before";
+ public static final String START = "start";
+ public static final String END = "end";
+ public static final String AFTER = "after";
+ public static final String BODY = "body";
private SimplePageMaster _layoutMaster;
private String _regionName;
protected int overflow;
-
protected Region(FONode parent) {
super(parent);
}
}
}
- if (parent instanceof SimplePageMaster) {
- _layoutMaster = (SimplePageMaster)parent;
- }
- else {
+ if (parent instanceof SimplePageMaster) {
+ _layoutMaster = (SimplePageMaster)parent;
+ } else {
throw new FOPException(this.name + " must be child "
+ "of simple-page-master, not "
+ parent.getName());
Rectangle2D absRegionRect = pageCTM.transform(relRegionRect);
// Get the region viewport rectangle in absolute coords by
// transforming it using the page CTM
- return new RegionViewport(absRegionRect);
+ return new RegionViewport(absRegionRect);
}
- abstract protected Rectangle getViewportRectangle(FODimension pageRefRect);
+ protected abstract Rectangle getViewportRectangle(FODimension pageRefRect);
/**
* Create the region reference area for this region master.
* height=top-bottom
*/
public RegionReference makeRegionReferenceArea(Rectangle2D absRegVPRect) {
- RegionReference r = new RegionReference(getRegionAreaClass());
- setRegionTraits(r, absRegVPRect);
- return r;
+ RegionReference r = new RegionReference(getRegionAreaClass());
+ setRegionTraits(r, absRegVPRect);
+ return r;
}
protected void setRegionTraits(RegionReference r, Rectangle2D absRegVPRect) {
// Common Border, Padding, and Background Properties
BorderAndPadding bap = propMgr.getBorderAndPadding();
BackgroundProps bProps = propMgr.getBackgroundProps();
- /* this.backgroundColor =
- this.properties.get("background-color").getColorType();*/
+/* backgroundColor = properties.get("background-color").getColorType();*/
// this.properties.get("clip");
// this.properties.get("display-align");
this.overflow = this.properties.get("overflow").getEnum();
- FODimension reldims = new FODimension(0,0);
- r.setCTM(propMgr.getCTMandRelDims(absRegVPRect, reldims));
+ FODimension reldims = new FODimension(0,0);
+ r.setCTM(propMgr.getCTMandRelDims(absRegVPRect, reldims));
- //r.setBackground(bProps);
+ //r.setBackground(bProps);
}
/**
* Return the enumerated value designating this type of region in the
* Area tree.
*/
- abstract protected int getRegionAreaClass();
+ protected abstract int getRegionAreaClass();
/**
* Returns the default region name (xsl-region-before, xsl-region-start,
}
protected Region getSiblingRegion(String regionClass) {
- // Ask parent for region
- return _layoutMaster.getRegion(regionClass);
+ // Ask parent for region
+ return _layoutMaster.getRegion(regionClass);
}
boolean getPrecedence() {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public class RegionAfter extends RegionBA {
-
public RegionAfter(FONode parent) {
super(parent);
}
-
protected Rectangle getViewportRectangle (FODimension reldims) {
- // Depends on extent and precedence
- Rectangle vpRect =
- new Rectangle(0, reldims.bpd - getExtent(),
- reldims.ipd, getExtent());
- if (getPrecedence() == false) {
- adjustIPD(vpRect);
- }
- return vpRect;
+ // Depends on extent and precedence
+ Rectangle vpRect =
+ new Rectangle(0, reldims.bpd - getExtent(),
+ reldims.ipd, getExtent());
+ if (getPrecedence() == false) {
+ adjustIPD(vpRect);
+ }
+ return vpRect;
}
-
protected String getDefaultRegionName() {
return "xsl-region-after";
}
return Region.AFTER;
}
-
}
+
}
public void end() {
- super.end();
+ super.end();
bPrecedence =
- (this.properties.get("precedence").getEnum()==Precedence.TRUE);
+ (this.properties.get("precedence").getEnum()==Precedence.TRUE);
}
/**
* and end regions if they are present.
*/
protected void adjustIPD(Rectangle vpRect) {
- int xoff = 0;
- Region start = getSiblingRegion(Region.START);
- if (start != null) {
- xoff = start.getExtent();
- vpRect.translate(xoff, 0);
- }
- Region end =getSiblingRegion(Region.END);
- if (end != null) {
- xoff += end.getExtent();
- }
- if (xoff > 0) {
- vpRect.grow(-xoff,0);
- }
+ int xoff = 0;
+ Region start = getSiblingRegion(Region.START);
+ if (start != null) {
+ xoff = start.getExtent();
+ vpRect.translate(xoff, 0);
+ }
+ Region end =getSiblingRegion(Region.END);
+ if (end != null) {
+ xoff += end.getExtent();
+ }
+ if (xoff > 0) {
+ vpRect.grow(-xoff,0);
+ }
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
}
public void end() {
- // The problem with this is that it might not be known yet....
- // Supposing extent is calculated in terms of percentage
+ // The problem with this is that it might not be known yet....
+ // Supposing extent is calculated in terms of percentage
this.extent = this.properties.get("extent").getLength().mvalue();
}
int getExtent() {
- return this.extent;
+ return this.extent;
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public class RegionBefore extends RegionBA {
-
public RegionBefore(FONode parent) {
super(parent);
}
// super.handleAttrs(attlist);
// }
-
protected String getDefaultRegionName() {
return "xsl-region-before";
}
return RegionReference.BEFORE;
}
-
protected Rectangle getViewportRectangle (FODimension reldims) {
- // Depends on extent and precedence
+ // Depends on extent and precedence
// This should return rectangle in writing-mode coordinates relative
// to the page-reference area rectangle
// This means the origin is (start, before) and the dimensions are (ipd,bpd)
// Before is always 0, start depends on extent
// ipd depends on precedence, bpd=extent
- Rectangle vpRect = new Rectangle(0, 0, reldims.ipd, getExtent());
- if (getPrecedence() == false) {
- adjustIPD(vpRect);
- }
- return vpRect;
+ Rectangle vpRect = new Rectangle(0, 0, reldims.ipd, getExtent());
+ if (getPrecedence() == false) {
+ adjustIPD(vpRect);
+ }
+ return vpRect;
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public class RegionEnd extends RegionSE {
-
public RegionEnd(FONode parent) {
super(parent);
}
protected Rectangle getViewportRectangle (FODimension reldims) {
- // Depends on extent and precedence
- Rectangle vpRect =
- new Rectangle(reldims.ipd - getExtent(), 0,
- getExtent(), reldims.bpd);
- adjustIPD(vpRect);
- return vpRect;
+ // Depends on extent and precedence
+ Rectangle vpRect =
+ new Rectangle(reldims.ipd - getExtent(), 0,
+ getExtent(), reldims.bpd);
+ adjustIPD(vpRect);
+ return vpRect;
}
protected String getDefaultRegionName() {
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
* diminish by extend of start and end if present.
*/
protected void adjustIPD(Rectangle refRect) {
- int yoff = 0;
- Region before = getSiblingRegion(Region.BEFORE);
- if (before != null && before.getPrecedence()) {
- yoff = before.getExtent();
- refRect.translate(0, yoff);
- }
- Region after = getSiblingRegion(Region.AFTER);
- if (after != null && after.getPrecedence()) {
- yoff += after.getExtent();
- }
- if (yoff > 0) {
- refRect.grow(0,-yoff);
- }
+ int yoff = 0;
+ Region before = getSiblingRegion(Region.BEFORE);
+ if (before != null && before.getPrecedence()) {
+ yoff = before.getExtent();
+ refRect.translate(0, yoff);
+ }
+ Region after = getSiblingRegion(Region.AFTER);
+ if (after != null && after.getPrecedence()) {
+ yoff += after.getExtent();
+ }
+ if (yoff > 0) {
+ refRect.grow(0,-yoff);
+ }
}
}
+
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources."
*/
public class RegionStart extends RegionSE {
-
public RegionStart(FONode parent) {
super(parent);
}
protected Rectangle getViewportRectangle (FODimension reldims) {
- // Depends on extent and precedence
+ // Depends on extent and precedence
// This is the rectangle relative to the page-reference area in
// writing-mode relative coordinates
- Rectangle vpRect =
- new Rectangle(0, 0, getExtent(), reldims.bpd);
- adjustIPD(vpRect);
- return vpRect;
+ Rectangle vpRect =
+ new Rectangle(0, 0, getExtent(), reldims.bpd);
+ adjustIPD(vpRect);
+ return vpRect;
}
protected String getDefaultRegionName() {
}
}
+
public class PFMReader {
private boolean invokedStandalone = false;
- public PFMReader() {}
-
+ public PFMReader() { }
/**
* Parse commandline arguments. put options in the HashMap and return
ArrayList arguments = new ArrayList();
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("-")) {
- if ((i + 1) < args.length &&!args[i + 1].startsWith("-")) {
+ if ((i + 1) < args.length && !args[i + 1].startsWith("-")) {
options.put(args[i], args[i + 1]);
i++;
} else {
return (String[])arguments.toArray(new String[0]);
}
- private final static void displayUsage() {
+ private static final void displayUsage() {
System.out.println(" java org.apache.fop.fonts.apps.PFMReader [options] metricfile.pfm xmlfile.xml\n");
System.out.println(" where options can be:\n");
System.out.println(" -fn <fontname>\n");
System.out.println("PFM Reader v1.1");
System.out.println();
- if (options.get("-ef") != null)
+ if (options.get("-ef") != null) {
embFile = (String)options.get("-ef");
+ }
- if (options.get("-er") != null)
+ if (options.get("-er") != null) {
embResource = (String)options.get("-er");
+ }
- if (options.get("-fn") != null)
+ if (options.get("-fn") != null) {
fontName = (String)options.get("-fn");
+ }
- if (options.get("-cn") != null)
+ if (options.get("-cn") != null) {
className = (String)options.get("-cn");
+ }
if (arguments.length != 2 || options.get("-h") != null
- || options.get("-help") != null || options.get("--help") != null)
+ || options.get("-help") != null || options.get("--help") != null) {
displayUsage();
- else {
+ } else {
PFMFile pfm = app.loadPFM(arguments[0]);
if (pfm != null) {
app.preview(pfm);
el = doc.createElement("embed");
root.appendChild(el);
- if (file != null)
+ if (file != null) {
el.setAttribute("file", file);
- if (resource != null)
+ }
+ if (resource != null) {
el.setAttribute("class", resource);
+ }
el = doc.createElement("encoding");
root.appendChild(el);
}
- private final static void displayUsage() {
+ private static final void displayUsage() {
System.out.println(" java org.apache.fop.fonts.apps.TTFReader [options] fontfile.ttf xmlfile.xml\n");
System.out.println(" where options can be:\n");
System.out.println("-enc ansi");
// FOP
import org.apache.fop.pdf.PDFColor;
-import org.apache.fop.pdf.PDFFilter;
import org.apache.fop.image.analyser.ImageReaderFactory;
import org.apache.fop.image.analyser.ImageReader;
import org.apache.fop.fo.FOUserAgent;
import java.awt.color.ColorSpace;
// FOP
-import org.apache.fop.pdf.PDFColor;
import org.apache.fop.image.analyser.ImageReader;
import org.apache.fop.fo.FOUserAgent;
// FOP
import org.apache.fop.apps.Driver;
-import org.apache.fop.pdf.PDFColor;
import org.apache.fop.image.analyser.ImageReader;
import org.apache.fop.image.analyser.EPSReader;
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// this.m_bitsPerPixel = cm.getPixelSize();
this.m_colorSpace = ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
if (cm.hasAlpha()) {
- int transparencyType = cm.getTransparency(); // java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
+ // java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
+ int transparencyType = cm.getTransparency();
if (transparencyType == java.awt.Transparency.OPAQUE) {
this.m_isTransparent = false;
} else if (transparencyType ==
import java.awt.color.ICC_ColorSpace;
// FOP
-import org.apache.fop.pdf.PDFColor;
-import org.apache.fop.pdf.DCTFilter;
import org.apache.fop.image.analyser.ImageReader;
import org.apache.fop.fo.FOUserAgent;
public static final int RIGHT = END;
private static class ResolvedCondLength implements Cloneable {
- int iLength; // Resolved length value
+ int iLength; // Resolved length value
boolean bDiscard;
ResolvedCondLength(CondLength length) {
iLength = length.mvalue();
}
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
}
* @return The copy.
*/
public Object clone() throws CloneNotSupportedException {
- BorderAndPadding bp = (BorderAndPadding) super.clone();
- bp.padding = (ResolvedCondLength[])padding.clone();
- bp.borderInfo = (BorderInfo[])borderInfo.clone();
- for (int i=0; i<padding.length; i++) {
- if (padding[i] != null) {
- bp.padding[i]=(ResolvedCondLength)padding[i].clone();
- }
- if (borderInfo[i] != null) {
- bp.borderInfo[i]=(BorderInfo)borderInfo[i].clone();
- }
- }
- return bp;
+ BorderAndPadding bp = (BorderAndPadding) super.clone();
+ bp.padding = (ResolvedCondLength[]) padding.clone();
+ bp.borderInfo = (BorderInfo[]) borderInfo.clone();
+ for (int i = 0; i < padding.length; i++) {
+ if (padding[i] != null) {
+ bp.padding[i] = (ResolvedCondLength) padding[i].clone();
+ }
+ if (borderInfo[i] != null) {
+ bp.borderInfo[i] = (BorderInfo) borderInfo[i].clone();
+ }
+ }
+ return bp;
}
public static class BorderInfo implements Cloneable {
- private int mStyle; // Enum for border style
- private ColorType mColor; // Border color
+ private int mStyle; // Enum for border style
+ private ColorType mColor; // Border color
private ResolvedCondLength mWidth;
BorderInfo(int style, CondLength width, ColorType color) {
mColor = color;
}
- public Object clone() throws CloneNotSupportedException {
- BorderInfo bi = (BorderInfo) super.clone();
- bi.mWidth = (ResolvedCondLength)mWidth.clone();
- // do we need to clone the Color too???
- return bi;
- }
+ public Object clone() throws CloneNotSupportedException {
+ BorderInfo bi = (BorderInfo) super.clone();
+ bi.mWidth = (ResolvedCondLength) mWidth.clone();
+ // do we need to clone the Color too???
+ return bi;
+ }
}
private BorderInfo[] borderInfo = new BorderInfo[4];
public int getBorderWidth(int side, boolean bDiscard) {
if ((borderInfo[side] == null) ||
- (borderInfo[side].mStyle == Constants.NONE) ||
- (bDiscard && borderInfo[side].mWidth.bDiscard)) {
+ (borderInfo[side].mStyle == Constants.NONE) ||
+ (bDiscard && borderInfo[side].mWidth.bDiscard)) {
return 0;
} else {
return borderInfo[side].mWidth.iLength;
- }
+ }
}
public ColorType getBorderColor(int side) {
}
public int getPadding(int side, boolean bDiscard) {
- if ((padding[side] == null) || (bDiscard && padding[side].bDiscard)) {
+ if ((padding[side] == null) ||
+ (bDiscard && padding[side].bDiscard)) {
return 0;
} else
return padding[side].iLength;
private String _fontFamily;
private String _fontStyle;
private int _fontWeight;
+
+ /**
+ * normal or small-caps font
+ */
private int _fontVariant;
private FontMetric _metric;
}
// Use default CodePointMapping
- char d = CodePointMapping.getMapping("WinAnsiEncoding").mapChar(c);
- if (d != 0) {
- c = d;
- } else {
- c = '#';
- }
+ char d = CodePointMapping.getMapping("WinAnsiEncoding").mapChar(c);
+ if (d != 0) {
+ c = d;
+ } else {
+ c = '#';
+ }
return c;
}
public String toString() {
- StringBuffer sbuf = new StringBuffer();
- sbuf.append('(');
- sbuf.append(_fontFamily);
- sbuf.append(',');
- sbuf.append(_fontName);
- sbuf.append(',');
- sbuf.append(_fontSize);
- sbuf.append(',');
- sbuf.append(_fontStyle);
- sbuf.append(',');
- sbuf.append(_fontWeight);
- sbuf.append(')');
- return sbuf.toString();
+ StringBuffer sbuf = new StringBuffer();
+ sbuf.append('(');
+ sbuf.append(_fontFamily);
+ sbuf.append(',');
+ sbuf.append(_fontName);
+ sbuf.append(',');
+ sbuf.append(_fontSize);
+ sbuf.append(',');
+ sbuf.append(_fontStyle);
+ sbuf.append(',');
+ sbuf.append(_fontWeight);
+ sbuf.append(')');
+ return sbuf.toString();
}
}
/**
* Capacity increment size
*/
- private final static int DEFAULT_BLOCK_SIZE = 2048;
+ private static final int DEFAULT_BLOCK_SIZE = 2048;
private int BLOCK_SIZE;
/**
/**
* Capacity increment size
*/
- private final static int DEFAULT_BLOCK_SIZE = 2048;
+ private static final int DEFAULT_BLOCK_SIZE = 2048;
private int BLOCK_SIZE;
/**
protected char freenode;
protected int length; // number of items in tree
- protected final static int BLOCK_SIZE = 2048; // allocation size for arrays
+ protected static final int BLOCK_SIZE = 2048; // allocation size for arrays
TernaryTree() {
init();
// * is enough space to place the float(s) anchored in the line.
// */
// protected void flush(Area area, boolean bFinished) {
- // if (area != null) {
- // // area.setFinished(true);
- // parentLM.addChild(area, bFinished); // ????
- // if (bFinished) {
- // setCurrentArea(null);
- // }
- // }
+ // if (area != null) {
+ // // area.setFinished(true);
+ // parentLM.addChild(area, bFinished); // ????
+ // if (bFinished) {
+ // setCurrentArea(null);
+ // }
+ // }
// }
/**
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
return curBlockArea;
}
- public void addBorders(Block curBlockArea) {
+ public void addBorders(Block curBlock) {
BorderProps bps = getBorderProps(BorderAndPadding.TOP);
if(bps.width != 0) {
- curBlockArea.addTrait(Trait.BORDER_START, bps);
+ curBlock.addTrait(Trait.BORDER_START, bps);
}
bps = getBorderProps(BorderAndPadding.BOTTOM);
if(bps.width != 0) {
- curBlockArea.addTrait(Trait.BORDER_END, bps);
+ curBlock.addTrait(Trait.BORDER_END, bps);
}
bps = getBorderProps(BorderAndPadding.LEFT);
if(bps.width != 0) {
- curBlockArea.addTrait(Trait.BORDER_BEFORE, bps);
+ curBlock.addTrait(Trait.BORDER_BEFORE, bps);
}
bps = getBorderProps(BorderAndPadding.RIGHT);
if(bps.width != 0) {
- curBlockArea.addTrait(Trait.BORDER_AFTER, bps);
+ curBlock.addTrait(Trait.BORDER_AFTER, bps);
}
}
* areas in the block-progression direction, such as Flow, Block, ListBlock.
*/
public abstract class BlockStackingLayoutManager extends AbstractLayoutManager {
- /** Reference to FO whose areas it's managing or to the traits
+ /**
+ * Reference to FO whose areas it's managing or to the traits
* of the FO.
*/
- LayoutManager curChildLM = null;
- BlockParent parentArea = null;
+ protected LayoutManager curChildLM = null;
+ protected BlockParent parentArea = null;
public BlockStackingLayoutManager(FObj fobj) {
super(fobj);
protected MinOptMax resolveSpaceSpecifier(Area nextArea) {
SpaceSpecifier spaceSpec = new SpaceSpecifier(false);
- // Area prevArea = getCurrentArea().getLast();
- // if (prevArea != null) {
- // spaceSpec.addSpace(prevArea.getSpaceAfter());
- // }
- // spaceSpec.addSpace(nextArea.getSpaceBefore());
+ // Area prevArea = getCurrentArea().getLast();
+ // if (prevArea != null) {
+ // spaceSpec.addSpace(prevArea.getSpaceAfter());
+ // }
+ // spaceSpec.addSpace(nextArea.getSpaceBefore());
return spaceSpec.resolve(false);
}
return false;
}
- // See if the whole thing fits, including space before
- // Calculate space between last child in curFlow and childArea
- //MinOptMax targetDim = parentArea.getAvailBPD();
MinOptMax spaceBefore = resolveSpaceSpecifier(childArea);
- //targetDim.subtract(spaceBefore);
- //if (targetDim.max >= childArea.getAllocationBPD().min) {
- //parentArea.addBlock(new InterBlockSpace(spaceBefore));
- // parentArea.addBlock((Block) childArea);
- // return false;
- //} else {
- parentArea.addBlock((Block) childArea);
- flush(); // hand off current area to parent
- // Probably need something like max BPD so we don't get into
- // infinite loops with large unbreakable chunks
-
- /*LayoutManager childLM =
- childArea.getGeneratingFObj(). getLayoutManager();
- if (childLM.splitArea(childArea, splitContext)) {
- //parentArea.addBlock(new InterBlockSpace(spaceBefore));
- parentArea.addBlock((Block) childArea);
- }*/
- //flush(); // hand off current area to parent
- //getParentArea(splitContext.nextArea);
- //getParentArea(childArea);
- // Check that reference IPD hasn't changed!!!
- // If it has, we must "reflow" the content
- //addChild(splitContext.nextArea);
- //addChild(childArea);
- return true;
- //}
+ parentArea.addBlock((Block) childArea);
+ flush(); // hand off current area to parent
+
+ return true;
}
int middlefollow = maxtb;
while (!curLM.isFinished()) {
+ MinOptMax lastSize = null;
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
- stack.add(bp.getStackingSize());
+ lastSize = bp.getStackingSize();
childBreaks.add(bp);
if (bp.getLead() > lineLead) {
middlefollow = bp.getMiddle();
}
}
+ if(lastSize != null) {
+ stack.add(lastSize);
+ }
}
if (maxtb - lineLead > middlefollow) {
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
MinOptMax stackSize = new MinOptMax();
while ((curLM = getChildLM()) != null) {
- if(curLM.generatesInlineAreas()) {
+ if (curLM.generatesInlineAreas()) {
// problem
curLM.setFinished(true);
continue;
// set stackLimit for remaining space
childLC.setStackLimit(MinOptMax.subtract(bpd, stackSize));
- if(bp.isForcedBreak()) {
+ if (bp.isForcedBreak()) {
breakPage = true;
break;
}
// check the stack bpd and if greater than available
// height then go to the last best break and return
// break position
- if(stackSize.opt > context.getStackLimit().opt) {
+ if (stackSize.opt > context.getStackLimit().opt) {
breakPage = true;
}
- if(breakPage) {
+ if (breakPage) {
return new BreakPoss(
new LeafPosition(this, blockBreaks.size() - 1));
}
}
setFinished(true);
- if(blockBreaks.size() > 0) {
+ if (blockBreaks.size() > 0) {
return new BreakPoss(
new LeafPosition(this, blockBreaks.size() - 1));
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
LayoutManager lm = getChildLM();
if (lm != null) {
return lm.canBreakBefore(context);
- } else
+ } else {
return false; // ??? NO child LM?
+ }
}
protected MinOptMax getPrevIPD(LayoutManager lm) {
m_prevBP = bp;
// if (bIsLast) {
- // setFinished(true); // Our last area, so indicate done
+ // setFinished(true); // Our last area, so indicate done
// }
return myBP;
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
}
/**
- * Call child layout managers to generate content as long as they
- * generate inline areas. If a block-level generating LM is found,
- * finish any line being filled and return to the parent LM.
+ * Call child layout managers to generate content.
+ * This gets the next break which is a full line.
+ *
*/
public BreakPoss getNextBreakPoss(LayoutContext context) {
// Get a break from currently active child LM
// Don't justify last line in the sequence or if forced line-end
int talign = bTextAlignment;
- if((bTextAlignment == TextAlign.JUSTIFY
+ if ((bTextAlignment == TextAlign.JUSTIFY
&& (m_prevBP.isForcedBreak()
|| isFinished()))) {
talign = TextAlign.START;
// points remain. Choose the best break.
if (hyph != null) {
return new HyphContext(hyph.getHyphenationPoints());
- } else
+ } else {
return null;
+ }
}
for(Iterator iter = m_vecInlineBreaks.listIterator(prevLineEnd);
iter.hasNext(); ) {
BreakPoss bp = (BreakPoss)iter.next();
- if(bp.getLead() > lineLead) {
+ if (bp.getLead() > lineLead) {
lineLead = bp.getLead();
}
- if(bp.getTotal() > maxtb) {
+ if (bp.getTotal() > maxtb) {
maxtb = bp.getTotal();
}
- if(bp.getMiddle() > middlefollow) {
+ if (bp.getMiddle() > middlefollow) {
middlefollow = bp.getMiddle();
}
// the stacking size of textLM accumulate for each break
// so the ipd is only added at the end of each LM
- if(bp.getLayoutManager() != lastLM) {
- if(lastLM != null) {
+ if (bp.getLayoutManager() != lastLM) {
+ if (lastLM != null) {
actual.add(lastBP.getStackingSize());
}
lastLM = bp.getLayoutManager();
}
lastBP = bp;
}
- if(lastBP != null) {
+ if (lastBP != null) {
// add final ipd
actual.add(lastBP.getStackingSize());
// ATTENTION: make sure this hasn't gotten start space for next
actual.add(lastBP.resolveTrailingSpace(true));
}
- if(maxtb - lineLead > middlefollow) {
+ if (maxtb - lineLead > middlefollow) {
middlefollow = maxtb - lineLead;
}
int indent = 0;
switch (textalign) {
case TextAlign.JUSTIFY:
- if(realWidth != 0) {
+ if (realWidth != 0) {
dAdjust = (targetWith - realWidth) / realWidth;
}
break;
lc.setLeadingSpace(lc.getTrailingSpace());
lc.setTrailingSpace(new SpaceSpecifier(false));
}
-if(lc.getTrailingSpace() != null) {
addSpace(lineArea, lc.getTrailingSpace().resolve(true),
lc.getSpaceAdjust());
-}
parentLM.addChild(lineArea);
}
setCurrentArea(null); // ?? necessary
* For now, only handle normal flow areas.
*/
public boolean addChild(Area childArea) {
- if (childArea == null)
+ if (childArea == null) {
return false;
+ }
if (childArea.getAreaClass() == Area.CLASS_NORMAL) {
return placeFlowRefArea(childArea);
- } else
+ } else {
; // TODO: all the others!
+ }
return false;
}
*/
private boolean needEmptyPage(int breakValue) {
return false;
- // if (breakValue == Constants.PAGE || curPage.isEmpty()) {
- // // any page is OK or we already have an empty page
- // return false;
- // }
- // else {
- // /* IF we are on the kind of page we need, we'll need a new page. */
- // if (curPage.getPageNumber()%2 != 0) {
- // // Current page is odd
- // return (breakValue == Constants.ODD_PAGE);
- // }
- // else {
- // return (breakValue == Constants.EVEN_PAGE);
- // }
- // }
+ // if (breakValue == Constants.PAGE || curPage.isEmpty()) {
+ // // any page is OK or we already have an empty page
+ // return false;
+ // }
+ // else {
+ // /* IF we are on the kind of page we need, we'll need a new page. */
+ // if (curPage.getPageNumber()%2 != 0) {
+ // // Current page is odd
+ // return (breakValue == Constants.ODD_PAGE);
+ // }
+ // else {
+ // return (breakValue == Constants.EVEN_PAGE);
+ // }
+ // }
}
/**
return m_childLM;
}
- abstract protected LayoutManager getLM(Object nextObj);
+ protected abstract LayoutManager getLM(Object nextObj);
- abstract protected Position getPos(Object nextObj);
+ protected abstract Position getPos(Object nextObj);
private void lookAhead() {
if (m_parentIter.hasNext()) {
private ArrayList m_vecAreaInfo;
/** Non-space characters on which we can end a line. */
- static private final String s_breakChars = "-/" ;
+ private static final String s_breakChars = "-/" ;
private char[] chars;
private TextInfo textInfo;
double dSpaceAdjust = context.getSpaceAdjust();
if (dSpaceAdjust > 0.0) {
// Stretch by factor
- // System.err.println("Potential stretch = " +
- // (ai.m_ipdArea.max - ai.m_ipdArea.opt));
+ // System.err.println("Potential stretch = " +
+ // (ai.m_ipdArea.max - ai.m_ipdArea.opt));
iAdjust = (int)((double)(ai.m_ipdArea.max -
ai.m_ipdArea.opt) * dSpaceAdjust);
} else if (dSpaceAdjust < 0.0) {
// Shrink by factor
- // System.err.println("Potential shrink = " +
- // (ai.m_ipdArea.opt - ai.m_ipdArea.min));
+ // System.err.println("Potential shrink = " +
+ // (ai.m_ipdArea.opt - ai.m_ipdArea.min));
iAdjust = (int)((double)(ai.m_ipdArea.opt -
ai.m_ipdArea.min) * dSpaceAdjust);
}
- // System.err.println("Text adjustment factor = " + dSpaceAdjust +
- // " total=" + iAdjust);
+ // System.err.println("Text adjustment factor = " + dSpaceAdjust +
+ // " total=" + iAdjust);
// Make an area containing all characters between start and end.
Word word = null;
Object oTrait) {
int iBP = bpProps.getBorderWidth(iSide, bDiscard);
if (iBP > 0) {
- // area.addTrait(new Trait(oTrait,
- // new BorderProps(bpProps.getBorderStyle(iSide),
- // iBP,
- // bpProps.getBorderColor(iSide))));
+ // area.addTrait(new Trait(oTrait,
+ // new BorderProps(bpProps.getBorderStyle(iSide),
+ // iBP,
+ // bpProps.getBorderColor(iSide))));
area.addTrait(oTrait,
new BorderProps(bpProps.getBorderStyle(iSide),
iBP, bpProps.getBorderColor(iSide)));
while (!curLM.isFinished()) {
if ((bp = curLM.getNextBreakPoss(childLC)) != null) {
stackSize.add(bp.getStackingSize());
- if (stackSize.min > context.getStackLimit().max) {
+ if (stackSize.opt > context.getStackLimit().max) {
// reset to last break
if (lastPos != null) {
reset(lastPos.getPosition());
import org.apache.fop.util.StreamUtilities;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.*;
+import java.io.InputStream;
+import java.io.OutputStream;
/**
* DCT Filter class. Right now it is just used as a dummy filter flag so
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
* p.append("\n/UseCMap ");
* if (base instanceof String) {
* p.append("/"+base);
- * } else { // base instanceof PDFStream
+ * } else {// base instanceof PDFStream
* p.append(((PDFStream)base).referencePDF());
* }
* }
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
// Java
import java.util.ArrayList;
-import java.io.IOException;
-import java.io.PrintWriter;
public class PDFColor extends PDFPathPaint {
protected static double blackFactor = 2.0; // could be 3.0 as well.
}
}
+
}
private int calculateNumComponents() {
- if (currentColorSpace == DEVICE_GRAY)
+ if (currentColorSpace == DEVICE_GRAY) {
return 1;
- else if (currentColorSpace == DEVICE_RGB)
+ } else if (currentColorSpace == DEVICE_RGB) {
return 3;
- else if (currentColorSpace == DEVICE_CMYK)
+ } else if (currentColorSpace == DEVICE_CMYK) {
return 4;
- else
+ } else {
return 0;
+ }
}
public void setColorSpace(int theColorSpace) {
}
p.append("endobj\n");
+ // end of if FunctionType 0
- } // end of if FunctionType 0
- else if (this.functionType == 2) {
+ } else if (this.functionType == 2) {
// DOMAIN
if (this.domain != null) {
p.append("/Domain [ ");
}
public boolean equals(Object obj) {
- if(obj == null) {
+ if (obj == null) {
return false;
}
- if(obj == this) {
+ if (obj == this) {
return true;
}
- if(!(obj instanceof PDFFunction)) {
+ if (!(obj instanceof PDFFunction)) {
return false;
}
PDFFunction func = (PDFFunction)obj;
- if(functionType != func.functionType) {
+ if (functionType != func.functionType) {
return false;
}
- if(bitsPerSample != func.bitsPerSample) {
+ if (bitsPerSample != func.bitsPerSample) {
return false;
}
- if(order != func.order) {
+ if (order != func.order) {
return false;
}
- if(interpolationExponentN != func.interpolationExponentN) {
+ if (interpolationExponentN != func.interpolationExponentN) {
return false;
}
- if(domain != null) {
- if(!domain.equals(func.domain)) {
+ if (domain != null) {
+ if (!domain.equals(func.domain)) {
return false;
}
- } else if(func.domain != null) {
+ } else if (func.domain != null) {
return false;
}
- if(range != null) {
- if(!range.equals(func.range)) {
+ if (range != null) {
+ if (!range.equals(func.range)) {
return false;
}
- } else if(func.range != null) {
+ } else if (func.range != null) {
return false;
}
- if(size != null) {
- if(!size.equals(func.size)) {
+ if (size != null) {
+ if (!size.equals(func.size)) {
return false;
}
- } else if(func.size != null) {
+ } else if (func.size != null) {
return false;
}
- if(encode != null) {
- if(!encode.equals(func.encode)) {
+ if (encode != null) {
+ if (!encode.equals(func.encode)) {
return false;
}
- } else if(func.encode != null) {
+ } else if (func.encode != null) {
return false;
}
- if(decode != null) {
- if(!decode.equals(func.decode)) {
+ if (decode != null) {
+ if (!decode.equals(func.decode)) {
return false;
}
- } else if(func.decode != null) {
+ } else if (func.decode != null) {
return false;
}
- if(functionDataStream != null) {
- if(!functionDataStream.equals(func.functionDataStream)) {
+ if (functionDataStream != null) {
+ if (!functionDataStream.equals(func.functionDataStream)) {
return false;
}
- } else if(func.functionDataStream != null) {
+ } else if (func.functionDataStream != null) {
return false;
}
- if(filter != null) {
- if(!filter.equals(func.filter)) {
+ if (filter != null) {
+ if (!filter.equals(func.filter)) {
return false;
}
- } else if(func.filter != null) {
+ } else if (func.filter != null) {
return false;
}
- if(cZero != null) {
- if(!cZero.equals(func.cZero)) {
+ if (cZero != null) {
+ if (!cZero.equals(func.cZero)) {
return false;
}
- } else if(func.cZero != null) {
+ } else if (func.cZero != null) {
return false;
}
- if(cOne != null) {
- if(!cOne.equals(func.cOne)) {
+ if (cOne != null) {
+ if (!cOne.equals(func.cOne)) {
return false;
}
- } else if(func.cOne != null) {
+ } else if (func.cOne != null) {
return false;
}
- if(functions != null) {
- if(!functions.equals(func.functions)) {
+ if (functions != null) {
+ if (!functions.equals(func.functions)) {
return false;
}
- } else if(func.functions != null) {
+ } else if (func.functions != null) {
return false;
}
- if(bounds != null) {
- if(!bounds.equals(func.bounds)) {
+ if (bounds != null) {
+ if (!bounds.equals(func.bounds)) {
return false;
}
- } else if(func.bounds != null) {
+ } else if (func.bounds != null) {
return false;
}
return true;
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
}
public void setAlpha(float val, boolean fill) {
- if(fill) {
+ if (fill) {
values.put(ca, new Float(val));
} else {
values.put(CA, new Float(val));
private void appendVal(StringBuffer sb, String name) {
Object val = values.get(name);
- if(val != null) {
+ if (val != null) {
sb.append("/" + name + " " + val + "\n");
}
}
*/
public boolean equals(Object obj) {
- if(obj == this) {
+ if (obj == this) {
return true;
}
- if(!(obj instanceof PDFGState)) {
+ if (!(obj instanceof PDFGState)) {
return false;
}
HashMap vals1 = values;
HashMap vals2 = ((PDFGState)obj).values;
- if(vals1.size() != vals2.size()) {
+ if (vals1.size() != vals2.size()) {
return false;
}
- for(Iterator iter = vals1.keySet().iterator(); iter.hasNext(); ) {
+ for(Iterator iter = vals1.keySet().iterator(); iter.hasNext();) {
Object str = iter.next();
Object obj1 = vals1.get(str);
- if(!obj1.equals(vals2.get(str))) {
+ if (!obj1.equals(vals2.get(str))) {
return false;
}
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
pb.append(this.number).append(" ").append(this.generation).append(" obj\n<< ");
pb.append("/N ").append(cp.getNumComponents()).append(" ");
- if (pdfColorSpace != null)
+ if (pdfColorSpace != null) {
pb.append("/Alternate /").append(pdfColorSpace.getColorSpacePDFString()).append(" ");
+ }
pb.append("/Length ").append((_data.getSize() + 1)).append(" ").append(filterEntry);
pb.append(" >>\n");
public byte[] toPDF() {
String p = this.number + " " + this.generation
+ " obj\n<< /Type /Info\n";
- if(title != null) {
+ if (title != null) {
p += "/Title (" + this.title + ")\n";
}
- if(author != null) {
+ if (author != null) {
p += "/Author (" + this.author + ")\n";
}
- if(subject != null) {
+ if (subject != null) {
p += "/Subject (" + this.subject + ")\n";
}
- if(keywords != null) {
+ if (keywords != null) {
p += "/Keywords (" + this.keywords + ")\n";
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public class PDFNumber {
- private PDFNumber() {}
+ private PDFNumber() { }
public static String doubleOut(Double doubleDown) {
StringBuffer p = new StringBuffer();
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
p.append(this.number + " " + this.generation
+ " obj\n<< \n/Type /Pattern \n");
- if(this.resources != null) {
+ if (this.resources != null) {
p.append("/Resources " + this.resources.referencePDF() + " \n");
}
public byte[] toPDF() { return null; }
public boolean equals(Object obj) {
- if(obj == null) {
+ if (obj == null) {
return false;
}
- if(obj == this) {
+ if (obj == this) {
return true;
}
- if(!(obj instanceof PDFPattern)) {
+ if (!(obj instanceof PDFPattern)) {
return false;
}
PDFPattern patt = (PDFPattern)obj;
- if(patternType != patt.patternType) {
+ if (patternType != patt.patternType) {
return false;
}
- if(paintType != patt.paintType) {
+ if (paintType != patt.paintType) {
return false;
}
- if(tilingType != patt.tilingType) {
+ if (tilingType != patt.tilingType) {
return false;
}
- if(xStep != patt.xStep) {
+ if (xStep != patt.xStep) {
return false;
}
- if(yStep != patt.yStep) {
+ if (yStep != patt.yStep) {
return false;
}
- if(bBox != null) {
- if(!bBox.equals(patt.bBox)) {
+ if (bBox != null) {
+ if (!bBox.equals(patt.bBox)) {
return false;
}
- } else if(patt.bBox != null) {
+ } else if (patt.bBox != null) {
return false;
}
- if(bBox != null) {
- if(!bBox.equals(patt.bBox)) {
+ if (bBox != null) {
+ if (!bBox.equals(patt.bBox)) {
return false;
}
- } else if(patt.bBox != null) {
+ } else if (patt.bBox != null) {
return false;
}
- if(xUID != null) {
- if(!xUID.equals(patt.xUID)) {
+ if (xUID != null) {
+ if (!xUID.equals(patt.xUID)) {
return false;
}
- } else if(patt.xUID != null) {
+ } else if (patt.xUID != null) {
return false;
}
- if(extGState != null) {
- if(!extGState.equals(patt.extGState)) {
+ if (extGState != null) {
+ if (!extGState.equals(patt.extGState)) {
return false;
}
- } else if(patt.extGState != null) {
+ } else if (patt.extGState != null) {
return false;
}
- if(matrix != null) {
- if(!matrix.equals(patt.matrix)) {
+ if (matrix != null) {
+ if (!matrix.equals(patt.matrix)) {
return false;
}
- } else if(patt.matrix != null) {
+ } else if (patt.matrix != null) {
return false;
}
- if(resources != null) {
- if(!resources.equals(patt.resources)) {
+ if (resources != null) {
+ if (!resources.equals(patt.resources)) {
return false;
}
- } else if(patt.resources != null) {
+ } else if (patt.resources != null) {
return false;
}
- if(shading != null) {
- if(!shading.equals(patt.shading)) {
+ if (shading != null) {
+ if (!shading.equals(patt.shading)) {
return false;
}
- } else if(patt.shading != null) {
+ } else if (patt.shading != null) {
return false;
}
- if(patternDataStream != null) {
- if(!patternDataStream.equals(patt.patternDataStream)) {
+ if (patternDataStream != null) {
+ if (!patternDataStream.equals(patt.patternDataStream)) {
return false;
}
- } else if(patt.patternDataStream != null) {
+ } else if (patt.patternDataStream != null) {
return false;
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
}
public boolean equals(Object obj) {
- if(obj == null) {
+ if (obj == null) {
return false;
}
- if(obj == this) {
+ if (obj == this) {
return true;
}
- if(!(obj instanceof PDFShading)) {
+ if (!(obj instanceof PDFShading)) {
return false;
}
PDFShading shad = (PDFShading)obj;
- if(shadingType != shad.shadingType) {
+ if (shadingType != shad.shadingType) {
return false;
}
- if(antiAlias != shad.antiAlias) {
+ if (antiAlias != shad.antiAlias) {
return false;
}
- if(bitsPerCoordinate != shad.bitsPerCoordinate) {
+ if (bitsPerCoordinate != shad.bitsPerCoordinate) {
return false;
}
- if(bitsPerFlag != shad.bitsPerFlag) {
+ if (bitsPerFlag != shad.bitsPerFlag) {
return false;
}
- if(bitsPerComponent != shad.bitsPerComponent) {
+ if (bitsPerComponent != shad.bitsPerComponent) {
return false;
}
- if(verticesPerRow != shad.verticesPerRow) {
+ if (verticesPerRow != shad.verticesPerRow) {
return false;
}
- if(colorSpace != null) {
- if(!colorSpace.equals(shad.colorSpace)) {
+ if (colorSpace != null) {
+ if (!colorSpace.equals(shad.colorSpace)) {
return false;
}
- } else if(shad.colorSpace != null) {
+ } else if (shad.colorSpace != null) {
return false;
}
- if(background != null) {
- if(!background.equals(shad.background)) {
+ if (background != null) {
+ if (!background.equals(shad.background)) {
return false;
}
- } else if(shad.background != null) {
+ } else if (shad.background != null) {
return false;
}
- if(bBox != null) {
- if(!bBox.equals(shad.bBox)) {
+ if (bBox != null) {
+ if (!bBox.equals(shad.bBox)) {
return false;
}
- } else if(shad.bBox != null) {
+ } else if (shad.bBox != null) {
return false;
}
- if(domain != null) {
- if(!domain.equals(shad.domain)) {
+ if (domain != null) {
+ if (!domain.equals(shad.domain)) {
return false;
}
- } else if(shad.domain != null) {
+ } else if (shad.domain != null) {
return false;
}
- if(matrix != null) {
- if(!matrix.equals(shad.matrix)) {
+ if (matrix != null) {
+ if (!matrix.equals(shad.matrix)) {
return false;
}
- } else if(shad.matrix != null) {
+ } else if (shad.matrix != null) {
return false;
}
- if(coords != null) {
- if(!coords.equals(shad.coords)) {
+ if (coords != null) {
+ if (!coords.equals(shad.coords)) {
return false;
}
- } else if(shad.coords != null) {
+ } else if (shad.coords != null) {
return false;
}
- if(extend != null) {
- if(!extend.equals(shad.extend)) {
+ if (extend != null) {
+ if (!extend.equals(shad.extend)) {
return false;
}
- } else if(shad.extend != null) {
+ } else if (shad.extend != null) {
return false;
}
- if(decode != null) {
- if(!decode.equals(shad.decode)) {
+ if (decode != null) {
+ if (!decode.equals(shad.decode)) {
return false;
}
- } else if(shad.decode != null) {
+ } else if (shad.decode != null) {
return false;
}
- if(function != null) {
- if(!function.equals(shad.function)) {
+ if (function != null) {
+ if (!function.equals(shad.function)) {
return false;
}
- } else if(shad.function != null) {
+ } else if (shad.function != null) {
return false;
}
return true;
* the possible combinations after completing.
*/
public class PDFState {
- private final static String COLOR = "color";
- private final static String BACKCOLOR = "backcolor";
- private final static String PAINT = "paint";
- private final static String BACKPAINT = "backpaint";
- private final static String LINECAP = "lineCap";
- private final static String LINEJOIN = "lineJoin";
- private final static String LINEWIDTH = "lineWidth";
- private final static String MITERLIMIT = "miterLimit";
- private final static String TEXT = "text";
- private final static String DASHOFFSET = "dashOffset";
- private final static String DASHARRAY = "dashArray";
- private final static String TRANSFORM = "transform";
- private final static String FONTSIZE = "fontSize";
- private final static String FONTNAME = "fontName";
- private final static String CLIP = "clip";
- private final static String GSTATE = "gstate";
-
- Color color = Color.black;
- Color backcolor = Color.white;
- Paint paint = null;
- Paint backPaint = null;
- int lineCap = 0;
- int lineJoin = 0;
- float lineWidth = 1;
- float miterLimit = 0;
- boolean text = false;
- int dashOffset = 0;
- int[] dashArray = new int[0];
- AffineTransform transform = new AffineTransform();
- float fontSize = 0;
- String fontName = "";
- Shape clip = null;
- PDFGState gstate = null;
+ private static final String COLOR = "color";
+ private static final String BACKCOLOR = "backcolor";
+ private static final String PAINT = "paint";
+ private static final String BACKPAINT = "backpaint";
+ private static final String LINECAP = "lineCap";
+ private static final String LINEJOIN = "lineJoin";
+ private static final String LINEWIDTH = "lineWidth";
+ private static final String MITERLIMIT = "miterLimit";
+ private static final String TEXT = "text";
+ private static final String DASHOFFSET = "dashOffset";
+ private static final String DASHARRAY = "dashArray";
+ private static final String TRANSFORM = "transform";
+ private static final String FONTSIZE = "fontSize";
+ private static final String FONTNAME = "fontName";
+ private static final String CLIP = "clip";
+ private static final String GSTATE = "gstate";
+
+ private Color color = Color.black;
+ private Color backcolor = Color.white;
+ private Paint paint = null;
+ private Paint backPaint = null;
+ private int lineCap = 0;
+ private int lineJoin = 0;
+ private float lineWidth = 1;
+ private float miterLimit = 0;
+ private boolean text = false;
+ private int dashOffset = 0;
+ private int[] dashArray = new int[0];
+ private AffineTransform transform = new AffineTransform();
+ private float fontSize = 0;
+ private String fontName = "";
+ private Shape clip = null;
+ private PDFGState gstate = null;
ArrayList stateStack = new ArrayList();
while(stateStack.size() > pos + 1) {
stateStack.remove(stateStack.size() - 1);
}
- if(stateStack.size() > pos) {
+ if (stateStack.size() > pos) {
pop();
}
}
}
public boolean setColor(Color col) {
- if(!col.equals(color)) {
+ if (!col.equals(color)) {
color = col;
return true;
}
}
public boolean setBackColor(Color col) {
- if(!col.equals(backcolor)) {
+ if (!col.equals(backcolor)) {
backcolor = col;
return true;
}
}
public boolean setPaint(Paint p) {
- if(paint == null) {
- if(p != null) {
+ if (paint == null) {
+ if (p != null) {
paint = p;
return true;
}
- } else if(!paint.equals(p)) {
+ } else if (!paint.equals(p)) {
paint = p;
return true;
}
* For clips it can start a new state
*/
public boolean checkClip(Shape cl) {
- if(clip == null) {
- if(cl != null) {
+ if (clip == null) {
+ if (cl != null) {
return true;
}
- } else if(!new Area(clip).equals(new Area(cl))) {
+ } else if (!new Area(clip).equals(new Area(cl))) {
return true;
}
return false;
public AffineTransform getTransform() {
AffineTransform tf;
AffineTransform at = new AffineTransform();
- for(Iterator iter = stateStack.iterator(); iter.hasNext(); ) {
+ for (Iterator iter = stateStack.iterator(); iter.hasNext();) {
HashMap map = (HashMap)iter.next();
tf = (AffineTransform)map.get(TRANSFORM);
at.concatenate(tf);
PDFGState state;
PDFGState newstate = new PDFGState(0);
newstate.addValues(defaultState);
- for(Iterator iter = stateStack.iterator(); iter.hasNext(); ) {
+ for (Iterator iter = stateStack.iterator(); iter.hasNext(); ) {
HashMap map = (HashMap)iter.next();
state = (PDFGState)map.get(GSTATE);
- if(state != null) {
+ if (state != null) {
newstate.addValues(state);
}
}
- if(gstate != null) {
+ if (gstate != null) {
newstate.addValues(gstate);
}
origLength = len;
}
- private final static boolean byteCmp(byte[] src, int offset, byte[] cmp) {
+ private static final boolean byteCmp(byte[] src, int offset, byte[] cmp) {
boolean ret = true;
for (int i = 0; ret == true && i < cmp.length; i++) {
// System.out.println("Compare: ");
/**
* The first and last non space-character
*/
- private final static int FIRST_CHAR = 32;
- private final static int LAST_CHAR = 255;
+ private static final int FIRST_CHAR = 32;
+ private static final int LAST_CHAR = 255;
/**
* This is a AWTFontMetrics that does the real calculation.
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
public char mapChar(char c) {
char d = mapping.mapChar(c);
- if(d != 0)
+ if(d != 0) {
return d;
- else
- return '#';
+ } else {
+ return '#';
+ }
}
}
/*
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * $Id$
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
return;
try {
- byte buff[] = str.getBytes("UTF-8");
+ byte buff[] = str.getBytes("UTF-8");
out.write(buff);
} catch (IOException e) {
throw new RuntimeException(e.toString());
}
}
+
}
// public static int higherBreak(int brkParent, int brkChild) {
- // if (brkParent == brkChild) return brkChild;
- // for (int i=0; i < s_breakPriorities.length; i++) {
- // int bp = s_breakPriorities[i];
- // if (bp == brkParent) return brkChild;
- // else if (bp == brkChild) return brkParent;
- // }
- // return brkChild;
+ // if (brkParent == brkChild) return brkChild;
+ // for (int i=0; i < s_breakPriorities.length; i++) {
+ // int bp = s_breakPriorities[i];
+ // if (bp == brkParent) return brkChild;
+ // else if (bp == brkChild) return brkParent;
+ // }
+ // return brkChild;
// }
public void combineWithParent(LayoutProps parentLP) {
if (bp == breakBefore) {
breakBefore = parentLP.breakBefore;
break;
- } else if (bp == parentLP.breakBefore)
+ } else if (bp == parentLP.breakBefore) {
break;
+ }
}
}
// Parent span always overrides child span
bIsSpan = parentLP.bIsSpan;
}
}
+
public final int iPrecedence; // Numeric only, if forcing, set to 0
public SpaceVal(Space spaceprop) {
- space = new MinOptMax(
- spaceprop.getMinimum().getLength().mvalue(),
- spaceprop.getOptimum().getLength().mvalue(),
- spaceprop.getMaximum().getLength().mvalue());
- bConditional = (spaceprop.getConditionality().getEnum() ==
- Constants.DISCARD);
- Property precProp = spaceprop.getPrecedence();
- if (precProp.getNumber() != null) {
- iPrecedence = precProp.getNumber().intValue();
- bForcing = false;
- }
- else {
- bForcing = (precProp.getEnum() == Constants.FORCE);
- iPrecedence=0;
- }
+ space = new MinOptMax( spaceprop.getMinimum().getLength().mvalue(),
+ spaceprop.getOptimum().getLength().mvalue(),
+ spaceprop.getMaximum().getLength().mvalue());
+ bConditional = (spaceprop.getConditionality().getEnum() ==
+ Constants.DISCARD);
+ Property precProp = spaceprop.getPrecedence();
+ if (precProp.getNumber() != null) {
+ iPrecedence = precProp.getNumber().intValue();
+ bForcing = false;
+ } else {
+ bForcing = (precProp.getEnum() == Constants.FORCE);
+ iPrecedence = 0;
+ }
}
- public SpaceVal(MinOptMax space, boolean bConditional, boolean bForcing,
- int iPrecedence) {
- this.space = space;
- this.bConditional = bConditional;
- this.bForcing = bForcing;
- this.iPrecedence = iPrecedence;
+ public SpaceVal(MinOptMax space, boolean bConditional,
+ boolean bForcing, int iPrecedence) {
+ this.space = space;
+ this.bConditional = bConditional;
+ this.bForcing = bForcing;
+ this.iPrecedence = iPrecedence;
}
}
/*
* $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
* inline content, such as an inline with borders and padding
* or a nested block object.
*/
- public static final char CODE_EOT=0;
+ public static final char CODE_EOT = 0;
- public static final int UCWHITESPACE=0; // unicode white space
- public static final int LINEFEED=1;
- public static final int EOT=2; // Boundary beteween text runs
- public static final int NONWHITESPACE=3;
- public static final int XMLWHITESPACE=4;
+ public static final int UCWHITESPACE = 0; // unicode white space
+ public static final int LINEFEED = 1;
+ public static final int EOT = 2; // Boundary beteween text runs
+ public static final int NONWHITESPACE = 3;
+ public static final int XMLWHITESPACE = 4;
/**
* of the passed character.
*/
public static int classOf(char c) {
- if (c == CODE_EOT) return EOT;
- if (c == '\n') return LINEFEED;
- if ( c==' '|| c == '\r' || c=='\t' ) return XMLWHITESPACE;
- if (isAnySpace(c)) return UCWHITESPACE;
- return NONWHITESPACE;
+ if (c == CODE_EOT) { return EOT; }
+ if (c == '\n') { return LINEFEED; }
+ if (c == ' '|| c == '\r' || c == '\t' ) { return XMLWHITESPACE; }
+ if (isAnySpace(c)) { return UCWHITESPACE; }
+ return NONWHITESPACE;
}
/**
// the font
int em = fs.width(fs.mapChar('m'));
int en = fs.width(fs.mapChar('n'));
- if (em <= 0)
+ if (em <= 0) {
em = 500 * fs.getFontSize();
- if (en <= 0)
+ }
+ if (en <= 0) {
en = em - 10;
+ }
- if (c == ' ')
+ if (c == ' ') {
width = em;
- if (c == '\u2000')
+ }
+ if (c == '\u2000') {
width = en;
- if (c == '\u2001')
+ }
+ if (c == '\u2001') {
width = em;
- if (c == '\u2002')
+ }
+ if (c == '\u2002') {
width = em / 2;
- if (c == '\u2003')
+ }
+ if (c == '\u2003') {
width = fs.getFontSize();
- if (c == '\u2004')
+ }
+ if (c == '\u2004') {
width = em / 3;
- if (c == '\u2005')
+ }
+ if (c == '\u2005') {
width = em / 4;
- if (c == '\u2006')
+ }
+ if (c == '\u2006') {
width = em / 6;
- if (c == '\u2007')
+ }
+ if (c == '\u2007') {
width = getCharWidth(' ', fs);
- if (c == '\u2008')
+ }
+ if (c == '\u2008') {
width = getCharWidth('.', fs);
- if (c == '\u2009')
+ }
+ if (c == '\u2009') {
width = em / 5;
- if (c == '\u200A')
+ }
+ if (c == '\u200A') {
width = 5;
- if (c == '\u200B')
+ }
+ if (c == '\u200B') {
width = 100;
- if (c == '\u202F')
+ }
+ if (c == '\u202F') {
width = getCharWidth(' ', fs) / 2;
- if (c == '\u3000')
+ }
+ if (c == '\u3000') {
width = getCharWidth(' ', fs) * 2;
+ }
}
}
* it's not non-breaking
*/
public static boolean isSpace(char c) {
- return (c == ' ' ||
- (c >= '\u2000' && c <= '\u200B'));
+ return (c == ' '
+ || (c >= '\u2000' && c <= '\u200B'));
// c == '\u2000' // en quad
// c == '\u2001' // em quad
// c == '\u2002' // en space
* space.
*/
public static boolean isNBSP(char c) {
- if (c == '\u00A0' || c == '\u202F' || // narrow no-break space
- c == '\u3000' || // ideographic space
- c == '\uFEFF') { // zero width no-break space
+ if (c == '\u00A0' || c == '\u202F' // narrow no-break space
+ || c == '\u3000' // ideographic space
+ || c == '\uFEFF') { // zero width no-break space
return true;
- } else
+ } else {
return false;
+ }
}
/**