You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2022/08/15 03:50:14 UTC
svn commit: r1903415 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDTextAppearanceHandler.java
Author: tilman
Date: Mon Aug 15 03:50:14 2022
New Revision: 1903415
URL: http://svn.apache.org/viewvc?rev=1903415&view=rev
Log:
PDFBOX-4892: optimize, as suggested by Valery Bokov
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDTextAppearanceHandler.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDTextAppearanceHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDTextAppearanceHandler.java?rev=1903415&r1=1903414&r2=1903415&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDTextAppearanceHandler.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDTextAppearanceHandler.java Mon Aug 15 03:50:14 2022
@@ -221,15 +221,17 @@ public class PDTextAppearanceHandler ext
contentStream.setLineCapStyle(0);
contentStream.setLineWidth(0.61f); // value from Adobe
- contentStream.addRect(1, 1, bbox.getWidth() - 2, bbox.getHeight() - 2);
- contentStream.moveTo(bbox.getWidth() / 4, bbox.getHeight() / 7 * 2);
- contentStream.lineTo(bbox.getWidth() * 3 / 4 - 1, bbox.getHeight() / 7 * 2);
- contentStream.moveTo(bbox.getWidth() / 4, bbox.getHeight() / 7 * 3);
- contentStream.lineTo(bbox.getWidth() * 3 / 4 - 1, bbox.getHeight() / 7 * 3);
- contentStream.moveTo(bbox.getWidth() / 4, bbox.getHeight() / 7 * 4);
- contentStream.lineTo(bbox.getWidth() * 3 / 4 - 1, bbox.getHeight() / 7 * 4);
- contentStream.moveTo(bbox.getWidth() / 4, bbox.getHeight() / 7 * 5);
- contentStream.lineTo(bbox.getWidth() * 3 / 4 - 1, bbox.getHeight() / 7 * 5);
+ float width = bbox.getWidth();
+ float height = bbox.getHeight();
+ contentStream.addRect(1, 1, width - 2, height - 2);
+ contentStream.moveTo(width / 4, height / 7 * 2);
+ contentStream.lineTo(width * 3 / 4 - 1, height / 7 * 2);
+ contentStream.moveTo(width / 4, height / 7 * 3);
+ contentStream.lineTo(width * 3 / 4 - 1, height / 7 * 3);
+ contentStream.moveTo(width / 4, height / 7 * 4);
+ contentStream.lineTo(width * 3 / 4 - 1, height / 7 * 4);
+ contentStream.moveTo(width / 4, height / 7 * 5);
+ contentStream.lineTo(width * 3 / 4 - 1, height / 7 * 5);
contentStream.fillAndStroke();
}
@@ -261,13 +263,15 @@ public class PDTextAppearanceHandler ext
gs.setBlendMode(BlendMode.NORMAL);
contentStream.setGraphicsStateParameters(gs);
contentStream.setNonStrokingColor(1f);
- drawCircle(contentStream, bbox.getWidth() / 2, bbox.getHeight() / 2, smallR);
+ float width = bbox.getWidth() / 2;
+ float height = bbox.getHeight() / 2;
+ drawCircle(contentStream, width, height, smallR);
contentStream.fill();
contentStream.restoreGraphicsState();
contentStream.setLineWidth(0.59f); // value from Adobe
- drawCircle(contentStream, bbox.getWidth() / 2, bbox.getHeight() / 2, smallR);
- drawCircle2(contentStream, bbox.getWidth() / 2, bbox.getHeight() / 2, largeR);
+ drawCircle(contentStream, width, height, smallR);
+ drawCircle2(contentStream, width, height, largeR);
contentStream.fillAndStroke();
}