Author: abelevich
Date: 2008-01-30 14:54:20 -0500 (Wed, 30 Jan 2008)
New Revision: 5741
Added:
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/images/ComboBoxListShadow.java
Modified:
trunk/sandbox/ui/combobox/src/main/config/resources/resource-config.xml
Log:
add shadow picture generate class
Modified: trunk/sandbox/ui/combobox/src/main/config/resources/resource-config.xml
===================================================================
--- trunk/sandbox/ui/combobox/src/main/config/resources/resource-config.xml 2008-01-30
19:53:23 UTC (rev 5740)
+++ trunk/sandbox/ui/combobox/src/main/config/resources/resource-config.xml 2008-01-30
19:54:20 UTC (rev 5741)
@@ -15,6 +15,9 @@
<resource
class="org.richfaces.renderkit.images.ComboBoxArrowImageDisable">
<name>org.richfaces.renderkit.images.ComboBoxArrowImageDisable</name>
</resource>
+ <resource class="org.richfaces.renderkit.images.ComboBoxListShadow">
+ <name>org.richfaces.renderkit.images.ComboBoxListShadow</name>
+ </resource>
</resource-config>
Added:
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/images/ComboBoxListShadow.java
===================================================================
---
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/images/ComboBoxListShadow.java
(rev 0)
+++
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/images/ComboBoxListShadow.java 2008-01-30
19:54:20 UTC (rev 5741)
@@ -0,0 +1,79 @@
+/**
+ *
+ */
+package org.richfaces.renderkit.images;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ConvolveOp;
+import java.awt.image.Kernel;
+import java.awt.image.RenderedImage;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.GifRenderer;
+import org.ajax4jsf.resource.ImageRenderer;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.PngRenderer;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.Zipper2;
+
+/**
+ * @author Anton Belevich
+ *
+ */
+public class ComboBoxListShadow extends Java2Dresource {
+
+ static final Dimension dimensions = new Dimension(1010, 1010);
+
+ public ComboBoxListShadow() {
+ setRenderer(new PngRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return dimensions;
+ }
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return dimensions;
+ }
+
+ protected RenderedImage getImage(ResourceContext context) {
+
+ ImageRenderer renderer = (ImageRenderer)getRenderer(null);
+ Dimension imageDimensions = getDimensions(context);
+
+ BufferedImage image = null;
+ if (imageDimensions.getHeight() > 0.0 && imageDimensions.getWidth() >
0.0) {
+
+ int cornerSize = 15;
+ int rectWidth = imageDimensions.width;
+ float shadowOpacity = 0.02f;
+
+ image = renderer.createImage(rectWidth,rectWidth);
+ Graphics2D g2d = image.createGraphics();
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_STROKE_NORMALIZE);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING,
RenderingHints.VALUE_DITHER_ENABLE);
+ g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
+ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
+ for (int i = 0; i < 10; i++) {
+ g2d.setColor(new Color(0.0f, 0.0f, 0.0f, shadowOpacity));
+ shadowOpacity = shadowOpacity * 1.4f;
+ g2d.fillRoundRect(i, i, rectWidth-2*i, rectWidth-2*i, cornerSize, cornerSize);
+ }
+ g2d.dispose();
+ }
+
+ return image;
+ }
+}
Show replies by date