]> source.dussan.org Git - poi.git/commitdiff
reduce statement complexity in drawContent, also has fewer FLOPS
authorJaven O'Neal <onealj@apache.org>
Sun, 17 Jul 2016 20:29:34 +0000 (20:29 +0000)
committerJaven O'Neal <onealj@apache.org>
Sun, 17 Jul 2016 20:29:34 +0000 (20:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753114 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/sl/draw/DrawTextShape.java

index b1179349d72faf17e72a3c80c3c92964c1d0798b..f6e3891e5f9cbb63c4a7774b7fa4fb3f615997c5 100644 (file)
@@ -70,16 +70,20 @@ public class DrawTextShape extends DrawSimpleShape {
         // Horizontal flipping applies only to shape outline and not to the text in the shape.\r
         // Applying flip second time restores the original not-flipped transform\r
         if (horzFlip ^ vertFlip) {\r
-            graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());\r
+            final double ax = anchor.getX();\r
+            final double ay = anchor.getY();\r
+            graphics.translate(ax + anchor.getWidth(), ay);\r
             graphics.scale(-1, 1);\r
-            graphics.translate(-anchor.getX(), -anchor.getY());\r
+            graphics.translate(-ax, -ay);\r
         }\r
 \r
         Double textRot = s.getTextRotation();\r
         if (textRot != null && textRot != 0) {\r
-            graphics.translate(anchor.getCenterX(), anchor.getCenterY());\r
+            final double cx = anchor.getCenterX();\r
+            final double cy = anchor.getCenterY();\r
+            graphics.translate(cx, cy);\r
             graphics.rotate(Math.toRadians(textRot));\r
-            graphics.translate(-anchor.getCenterX(), -anchor.getCenterY());\r
+            graphics.translate(-cx, -cy);\r
         }\r
 \r
         // first dry-run to calculate the total height of the text\r
@@ -101,16 +105,19 @@ public class DrawTextShape extends DrawSimpleShape {
 \r
         TextDirection textDir = s.getTextDirection();\r
         if (textDir == TextDirection.VERTICAL || textDir == TextDirection.VERTICAL_270) {\r
-            double deg = (textDir == TextDirection.VERTICAL) ? 90 : 270;\r
-            graphics.translate(anchor.getCenterX(), anchor.getCenterY());\r
+            final double deg = (textDir == TextDirection.VERTICAL) ? 90 : 270;\r
+            final double cx = anchor.getCenterX();\r
+            final double cy = anchor.getCenterY();\r
+            graphics.translate(cx, cy);\r
             graphics.rotate(Math.toRadians(deg));\r
-            graphics.translate(-anchor.getCenterX(), -anchor.getCenterY());\r
+            graphics.translate(-cx, -cy);\r
             \r
             // old top/left edge is now bottom/left or top/right - as we operate on the already\r
             // rotated drawing context, both verticals can be moved in the same direction\r
-            double w = anchor.getWidth();\r
-            double h = anchor.getHeight();\r
-            graphics.translate((w-h)/2d,(h-w)/2d);\r
+            final double w = anchor.getWidth();\r
+            final double h = anchor.getHeight();\r
+            final double dx = (w-h)/2d;\r
+            graphics.translate(dx,-dx);\r
         }\r
 \r
         drawParagraphs(graphics, x, y);\r