You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gr...@apache.org on 2008/03/25 19:07:35 UTC
svn commit: r640919 - in
/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha:
CAPTCHAComponent.java CAPTCHARenderer.java util/CAPTCHAImageGenerator.java
Author: grantsmith
Date: Tue Mar 25 11:07:33 2008
New Revision: 640919
URL: http://svn.apache.org/viewvc?rev=640919&view=rev
Log:
o CAPTCHA code cleanup of redundant initializers and casts.
Modified:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHAComponent.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHARenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/util/CAPTCHAImageGenerator.java
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHAComponent.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHAComponent.java?rev=640919&r1=640918&r2=640919&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHAComponent.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHAComponent.java Tue Mar 25 11:07:33 2008
@@ -49,7 +49,7 @@
Object values[] = new Object[2];
values[0] = super.saveState(context);
values[1] = _captchaSessionKeyName;
- return ((Object) (values));
+ return ((values));
}
public void restoreState(FacesContext context, Object state) {
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHARenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHARenderer.java?rev=640919&r1=640918&r2=640919&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHARenderer.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/CAPTCHARenderer.java Tue Mar 25 11:07:33 2008
@@ -67,14 +67,13 @@
private void generateImageTag(FacesContext context, CAPTCHAComponent component)
throws IOException {
- AddResource addResource = null;
- String url = null;
- CAPTCHAComponent captchaComponent = (CAPTCHAComponent) component;
- ResponseWriter writer = context.getResponseWriter();
+ AddResource addResource;
+ String url;
+ ResponseWriter writer = context.getResponseWriter();
Map params = ComponentUtils.getParameterMap(component);
- String captchaSessionKeyName = captchaComponent.getCaptchaSessionKeyName();
+ String captchaSessionKeyName = component.getCaptchaSessionKeyName();
- writer.startElement(HTML.IMG_ELEM, captchaComponent);
+ writer.startElement(HTML.IMG_ELEM, component);
if (captchaSessionKeyName != null) {
params.put(CAPTCHAComponent.ATTRIBUTE_CAPTCHASESSIONKEYNAME,
@@ -140,7 +139,7 @@
.getRequestParameterMap();
HttpServletRequest request = (HttpServletRequest) facesContext
.getExternalContext().getRequest();
- String captchaText = null;
+ String captchaText;
CAPTCHAImageGenerator captchaImageGenerator = new CAPTCHAImageGenerator();
String captchaSessionKeyName = requestMap.get(
CAPTCHAComponent.ATTRIBUTE_CAPTCHASESSIONKEYNAME).toString();
Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/util/CAPTCHAImageGenerator.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/util/CAPTCHAImageGenerator.java?rev=640919&r1=640918&r2=640919&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/util/CAPTCHAImageGenerator.java (original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/captcha/util/CAPTCHAImageGenerator.java Tue Mar 25 11:07:33 2008
@@ -47,8 +47,8 @@
*/
private void drawTextOnImage(Graphics2D graphics, String captchaText) {
- Font font = null;
- TextLayout textLayout = null;
+ Font font;
+ TextLayout textLayout;
double currentFontStatus = Math.random();
// Generate random font status.
@@ -102,10 +102,10 @@
public void generateImage(HttpServletResponse response, String captchaText)
throws IOException {
- BufferedImage bufferedImage = null;
- Graphics2D graphics = null;
- PNGEncodeParam param = null;
- PNGImageEncoder captchaPNGImage = null;
+ BufferedImage bufferedImage;
+ Graphics2D graphics;
+ PNGEncodeParam param;
+ PNGImageEncoder captchaPNGImage;
// Create the CAPTCHA Image.
@@ -186,11 +186,11 @@
*/
private void drawBrokenLineOnImage(Graphics2D graphics) {
- int yPoint1 = 0;
- int yPoint2 = 0;
- int yPoint3 = 0;
- int yPoint4 = 0;
- int yPoint5 = 0;
+ int yPoint1;
+ int yPoint2;
+ int yPoint3;
+ int yPoint4;
+ int yPoint5;
Random random = new Random();
// Random Y Points.
@@ -217,9 +217,9 @@
*/
private double getDelta(int period, double i, double phase, double frames) {
return (double) (period / 2)
- * Math.sin((double) i / (double) period
- + (2 * CAPTCHAConstants.PI * (double) phase)
- / (double) frames);
+ * Math.sin(i / (double) period
+ + (2 * CAPTCHAConstants.PI * phase)
+ / frames);
}
/*
@@ -231,8 +231,8 @@
int periodValue = 20;
int numberOfFrames = 15;
int phaseNumber = 7;
- double deltaX = 0;
- double deltaY = 0;
+ double deltaX;
+ double deltaY;
applyCurrentGradientPaint(graphics, bufferedImageWidth,
bufferedImageHeight);