Author: nbelaevski
Date: 2008-04-21 11:55:42 -0400 (Mon, 21 Apr 2008)
New Revision: 8020
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java
Log:
BaseControlBackroundImage updated
Modified:
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java
===================================================================
---
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2008-04-21
15:32:14 UTC (rev 8019)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/BaseGradient.java 2008-04-21
15:55:42 UTC (rev 8020)
@@ -160,33 +160,38 @@
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
Data dataToStore = (Data) restoreData(resourceContext);
- if (dataToStore != null && dataToStore.headerBackgroundColor!=null
&& dataToStore.headerGradientColor!=null) {
- Color baseColor = new Color(dataToStore.headerBackgroundColor.intValue());
- Color alternateColor = new Color(dataToStore.headerGradientColor.intValue());
- BiColor biColor = new GradientType.BiColor(baseColor, alternateColor);
-
- GradientType type = dataToStore.gradientType;
- BiColor firstLayer = type.getFirstLayerColors(biColor);
- BiColor secondLayer = type.getSecondLayerColors(biColor);
-
- Dimension dim = getDimensions(resourceContext);
- Rectangle2D rect =
- new Rectangle2D.Float(
- 0,
- 0,
- dim.width,
- dim.height);
+ if (dataToStore != null) {
+ Integer headerBackgroundColor = dataToStore.getHeaderBackgroundColor();
+ Integer headerGradientColor = dataToStore.getHeaderGradientColor();
- drawGradient(g2d, rect, firstLayer, gradientHeight, horizontal);
- drawGradient(g2d, rect, secondLayer, gradientHeight / 2, horizontal);
+ if (headerBackgroundColor != null && headerGradientColor != null) {
+ Color baseColor = new Color(headerBackgroundColor.intValue());
+ Color alternateColor = new Color(headerGradientColor.intValue());
+ BiColor biColor = new GradientType.BiColor(baseColor, alternateColor);
+
+ GradientType type = dataToStore.getGradientType();
+ BiColor firstLayer = type.getFirstLayerColors(biColor);
+ BiColor secondLayer = type.getSecondLayerColors(biColor);
+
+ Dimension dim = getDimensions(resourceContext);
+ Rectangle2D rect =
+ new Rectangle2D.Float(
+ 0,
+ 0,
+ dim.width,
+ dim.height);
+
+ drawGradient(g2d, rect, firstLayer, gradientHeight, horizontal);
+ drawGradient(g2d, rect, secondLayer, gradientHeight / 2, horizontal);
+ }
}
}
protected void restoreData(Data data, Zipper2 zipper2) {
if (zipper2.hasMore()) {
- data.headerBackgroundColor = new Integer(zipper2.nextIntColor());
- data.headerGradientColor = new Integer(zipper2.nextIntColor());
- data.gradientType = GradientType.values()[zipper2.nextByte()];
+ data.setHeaderBackgroundColor(Integer.valueOf(zipper2.nextIntColor()));
+ data.setHeaderGradientColor(Integer.valueOf(zipper2.nextIntColor()));
+ data.setGradientType(GradientType.values()[zipper2.nextByte()]);
}
}
@@ -205,20 +210,22 @@
}
private void saveData(FacesContext context, Data data, String baseColor, String
gradientColor) {
- data.headerBackgroundColor = getColorValueParameter(context, baseColor, false);
- data.headerGradientColor = getColorValueParameter(context, gradientColor, false);
+ Integer headerBackgroundColor = getColorValueParameter(context, baseColor, false);
+ Integer headerGradientColor = getColorValueParameter(context, gradientColor,
false);
- if (!(data.headerBackgroundColor == null && data.headerGradientColor ==
null)) {
- if (data.headerBackgroundColor == null) {
- data.headerBackgroundColor = getColorValueParameter(context, baseColor, true);
+ if (!(headerBackgroundColor == null && headerGradientColor == null)) {
+ if (headerBackgroundColor == null) {
+ headerBackgroundColor = getColorValueParameter(context, baseColor, true);
}
- if (data.headerGradientColor == null) {
- data.headerGradientColor = getColorValueParameter(context, gradientColor, true);
+ if (headerGradientColor == null) {
+ headerGradientColor = getColorValueParameter(context, gradientColor, true);
}
}
- data.gradientType = GradientType.getBySkinParameter(getValueParameter(context,
Skin.gradientType));
+ data.setHeaderBackgroundColor(headerBackgroundColor);
+ data.setHeaderGradientColor(headerGradientColor);
+ data.setGradientType(GradientType.getBySkinParameter(getValueParameter(context,
Skin.gradientType)));
}
protected void saveData(FacesContext context, Data data) {
@@ -279,9 +286,9 @@
*
*/
private static final long serialVersionUID = 1732700513743861250L;
- protected Integer headerBackgroundColor;
- protected Integer headerGradientColor;
- protected GradientType gradientType;
+ private Integer headerBackgroundColor;
+ private Integer headerGradientColor;
+ private GradientType gradientType;
public byte[] toByteArray() {
if (headerBackgroundColor != null && headerGradientColor != null &&
gradientType != null) {
@@ -293,6 +300,31 @@
return null;
}
}
+
+ public Integer getHeaderBackgroundColor() {
+ return headerBackgroundColor;
+ }
+
+ public void setHeaderBackgroundColor(Integer headerBackgroundColor) {
+ this.headerBackgroundColor = headerBackgroundColor;
+ }
+
+ public Integer getHeaderGradientColor() {
+ return headerGradientColor;
+ }
+
+ public void setHeaderGradientColor(Integer headerGradientColor) {
+ this.headerGradientColor = headerGradientColor;
+ }
+
+ public GradientType getGradientType() {
+ return gradientType;
+ }
+
+ public void setGradientType(GradientType gradientType) {
+ this.gradientType = gradientType;
+ }
+
}
}
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-04-21
15:32:14 UTC (rev 8019)
+++
trunk/framework/impl/src/main/java/org/richfaces/renderkit/html/images/BaseControlBackgroundImage.java 2008-04-21
15:55:42 UTC (rev 8020)
@@ -49,7 +49,7 @@
public Dimension getDimensions(FacesContext facesContext, Object data) {
Data data2 = (Data) data;
if (data != null) {
- return new Dimension(super.getDimensions(facesContext, data).width,
data2.height);
+ return new Dimension(super.getDimensions(facesContext, data).width,
data2.getHeight());
} else {
return DIMENSION;
}
@@ -89,12 +89,12 @@
@Override
protected void saveData(FacesContext context,
org.richfaces.renderkit.html.BaseGradient.Data data) {
super.saveData(context, data);
- ((Data) data).height = getHeight(context);
+ ((Data) data).setHeight(getHeight(context));
}
protected void restoreData(org.richfaces.renderkit.html.BaseGradient.Data data,
Zipper2 zipper2) {
if (zipper2.hasMore()) {
- ((Data) data).height = zipper2.nextInt();
+ ((Data) data).setHeight(zipper2.nextInt());
super.restoreData(data, zipper2);
}
}
@@ -106,7 +106,7 @@
*/
private static final long serialVersionUID = -1499766195614003931L;
- protected Integer height;
+ private Integer height;
@Override
public byte[] toByteArray() {
@@ -116,5 +116,22 @@
return result;
}
+
+ public Integer getHeight() {
+ return height;
+ }
+
+ public void setHeight(Integer height) {
+ this.height = height;
+ }
+
+ public GradientType getGradientType() {
+ return GradientType.PLAIN;
+ }
+
+ public void setGradientType(GradientType gradientType) {
+ //does nothing
+ }
+
};
}