Revision: 4024
          http://vexi.svn.sourceforge.net/vexi/?rev=4024&view=rev
Author:   clrg
Date:     2011-02-09 01:42:36 +0000 (Wed, 09 Feb 2011)

Log Message:
-----------
Only calc text size once (instead of 4 times!) when calculating box text 
dimensions

Modified Paths:
--------------
    
trunk/org.vexi-core.main/src/main/java/org/vexi/core/BoxRenderProperties.java

Modified: 
trunk/org.vexi-core.main/src/main/java/org/vexi/core/BoxRenderProperties.java
===================================================================
--- 
trunk/org.vexi-core.main/src/main/java/org/vexi/core/BoxRenderProperties.java   
    2011-02-07 17:37:01 UTC (rev 4023)
+++ 
trunk/org.vexi-core.main/src/main/java/org/vexi/core/BoxRenderProperties.java   
    2011-02-09 01:42:36 UTC (rev 4024)
@@ -13,7 +13,11 @@
 import org.vexi.graphics.Font;
 import org.vexi.graphics.Picture;
 
-/** amalgamates common text properties for memory/runtime efficiency */
+/**
+ *  amalgamates Box rendering properties for memory/runtime efficiency
+ *  - text properties font, fontsize, text, textcolor
+ *  - fill properties texture, fillcolor
+ **/
 final class BoxRenderProperties implements Constants {
 
     //////// INSTANCE PROPERTIES /////////////////////////////////////
@@ -417,16 +421,17 @@
         return true;
     }
 
-    /** synchronize dimensions with text object contents */
+    /** establish dimensions of rendered text contents */
     private void calculateDimensions() {
         if (text == EMPTY_STRING) {
             textwidth = 0;
             textheight = 0;
             return;
         }
-        int iwidth = font.textwidth(text.toString());
-        int iheight = font.textheight(text.toString());
-        textwidth = iwidth > Short.MAX_VALUE ? Short.MAX_VALUE : (short) 
font.textwidth(text.toString());
-        textheight = iheight > Short.MAX_VALUE ? Short.MAX_VALUE : (short) 
font.textheight(text.toString());
+        long textsize = font.textsize(text.toString());
+        int iwidth = (int)((textsize >>> 32) & 0xffffffff);
+        int iheight = (int)(textsize & 0xffffffffL);
+        textwidth = iwidth > Short.MAX_VALUE ? Short.MAX_VALUE : (short)iwidth;
+        textheight = iheight > Short.MAX_VALUE ? Short.MAX_VALUE : 
(short)iheight;
     }
 }


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to