Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.jasperreports.engine.util
Class JdkGlyphFixTextMeasurer

    java.lang.Object
      net.sf.jasperreports.engine.fill.TextMeasurer
          net.sf.jasperreports.engine.util.JdkGlyphFixTextMeasurer

All Implemented Interfaces:
  JRTextMeasurer

    public class JdkGlyphFixTextMeasurer

extends TextMeasurer

A text measurer implementation that extends `the default text measurer` and adds a workaround for Sun JDK bug 6367148/ 6611637.

The workaround consists of simply reattempting the text measuring when a `java.lang.NullPointer` exception is thrown from `sun.font.GlyphLayout`.

Version:
  $Id: JdkGlyphFixTextMeasurer.java 3717 2010-04-09 10:01:33Z teodord $
Author:
  Lucian Chirita (lucianc@users.sourceforge.net)
See Also:
  `JdkGlyphFixTextMeasurerFactory`

Nested Class Summary

Nested classes/interfaces inherited from class net.sf.jasperreports.engine.fill.TextMeasurer
`TextMeasurer.TextMeasuredState`

Field Summary
`static int` | `DEFAULT_ATTEMPT_SLEEP` The default between attempts sleep time.
`static int` | `DEFAULT_ATTEMPTS` The default attempt count.
`protected static java.lang.String` | `JDK_EXCEPTION_CLASS_PREFIX`
`static java.lang.String` | `PROPERTY_ATTEMPT_SLEEP` A property that specifies the number of milliseconds to sleep between measuring reattempts.
`static java.lang.String` | `PROPERTY_ATTEMPTS` A property that specifies the number of times the measurer should attempt to measure a single text element before giving up.
`static java.lang.String` | `PROPERTY_CATCH_EMPTY_STACKTRACE` Whether `java.lang.NullPointer` exceptions with empty stacktraces should be caught.

Constructor Summary
`JdkGlyphFixTextMeasurer(JRCommonText textElement)` Create a text measurer for a text element.

Method Summary
`protected boolean` | `isJdkGlyphError(java.lang.NullPointerException e)`
`JRMeasuredText` | `measure(JRStyledText styledText, int remainingTextStart, int availableStretchHeight, boolean canOverflow)` Calls `super.measure`, catches `sun.font.GlyphLayout` NPEs and reattempts the call.

Methods inherited from class net.sf.jasperreports.engine.fill.TextMeasurer
`appendTruncateSuffix, getTextPropertiesHolder, getTruncateSuffix, initialize, isToTruncateAtChar, processLastTruncatedRow, renderNextLine, renderParagraph, setAttributes, setAttributes, truncateLastLineAtChar`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### JDK_EXCEPTION_CLASS_PREFIX

    protected static final java.lang.String JDK_EXCEPTION_CLASS_PREFIX

See Also:
  Constant Field Values

### DEFAULT_ATTEMPTS

    public static final int DEFAULT_ATTEMPTS

  The default attempt count.

  See Also:
    Constant Field Values

### DEFAULT_ATTEMPT_SLEEP

    public static final int DEFAULT_ATTEMPT_SLEEP

  The default between attempts sleep time.

  See Also:
    Constant Field Values

### PROPERTY_ATTEMPTS

    public static final java.lang.String PROPERTY_ATTEMPTS

  A property that specifies the number of times the measurer should attempt to measure a single text element before giving up. The default value is 20.

  See Also:
    `DEFAULT_ATTEMPTS`, Constant Field Values

### PROPERTY_ATTEMPT_SLEEP

    public static final java.lang.String PROPERTY_ATTEMPT_SLEEP

  A property that specifies the number of milliseconds to sleep between measuring reattempts. The default value is 0, which means that the measurer will not pause between reattempts.

  See Also:
    `DEFAULT_ATTEMPT_SLEEP`, Constant Field Values

### PROPERTY_CATCH_EMPTY_STACKTRACE

    public static final java.lang.String PROPERTY_CATCH_EMPTY_STACKTRACE

  Whether `java.lang.NullPointer` exceptions with empty stacktraces should be caught. This is useful when running on a Sun server JVM (java -server), which might omit exception stacktraces in some cases.

  See Also:
    Constant Field Values

Constructor Detail

### JdkGlyphFixTextMeasurer

    public JdkGlyphFixTextMeasurer(JRCommonText textElement)

  Create a text measurer for a text element.

  Parameters:
    `textElement` - the text element

Method Detail

### measure

    public JRMeasuredText measure(JRStyledText styledText,
                                  int remainingTextStart,
                                  int availableStretchHeight,
                                  boolean canOverflow)

  Calls `super.measure`, catches `sun.font.GlyphLayout` NPEs and reattempts the call.

  Specified by:
    `measure` in interface `JRTextMeasurer`
  Overrides:
    `measure` in class `TextMeasurer`
  Parameters:
    `styledText` - the full text
    `remainingTextStart` - the start index of the remaining text
    `availableStretchHeight` - the available stretch height
    `canOverflow` - whether the text element is able to overflow
  Returns:
    text measuring information

### isJdkGlyphError

    protected boolean isJdkGlyphError(java.lang.NullPointerException e)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com