@@ -118,6 +118,8 @@ public void generateNormalAppearance()
118118 }
119119 cs .setLineWidth (ab .width );
120120
121+ String lineEndingStyle = annotation .getLineEndingStyle ();
122+
121123 // draw callout line(s)
122124 // must be done before retangle paint to avoid a line cutting through cloud
123125 // see CTAN-example-Annotations.pdf
@@ -127,7 +129,7 @@ public void generateNormalAppearance()
127129 float y = pathsArray [i * 2 + 1 ];
128130 if (i == 0 )
129131 {
130- if (SHORT_STYLES .contains (annotation . getLineEndingStyle () ))
132+ if (SHORT_STYLES .contains (lineEndingStyle ))
131133 {
132134 // modify coordinate to shorten the segment
133135 // https://stackoverflow.com/questions/7740507/extend-a-line-segment-a-specific-distance
@@ -155,15 +157,15 @@ public void generateNormalAppearance()
155157 // paint the styles here and after line(s) draw, to avoid line crossing a filled shape
156158 if (PDAnnotationFreeText .IT_FREE_TEXT_CALLOUT .equals (annotation .getIntent ())
157159 // check only needed to avoid q cm Q if LE_NONE
158- && !LE_NONE .equals (annotation . getLineEndingStyle () )
160+ && !LE_NONE .equals (lineEndingStyle )
159161 && pathsArray .length >= 4 )
160162 {
161163 float x2 = pathsArray [2 ];
162164 float y2 = pathsArray [3 ];
163165 float x1 = pathsArray [0 ];
164166 float y1 = pathsArray [1 ];
165167 cs .saveGraphicsState ();
166- if (ANGLED_STYLES .contains (annotation . getLineEndingStyle () ))
168+ if (ANGLED_STYLES .contains (lineEndingStyle ))
167169 {
168170 // do a transform so that first "arm" is imagined flat,
169171 // like in line handler.
@@ -177,7 +179,7 @@ public void generateNormalAppearance()
177179 {
178180 cs .transform (Matrix .getTranslateInstance (x1 , y1 ));
179181 }
180- drawStyle (annotation . getLineEndingStyle () , cs , 0 , 0 , ab .width , hasStroke , hasBackground , false );
182+ drawStyle (lineEndingStyle , cs , 0 , 0 , ab .width , hasStroke , hasBackground , false );
181183 cs .restoreGraphicsState ();
182184 }
183185
@@ -288,7 +290,8 @@ public void generateNormalAppearance()
288290 cs .addRect (xOffset , clipY , clipWidth , clipHeight );
289291 cs .clip ();
290292
291- if (annotation .getContents () != null )
293+ String annotationContents = annotation .getContents ();
294+ if (annotationContents != null )
292295 {
293296 cs .beginText ();
294297 cs .setFont (font , fontSize );
@@ -298,7 +301,7 @@ public void generateNormalAppearance()
298301 appearanceStyle .setFontSize (fontSize );
299302 PlainTextFormatter formatter = new PlainTextFormatter .Builder (cs )
300303 .style (appearanceStyle )
301- .text (new PlainText (annotation . getContents () ))
304+ .text (new PlainText (annotationContents ))
302305 .width (width - ab .width * 4 )
303306 .wrapLines (true )
304307 .initialOffset (xOffset , yOffset )
0 commit comments