diff options
Diffstat (limited to 'src/java/org/apache/fop/area/inline')
19 files changed, 0 insertions, 2380 deletions
diff --git a/src/java/org/apache/fop/area/inline/AbstractTextArea.java b/src/java/org/apache/fop/area/inline/AbstractTextArea.java deleted file mode 100644 index c2c4fe67b..000000000 --- a/src/java/org/apache/fop/area/inline/AbstractTextArea.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -/** - * Abstract base class for both TextArea and Character. - */ -public abstract class AbstractTextArea extends InlineParent { - - private static final long serialVersionUID = -1246306443569094371L; - - /** - * this class stores information about spaces and potential adjustments - * that can be used in order to re-compute adjustments when a - * page-number or a page-number-citation is resolved - */ - // @SuppressFBWarnings("SE_INNER_CLASS") - protected class TextAdjustingInfo extends InlineAdjustingInfo { - - private static final long serialVersionUID = -2412095162983479947L; - - /** difference between the optimal width of a space - * and the default width of a space according to the font - * (this is equivalent to the property word-spacing.optimum) - */ - protected int spaceDifference; - - /** - * Constructor - * - * @param stretch the available space for stretching - * @param shrink the available space for shrinking - * @param adj space adjustment type - */ - protected TextAdjustingInfo(int stretch, int shrink, int adj) { - super(stretch, shrink, adj); - } - } - - private int textWordSpaceAdjust; - private int textLetterSpaceAdjust; - private TextAdjustingInfo textAdjustingInfo; - private int baselineOffset; - - /** - * Default constructor - */ - public AbstractTextArea() { - } - - /** - * Constructor with extra parameters: - * create a TextAdjustingInfo object - * @param stretch the available stretch of the text - * @param shrink the available shrink of the text - * @param adj the current adjustment of the area - */ - public AbstractTextArea(int stretch, int shrink, int adj) { - textAdjustingInfo = new TextAdjustingInfo(stretch, shrink, adj); - } - - /** - * Get text word space adjust. - * - * @return the text word space adjustment - */ - public int getTextWordSpaceAdjust() { - return textWordSpaceAdjust; - } - - /** - * Set text word space adjust. - * - * @param textWordSpaceAdjust the text word space adjustment - */ - public void setTextWordSpaceAdjust(int textWordSpaceAdjust) { - this.textWordSpaceAdjust = textWordSpaceAdjust; - } - - /** - * Get text letter space adjust. - * - * @return the text letter space adjustment - */ - public int getTextLetterSpaceAdjust() { - return textLetterSpaceAdjust; - } - - /** - * Set text letter space adjust. - * - * @param textLetterSpaceAdjust the text letter space adjustment - */ - public void setTextLetterSpaceAdjust(int textLetterSpaceAdjust) { - this.textLetterSpaceAdjust = textLetterSpaceAdjust; - } - - /** - * Set the difference between optimal width of a space and - * default width of a space according to the font; this part - * of the space adjustment is fixed and must not be - * multiplied by the variation factor. - * @param spaceDiff the space difference - */ - public void setSpaceDifference(int spaceDiff) { - textAdjustingInfo.spaceDifference = spaceDiff; - } - - /** - * recursively apply the variation factor to all descendant areas - * @param variationFactor the variation factor that must be applied to adjustments - * @param lineStretch the total stretch of the line - * @param lineShrink the total shrink of the line - * @return true if there is an UnresolvedArea descendant - */ - public boolean applyVariationFactor(double variationFactor, - int lineStretch, int lineShrink) { - if (textAdjustingInfo != null) { - // compute the new adjustments: - // if the variation factor is negative, it means that before - // the ipd variation the line had to stretch and now it has - // to shrink (or vice versa); - // in this case, if the stretch and shrink are not equally - // divided among the inline areas, we must compute a - // balancing factor - double balancingFactor = 1.0; - if (variationFactor < 0) { - if (textWordSpaceAdjust < 0) { - // from a negative adjustment to a positive one - balancingFactor - = ((double) textAdjustingInfo.availableStretch - / textAdjustingInfo.availableShrink) - * ((double) lineShrink / lineStretch); - } else { - // from a positive adjustment to a negative one - balancingFactor - = ((double) textAdjustingInfo.availableShrink - / textAdjustingInfo.availableStretch) - * ((double) lineStretch / lineShrink); - } - } - textWordSpaceAdjust = (int) ((textWordSpaceAdjust - textAdjustingInfo.spaceDifference) - * variationFactor * balancingFactor) - + textAdjustingInfo.spaceDifference; - textLetterSpaceAdjust *= variationFactor; - // update the ipd of the area - int oldAdjustment = textAdjustingInfo.adjustment; - textAdjustingInfo.adjustment *= balancingFactor * variationFactor; - ipd += textAdjustingInfo.adjustment - oldAdjustment; - } - return false; - } - - /** - * Get baseline offset, i.e. the distance from the before edge - * of this area to the nominal baseline. - * - * @return the baseline offset - */ - public int getBaselineOffset() { - return baselineOffset; - } - - /** - * Set the baseline offset. - * - * @param baselineOffset the baseline offset - */ - public void setBaselineOffset(int baselineOffset) { - this.baselineOffset = baselineOffset; - } - - @Override - int getVirtualOffset() { - return getBlockProgressionOffset(); - } - - @Override - int getVirtualBPD() { - /* Word and space areas don't have a properly set bpd; return this area's bpd instead. */ - return getBPD(); - } -} diff --git a/src/java/org/apache/fop/area/inline/Anchor.java b/src/java/org/apache/fop/area/inline/Anchor.java deleted file mode 100644 index 8ad663111..000000000 --- a/src/java/org/apache/fop/area/inline/Anchor.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -/** - * Anchor area for footnote or float. - * Not sure if this is needed. - */ -public class Anchor extends InlineArea { - - private static final long serialVersionUID = 5227798744787823499L; - - // has a keep with adjacent area - // has reference to associated footnote or float out-of-line area - -} - diff --git a/src/java/org/apache/fop/area/inline/BasicLinkArea.java b/src/java/org/apache/fop/area/inline/BasicLinkArea.java deleted file mode 100644 index 68af92319..000000000 --- a/src/java/org/apache/fop/area/inline/BasicLinkArea.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import org.apache.fop.area.Area; -import org.apache.fop.area.LinkResolver; - -/** - * An inline area produced by an fo:basic-link element. This class implements a different - * behavior to what is prescribed by the XSL-FO 1.1 Recommendation. With the standard - * behavior, there is no easy way to make a link cover e.g. a whole image. - * - * <p>See following bug report at W3C's: - * http://www.w3.org/Bugs/Public/show_bug.cgi?id=11672</p> - */ -public class BasicLinkArea extends InlineParent { - - private static final long serialVersionUID = 5183753430412208151L; - - private LinkResolver resolver; - - @Override - public void setParentArea(Area parentArea) { - super.setParentArea(parentArea); - /* - * Perform necessary modifications to make this area encompass all of its children - * elements, so as to have a useful active area. We assume that this method is - * called after all of the children areas have been added to this area. - */ - /* Make this area start at its beforest child. */ - setBlockProgressionOffset(getBlockProgressionOffset() + minChildOffset); - /* Update children offsets accordingly. */ - for (InlineArea inline : inlines) { - inline.setBlockProgressionOffset(inline.getBlockProgressionOffset() - minChildOffset); - } - setBPD(getVirtualBPD()); - } - - /** - * Establish (or remove) back-pointer to link resolver. - * @param resolver the link resolver that will resolve this basic link or null - */ - public void setResolver(LinkResolver resolver) { - assert (resolver == null) || (this.resolver == null); - this.resolver = resolver; - } - - /** - * Obtain back-pointer to link resolver. - * @return resolver the link resolver that will resolve this basic link or null - */ - public LinkResolver getResolver() { - return this.resolver; - } -} diff --git a/src/java/org/apache/fop/area/inline/Container.java b/src/java/org/apache/fop/area/inline/Container.java deleted file mode 100644 index 3d0060007..000000000 --- a/src/java/org/apache/fop/area/inline/Container.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.fop.area.Area; -import org.apache.fop.area.Block; - -/** - * Container area for inline container. - * This area should be placed in a viewport as a result of the - * inline container formatting object. - * This allows an inline area to have blocks as children. - */ -public class Container extends Area { - - private static final long serialVersionUID = 5256423939348189260L; - - /** - * The list of block areas stacked inside this container - */ - protected List<Block> blocks = new ArrayList<Block>(); - - /** - * The width of this container - */ - protected int width; - - /** - * Create a new container area - */ - public Container() { - } - - @Override - public void addChildArea(Area child) { - if (!(child instanceof Block)) { - throw new IllegalArgumentException("Container only accepts block areas"); - } - blocks.add((Block) child); - } - - /** - * Get the block areas stacked inside this container area. - * - * @return the list of block areas - */ - public List<Block> getBlocks() { - return blocks; - } - - /** - * Get the width of this container area. - * - * @return the width - */ - public int getWidth() { - return width; - } -} - diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java deleted file mode 100644 index 786b0265d..000000000 --- a/src/java/org/apache/fop/area/inline/FilledArea.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.util.ArrayList; -import java.util.List; - -/** - * Filled area. - * This inline area contains some inline areas. - * When the renderer gets the child areas to render - * the inline areas are repeated to fill the ipd of - * this inline parent. - * This extends InlineParent so that the renderer will render - * this as a normal inline parent. - */ -public class FilledArea extends InlineParent { - - private static final long serialVersionUID = 8586584705587017474L; - - private int unitWidth; - - /** Create a new filled area. */ - public FilledArea() { - } - - /** - * Set the offset of the descendant TextAreas, - * instead of the offset of the FilledArea itself. - * - * @param v the offset - */ - /* - public void setBlockProgressionOffset(int v) { - setChildOffset(inlines.listIterator(), v); - } - - private void setChildOffset(ListIterator childrenIterator, int v) { - while (childrenIterator.hasNext()) { - InlineArea child = (InlineArea) childrenIterator.next(); - if (child instanceof InlineParent) { - setChildOffset(((InlineParent) child).getChildAreas().listIterator(), v); - } else if (child instanceof InlineViewport) { - // nothing - } else { - child.setBlockProgressionOffset(v); - } - } - } - */ - - /** - * Set the unit width for the areas to fill the full width. - * - * @param width the unit width - */ - public void setUnitWidth(int width) { - this.unitWidth = width; - } - - /** - * Return the unit width for the areas to fill the full width. - * - * @return the unit width - */ - public int getUnitWidth() { - return this.unitWidth; - } - - /** {@inheritDoc} */ - @Override - public int getBPD() { - int bpd = 0; - for (InlineArea area : getChildAreas()) { - if (bpd < area.getBPD()) { - bpd = area.getBPD(); - } - } - return bpd; - } - - /** - * Get the child areas for this filled area. - * This copies the references of the inline areas so that - * it fills the total width of the area a whole number of times - * for the unit width. - * - * @return the list of child areas copied to fill the width - */ - @Override - public List<InlineArea> getChildAreas() { - int units = getIPD() / unitWidth; - List<InlineArea> newList = new ArrayList<InlineArea>(); - for (int count = 0; count < units; count++) { - newList.addAll(inlines); - } - return newList; - } - - /** - * Recursively apply the variation factor to all descendant areas - * @param variationFactor the variation factor that must be applied to adjustments - * @param lineStretch the total stretch of the line - * @param lineShrink the total shrink of the line - * @return true if there is an UnresolvedArea descendant - */ - @Override - public boolean applyVariationFactor(double variationFactor, - int lineStretch, int lineShrink) { - setIPD(getIPD() + adjustingInfo.applyVariationFactor(variationFactor)); - return false; - } - -} - diff --git a/src/java/org/apache/fop/area/inline/ForeignObject.java b/src/java/org/apache/fop/area/inline/ForeignObject.java deleted file mode 100644 index cc0e0b0ad..000000000 --- a/src/java/org/apache/fop/area/inline/ForeignObject.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import org.w3c.dom.Document; - -import org.apache.fop.area.Area; - -// cacheable object -/** - * Foreign object inline area. - * This inline area represents an instream-foreign object. - * This holds an xml document and the associated namespace. - */ -public class ForeignObject extends Area { - - private static final long serialVersionUID = -214947698798577885L; - - private Document doc; - private String namespace; - - /** - * Create a new foreign object with the given dom and namespace. - * - * @param d the xml document - * @param ns the namespace of the document - */ - public ForeignObject(Document d, String ns) { - doc = d; - namespace = ns; - } - - /** - * Create a new empty foreign object for which the DOM Document will be set later. - * - * @param ns the namespace of the document - */ - public ForeignObject(String ns) { - namespace = ns; - } - - /** - * Sets the DOM document for this foreign object. - * @param document the DOM document - */ - public void setDocument(Document document) { - this.doc = document; - } - - /** - * Get the document for this foreign object. - * - * @return the xml document - */ - public Document getDocument() { - return doc; - } - - /** - * Get the namespace of this foreign object. - * - * @return the namespace of this document - */ - public String getNameSpace() { - return namespace; - } -} - diff --git a/src/java/org/apache/fop/area/inline/Image.java b/src/java/org/apache/fop/area/inline/Image.java deleted file mode 100644 index e6e355254..000000000 --- a/src/java/org/apache/fop/area/inline/Image.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import org.apache.fop.area.Area; - -/** - * Image area for external-graphic. - * This area holds information for rendering an image. - * The url of the image is used as a key to reference the image cache. - */ -public class Image extends Area { - - private static final long serialVersionUID = 4800834714349695386L; - - private String url; - - /** - * Create a new image with the given url. - * - * @param url the url of the image - */ - public Image(String url) { - this.url = url; - } - - /** - * Get the url of this image. - * This url is used as a key to locate the actual image data. - * - * @return the url of this image - */ - public String getURL() { - return this.url; - } -} - diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java deleted file mode 100644 index 1733f7b3d..000000000 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.io.Serializable; -import java.util.List; - -import org.apache.fop.area.Area; -import org.apache.fop.area.LineArea; -import org.apache.fop.area.Trait; -import org.apache.fop.complexscripts.bidi.InlineRun; - -/** - * Inline Area - * This area is for all inline areas that can be placed - * in a line area. - */ -public class InlineArea extends Area { - - private static final long serialVersionUID = -8940066479810170980L; - - /** - * this class stores information about potential adjustments - * that can be used in order to re-compute adjustments when a - * page-number or a page-number-citation is resolved - */ - // @SuppressFBWarnings("SE_INNER_CLASS") - protected class InlineAdjustingInfo implements Serializable { - - private static final long serialVersionUID = -5601387735459712149L; - - /** stretch of the inline area */ - protected int availableStretch; - /** shrink of the inline area */ - protected int availableShrink; - /** total adjustment (= ipd - width of fixed elements) */ - protected int adjustment; - - /** - * Constructor - * - * @param stretch the available space for stretching - * @param shrink the available space for shrinking - * @param adj space adjustment type - */ - protected InlineAdjustingInfo(int stretch, int shrink, int adj) { - availableStretch = stretch; - availableShrink = shrink; - adjustment = adj; - } - - /** - * Apply the variation factor - * - * @param variationFactor the factor by which the adjustment is to be changed - * @return the IPD increase - */ - protected int applyVariationFactor(double variationFactor) { - int oldAdjustment = adjustment; - adjustment *= variationFactor; - return adjustment - oldAdjustment; - } - } - - /** - * offset position from before edge of parent area - */ - protected int blockProgressionOffset; - - /** - * parent area - * it is needed in order to recompute adjust ratio and indents - * when a page-number or a page-number-citation is resolved - */ - private Area parentArea; - - /** - * ipd variation of child areas: if this area has not already - * been added and cannot notify its parent area, store the variation - * and wait for the parent area to be set - */ - private int storedIPDVariation; - - /** - * The adjustment information object - */ - protected InlineAdjustingInfo adjustingInfo; - - /** - * Default constructor for inline area. - */ - public InlineArea() { - this (0, -1); - } - - /** - * Instantiate inline area. - * @param blockProgressionOffset a block progression offset or zero - * @param bidiLevel a resolved bidi level or -1 - */ - protected InlineArea(int blockProgressionOffset, int bidiLevel) { - this.blockProgressionOffset = blockProgressionOffset; - setBidiLevel(bidiLevel); - } - - /** - * @return the adjustment information object - */ - public InlineAdjustingInfo getAdjustingInfo() { - return adjustingInfo; - } - - /** - * Create a new adjustment information object - * @param stretch the available space for stretching - * @param shrink the available space for shrinking - * @param adjustment space adjustment type - */ - public void setAdjustingInfo(int stretch, int shrink, int adjustment) { - adjustingInfo = new InlineAdjustingInfo(stretch, shrink, adjustment); - } - - /** - * Sets the adjustment information from an existing object - * @param adjustingInfo the existing adjustment object - */ - public void setAdjustingInfo(InlineAdjustingInfo adjustingInfo) { - this.adjustingInfo = adjustingInfo; - } - - /** - * Modify the adjustment value in the adjustment information object - * @param adjustment the new adjustment value - */ - public void setAdjustment(int adjustment) { - if (adjustingInfo != null) { - adjustingInfo.adjustment = adjustment; - } - } - - /** - * Increase the inline progression dimensions of this area. - * This is used for inline parent areas that contain mulitple child areas. - * - * @param ipd the inline progression to increase by - */ - public void increaseIPD(int ipd) { - this.ipd += ipd; - } - - /** - * Set the block progression offset of this inline area. - * This is used to set the offset of the inline area - * which is relative to the before edge of the parent area. - * - * @param blockProgressionOffset the offset - */ - public void setBlockProgressionOffset(int blockProgressionOffset) { - this.blockProgressionOffset = blockProgressionOffset; - } - - /** - * Get the block progression offset of this inline area. - * This returns the offset of the inline area - * relative to the before edge of the parent area. - * - * @return the blockProgressionOffset - */ - public int getBlockProgressionOffset() { - return blockProgressionOffset; - } - - /** - * @param parentArea The parentArea to set. - */ - public void setParentArea(Area parentArea) { - this.parentArea = parentArea; - } - - /** - * @return Returns the parentArea. - */ - public Area getParentArea() { - return parentArea; - } - - /** - * Set the parent for the child area. - * - * {@inheritDoc} - */ - @Override - public void addChildArea(Area childArea) { - super.addChildArea(childArea); - if (childArea instanceof InlineArea) { - ((InlineArea) childArea).setParentArea(this); - } - } - - /** @return true if the inline area is underlined. */ - public boolean hasUnderline() { - return getTraitAsBoolean(Trait.UNDERLINE); - } - - /** @return true if the inline area is overlined. */ - public boolean hasOverline() { - return getTraitAsBoolean(Trait.OVERLINE); - } - - /** @return true if the inline area has a line through. */ - public boolean hasLineThrough() { - return getTraitAsBoolean(Trait.LINETHROUGH); - } - - /** @return true if the inline area is blinking. */ - public boolean isBlinking() { - return getTraitAsBoolean(Trait.BLINK); - } - - /** - * recursively apply the variation factor to all descendant areas - * @param variationFactor the variation factor that must be applied to adjustments - * @param lineStretch the total stretch of the line - * @param lineShrink the total shrink of the line - * @return true if there is an UnresolvedArea descendant - */ - public boolean applyVariationFactor(double variationFactor, - int lineStretch, int lineShrink) { - // default behaviour: update the IPD and return false - if (adjustingInfo != null) { - setIPD(getIPD() + adjustingInfo.applyVariationFactor(variationFactor)); - } - return false; - } - - /** - * Apply IPD variation. - * @param ipdVariation the variation - */ - public void handleIPDVariation(int ipdVariation) { - if (log.isTraceEnabled()) { - log.trace("Handling IPD variation for " + getClass().getSimpleName() - + ": increase by " + ipdVariation + " mpt."); - } - - if (ipdVariation != 0) { - increaseIPD(ipdVariation); - notifyIPDVariation(ipdVariation); - } - } - - /** - * notify the parent area about the ipd variation of this area - * or of a descendant area - * @param ipdVariation the difference between new and old ipd - */ - protected void notifyIPDVariation(int ipdVariation) { - Area parentArea = getParentArea(); - if (parentArea instanceof InlineArea) { - ((InlineArea) parentArea).handleIPDVariation(ipdVariation); - } else if (parentArea instanceof LineArea) { - ((LineArea) parentArea).handleIPDVariation(ipdVariation); - } else if (parentArea == null) { - // parent area not yet set: store the variations - storedIPDVariation += ipdVariation; - } - } - - /** - * Returns the offset that this area would have if its offset and size were taking - * children areas into account. The bpd of an inline area is taken from its nominal - * font and doesn't depend on the bpds of its children elements. However, in the case - * of a basic-link element we want the active area to cover all of the children - * elements. - * - * @return the offset that this area would have if the before-edge of its - * content-rectangle were coinciding with the <q>beforest</q> before-edge of its - * children allocation-rectangles. - * @see #getVirtualBPD() - * @see BasicLinkArea - */ - int getVirtualOffset() { - return getBlockProgressionOffset(); - } - - /** - * Returns the block-progression-dimension that this area would have if it were taking - * its children elements into account. See {@linkplain #getVirtualOffset()}. - * - * @return the bpd - */ - int getVirtualBPD() { - return getBPD(); - } - - /** - * Collection bidi inline runs. - * @param runs current list of inline runs - * @return modified list of inline runs, having appended new run - */ - public List collectInlineRuns(List runs) { - assert runs != null; - runs.add(new InlineRun(this, new int[] {getBidiLevel()})); - return runs; - } - - /** - * Determine if inline area IA is an ancestor inline area or same as this area. - * @param ia inline area to test - * @return true if specified inline area is an ancestor or same as this area - */ - public boolean isAncestorOrSelf(InlineArea ia) { - return (ia == this) || isAncestor(ia); - } - - /** - * Determine if inline area IA is an ancestor inline area of this area. - * @param ia inline area to test - * @return true if specified inline area is an ancestor of this area - */ - public boolean isAncestor(InlineArea ia) { - for (Area p = getParentArea(); p != null;) { - if (p == ia) { - return true; - } else if (p instanceof InlineArea) { - p = ((InlineArea) p).getParentArea(); - } else { - p = null; - } - } - return false; - } - -} diff --git a/src/java/org/apache/fop/area/inline/InlineBlockParent.java b/src/java/org/apache/fop/area/inline/InlineBlockParent.java deleted file mode 100644 index f2a7fecee..000000000 --- a/src/java/org/apache/fop/area/inline/InlineBlockParent.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import org.apache.fop.area.Area; -import org.apache.fop.area.Block; - - -/** - * Inline block parent area. - * This is an inline area that can have one block area as a child - */ -public class InlineBlockParent extends InlineArea { - - - private static final long serialVersionUID = -3661746143321407377L; - - /** - * The list of inline areas added to this inline parent. - */ - protected Block child; - - /** - * Create a new inline block parent to add areas to. - */ - public InlineBlockParent() { - } - - /** - * Override generic Area method. - * - * @param childArea the child area to add - */ - @Override - public void addChildArea(Area childArea) { - if (child != null) { - throw new IllegalStateException("InlineBlockParent may have only one child area."); - } - if (childArea instanceof Block) { - child = (Block) childArea; - //Update extents from the child - setIPD(childArea.getAllocIPD()); - setBPD(childArea.getAllocBPD()); - } else { - throw new IllegalArgumentException("The child of an InlineBlockParent must be a" - + " Block area"); - } - } - - /** - * Get the child areas for this inline parent. - * - * @return the list of child areas - */ - public Block getChildArea() { - return child; - } - -} diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java deleted file mode 100644 index 2e03f4d80..000000000 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.fop.area.Area; - -/** - * Inline parent area. - * This is an inline area that can have other inlines as children. - */ -public class InlineParent extends InlineArea { - - private static final long serialVersionUID = -3047168298770354813L; - - /** - * The list of inline areas added to this inline parent. - */ - protected List<InlineArea> inlines = new ArrayList<InlineArea>(); - - /** Controls whether the IPD is automatically adjusted based on the area's children. */ - protected transient boolean autoSize; - - /** The offset of the <q>beforest</q> child area of this area. */ - protected int minChildOffset; - - /** - * The offset of the <q>afterest</q> child area of this area. Offset from the - * before-edge of this area's content-rectangle and the after-edge of the child area's - * allocation-rectangle. - */ - private int maxAfterEdge; - - private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { - ois.defaultReadObject(); - } - - @Override - public void addChildArea(Area c) { - assert c instanceof InlineArea; - if (inlines.size() == 0) { - autoSize = (getIPD() == 0); - } - InlineArea childArea = (InlineArea) c; - inlines.add(childArea); - // set the parent area for the child area - childArea.setParentArea(this); - if (autoSize) { - increaseIPD(childArea.getAllocIPD()); - } - updateLevel(childArea.getBidiLevel()); - int childOffset = childArea.getVirtualOffset(); - minChildOffset = Math.min(minChildOffset, childOffset); - maxAfterEdge = Math.max(maxAfterEdge, childOffset + childArea.getVirtualBPD()); - } - - @Override - int getVirtualOffset() { - return getBlockProgressionOffset() + minChildOffset; - } - - @Override - int getVirtualBPD() { - return maxAfterEdge - minChildOffset; - } - - /** - * Get the child areas for this inline parent. - * - * @return the list of child areas - */ - public List<InlineArea> getChildAreas() { - return inlines; - } - - /** - * recursively apply the variation factor to all descendant areas - * @param variationFactor the variation factor that must be applied to adjustments - * @param lineStretch the total stretch of the line - * @param lineShrink the total shrink of the line - * @return true if there is an UnresolvedArea descendant - */ - @Override - public boolean applyVariationFactor(double variationFactor, - int lineStretch, int lineShrink) { - boolean hasUnresolvedAreas = false; - int cumulativeIPD = 0; - // recursively apply variation factor to descendant areas - for (int i = 0, len = inlines.size(); i < len; i++) { - InlineArea inline = inlines.get(i); - hasUnresolvedAreas |= inline.applyVariationFactor( - variationFactor, lineStretch, lineShrink); - cumulativeIPD += inline.getIPD(); //Update this area's IPD based on changes to children - } - setIPD(cumulativeIPD); - - return hasUnresolvedAreas; - } - - @Override - public List collectInlineRuns(List runs) { - for (Iterator<InlineArea> it = getChildAreas().iterator(); it.hasNext();) { - InlineArea ia = it.next(); - runs = ia.collectInlineRuns(runs); - } - return runs; - } - - /** - * Reset bidirectionality level of all children to default (-1), - * signalling that they will inherit the level of their parent text area. - */ - public void resetChildrenLevel() { - for (Iterator it = inlines.iterator(); it.hasNext();) { - ((InlineArea) it.next()) .resetBidiLevel(); - } - } - - private void updateLevel(int newLevel) { - if (newLevel >= 0) { - int curLevel = getBidiLevel(); - if (curLevel >= 0) { - if (newLevel < curLevel) { - setBidiLevel(newLevel); - } - } else { - setBidiLevel(newLevel); - } - } - } - - -} diff --git a/src/java/org/apache/fop/area/inline/InlineViewport.java b/src/java/org/apache/fop/area/inline/InlineViewport.java deleted file mode 100644 index e111bdd9d..000000000 --- a/src/java/org/apache/fop/area/inline/InlineViewport.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.awt.Rectangle; -import java.awt.geom.Rectangle2D; -import java.io.IOException; -import java.util.TreeMap; - -import org.apache.fop.area.Area; -import org.apache.fop.area.Viewport; - -/** - * Inline viewport area. - * This is an inline-level viewport area for inline container, - * external graphic and instream foreign object. This viewport - * holds the area and positions it. - */ -public class InlineViewport extends InlineArea implements Viewport { - - private static final long serialVersionUID = 813338534627918689L; - - // contents could be container, foreign object or image - private Area content; - // clipping for the viewport - private boolean clip; - // position of the child area relative to this area - private Rectangle2D contentPosition; - - /** - * Create a new viewport area with the content area. - * - * @param child the child content area of this viewport - */ - public InlineViewport(Area child) { - this(child, -1); - } - - /** - * Create a new viewport area with the content area. - * - * @param child the child content area of this viewport - * @param bidiLevel the bidirectional embedding level (or -1 if not defined) - */ - public InlineViewport(Area child, int bidiLevel) { - super(0, bidiLevel); - this.content = child; - } - - /** - * Set the clip of this viewport. - * - * @param c true if this viewport should clip - */ - public void setClip(boolean c) { - this.clip = c; - } - - /** {@inheritDoc} */ - public boolean hasClip() { - return this.clip; - } - - /** {@inheritDoc} */ - public Rectangle getClipRectangle() { - if (clip) { - return new Rectangle(getIPD(), getBPD()); - } else { - return null; - } - } - - /** - * Set the position and size of the content of this viewport. - * - * @param cp the position and size to place the content - */ - public void setContentPosition(Rectangle2D cp) { - this.contentPosition = cp; - } - - /** - * Get the position and size of the content of this viewport. - * - * @return the position and size to place the content - */ - public Rectangle2D getContentPosition() { - return this.contentPosition; - } - - /** - * Sets the content area. - * @param content the content area - */ - public void setContent(Area content) { - this.content = content; - } - - /** - * Get the content area for this viewport. - * - * @return the content area - */ - public Area getContent() { - return this.content; - } - - private void writeObject(java.io.ObjectOutputStream out) - throws IOException { - out.writeBoolean(contentPosition != null); - if (contentPosition != null) { - out.writeFloat((float) contentPosition.getX()); - out.writeFloat((float) contentPosition.getY()); - out.writeFloat((float) contentPosition.getWidth()); - out.writeFloat((float) contentPosition.getHeight()); - } - out.writeBoolean(clip); - out.writeObject((TreeMap)traits); - out.writeObject(content); - } - - private void readObject(java.io.ObjectInputStream in) - throws IOException, ClassNotFoundException { - if (in.readBoolean()) { - contentPosition = new Rectangle2D.Float(in.readFloat(), - in.readFloat(), - in.readFloat(), - in.readFloat()); - } - this.clip = in.readBoolean(); - this.traits = (TreeMap) in.readObject(); - this.content = (Area) in.readObject(); - } - - public int getEffectiveIPD() { - return getIPD(); - } -} diff --git a/src/java/org/apache/fop/area/inline/Leader.java b/src/java/org/apache/fop/area/inline/Leader.java deleted file mode 100644 index ff8ba12b0..000000000 --- a/src/java/org/apache/fop/area/inline/Leader.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import org.apache.fop.fo.Constants; - -/** - * This is a leader inline area. - * This class is only used for leader with leader-pattern of rule. - */ -public class Leader extends InlineArea { - - // in the case of use content or dots this is replaced - // with the set of inline areas - // if space replaced with a space - // otherwise this is a holder for a line - - - private static final long serialVersionUID = -8011373048313956301L; - - private int ruleStyle = Constants.EN_SOLID; - private int ruleThickness = 1000; - - /** - * Create a new leader area. - */ - public Leader() { - } - - /** - * Set the rule style of this leader area. - * - * @param style the rule style for the leader line - */ - public void setRuleStyle(int style) { - ruleStyle = style; - } - - /** - * Set the rule style of this leader area. - * @param style the rule style for the leader area (XSL enum values) - */ - public void setRuleStyle(String style) { - if ("dotted".equalsIgnoreCase(style)) { - setRuleStyle(Constants.EN_DOTTED); - } else if ("dashed".equalsIgnoreCase(style)) { - setRuleStyle(Constants.EN_DASHED); - } else if ("solid".equalsIgnoreCase(style)) { - setRuleStyle(Constants.EN_SOLID); - } else if ("double".equalsIgnoreCase(style)) { - setRuleStyle(Constants.EN_DOUBLE); - } else if ("groove".equalsIgnoreCase(style)) { - setRuleStyle(Constants.EN_GROOVE); - } else if ("ridge".equalsIgnoreCase(style)) { - setRuleStyle(Constants.EN_RIDGE); - } else if ("none".equalsIgnoreCase(style)) { - setRuleStyle(Constants.EN_NONE); - } - } - - /** - * Set the rule thickness of the rule in miilipoints. - * - * @param rt the rule thickness in millipoints - */ - public void setRuleThickness(int rt) { - ruleThickness = rt; - } - - /** - * Get the rule style of this leader. - * - * @return the rule style - */ - public int getRuleStyle() { - return ruleStyle; - } - - /** @return the rule style as string */ - public String getRuleStyleAsString() { - switch (getRuleStyle()) { - case Constants.EN_DOTTED: return "dotted"; - case Constants.EN_DASHED: return "dashed"; - case Constants.EN_SOLID: return "solid"; - case Constants.EN_DOUBLE: return "double"; - case Constants.EN_GROOVE: return "groove"; - case Constants.EN_RIDGE: return "ridge"; - case Constants.EN_NONE: return "none"; - default: - throw new IllegalStateException("Unsupported rule style: " + getRuleStyle()); - } - } - - /** - * Get the rule thickness of the rule in miilipoints. - * - * @return the rule thickness in millipoints - */ - public int getRuleThickness() { - return ruleThickness; - } - -} - diff --git a/src/java/org/apache/fop/area/inline/ResolvedPageNumber.java b/src/java/org/apache/fop/area/inline/ResolvedPageNumber.java deleted file mode 100644 index cbef88b7e..000000000 --- a/src/java/org/apache/fop/area/inline/ResolvedPageNumber.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.io.IOException; -import java.io.ObjectInputStream; - -/** - * Always (pre-) resolved page number area. Needed by BIDI code to distinguish - * from UnresolvedPageNumber. - */ -public class ResolvedPageNumber extends TextArea { - - private static final long serialVersionUID = -1758369835371647979L; - - private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { - ois.defaultReadObject(); - } - -} diff --git a/src/java/org/apache/fop/area/inline/Space.java b/src/java/org/apache/fop/area/inline/Space.java deleted file mode 100644 index b097e4349..000000000 --- a/src/java/org/apache/fop/area/inline/Space.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -/** - * Inline space area. - * This is used for adding a inline space to the output. - */ -public class Space extends InlineArea { - - private static final long serialVersionUID = -8748265505356839796L; - - /** - * Default constructor. - */ - public Space() { - } - -} diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java deleted file mode 100644 index be7b61a9f..000000000 --- a/src/java/org/apache/fop/area/inline/SpaceArea.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -/** - * A space - */ -public class SpaceArea extends InlineArea { - - private static final long serialVersionUID = 2218803009825411416L; - - /** - * The space for this space area - */ - protected char space; - - /** - * Is this space adjustable? - */ - protected boolean isAdjustable; - - /** - * Create a space area - * @param space the space character - * @param blockProgressionOffset the offset for the next area - * @param adjustable is this space adjustable? - * @param bidiLevel the bidirectional embedding level (or -1 if not defined) - */ - public SpaceArea(int blockProgressionOffset, int bidiLevel, char space, boolean adjustable) { - super(blockProgressionOffset, bidiLevel); - this.space = space; - this.isAdjustable = adjustable; - } - - /** @return Returns the space. */ - public String getSpace() { - return String.valueOf(space); - } - - /** @return true if the space is adjustable (WRT word-space processing) */ - public boolean isAdjustable() { - return this.isAdjustable; - } - -} diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java deleted file mode 100644 index 5a1b31c98..000000000 --- a/src/java/org/apache/fop/area/inline/TextArea.java +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.util.Arrays; - -import org.apache.fop.util.CharUtilities; - -/** - * A text inline area. - */ -public class TextArea extends AbstractTextArea { - - private static final long serialVersionUID = 7315900267242540809L; - - private boolean isHyphenated; - - /** - * Create a text inline area - */ - public TextArea() { - } - - /** - * Constructor with extra parameters: - * create a TextAdjustingInfo object - * @param stretch the available stretch of the text - * @param shrink the available shrink of the text - * @param adj the current total adjustment - */ - public TextArea(int stretch, int shrink, int adj) { - super(stretch, shrink, adj); - } - - /** - * Remove the old text - */ - public void removeText() { - inlines.clear(); - } - - /** - * Create and add a WordArea child to this TextArea. - * - * @param word the word string - * @param offset the offset for the next area - */ - public void addWord(String word, int offset) { - addWord(word, 0, null, null, null, offset); - } - - /** - * Create and add a WordArea child to this TextArea. - * - * @param word the word string - * @param offset the offset for the next area - * @param level bidirectional level that applies to entire word - */ - public void addWord(String word, int offset, int level) { - addWord(word, 0, null, makeLevels(level, word.length()), null, offset); - } - - /** - * Create and add a WordArea child to this TextArea. - * - * @param word the word string - * @param ipd the word's ipd - * @param letterAdjust the letter adjustment array (may be null) - * @param levels array of resolved bidirectional levels of word characters, - * or null if default level - * @param gposAdjustments array of general position adjustments or null if none apply - * @param blockProgressionOffset the offset for the next area - */ - public void addWord( - String word, int ipd, int[] letterAdjust, int[] levels, - int[][] gposAdjustments, int blockProgressionOffset) { - int minWordLevel = findMinLevel(levels, getBidiLevel()); - WordArea wordArea = new WordArea( - blockProgressionOffset, minWordLevel, word, letterAdjust, levels, gposAdjustments); - wordArea.setIPD(ipd); - addChildArea(wordArea); - wordArea.setParentArea(this); - updateLevel(minWordLevel); - } - - /** - * Create and add a SpaceArea child to this TextArea - * - * @param space the space character - * @param ipd the space's ipd - * @param blockProgressionOffset the offset for the next area - * @param adjustable is this space adjustable? - * @param level resolved bidirection level of space character - */ - public void addSpace( - char space, int ipd, boolean adjustable, int blockProgressionOffset, int level) { - SpaceArea spaceArea = new SpaceArea(blockProgressionOffset, level, space, adjustable); - spaceArea.setIPD(ipd); - addChildArea(spaceArea); - spaceArea.setParentArea(this); - updateLevel(level); - } - - /** - * Records that the last word in this text area is hyphenated. - */ - public void setHyphenated() { - this.isHyphenated = true; - } - - /** - * Returns {@code true} if the last word in this area is hyphenated. - */ - public boolean isHyphenated() { - return isHyphenated; - } - - /** - * Get the whole text string. - * Renderers whose space adjustment handling is not affected - * by multi-byte characters can use this method to render the - * whole TextArea at once; the other renderers (for example - * PDFRenderer) have to implement renderWord(WordArea) and - * renderSpace(SpaceArea) in order to correctly place each - * text fragment. - * - * @return the text string - */ - public String getText() { - StringBuilder text = new StringBuilder(); - // assemble the text - for (InlineArea inline : inlines) { - if (inline instanceof WordArea) { - text.append(((WordArea) inline).getWord()); - } else { - assert (inline instanceof SpaceArea); - text.append(((SpaceArea) inline).getSpace()); - } - } - return text.toString(); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - StringBuffer sb = new StringBuffer(super.toString()); - sb.append(" {text=\""); - sb.append(CharUtilities.toNCRefs(getText())); - sb.append("\""); - sb.append("}"); - return sb.toString(); - } - - public void updateLevel(int newLevel) { - if (newLevel >= 0) { - int curLevel = getBidiLevel(); - if (curLevel >= 0) { - if (newLevel < curLevel) { - setBidiLevel(newLevel); - } - } else { - setBidiLevel(newLevel); - } - } - } - - private static int findMinLevel(int[] levels, int defaultLevel) { - if (levels != null) { - int lMin = Integer.MAX_VALUE; - for (int i = 0, n = levels.length; i < n; i++) { - int l = levels [ i ]; - if ((l >= 0) && (l < lMin)) { - lMin = l; - } - } - if (lMin == Integer.MAX_VALUE) { - return -1; - } else { - return lMin; - } - } else { - return defaultLevel; - } - } - - private int[] makeLevels(int level, int count) { - if (level >= 0) { - int[] levels = new int [ count ]; - Arrays.fill(levels, level); - return levels; - } else { - return null; - } - } - - public int getEffectiveIPD() { - return getIPD(); - } -} - diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java deleted file mode 100644 index 2d5845718..000000000 --- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.util.List; - -import org.apache.fop.area.PageViewport; -import org.apache.fop.area.Resolvable; -import org.apache.fop.complexscripts.bidi.InlineRun; -import org.apache.fop.fonts.Font; - -/** - * Unresolvable page number area. - * This is a word area that resolves itself to a page number - * from an id reference. - */ -public class UnresolvedPageNumber extends TextArea implements Resolvable { - - - private static final long serialVersionUID = -1758090835371647980L; - - private boolean resolved; - private String pageIDRef; - private String text; - private boolean pageType; - - /** Indicates that the reference refers to the first area generated by a formatting object. */ - public static final boolean FIRST = true; - /** Indicates that the reference refers to the last area generated by a formatting object. */ - public static final boolean LAST = false; - - //Transient fields - private transient Font font; - - public UnresolvedPageNumber() { - this(null, null, FIRST); - } - - /** - * Create a new unresolved page number. - * - * @param id the id reference for resolving this - * @param f the font for formatting the page number - */ - public UnresolvedPageNumber(String id, Font f) { - this(id, f, FIRST); - } - - /** - * Create a new unresolved page number. - * - * @param id the id reference for resolving this - * @param f the font for formatting the page number - * @param type indicates whether the reference refers to the first or last area generated by - * a formatting object - */ - public UnresolvedPageNumber(String id, Font f, boolean type) { - pageIDRef = id; - font = f; - text = "?"; - pageType = type; - } - - private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException { - ois.defaultReadObject(); - } - - /** - * Get the id references for this area. - * - * @return the id reference for this unresolved page number - */ - public String[] getIDRefs() { - return new String[] {pageIDRef}; - } - - /** - * Get the (resolved or unresolved) text. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Resolve the page number idref - * This resolves the idref for this object by getting the page number - * string from the first page in the list of pages that apply - * for this ID. The page number text is then set to the String value - * of the page number. - * - * TODO: [GA] May need to run bidi algorithm and script processor - * on resolved page number. - * - * @param id an id whose PageViewports have been determined - * @param pages the list of PageViewports associated with this ID - */ - public void resolveIDRef(String id, List<PageViewport> pages) { - if (!resolved && pageIDRef.equals(id) && pages != null) { - if (log.isDebugEnabled()) { - log.debug("Resolving pageNumber: " + id); - } - resolved = true; - int pageIndex = pageType ? 0 : pages.size() - 1; - PageViewport page = pages.get(pageIndex); - // replace the text - removeText(); - text = page.getPageNumberString(); - addWord(text, 0, getBidiLevel()); - // update ipd - if (font != null) { - handleIPDVariation(font.getWordWidth(text) - getIPD()); - // set the Font object to null, as we don't need it any more - font = null; - } else { - log.warn("Cannot update the IPD of an unresolved page number." - + " No font information available."); - } - } - } - - /** - * Check if this is resolved. - * - * @return true when this has been resolved - */ - public boolean isResolved() { - return resolved; - } - - /** - * recursively apply the variation factor to all descendant areas - * @param variationFactor the variation factor that must be applied to adjustment ratios - * @param lineStretch the total stretch of the line - * @param lineShrink the total shrink of the line - * @return true if there is an UnresolvedArea descendant - */ - @Override - public boolean applyVariationFactor(double variationFactor, - int lineStretch, int lineShrink) { - return true; - } - - /** - * Collection bidi inline runs. - * Override of @{link InlineParent} implementation. - * - * N.B. [GA] without this override, the page-number-citation_writing_mode_rl - * layout engine test will fail. It may be that the test needs to - * be updated rather than using this override. - * @param runs current list of inline runs - * @return modified list of inline runs, having appended new run - */ - @Override - public List collectInlineRuns(List runs) { - assert runs != null; - runs.add(new InlineRun(this, new int[] {getBidiLevel()})); - return runs; - } -} diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java deleted file mode 100644 index 24cc9478c..000000000 --- a/src/java/org/apache/fop/area/inline/WordArea.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* $Id$ */ - -package org.apache.fop.area.inline; - -import java.util.Arrays; -import java.util.List; - -import org.apache.fop.complexscripts.bidi.InlineRun; -import org.apache.fop.complexscripts.util.CharMirror; - -/** - * A string of characters without spaces - */ -public class WordArea extends InlineArea { - - private static final long serialVersionUID = 6444644662158970942L; - - /** The text for this word area */ - protected String word; - - /** An array of width for adjusting the individual letters (optional) */ - protected int[] letterAdjust; - - /** - * An array of resolved bidirectional levels corresponding to each character - * in word (optional) - */ - protected int[] levels; - - /** - * An array of glyph positioning adjustments to apply to each glyph 'char' in word (optional) - */ - protected int[][] gposAdjustments; - - /** - * A flag indicating whether the content of word is reversed in relation to - * its original logical order. - */ - protected boolean reversed; - - /** - * Create a word area - * @param blockProgressionOffset the offset for this area - * @param level the bidirectional embedding level (or -1 if not defined) for word as a group - * @param word the word string - * @param letterAdjust the letter adjust array (may be null) - * @param levels array of per-character (glyph) bidirectional levels, - * in case word area is heterogenously leveled - * @param gposAdjustments array of general position adjustments or null if none apply - * @param reversed true if word is known to be reversed at construction time - */ - public WordArea( - int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels, - int[][] gposAdjustments, boolean reversed) { - super(blockProgressionOffset, level); - int length = (word != null) ? word.length() : 0; - this.word = word; - this.letterAdjust = maybeAdjustLength(letterAdjust, length); - this.levels = maybePopulateLevels(levels, level, length); - this.gposAdjustments = maybeAdjustLength(gposAdjustments, length); - this.reversed = reversed; - } - - /** - * Create a word area - * @param blockProgressionOffset the offset for this area - * @param level the bidirectional embedding level (or -1 if not defined) for word as a group - * @param word the word string - * @param letterAdjust the letter adjust array (may be null) - * @param levels array of per-character (glyph) bidirectional levels, - * in case word area is heterogenously leveled - * @param gposAdjustments array of general position adjustments or null if none apply - */ - public WordArea( - int blockProgressionOffset, int level, String word, int[] letterAdjust, int[] levels, - int[][] gposAdjustments) { - this (blockProgressionOffset, level, word, letterAdjust, levels, gposAdjustments, false); - } - - /** @return Returns the word. */ - public String getWord() { - return word; - } - - /** @return the array of letter adjust widths */ - public int[] getLetterAdjustArray() { - return this.letterAdjust; - } - - /** - * Obtain per-character (glyph) bidi levels. - * @return a (possibly empty) array of levels or null (if none resolved) - */ - public int[] getBidiLevels() { - return levels; - } - - /** - * <p>Obtain per-character (glyph) bidi levels over a specified subsequence.</p> - * <p>If word has been reversed, then the subsequence is over the reversed word.</p> - * @param start starting (inclusive) index of subsequence - * @param end ending (exclusive) index of subsequence - * @return a (possibly null) array of per-character (glyph) levels over the specified - * sequence - */ - public int[] getBidiLevels(int start, int end) { - assert start <= end; - if (this.levels != null) { - int n = end - start; - int[] levels = new int [ n ]; - for (int i = 0; i < n; i++) { - levels[i] = this.levels [ start + i ]; - } - return levels; - } else { - return null; - } - } - - /** - * <p>Obtain per-character (glyph) level at a specified index position.</p> - * <p>If word has been reversed, then the position is relative to the reversed word.</p> - * @param position the index of the (possibly reversed) character from which to obtain the - * level - * @return a resolved bidirectional level or, if not specified, then -1 - */ - public int bidiLevelAt(int position) { - if (position > word.length()) { - throw new IndexOutOfBoundsException(); - } else if (levels != null) { - return levels [ position ]; - } else { - return -1; - } - } - - @Override - public List collectInlineRuns(List runs) { - assert runs != null; - InlineRun r; - int[] levels = getBidiLevels(); - if ((levels != null) && (levels.length > 0)) { - r = new InlineRun(this, levels); - } else { - r = new InlineRun(this, getBidiLevel(), word.length()); - } - runs.add(r); - return runs; - } - - /** - * Obtain per-character (glyph) position adjustments. - * @return a (possibly empty) array of adjustments, each having four elements, or null - * if no adjustments apply - */ - public int[][] getGlyphPositionAdjustments() { - return gposAdjustments; - } - - /** - * <p>Obtain per-character (glyph) position adjustments at a specified index position.</p> - * <p>If word has been reversed, then the position is relative to the reversed word.</p> - * @param position the index of the (possibly reversed) character from which to obtain the - * level - * @return an array of adjustments or null if none applies - */ - public int[] glyphPositionAdjustmentsAt(int position) { - if (position > word.length()) { - throw new IndexOutOfBoundsException(); - } else if (gposAdjustments != null) { - return gposAdjustments [ position ]; - } else { - return null; - } - } - - /** - * <p>Reverse characters and corresponding per-character levels and glyph position - * adjustments.</p> - * @param mirror if true, then perform mirroring if mirrorred characters - */ - public void reverse(boolean mirror) { - if (word.length() > 0) { - word = ((new StringBuffer(word)) .reverse()) .toString(); - if (levels != null) { - reverse(levels); - } - if (gposAdjustments != null) { - reverse(gposAdjustments); - } - reversed = !reversed; - if (mirror) { - word = CharMirror.mirror(word); - } - } - } - - /** - * <p>Perform mirroring on mirrorable characters.</p> - */ - public void mirror() { - if (word.length() > 0) { - word = CharMirror.mirror(word); - } - } - - /** - * <p>Determined if word has been reversed (in relation to original logical order).</p> - * <p>If a word is reversed, then both its characters (glyphs) and corresponding per-character - * levels are in reverse order.</p> - * <p>Note: this information is used in order to process non-spacing marks during rendering as - * well as provide hints for caret direction.</p> - * @return true if word is reversed - */ - public boolean isReversed() { - return reversed; - } - - /* - * If int[] array is not of specified length, then create - * a new copy of the first length entries. - */ - private static int[] maybeAdjustLength(int[] ia, int length) { - if (ia != null) { - if (ia.length == length) { - return ia; - } else { - int[] iaNew = new int [ length ]; - for (int i = 0, n = ia.length; i < n; i++) { - if (i < length) { - iaNew [ i ] = ia [ i ]; - } else { - break; - } - } - return iaNew; - } - } else { - return ia; - } - } - - /* - * If int[][] matrix is not of specified length, then create - * a new shallow copy of the first length entries. - */ - private static int[][] maybeAdjustLength(int[][] im, int length) { - if (im != null) { - if (im.length == length) { - return im; - } else { - int[][] imNew = new int [ length ][]; - for (int i = 0, n = im.length; i < n; i++) { - if (i < length) { - imNew [ i ] = im [ i ]; - } else { - break; - } - } - return imNew; - } - } else { - return im; - } - } - - private static int[] maybePopulateLevels(int[] levels, int level, int count) { - if ((levels == null) && (level >= 0)) { - levels = new int[count]; - Arrays.fill(levels, level); - } - return maybeAdjustLength(levels, count); - } - - private static void reverse(int[] a) { - for (int i = 0, n = a.length, m = n / 2; i < m; i++) { - int k = n - i - 1; - int t = a [ k ]; - a [ k ] = a [ i ]; - a [ i ] = t; - } - } - - private static void reverse(int[][] aa) { - for (int i = 0, n = aa.length, m = n / 2; i < m; i++) { - int k = n - i - 1; - int[] t = aa [ k ]; - aa [ k ] = aa [ i ]; - aa [ i ] = t; - } - } - -} diff --git a/src/java/org/apache/fop/area/inline/package.html b/src/java/org/apache/fop/area/inline/package.html deleted file mode 100644 index 064a17d0c..000000000 --- a/src/java/org/apache/fop/area/inline/package.html +++ /dev/null @@ -1,23 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. ---> -<!-- $Id$ --> -<HTML> -<TITLE>org.apache.fop.area.inline Package</TITLE> -<BODY> -<P>FOP's area tree: inline-level areas</P> -</BODY> -</HTML>
\ No newline at end of file |