Author: dsvyatobatsko
Date: 2008-01-10 13:10:39 -0500 (Thu, 10 Jan 2008)
New Revision: 5276
Added:
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarAnimatedBg.java
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarBg.java
Modified:
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss
Log:
Added:
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarAnimatedBg.java
===================================================================
---
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarAnimatedBg.java
(rev 0)
+++
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarAnimatedBg.java 2008-01-10
18:10:39 UTC (rev 5276)
@@ -0,0 +1,147 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.AnimationResource;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.Zipper2;
+import org.richfaces.skin.SkinFactory;
+
+public class ProgressBarAnimatedBg extends AnimationResource {
+
+ private static int NUMBER_OF_FRAMES = 12;
+ private BufferedImage mainStage;
+ private Dimension frameSize = new Dimension(24, 48);
+
+ private Color progressbarSpiralColor;
+ private Color progressbarBackgroundColor;
+ private Color progressbarShadowStartColor;
+ private Color progressbarShadowEndColor;
+
+ @Override
+ protected Dimension getFrameSize(ResourceContext resourceContext) {
+ return frameSize;
+ }
+
+ /**
+ * @see Java2Dresource#isCacheable(ResourceContext)
+ */
+ public boolean isCacheable(ResourceContext ctx) {
+ return true;
+ }
+
+ @Override
+ protected int getNumberOfFrames() {
+ return NUMBER_OF_FRAMES;
+ }
+
+ @Override
+ protected void paint(ResourceContext context, Graphics2D g2d, int frameIndex) {
+ if (mainStage == null) {
+ mainStage = createMainStage();
+ }
+ BufferedImage frame = mainStage.getSubimage(0, 48 - frameIndex * 4, frameSize.width,
frameSize.height);
+ g2d.drawImage(frame, null, null);
+ // paint a shadow in the form of semi-transparent gradient
+ g2d.setPaint(new GradientPaint(0, 0, progressbarShadowStartColor, 0, 7,
progressbarShadowEndColor));
+ g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
+ g2d.fillRect(0, 0, frameSize.width, 7);
+ }
+
+ /**
+ * Creates a main stage for progress bar background.
+ *
+ * @return a <code>BufferedImage</code> object
+ */
+ private BufferedImage createMainStage() {
+ BufferedImage retVal = new BufferedImage(frameSize.width,
+ frameSize.height * 2, BufferedImage.TYPE_INT_ARGB);
+ Graphics g = retVal.getGraphics();
+ g.setColor(progressbarBackgroundColor);
+ g.fillRect(0, 0, frameSize.width, frameSize.height * 2);
+ g.setColor(progressbarSpiralColor);
+ for (int k : new int[] { -24, 0, 24, 48, 72 }) {
+ g.fillPolygon(new int[] { 0, 24, 24, 0 }, new int[] { 24 + k, k,
+ 12 + k, 36 + k }, 4);
+ }
+ g.dispose();
+
+ return retVal;
+ }
+
+ protected Object getDataToStore(FacesContext context, Object data) {
+ byte[] retVal = null;
+ if (progressbarSpiralColor == null) {
+ progressbarSpiralColor = getColorValueParameter(context,
"progressbarSpiralColor");
+ }
+ if (progressbarBackgroundColor == null) {
+ progressbarBackgroundColor = getColorValueParameter(context,
"progressbarBackgroundColor");
+ }
+ if (progressbarShadowStartColor == null) {
+ progressbarShadowStartColor = getColorValueParameter(context,
"progressbarShadowStartColor");
+ }
+ if (progressbarShadowEndColor == null) {
+ progressbarShadowEndColor = getColorValueParameter(context,
"progressbarShadowEndColor");
+ }
+
+ retVal = new byte[3 * 4];
+ new Zipper2(retVal).addColor(progressbarSpiralColor).addColor(
+ progressbarBackgroundColor).addColor(
+ progressbarShadowStartColor)
+ .addColor(progressbarShadowEndColor);
+
+ return retVal;
+ }
+
+ protected Object deserializeData(byte[] objectArray) {
+ if (objectArray != null) {
+ Zipper2 zipper2 = new Zipper2(objectArray);
+ progressbarSpiralColor = zipper2.nextColor();
+ progressbarBackgroundColor = zipper2.nextColor();
+ progressbarShadowStartColor = zipper2.nextColor();
+ progressbarShadowEndColor = zipper2.nextColor();
+ }
+
+ return objectArray;
+ }
+
+ private Color getColorValueParameter(FacesContext context, String name) {
+ Color retVal = null;
+ String color = (String)
SkinFactory.getInstance().getSkin(context).getParameter(context, name);
+ if (color != null && !color.trim().equals("")) {
+ retVal = HtmlColor.decode(color);
+ }
+ return retVal;
+ }
+
+}
Property changes on:
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarAnimatedBg.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarBg.java
===================================================================
---
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarBg.java
(rev 0)
+++
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarBg.java 2008-01-10
18:10:39 UTC (rev 5276)
@@ -0,0 +1,146 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.renderkit.html.images;
+
+import java.awt.AlphaComposite;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.InternetResourceBuilder;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.PngRenderer;
+import org.ajax4jsf.resource.ResourceContext;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.Zipper2;
+import org.richfaces.skin.SkinFactory;
+
+public class ProgressBarBg extends Java2Dresource {
+
+ private Dimension dim = new Dimension(24, 48);
+
+ private Color progressbarSpiralColor;
+ private Color progressbarBackgroundColor;
+ private Color progressbarShadowStartColor;
+ private Color progressbarShadowEndColor;
+
+ /**
+ * <P>
+ * No args constructor.
+ * </p>
+ */
+ public ProgressBarBg() {
+ setRenderer(new PngRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+ /**
+ * @see Java2Dresource#getDimensions(ResourceContext)
+ */
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return dim;
+ }
+
+ /**
+ * @see Java2Dresource#getDimensions(FacesContext, Object)
+ */
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return dim;
+ }
+
+ /**
+ * @see Java2Dresource#isCacheable(ResourceContext)
+ */
+ public boolean isCacheable(ResourceContext ctx) {
+ return true;
+ }
+
+ /**
+ * <P>
+ * Paints fixed progress bar background.
+ * </p>
+ */
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setColor(progressbarBackgroundColor);
+ g2d.fillRect(0, 0, dim.width, dim.height);
+ g2d.setColor(progressbarSpiralColor);
+ for (int k : new int[] { -24, 0, 24 }) {
+ g2d.fillPolygon(new int[] { 0, 24, 24, 0 }, new int[] { 24 + k,
+ k, 12 + k, 36 + k }, 4);
+ }
+ //paint a shadow in the form of semi-transparent gradient
+ g2d.setPaint(new GradientPaint(0, 0, progressbarShadowStartColor, 0, 7,
progressbarShadowEndColor));
+ g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
+ g2d.fillRect(0, 0, dim.width, 7);
+ }
+
+ protected Object getDataToStore(FacesContext context, Object data) {
+ byte[] retVal = null;
+ if (progressbarSpiralColor == null) {
+ progressbarSpiralColor = getColorValueParameter(context,
"progressbarSpiralColor");
+ }
+ if (progressbarBackgroundColor == null) {
+ progressbarBackgroundColor = getColorValueParameter(context,
"progressbarBackgroundColor");
+ }
+ if (progressbarShadowStartColor == null) {
+ progressbarShadowStartColor = getColorValueParameter(context,
"progressbarShadowStartColor");
+ }
+ if (progressbarShadowEndColor == null) {
+ progressbarShadowEndColor = getColorValueParameter(context,
"progressbarShadowEndColor");
+ }
+
+ retVal = new byte[3 * 4];
+ new Zipper2(retVal).addColor(progressbarSpiralColor).addColor(
+ progressbarBackgroundColor).addColor(
+ progressbarShadowStartColor)
+ .addColor(progressbarShadowEndColor);
+
+ return retVal;
+ }
+
+ protected Object deserializeData(byte[] objectArray) {
+ if (objectArray != null) {
+ Zipper2 zipper2 = new Zipper2(objectArray);
+ progressbarSpiralColor = zipper2.nextColor();
+ progressbarBackgroundColor = zipper2.nextColor();
+ progressbarShadowStartColor = zipper2.nextColor();
+ progressbarShadowEndColor = zipper2.nextColor();
+ }
+
+ return objectArray;
+ }
+
+ private Color getColorValueParameter(FacesContext context, String name) {
+ Color retVal = null;
+ String color = (String)
SkinFactory.getInstance().getSkin(context).getParameter(context, name);
+ if (color != null && !color.trim().equals("")) {
+ retVal = HtmlColor.decode(color);
+ }
+ return retVal;
+ }
+
+}
Property changes on:
trunk/sandbox/ui/progressBAR/src/main/java/org/richfaces/renderkit/html/images/ProgressBarBg.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss
===================================================================
---
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss 2008-01-10
17:50:30 UTC (rev 5275)
+++
trunk/sandbox/ui/progressBAR/src/main/resources/org/richfaces/renderkit/html/css/progressBar.xcss 2008-01-10
18:10:39 UTC (rev 5276)
@@ -19,15 +19,14 @@
<u:selector name=".rich-progress-bar-completed">
<u:style name="background-image">
- <f:resource
f:key="/org/richfaces/renderkit/html/images/bg_ProgressBar.png" />
+ <f:resource
f:key="org.richfaces.renderkit.html.images.ProgressBarBg" />
</u:style>
</u:selector>
-
+
<u:selector name=".rich-progress-bar-permanent">
<u:style name="background-image">
- <f:resource
f:key="/org/richfaces/renderkit/html/images/bg_ProgressBar_perm.gif" />
+ <f:resource
f:key="org.richfaces.renderkit.html.images.ProgressBarAnimatedBg" />
</u:style>
</u:selector>
-
-
+
</f:template>
\ No newline at end of file