public class JdkGlyphFixTextMeasurer extends TextMeasurer
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
.
JdkGlyphFixTextMeasurerFactory
TextMeasurer.TextMeasuredState
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
JdkGlyphFixTextMeasurer(JRCommonText textElement)
Create a text measurer for a text element.
|
Modifier and Type | Method and Description |
---|---|
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. |
appendTruncateSuffix, getFontRenderContext, getTextPropertiesHolder, getTruncateSuffix, initialize, isToTruncateAtChar, processLastTruncatedRow, renderNextLine, renderParagraph, setAttributes, setAttributes, truncateLastLineAtChar
protected static final java.lang.String JDK_EXCEPTION_CLASS_PREFIX
public static final int DEFAULT_ATTEMPTS
public static final int DEFAULT_ATTEMPT_SLEEP
public static final java.lang.String PROPERTY_ATTEMPTS
DEFAULT_ATTEMPTS
,
Constant Field Valuespublic static final java.lang.String PROPERTY_ATTEMPT_SLEEP
DEFAULT_ATTEMPT_SLEEP
,
Constant Field Valuespublic static final java.lang.String PROPERTY_CATCH_EMPTY_STACKTRACE
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.public JdkGlyphFixTextMeasurer(JRCommonText textElement)
textElement
- the text elementpublic JRMeasuredText measure(JRStyledText styledText, int remainingTextStart, int availableStretchHeight, boolean canOverflow)
super.measure
, catches
sun.font.GlyphLayout
NPEs and reattempts the call.measure
in interface JRTextMeasurer
measure
in class TextMeasurer
styledText
- the full textremainingTextStart
- the start index of the remaining textavailableStretchHeight
- the available stretch heightcanOverflow
- whether the text element is able to overflowprotected boolean isJdkGlyphError(java.lang.NullPointerException e)
© 2001-2010 Jaspersoft Corporation www.jaspersoft.com