You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/07/17 20:29:34 UTC

svn commit: r1753114 - /poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java

Author: onealj
Date: Sun Jul 17 20:29:34 2016
New Revision: 1753114

URL: http://svn.apache.org/viewvc?rev=1753114&view=rev
Log:
reduce statement complexity in drawContent, also has fewer FLOPS

Modified:
    poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java

Modified: poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java?rev=1753114&r1=1753113&r2=1753114&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java (original)
+++ poi/trunk/src/java/org/apache/poi/sl/draw/DrawTextShape.java Sun Jul 17 20:29:34 2016
@@ -70,16 +70,20 @@ public class DrawTextShape extends DrawS
         // Horizontal flipping applies only to shape outline and not to the text in the shape.
         // Applying flip second time restores the original not-flipped transform
         if (horzFlip ^ vertFlip) {
-            graphics.translate(anchor.getX() + anchor.getWidth(), anchor.getY());
+            final double ax = anchor.getX();
+            final double ay = anchor.getY();
+            graphics.translate(ax + anchor.getWidth(), ay);
             graphics.scale(-1, 1);
-            graphics.translate(-anchor.getX(), -anchor.getY());
+            graphics.translate(-ax, -ay);
         }
 
         Double textRot = s.getTextRotation();
         if (textRot != null && textRot != 0) {
-            graphics.translate(anchor.getCenterX(), anchor.getCenterY());
+            final double cx = anchor.getCenterX();
+            final double cy = anchor.getCenterY();
+            graphics.translate(cx, cy);
             graphics.rotate(Math.toRadians(textRot));
-            graphics.translate(-anchor.getCenterX(), -anchor.getCenterY());
+            graphics.translate(-cx, -cy);
         }
 
         // first dry-run to calculate the total height of the text
@@ -101,16 +105,19 @@ public class DrawTextShape extends DrawS
 
         TextDirection textDir = s.getTextDirection();
         if (textDir == TextDirection.VERTICAL || textDir == TextDirection.VERTICAL_270) {
-            double deg = (textDir == TextDirection.VERTICAL) ? 90 : 270;
-            graphics.translate(anchor.getCenterX(), anchor.getCenterY());
+            final double deg = (textDir == TextDirection.VERTICAL) ? 90 : 270;
+            final double cx = anchor.getCenterX();
+            final double cy = anchor.getCenterY();
+            graphics.translate(cx, cy);
             graphics.rotate(Math.toRadians(deg));
-            graphics.translate(-anchor.getCenterX(), -anchor.getCenterY());
+            graphics.translate(-cx, -cy);
             
             // old top/left edge is now bottom/left or top/right - as we operate on the already
             // rotated drawing context, both verticals can be moved in the same direction
-            double w = anchor.getWidth();
-            double h = anchor.getHeight();
-            graphics.translate((w-h)/2d,(h-w)/2d);
+            final double w = anchor.getWidth();
+            final double h = anchor.getHeight();
+            final double dx = (w-h)/2d;
+            graphics.translate(dx,-dx);
         }
 
         drawParagraphs(graphics, x, y);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org