Author: nbelaevski
Date: 2010-08-20 10:03:25 -0400 (Fri, 20 Aug 2010)
New Revision: 18846
Removed:
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java
Modified:
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
Log:
https://jira.jboss.org/browse/RF-8936
Deleted:
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java
===================================================================
---
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java 2010-08-20
14:02:27 UTC (rev 18845)
+++
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java 2010-08-20
14:03:25 UTC (rev 18846)
@@ -1,126 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.awt.GradientPaint;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.util.HtmlColor;
-import org.richfaces.resource.DynamicResource;
-import org.richfaces.resource.ImageType;
-
-/**
- * implementation of the default CANCEL icon renderer
- *
- * @author Anton Belevich
- * @since 3.2.0
- */
-@DynamicResource
-public class CancelControlIcon extends Java2Dresource {
-
- protected static final String ALTERNATE_COLOR = "#ED6161";
-
- private static final Dimension DIMENSIONS = new Dimension(11, 11);
-
- protected Integer iconColor;
- protected Integer iconBorderColor;
-
- public CancelControlIcon() {
- super(ImageType.GIF);
- }
-
- @Override
- public Dimension getDimension() {
- return DIMENSIONS;
- }
-
- @Override
- public void readState(FacesContext context, DataInput stream) throws IOException {
- super.readState(context, stream);
-
- this.iconColor = stream.readInt();
- this.iconBorderColor = stream.readInt();
- }
-
- public void writeState(FacesContext context, DataOutput stream) throws IOException {
- super.writeState(context, stream);
-
- stream.writeInt(this.iconColor);
- stream.writeInt(this.iconBorderColor);
- }
-
- @Override
- protected void paint(Graphics2D g2d, Dimension dimension) {
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
-// g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-// g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
RenderingHints.VALUE_STROKE_DEFAULT);
- g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
RenderingHints.VALUE_COLOR_RENDER_DEFAULT);
- 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_BILINEAR);
- g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_DEFAULT);
- Color iconColour = new Color(iconColor);
- Color iconBorder = new Color(iconBorderColor);
- g2d.setColor(iconColour);
-
- Color altenateColor = HtmlColor.decode(ALTERNATE_COLOR);
- GradientPaint gradient = new GradientPaint(2, 3, altenateColor, 3, 9,
iconColour);
- g2d.setPaint(gradient);
-
- // draw cross
- g2d.drawLine(2, 3, 7, 8);
- g2d.drawLine(3, 3, 7, 7);
- g2d.drawLine(3, 2, 8, 7);
-
- g2d.drawLine(2, 7, 7, 2);
- g2d.drawLine(3, 7, 7, 3);
- g2d.drawLine(3, 8, 8, 3);
-
- //draw border
- g2d.setColor(iconBorder);
- g2d.drawLine(1, 3, 3, 5);
- g2d.drawLine(3, 5, 1, 7);
- g2d.drawLine(1, 7, 3, 9);
- g2d.drawLine(3, 9, 5, 7);
- g2d.drawLine(5, 7, 7, 9);
- g2d.drawLine(7, 9, 9, 7);
- g2d.drawLine(9, 7, 7, 5);
- g2d.drawLine(7, 5, 9, 3);
- g2d.drawLine(9, 3, 7, 1);
- g2d.drawLine(7, 1, 5, 3);
- g2d.drawLine(5, 3, 3, 1);
- g2d.drawLine(3, 1, 1, 3);
-
-
- }
-}
-
Modified:
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java
===================================================================
---
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java 2010-08-20
14:02:27 UTC (rev 18845)
+++
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/InputErrorIcon.java 2010-08-20
14:03:25 UTC (rev 18846)
@@ -20,30 +20,27 @@
*/
package org.richfaces.renderkit.html.images;
-import org.ajax4jsf.resource.ResourceContext;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
-import java.awt.*;
-
public class InputErrorIcon extends OneColorBasedResource {
+ private static final Dimension DIMENSION = new Dimension(6, 11);
+
public InputErrorIcon() {
- super(6, 11, "warningColor");
+ super("warningColor");
}
- /**
- * @see org.ajax4jsf.resource.Java2Dresource#paint(ResourceContext, Graphics2D)
- */
- protected void paint(ResourceContext context, Graphics2D g2d) {
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
+ @Override
+ public Dimension getDimension() {
+ return DIMENSION;
+ }
+
+ @Override
+ public void paint(Graphics2D g2d, Dimension dimension) {
g2d.setColor(getBasicColor());
g2d.fillRect(3, 2, 2, 6);
g2d.fillRect(3, 9, 2, 2);
}
- @Override
- public Dimension getDimension() {
- // TODO Auto-generated method stub
- return null;
- }
-
}
Modified:
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java
===================================================================
---
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2010-08-20
14:02:27 UTC (rev 18845)
+++
trunk/core/impl/src/main/java/org/richfaces/renderkit/html/images/OneColorBasedResource.java 2010-08-20
14:03:25 UTC (rev 18846)
@@ -23,40 +23,84 @@
import java.awt.Color;
import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Date;
+import java.util.Map;
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.resource.CacheableResource;
import org.richfaces.resource.DynamicResource;
import org.richfaces.resource.ImageType;
+import org.richfaces.resource.Java2DUserResource;
+import org.richfaces.resource.StateHolderResource;
+import org.richfaces.skin.Skin;
+import org.richfaces.skin.SkinFactory;
@DynamicResource
-public abstract class OneColorBasedResource extends Java2Dresource {
+public abstract class OneColorBasedResource implements Java2DUserResource,
CacheableResource, StateHolderResource {
- private Dimension dimension;
-
private String basicColorParamName;
private Color basicColor;
- public OneColorBasedResource(int width, int height, final String basicColorParamName)
{
- super(ImageType.GIF);
+ public OneColorBasedResource(final String basicColorParamName) {
this.basicColorParamName = basicColorParamName;
- this.dimension = new Dimension(width, height);
-
}
/**
- * @see Java2Dresource#isCacheable(ResourceContext)
- */
- public boolean isCacheable(ResourceContext ctx) {
- return true;
- }
-
- /**
* Gets value of basicColor field.
* @return value of basicColor field
*/
- public Color getBasicColor() {
+ protected Color getBasicColor() {
return basicColor;
}
+
+ public boolean isTransient() {
+ return false;
+ }
+
+ public void writeState(FacesContext context, DataOutput dataOutput) throws
IOException {
+ Skin skin = SkinFactory.getInstance(context).getSkin(context);
+ dataOutput.writeInt(skin.getColorParameter(context, basicColorParamName));
+ }
+
+ public void readState(FacesContext context, DataInput dataInput) throws IOException
{
+ basicColor = new Color(dataInput.readInt());
+ }
+
+ public boolean isCacheable(FacesContext context) {
+ return true;
+ }
+
+ public Date getExpires(FacesContext context) {
+ return null;
+ }
+
+ public int getTimeToLive(FacesContext context) {
+ return 0;
+ }
+
+ public String getEntityTag(FacesContext context) {
+ return null;
+ }
+
+ public Map<String, String> getResponseHeaders() {
+ return null;
+ }
+
+ public Date getLastModified() {
+ return null;
+ }
+
+ public ImageType getImageType() {
+ return ImageType.GIF;
+ }
+
+ public abstract Dimension getDimension();
+
+ public abstract void paint(Graphics2D graphics2d, Dimension dimension);
}