]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Exceptions from preprocess text now pass back through the constructor.
authorPeter Bernard West <pbwest@apache.org>
Sun, 30 May 2004 16:27:50 +0000 (16:27 +0000)
committerPeter Bernard West <pbwest@apache.org>
Sun, 30 May 2004 16:27:50 +0000 (16:27 +0000)
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

src/java/org/apache/fop/area/LineArea.java

index e3b7f081bbb5d9421f9ccc069db5c536f078181e..a038336c38505237f2ac13ff93c924abdd51757b 100644 (file)
@@ -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();
     }
 
     /** <code>generatedBy</code> as an <code>FOPageSeqNode</code> */
@@ -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);
+        
+    }
 
 }