You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by jk...@apache.org on 2007/05/22 00:15:05 UTC

svn commit: r540320 - in /tapestry/tapestry4/trunk: tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/ tapestry-contrib/src/test/org/apache/tapestry/contrib/services/ tapestry-examples/TimeTracker/src/context/ tapestry-examples/TimeTr...

Author: jkuhnert
Date: Mon May 21 15:15:04 2007
New Revision: 540320

URL: http://svn.apache.org/viewvc?view=rev&rev=540320
Log:
-) Fixed RoundedCornerGenerator to properly produce GIF images so that IE can render them.

-) Fixed buffered image size and x/y offsets to be pixel perfect precise about total image size and position in the returned rendered buffer.

Modified:
    tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerGenerator.java
    tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java
    tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html
    tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/component/Locale.java

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerGenerator.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerGenerator.java?view=diff&rev=540320&r1=540319&r2=540320
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerGenerator.java (original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerGenerator.java Mon May 21 15:15:04 2007
@@ -63,6 +63,8 @@
                                      String angle, int shadowWidth, float endOpacity)
     throws Exception
     {
+        width = width * 2;
+        height = height * 2;
         float startAngle = getStartAngle(angle);
         Color bgColor = backgroundColor == null ? null : decodeColor(backgroundColor);
 
@@ -71,14 +73,14 @@
             BufferedImage arc = drawArc(color, backgroundColor, width, height, angle, false, -1);
             BufferedImage ret = arc;
 
+            Arc2D.Float arcArea = new Arc2D.Float(0, 0, width, height, startAngle, 90, Arc2D.PIE);
             if (bgColor != null) {
                 
                 ret = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
                 Graphics2D g2 = (Graphics2D)ret.createGraphics();
                 g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-
-                Arc2D.Float arcArea = new Arc2D.Float(0, 0, width, height, startAngle, 90, Arc2D.PIE);
-
+                g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+                
                 g2.setColor(bgColor);
                 g2.fill(arcArea.getBounds2D());
 
@@ -86,8 +88,9 @@
                 
                 g2.dispose();
             }
-
-            return ret;
+            
+            return convertType(ret, BufferedImage.TYPE_INT_RGB).getSubimage((int)arcArea.getBounds2D().getX(), (int)arcArea.getBounds2D().getY(),
+                    (int)arcArea.getBounds2D().getWidth(), (int)arcArea.getBounds2D().getHeight());
         }
 
         BufferedImage mask = drawArc(color, backgroundColor, width, height, angle, true, shadowWidth);
@@ -111,8 +114,6 @@
 
             startX -= shadowSize * 2;
             startY -= shadowSize * 2;
-            // startX -= shadowSize;
-            // startY -= shadowSize;
         }
 
         BufferedImage ret = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
@@ -135,7 +136,18 @@
         g2.setClip(null);
         g2.drawImage(arc, 0, 0, null);
 
-        return ret;
+        return convertType(ret, BufferedImage.TYPE_INT_RGB).getSubimage((int)arcArea.getBounds2D().getX(), (int)arcArea.getBounds2D().getY(),
+                    (int)arcArea.getBounds2D().getWidth(), (int)arcArea.getBounds2D().getHeight());
+    }
+
+    static BufferedImage convertType(BufferedImage image, int type) {
+        BufferedImage result = new BufferedImage(image.getWidth(), image.getHeight(), type);
+        Graphics2D g = result.createGraphics();
+        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
+        g.drawRenderedImage(image, null);
+        g.dispose();
+        return result;
     }
 
     BufferedImage drawArc(String color, String backgroundColor, int width, int height, String angle, boolean masking, int shadowWidth)

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java?view=diff&rev=540320&r1=540319&r2=540320
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java (original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/RoundedCornerService.java Mon May 21 15:15:04 2007
@@ -102,7 +102,7 @@
         
         try {
             
-            String type = "png"; //(bgColor != null) ? "gif" : "png";
+            String type = (bgColor != null) ? "gif" : "png";
 
             byte[] data = (byte[])_imageCache.get(hashKey);
             if (data != null) {

Modified: tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java?view=diff&rev=540320&r1=540319&r2=540320
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java (original)
+++ tapestry/tapestry4/trunk/tapestry-contrib/src/test/org/apache/tapestry/contrib/services/TestRoundedUtil.java Mon May 21 15:15:04 2007
@@ -73,7 +73,6 @@
         g2.drawImage(image, 0, 0, null);
     }
     */
-    
 
     protected void paintComponent(Graphics g) {
 
@@ -84,7 +83,7 @@
 
         try {
 
-            image = generator.buildCorner("FF7E00", "white", 60, 60, "tr", -1, -1);
+            image = generator.buildCorner("FF7E00", "white", 160, 160, "tr", 8, 0.6f);
         }
         catch (Exception e) {
             e.printStackTrace();

Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html?view=diff&rev=540320&r1=540319&r2=540320
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html Mon May 21 15:15:04 2007
@@ -8,9 +8,11 @@
 
     .localeList {
         background: #2A78B0;
-        display:block;
+        display:block !important;
 		float:left;
         width:20%;
+        margin-bottom: 0px;
+        margin-right: 0px;
         margin-top:0.6em;
 		margin-left:0.5em;
     }
@@ -18,7 +20,7 @@
     .localeList p { margin: 0 10px;}
 
     .roundtop {
-        background: url("rounded?c=2A78B0&bc=white&w=8&h=8&a=tr") no-repeat top right;
+        background: transparent url("rounded?c=2A78B0&bc=white&w=8&h=8&a=tr") no-repeat top right;
     }
     .selectedRoundtop {
         background: url("rounded?c=efefef&bc=white&w=8&h=8&a=tr") no-repeat top right;

Modified: tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/component/Locale.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/component/Locale.java?view=diff&rev=540320&r1=540319&r2=540320
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/component/Locale.java (original)
+++ tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/java/org/apache/tapestry/timetracker/component/Locale.java Mon May 21 15:15:04 2007
@@ -28,7 +28,7 @@
 
     void renderRow(IMarkupWriter writer, String selectedCssClass, String cssClass, String anchor, boolean selected)
     {
-         writer.begin("div");
+        writer.begin("div");
         writer.attribute("class", selected ? selectedCssClass :cssClass);
 
         writer.beginEmpty("img");