tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkuhn...@apache.org
Subject svn commit: r544718 - in /tapestry/tapestry4/trunk: tapestry-contrib/src/java/org/apache/tapestry/contrib/services/impl/ tapestry-contrib/src/test/org/apache/tapestry/contrib/services/ tapestry-framework/src/js/scriptaculous-1.7.1/
Date Wed, 06 Jun 2007 03:34:39 GMT
Author: jkuhnert
Date: Tue Jun  5 20:34:38 2007
New Revision: 544718

URL: http://svn.apache.org/viewvc?view=rev&rev=544718
Log:
Fixed bug in Rounded corners service where it wasn't producing PNG images properly when no
background color was specified.

Tried and failed to fix TAPESTRY-1535.  Now I'm re-remembering why I hated prototype the first
time around.

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-framework/src/js/scriptaculous-1.7.1/prototype.js

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=544718&r1=544717&r2=544718
==============================================================================
--- 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
Tue Jun  5 20:34:38 2007
@@ -70,7 +70,7 @@
 
         if (shadowWidth <= 0) {
 
-            BufferedImage arc = drawArc(color, backgroundColor, width, height, angle, false,
-1);
+            BufferedImage arc = drawArc(color, width, height, angle, false, -1);
             BufferedImage ret = arc;
 
             Arc2D.Float arcArea = new Arc2D.Float(0, 0, width, height, startAngle, 90, Arc2D.PIE);
@@ -87,14 +87,16 @@
                 g2.drawImage(arc, 0, 0, null);
                 
                 g2.dispose();
+
+                ret = convertType(ret, BufferedImage.TYPE_INT_RGB);
             }
-            
-            return convertType(ret, BufferedImage.TYPE_INT_RGB).getSubimage((int)arcArea.getBounds2D().getX(),
(int)arcArea.getBounds2D().getY(),
-                    (int)arcArea.getBounds2D().getWidth(), (int)arcArea.getBounds2D().getHeight());
+
+            return ret.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);
-        BufferedImage arc = drawArc(color, backgroundColor, width, height, angle, false,
shadowWidth);
+        BufferedImage mask = drawArc(color, width, height, angle, true, shadowWidth);
+        BufferedImage arc = drawArc(color, width, height, angle, false, shadowWidth);
 
         float startX = 0;
         float startY = 0;
@@ -150,10 +152,9 @@
         return result;
     }
 
-    BufferedImage drawArc(String color, String backgroundColor, int width, int height, String
angle, boolean masking, int shadowWidth)
+    BufferedImage drawArc(String color, int width, int height, String angle, boolean masking,
int shadowWidth)
     {
         Color arcColor = decodeColor(color);
-        Color bgColor = backgroundColor == null ? null : decodeColor(backgroundColor);
         float startAngle = getStartAngle(angle);
 
         int canvasWidth = width;
@@ -204,6 +205,7 @@
         
         // draw arc
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+        g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
 
         g2.setColor(arcColor);
         g2.setComposite(AlphaComposite.Src);

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=544718&r1=544717&r2=544718
==============================================================================
--- 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
Tue Jun  5 20:34:38 2007
@@ -1,5 +1,6 @@
 package org.apache.tapestry.contrib.services.impl;
 
+import org.apache.commons.logging.Log;
 import org.apache.hivemind.util.Defense;
 import org.apache.tapestry.IRequestCycle;
 import org.apache.tapestry.engine.IEngineService;
@@ -59,6 +60,8 @@
     // holds pre-built binaries for previously generated colors
     private Map _imageCache = new HashMap();
 
+    private Log _log;
+
     public ILink getLink(boolean post, Object parameter)
     {
         Defense.notNull(parameter, "parameter");
@@ -130,6 +133,20 @@
 
             data = bo.toByteArray();
 
+            if (data == null || data.length < 1)
+            {
+                _log.error("Image generated had zero length byte array from parameters of:\n"
+                           + "[color:" + color + ", bgColor:" + bgColor
+                           + ", width:" + width + ", height:" + height
+                           + ", angle:" + angle + ", shadowWidth:" + shadowWidth
+                           + ", shadowOpacity:" + shadowOpacity + ", side:" + side
+                           + ", wholeShadow: " + wholeShadow + ", arcWidth: " + arcWidth
+                           + ", arcHeight:" + arcHeight + "\n image: " + image);
+
+                _response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                return;
+            }
+
             _imageCache.put(hashKey, data);
 
             writeImageResponse(data, type);
@@ -219,5 +236,10 @@
     public void setResponse(WebResponse response)
     {
         _response = response;
+    }
+
+    public void setLog(Log log)
+    {
+        _log = log;
     }
 }

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=544718&r1=544717&r2=544718
==============================================================================
--- 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
Tue Jun  5 20:34:38 2007
@@ -83,7 +83,7 @@
 
         try {
 
-            image = generator.buildCorner("FF7E00", "white", 160, 160, "tr", 8, 0.6f);
+            image = generator.buildCorner("6188C7", "white", 6, 6, "tr", -1, -1);
         }
         catch (Exception e) {
             e.printStackTrace();

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/prototype.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/prototype.js?view=diff&rev=544718&r1=544717&r2=544718
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/prototype.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/scriptaculous-1.7.1/prototype.js Tue
Jun  5 20:34:38 2007
@@ -3016,9 +3016,12 @@
     element = $(element);
     useCapture = useCapture || false;
 
-    if (name == 'keypress' &&
+    /* if (name == 'keypress' &&
       (Prototype.Browser.WebKit || element.attachEvent))
-      name = 'keydown';
+      name = 'keydown';*/
+    if (name == 'keypress' &&
+        ((element.attachEvent && !window.opera) || Prototype.Browser.WebKit))
+        name = 'keydown';
 
     Event._observeAndCache(element, name, observer, useCapture);
   },
@@ -3028,7 +3031,7 @@
     useCapture = useCapture || false;
 
     if (name == 'keypress' &&
-        (Prototype.Browser.WebKit || element.attachEvent))
+        ((element.attachEvent && !window.opera) || Prototype.Browser.WebKit))
       name = 'keydown';
 
     if (element.removeEventListener) {



Mime
View raw message