Author: dsvyatobatsko
Date: 2008-03-05 07:40:21 -0500 (Wed, 05 Mar 2008)
New Revision: 6557
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
Log:
just formatted
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-05
12:20:31 UTC (rev 6556)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2008-03-05
12:40:21 UTC (rev 6557)
@@ -42,172 +42,170 @@
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
-import com.opensymphony.oscache.util.StringUtil;
-
/**
* Created 23.02.2008
+ *
* @author Nick Belaevski
* @since 3.2
*/
public class BaseControlBackgroundImage extends Java2Dresource {
- private static final Dimension DIMENSION = new Dimension(1, 1);
-
- private String baseColor;
- private String gradientColor;
- private int width;
-
- public BaseControlBackgroundImage(String baseColor, String gradientColor, int width) {
- super();
-
- this.baseColor = baseColor;
- this.gradientColor = gradientColor;
- this.width = width;
+ private static final Dimension DIMENSION = new Dimension(1, 1);
- setRenderer(new GifRenderer());
- setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
- }
+ private String baseColor;
- public Dimension getDimensions(FacesContext facesContext, Object data) {
- Data d = (Data) data;
- if (d != null) {
- return new Dimension(width, d.height.intValue());
- } else {
- return DIMENSION;
- }
- }
+ private String gradientColor;
- protected Dimension getDimensions(ResourceContext resourceContext) {
- return getDimensions(null, restoreData(resourceContext));
- }
+ private int width;
- protected void paint(ResourceContext resourceContext, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_DITHERING,
RenderingHints.VALUE_DITHER_ENABLE);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
- Data dataToStore = (Data) restoreData(resourceContext);
- if (dataToStore != null && dataToStore.headerBackgroundColor!=null &&
dataToStore.headerGradientColor!=null) {
- Color baseColor = new Color(dataToStore.headerBackgroundColor.intValue());
- Dimension dim = getDimensions(resourceContext);
- Rectangle2D rect =
- new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- dim.height);
- Color alternateColor = new Color(dataToStore.headerGradientColor.intValue());
+ public BaseControlBackgroundImage(String baseColor, String gradientColor, int width)
{
+ super();
+
+ this.baseColor = baseColor;
+ this.gradientColor = gradientColor;
+ this.width = width;
+
+ setRenderer(new GifRenderer());
+ setLastModified(new Date(InternetResourceBuilder.getInstance().getStartTime()));
+ }
+
+ public Dimension getDimensions(FacesContext facesContext, Object data) {
+ Data d = (Data) data;
+ if (d != null) {
+ return new Dimension(width, d.height.intValue());
+ } else {
+ return DIMENSION;
+ }
+ }
+
+ protected Dimension getDimensions(ResourceContext resourceContext) {
+ return getDimensions(null, restoreData(resourceContext));
+ }
+
+ protected void paint(ResourceContext resourceContext, Graphics2D g2d) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ g2d.setRenderingHint(RenderingHints.KEY_DITHERING,
RenderingHints.VALUE_DITHER_ENABLE);
+ g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
+ Data dataToStore = (Data) restoreData(resourceContext);
+ if (dataToStore != null && dataToStore.headerBackgroundColor != null
&& dataToStore.headerGradientColor != null) {
+ Color baseColor = new Color(dataToStore.headerBackgroundColor.intValue());
+ Dimension dim = getDimensions(resourceContext);
+ Rectangle2D rect = new Rectangle2D.Float(0, 0, dim.width, dim.height);
+ Color alternateColor = new
Color(dataToStore.headerGradientColor.intValue());
GradientPaint gragient = new GradientPaint(0, 0, baseColor, 0, dim.height,
alternateColor);
- g2d.setPaint(gragient);
- g2d.fill(rect);
- }
- }
+ g2d.setPaint(gragient);
+ g2d.fill(rect);
+ }
+ }
- protected final Integer getHeight(FacesContext context, String heightParamName) {
- SkinFactory skinFactory = SkinFactory.getInstance();
- Skin skin = skinFactory.getSkin(context);
+ 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);
- }
+ 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);
- }
+ 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 Integer getHeight(FacesContext context) {
+ return getHeight(context, Skin.generalSizeFont);
+ }
- protected Object deserializeData(byte[] objectArray) {
- Data data = new Data();
- if (objectArray != null) {
- Zipper2 zipper2 = new Zipper2(objectArray);
- data.headerBackgroundColor = new Integer(zipper2.nextIntColor());
- data.headerGradientColor = new Integer(zipper2.nextIntColor());
- data.height = new Integer(zipper2.nextInt());
- }
+ protected Object deserializeData(byte[] objectArray) {
+ Data data = new Data();
+ if (objectArray != null) {
+ Zipper2 zipper2 = new Zipper2(objectArray);
+ data.headerBackgroundColor = new Integer(zipper2.nextIntColor());
+ data.headerGradientColor = new Integer(zipper2.nextIntColor());
+ data.height = new Integer(zipper2.nextInt());
+ }
- return data;
- }
+ return data;
+ }
- protected Object getDataToStore(FacesContext context, Object data) {
- Integer h = getHeight(context);
- if (baseColor == null) {
- return new Data(context, h).toByteArray();
- } else {
- return new Data(context, baseColor, gradientColor, h).toByteArray();
- }
- }
+ protected Object getDataToStore(FacesContext context, Object data) {
+ Integer h = getHeight(context);
+ if (baseColor == null) {
+ return new Data(context, h).toByteArray();
+ } else {
+ return new Data(context, baseColor, gradientColor, h).toByteArray();
+ }
+ }
- public boolean isCacheable() {
- return true;
- }
-
- protected static class Data implements Serializable {
- public Data() {
- }
+ public boolean isCacheable() {
+ return true;
+ }
- protected Data(FacesContext context, Integer height) {
- this(context, Skin.headerBackgroundColor, "headerGradientColor", height);
- }
+ protected static class Data implements Serializable {
+ public Data() {
+ }
- protected Data(FacesContext context, String baseColor, String gradientColor, Integer
height) {
- this.headerBackgroundColor = getColorValueParameter(context, baseColor, false);
- this.headerGradientColor = getColorValueParameter(context, gradientColor, false);
- this.height = height;
-
- if (!(this.headerBackgroundColor == null && this.headerGradientColor == null))
{
- if (this.headerBackgroundColor == null) {
- this.headerBackgroundColor = getColorValueParameter(context, baseColor, true);
- }
-
- if (this.headerGradientColor == null) {
- this.headerGradientColor = getColorValueParameter(context, gradientColor, true);
- }
- }
- }
+ protected Data(FacesContext context, Integer height) {
+ this(context, Skin.headerBackgroundColor, "headerGradientColor",
height);
+ }
- private Integer getColorValueParameter(FacesContext context, String name, boolean
useDefault) {
- Skin skin;
- if (useDefault) {
- skin = SkinFactory.getInstance().getDefaultSkin(context);
- } else {
- skin = SkinFactory.getInstance().getSkin(context);
- }
-
- String tmp = (String) skin.getParameter(context,name);
- if (tmp!=null && tmp.length() != 0) {
- return new Integer(HtmlColor.decode(tmp).getRGB());
- } else {
- return null;
- }
- }
+ protected Data(FacesContext context, String baseColor, String gradientColor,
Integer height) {
+ this.headerBackgroundColor = getColorValueParameter(context, baseColor,
false);
+ this.headerGradientColor = getColorValueParameter(context, gradientColor,
false);
+ this.height = height;
- /**
- *
- */
- private static final long serialVersionUID = 1732700513743861250L;
- protected Integer headerBackgroundColor;
- protected Integer headerGradientColor;
- protected Integer height;
- public byte[] toByteArray() {
- if (headerBackgroundColor != null && headerGradientColor != null) {
- byte[] ret = new byte[10];
- new Zipper2(ret).
- addColor(headerBackgroundColor.intValue()).
- addColor(headerGradientColor.intValue()).
- addInt(height);
- return ret;
- } else {
- return null;
- }
- }
- }
+ if (!(this.headerBackgroundColor == null && this.headerGradientColor
== null)) {
+ if (this.headerBackgroundColor == null) {
+ this.headerBackgroundColor = getColorValueParameter(context,
baseColor, true);
+ }
+ if (this.headerGradientColor == null) {
+ this.headerGradientColor = getColorValueParameter(context,
gradientColor, true);
+ }
+ }
+ }
+
+ private Integer getColorValueParameter(FacesContext context, String name, boolean
useDefault) {
+ Skin skin;
+ if (useDefault) {
+ skin = SkinFactory.getInstance().getDefaultSkin(context);
+ } else {
+ skin = SkinFactory.getInstance().getSkin(context);
+ }
+
+ String tmp = (String) skin.getParameter(context, name);
+ if (tmp != null && tmp.length() != 0) {
+ return new Integer(HtmlColor.decode(tmp).getRGB());
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1732700513743861250L;
+
+ protected Integer headerBackgroundColor;
+
+ protected Integer headerGradientColor;
+
+ protected Integer height;
+
+ public byte[] toByteArray() {
+ if (headerBackgroundColor != null && headerGradientColor != null) {
+ byte[] ret = new byte[10];
+ new
Zipper2(ret).addColor(headerBackgroundColor.intValue()).addColor(headerGradientColor.intValue())
+ .addInt(height);
+ return ret;
+ } else {
+ return null;
+ }
+ }
+ }
+
}