Author: jkuhnert
Date: Sat Jun 16 15:03:55 2007
New Revision: 547990
URL: http://svn.apache.org/viewvc?view=rev&rev=547990
Log:
TAPESTRY-1582. Whole shadow generation wasn't using foreground color or
converting the image to non alpha transparent GIF compatible format.
Modified:
tapestry/tapestry4/trunk/src/site/xdoc/developmentguide/hivemind/roundedcorners.xml
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
Modified:
tapestry/tapestry4/trunk/src/site/xdoc/developmentguide/hivemind/roundedcorners.xml
URL:
http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/src/site/xdoc/developmentguide/hivemind/roundedcorners.xml?view=diff&rev=547990&r1=547989&r2=547990
==============================================================================
---
tapestry/tapestry4/trunk/src/site/xdoc/developmentguide/hivemind/roundedcorners.xml
(original)
+++
tapestry/tapestry4/trunk/src/site/xdoc/developmentguide/hivemind/roundedcorners.xml
Sat Jun 16 15:03:55 2007
@@ -245,7 +245,7 @@
display:block;
margin-top:2em;
padding: 0 1.1em 2em;
- background:
url("rounded?bc=white&w=600&h=40&shadow=true&ah=10&aw=10&sw=4&o=.5") left
bottom no-repeat;
+ background:
url("rounded?c=white&bc=white&w=600&h=40&shadow=true&ah=10&aw=10&sw=4&o=.5")
left bottom no-repeat;
}
</style>]]></source>
@@ -270,6 +270,23 @@
<th>Required</th>
<th>Default</th>
<th>Description</th>
+ </tr>
+ <tr>
+ <td>c</td>
+ <td>
+ Hex string <br />
+ or <br />
+ any <a
href="http://www.w3.org/TR/REC-CSS2/syndata.html#color-units">css2</a> color
name.
+ </td>
+ <td>yes</td>
+ <td> </td>
+ <td>
+ Primary color of the generated image. Can be any
standard hex string - such as <code>FF9900</code> or any
+ of the 16 standard css2 colors defined in the <a
href="http://www.w3.org/TR/REC-CSS2/syndata.html#color-units">w3 css2 spec</a>.
+
+ <br /><br />
+ <strong>CSS2 Color names:</strong> aqua, black, blue,
fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal,
white, and yellow
+ </td>
</tr>
<tr>
<td>bc</td>
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=547990&r1=547989&r2=547990
==============================================================================
---
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
Sat Jun 16 15:03:55 2007
@@ -267,10 +267,11 @@
return img.getSubimage(sampleX, sampleY, sampleWidth, sampleHeight);
}
- public BufferedImage buildShadow(String backgroundColor, int width, int
height,
+ public BufferedImage buildShadow(String color, String backgroundColor, int
width, int height,
float arcWidth, float arcHeight,
int shadowWidth, float endOpacity)
{
+ Color fgColor = color == null ? Color.WHITE : decodeColor(color);
Color bgColor = backgroundColor == null ? null :
decodeColor(backgroundColor);
BufferedImage mask = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
@@ -279,6 +280,7 @@
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
RoundRectangle2D.Float fillArea = new RoundRectangle2D.Float(0, 0,
width, height, arcHeight, arcWidth);
+ g2.setColor(fgColor);
g2.fill(fillArea);
g2.dispose();
@@ -304,8 +306,8 @@
g2 = img.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- if (bgColor != null) {
-
+ if (bgColor != null)
+ {
fillArea = new RoundRectangle2D.Float(0, 0, width + (shadowWidth *
2), height + (shadowWidth * 2), arcHeight, arcWidth);
g2.setColor(bgColor);
g2.fill(fillArea.getBounds2D());
@@ -313,16 +315,16 @@
g2.drawImage(clipImg, 0, 0, null);
- if (bgColor != null) {
-
+ if (fgColor != null)
+ {
fillArea = new RoundRectangle2D.Float(0, 0, width, height,
arcHeight, arcWidth);
- g2.setColor(bgColor);
+ g2.setColor(fgColor);
g2.fill(fillArea);
}
g2.dispose();
- return img;
+ return convertType(img, BufferedImage.TYPE_INT_RGB);
}
public BufferedImage buildSideShadow(String side, int size, float opacity)
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=547990&r1=547989&r2=547990
==============================================================================
---
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
Sat Jun 16 15:03:55 2007
@@ -108,22 +108,22 @@
String type = (bgColor != null) ? "gif" : "png";
byte[] data = (byte[])_imageCache.get(hashKey);
- if (data != null) {
-
+ if (data != null)
+ {
writeImageResponse(data, type);
return;
}
BufferedImage image = null;
- if (wholeShadow) {
-
- image = _generator.buildShadow(bgColor, width, height,
arcWidth, arcHeight, shadowWidth, shadowOpacity);
- } else if (side != null) {
-
+ if (wholeShadow)
+ {
+ image = _generator.buildShadow(color, bgColor, width, height,
arcWidth, arcHeight, shadowWidth, shadowOpacity);
+ } else if (side != null)
+ {
image = _generator.buildSideShadow(side, shadowWidth,
shadowOpacity);
- } else {
-
+ } else
+ {
image = _generator.buildCorner(color, bgColor, width, height,
angle, shadowWidth, shadowOpacity);
}
@@ -151,6 +151,9 @@
writeImageResponse(data, type);
+ } catch (IOException eof)
+ {
+ // ignored / expected exceptions happen when browser prematurely
abandons connections - IE does this a lot
} catch (Throwable ex) {
ex.printStackTrace();
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=547990&r1=547989&r2=547990
==============================================================================
---
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
Sat Jun 16 15:03:55 2007
@@ -27,7 +27,7 @@
return new Dimension(200,200);
}
-/*
+
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
@@ -37,7 +37,7 @@
try {
- image = generator.buildShadow("white", 100, 100, 20f, 20f, 6,
0.5f);
+ image = generator.buildShadow("99ccff", "white", 100, 100, 20f,
20f, 6, 0.5f);
}
catch (Exception e) {
e.printStackTrace();
@@ -49,7 +49,7 @@
g2.drawImage(image, 0, 0, null);
}
-*/
+
/*
protected void paintComponent(Graphics g) {
@@ -74,6 +74,7 @@
}
*/
+ /*
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
@@ -93,7 +94,7 @@
g2.drawImage(image, 0, 0, null);
- }
+ }*/
private static void createAndShowGUI() {
//Create and set up the window.
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=547990&r1=547989&r2=547990
==============================================================================
---
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html
(original)
+++
tapestry/tapestry4/trunk/tapestry-examples/TimeTracker/src/context/LocaleList.html
Sat Jun 16 15:03:55 2007
@@ -45,9 +45,8 @@
.detail {
display:block;
- margin-top:2em;
padding: 0 1.1em 2em;
- background:
url("rounded?bc=white&w=600&h=40&shadow=true&ah=10&aw=10&sw=4&o=.5") left
bottom no-repeat;
+ background:
url("rounded?c=99ccff&bc=white&w=600&h=50&shadow=true&ah=10&aw=10&sw=2&o=.5")
left bottom no-repeat;
}
.status {
@@ -74,6 +73,7 @@
<div jwcid="[EMAIL PROTECTED]">
<p class="detail" jwcid="@If" condition="ognl:selected" >
+ <br/>
<strong>Country:</strong>
<span jwcid="@Insert" value="ognl:selected.displayCountry"
mode="ognl:@[EMAIL PROTECTED]" />