pbwest      2004/05/30 09:27:51

  Modified:    src/java/org/apache/fop/area Tag: FOP_0-20-0_Alt-Design
                        LineArea.java
  Log:
  Exceptions from preprocess text now pass back through the constructor.
  Initial logic of preprocessText extracted into setupMeasurement().
  Minima and maxima now handled using AreaRanges.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.2.2.4   +36 -37    xml-fop/src/java/org/apache/fop/area/LineArea.java
  
  Index: LineArea.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/LineArea.java,v
  retrieving revision 1.2.2.3
  retrieving revision 1.2.2.4
  diff -u -r1.2.2.3 -r1.2.2.4
  --- LineArea.java     30 May 2004 06:15:57 -0000      1.2.2.3
  +++ LineArea.java     30 May 2004 16:27:50 -0000      1.2.2.4
  @@ -29,6 +29,7 @@
   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 @@
        * @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 @@
        * 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 @@
           // 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 @@
               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);
  +        
  +    }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to