From: Peter Bernard West Date: Sun, 30 May 2004 16:27:50 +0000 (+0000) Subject: Exceptions from preprocess text now pass back through the constructor. X-Git-Tag: Defoe_export~104 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=377bd19ae286093081a5a40063b99a50777be74e;p=xmlgraphics-fop.git Exceptions from preprocess text now pass back through the constructor. Initial logic of preprocessText extracted into setupMeasurement(). Minima and maxima now handled using AreaRanges. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@197675 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index e3b7f081b..a038336c3 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -29,6 +29,7 @@ import java.text.AttributedString; import java.text.BreakIterator; import java.util.Map; +import org.apache.fop.apps.FOPException; import org.apache.fop.datastructs.Node; import org.apache.fop.datatypes.TextDecorations; import org.apache.fop.fo.FOPageSeqNode; @@ -64,17 +65,12 @@ public class LineArea extends BlockArea { * @param sync the synchronization object of this node */ public LineArea(String text, FoPageSequence pageSeq, - FOPageSeqNode generatedBy, Node parent, Object sync) { + FOPageSeqNode generatedBy, Node parent, Object sync) + throws PropertyException, FOPException { super(pageSeq, generatedBy, parent, sync); generator = generatedBy; this.text = text; - try { - preprocessText(); - } catch (PropertyException e) { - throw new RuntimeException(e); - } catch (FontException e) { - throw new RuntimeException(e); - } + preprocessText(); } /** generatedBy as an FOPageSeqNode */ @@ -134,30 +130,7 @@ public class LineArea extends BlockArea { * attributes of the text are applied. */ private void preprocessText() throws PropertyException, FontException { - // Get the font, size, style and weight attributes - attributes = generator.getFontAttributes(); - font = generator.getFopFont(attributes); - TextDecorations decorations = generator.getDecorations(); - // Add the text decorations - // TODO separate color support for text decorations - if (decorations.underlined()) { - attributes.put(TextAttribute.UNDERLINE, - TextAttribute.UNDERLINE_LOW_ONE_PIXEL); - } - if (decorations.overlined()) { - // Not supported yet - } - if (decorations.struckthrough()) { - attributes.put(TextAttribute.STRIKETHROUGH, - TextAttribute.STRIKETHROUGH_ON); - } - attText = new AttributedString(text, attributes); - AttributedCharacterIterator iter = attText.getIterator(); - FontRenderContext identityFRC = - new FontRenderContext( - null, IS_ANTI_ALIASED, USES_FRACTIONAL_METRICS); - measurer = new TextMeasurer(iter, identityFRC); - layout = new TextLayout(iter, identityFRC); + setupMeasurement(); // Find minima and maxima for this text // Text dimensions based on baseline-to-baseline leading and the // descent of the TextLayout @@ -169,9 +142,8 @@ public class LineArea extends BlockArea { // To determine the minima, the shortest length of text is determined, // a TextLayout is formed from that, and the corresponding BPDim and // IPDim values are determined. - iPDimMax = new Float(layout.getVisibleAdvance()); - bPDimMax = - new Float(Math.max( + pageSpaceRange.setIPDimMax(layout.getVisibleAdvance()); + pageSpaceRange.setBPDimMax(Math.max( layout.getLeading(), (layout.getAscent() + layout.getDescent()))); // Find the longest fragment of the text @@ -186,10 +158,37 @@ public class LineArea extends BlockArea { maxWordWidth = Math.max(maxWordWidth, width); begin = boundary; } - iPDimMin = new Float(maxWordWidth); + pageSpaceRange.setIPDimMin(maxWordWidth); // For now, set bPDimMin = bPDimMax. - bPDimMin = bPDimMax; + pageSpaceRange.setBPDimMin(maxWordWidth); } + private void setupMeasurement() throws PropertyException, FontException { + // Get the font, size, style and weight attributes + attributes = generator.getFontAttributes(); + font = generator.getFopFont(attributes); + TextDecorations decorations = generator.getDecorations(); + // Add the text decorations + // TODO separate color support for text decorations + if (decorations.underlined()) { + attributes.put(TextAttribute.UNDERLINE, + TextAttribute.UNDERLINE_LOW_ONE_PIXEL); + } + if (decorations.overlined()) { + // Not supported yet + } + if (decorations.struckthrough()) { + attributes.put(TextAttribute.STRIKETHROUGH, + TextAttribute.STRIKETHROUGH_ON); + } + attText = new AttributedString(text, attributes); + AttributedCharacterIterator iter = attText.getIterator(); + FontRenderContext identityFRC = + new FontRenderContext( + null, IS_ANTI_ALIASED, USES_FRACTIONAL_METRICS); + measurer = new TextMeasurer(iter, identityFRC); + layout = new TextLayout(iter, identityFRC); + + } }