Author: dsvyatobatsko
Date: 2008-03-04 14:15:18 -0500 (Tue, 04 Mar 2008)
New Revision: 6549
Added:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
Log:
Std. Components Skinning
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2008-03-04
19:10:36 UTC (rev 6548)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2008-03-04
19:15:18 UTC (rev 6549)
@@ -42,6 +42,8 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
+import com.opensymphony.oscache.util.StringUtil;
+
/**
* Created 23.02.2008
* @author Nick Belaevski
@@ -101,6 +103,27 @@
}
}
+ protected final Integer getHeight(FacesContext context, String heightParamName) {
+ SkinFactory skinFactory = SkinFactory.getInstance();
+ Skin skin = skinFactory.getSkin(context);
+
+ String height = (String) skin.getParameter(context, heightParamName);
+ if (height == null || height.length() == 0) {
+ skin = skinFactory.getDefaultSkin(context);
+ height = (String) skin.getParameter(context, heightParamName);
+ }
+
+ if (height != null && height.length() != 0) {
+ return Integer.valueOf(HtmlDimensions.decode(height).intValue());
+ } else {
+ return Integer.valueOf(16);
+ }
+ }
+
+ protected Integer getHeight(FacesContext context) {
+ return getHeight(context, Skin.generalSizeFont);
+ }
+
protected Object deserializeData(byte[] objectArray) {
Data data = new Data();
if (objectArray != null) {
@@ -112,15 +135,16 @@
return data;
}
-
+
protected Object getDataToStore(FacesContext context, Object data) {
- if (baseColor == null) {
- return new Data(context).toByteArray();
+ Integer h = getHeight(context);
+ if (baseColor == null) {
+ return new Data(context, h).toByteArray();
} else {
- return new Data(context, baseColor, gradientColor).toByteArray();
+ return new Data(context, baseColor, gradientColor, h).toByteArray();
}
}
-
+
public boolean isCacheable() {
return true;
}
@@ -129,14 +153,14 @@
public Data() {
}
- protected Data(FacesContext context) {
- this(context, Skin.headerBackgroundColor, "headerGradientColor");
+ protected Data(FacesContext context, Integer height) {
+ this(context, Skin.headerBackgroundColor, "headerGradientColor", height);
}
- protected Data(FacesContext context, String baseColor, String gradientColor) {
+ protected Data(FacesContext context, String baseColor, String gradientColor, Integer
height) {
this.headerBackgroundColor = getColorValueParameter(context, baseColor, false);
this.headerGradientColor = getColorValueParameter(context, gradientColor, false);
- this.height = getHeight(context);
+ this.height = height;
if (!(this.headerBackgroundColor == null && this.headerGradientColor == null))
{
if (this.headerBackgroundColor == null) {
@@ -149,23 +173,6 @@
}
}
- private Integer getHeight(FacesContext context) {
- SkinFactory skinFactory = SkinFactory.getInstance();
- Skin skin = skinFactory.getSkin(context);
-
- String height = (String) skin.getParameter(context, Skin.generalSizeFont);
- if (height == null || height.length() == 0) {
- skin = skinFactory.getDefaultSkin(context);
- height = (String) skin.getParameter(context, Skin.generalSizeFont);
- }
-
- if (height != null && height.length() != 0) {
- return Integer.valueOf(HtmlDimensions.decode(height).intValue());
- } else {
- return Integer.valueOf(16);
- }
- }
-
private Integer getColorValueParameter(FacesContext context, String name, boolean
useDefault) {
Skin skin;
if (useDefault) {
Added:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java 2008-03-04
19:15:18 UTC (rev 6549)
@@ -0,0 +1,45 @@
+/**
+ * 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.Graphics2D;
+import java.awt.RenderingHints;
+
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.resource.ResourceContext;
+
+public class InputErrorIcon extends OneColorBasedResource {
+
+ public InputErrorIcon() {
+ super(6, 11, "warningColor");
+ }
+
+ /**
+ * @see Java2Dresource#paint(ResourceContext, Graphics2D)
+ */
+ protected void paint(ResourceContext context, Graphics2D g2d) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setColor(getBasicColor());
+ g2d.fillRect(3, 2, 2, 6);
+ g2d.fillRect(3, 9, 2, 2);
+ }
+
+}
Property changes on:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2008-03-04
19:15:18 UTC (rev 6549)
@@ -0,0 +1,117 @@
+/**
+ * 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.Color;
+import java.awt.Dimension;
+import java.util.Date;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.resource.GifRenderer;
+import org.ajax4jsf.resource.InternetResourceBuilder;
+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 OneColorBasedResource extends Java2Dresource {
+
+ private Dimension dimension;
+
+ private String basicColorParamName;
+
+ private Color basicColor;
+
+ public OneColorBasedResource(int width, int height, final String basicColorParamName)
{
+ this.basicColorParamName = basicColorParamName;
+ this.dimension = new Dimension(width, height);
+ setRenderer(new GifRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+ /**
+ * @see Java2Dresource#getDimensions(ResourceContext)
+ */
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return dimension;
+ }
+
+ /**
+ * @see Java2Dresource#getDimensions(FacesContext, Object)
+ */
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ return dimension;
+ }
+
+ /**
+ * @see Java2Dresource#isCacheable(ResourceContext)
+ */
+ public boolean isCacheable(ResourceContext ctx) {
+ return true;
+ }
+
+ /**
+ * Gets value of basicColor field.
+ * @return value of basicColor field
+ */
+ public Color getBasicColor() {
+ return basicColor;
+ }
+
+ /**
+ * @see InternetResourceBase#getDataToStore(FacesContext, Object)
+ */
+ protected Object getDataToStore(FacesContext context, Object data) {
+ byte[] retVal = null;
+ if (basicColor == null) {
+ basicColor = getColorValueParameter(context, basicColorParamName);
+ }
+
+ retVal = new byte[3 * 1];
+ new Zipper2(retVal).addColor(basicColor);
+
+ return retVal;
+ }
+
+ /**
+ * @see InternetResourceBase#deserializeData(byte[])
+ */
+ protected Object deserializeData(byte[] objectArray) {
+ if (objectArray != null) {
+ Zipper2 zipper2 = new Zipper2(objectArray);
+ basicColor = 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/framework/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java 2008-03-04
19:15:18 UTC (rev 6549)
@@ -0,0 +1,38 @@
+/**
+ * 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 javax.faces.context.FacesContext;
+
+import org.richfaces.skin.Skin;
+
+public class StandardButtonBgImage extends BaseControlBackgroundImage {
+
+ public StandardButtonBgImage() {
+ super(Skin.additionalBackgroundColor, "trimColor", 9);
+ }
+
+ protected Integer getHeight(FacesContext context) {
+ return (int) (1.7 * super.getHeight(context, Skin.buttonSizeFont));
+ }
+
+}
Property changes on:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonBgImage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java
(rev 0)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java 2008-03-04
19:15:18 UTC (rev 6549)
@@ -0,0 +1,38 @@
+/**
+ * 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 javax.faces.context.FacesContext;
+
+import org.richfaces.skin.Skin;
+
+public class StandardButtonPressedBgImage extends BaseControlBackgroundImage {
+
+ public StandardButtonPressedBgImage() {
+ super("trimColor", Skin.additionalBackgroundColor, 9);
+ }
+
+ protected Integer getHeight(FacesContext context) {
+ return (int) (1.7 * super.getHeight(context, Skin.buttonSizeFont));
+ }
+
+}
Property changes on:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/StandardButtonPressedBgImage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native