Author: Alex.Kolonitsky
Date: 2010-04-20 12:12:31 -0400 (Tue, 20 Apr 2010)
New Revision: 16780
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/Xcss2EcssConverter.java
Log:
fix checkstyle
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java 2010-04-20
15:57:57 UTC (rev 16779)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/CustomizeableGradient.java 2010-04-20
16:12:31 UTC (rev 16780)
@@ -21,6 +21,14 @@
package org.richfaces.renderkit.html;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.NumericDataInputStream;
+import org.richfaces.renderkit.html.images.GradientAlignment;
+import org.richfaces.renderkit.html.images.GradientType;
+import org.richfaces.renderkit.html.images.GradientType.BiColor;
+import org.richfaces.skin.Skin;
+
+import javax.faces.context.FacesContext;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
@@ -30,16 +38,6 @@
import java.awt.geom.Rectangle2D;
import java.util.Map;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.util.NumericDataInputStream;
-import org.richfaces.renderkit.html.images.GradientAlignment;
-import org.richfaces.renderkit.html.images.GradientType;
-import org.richfaces.renderkit.html.images.GradientType.BiColor;
-import org.richfaces.skin.Skin;
-import org.richfaces.skin.SkinFactory;
-
/**
* @author Nick Belaevski - nbelaevski(a)exadel.com
* created 02.02.2007
Modified:
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java 2010-04-20
15:57:57 UTC (rev 16779)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/html/images/CancelControlIcon.java 2010-04-20
16:12:31 UTC (rev 16780)
@@ -20,45 +20,42 @@
*/
package org.richfaces.renderkit.html.images;
+import org.ajax4jsf.resource.Java2Dresource;
+import org.ajax4jsf.util.HtmlColor;
+import org.ajax4jsf.util.NumericDataInputStream;
+
+import javax.faces.context.FacesContext;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
-import java.util.Date;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.resource.Java2Dresource;
-import org.ajax4jsf.resource.ResourceContext;
-import org.ajax4jsf.resource.Java2Dresource.ImageType;
-import org.ajax4jsf.util.HtmlColor;
-import org.ajax4jsf.util.NumericDataInputStream;
-import org.ajax4jsf.util.Zipper2;
-
-/**
+/**
* implementation of the default CANCEL icon renderer
+ *
* @author Anton Belevich
* @since 3.2.0
- *
*/
public class CancelControlIcon extends Java2Dresource {
- protected static final String ALTERNATE_COLOR = "#ED6161";
- protected Integer iconColor;
+ protected static final String ALTERNATE_COLOR = "#ED6161";
+
+ private static final Dimension DIMENSIONS = new Dimension(11, 11);
+
+ protected Integer iconColor;
protected Integer iconBorderColor;
- private static final Dimension dimensions = new Dimension(11, 11);
- public CancelControlIcon() {
- super(ImageType.GIF);
- }
-
- @Override
- public Dimension getDimension() {
- return dimensions;
- }
-
- @Override
+ public CancelControlIcon() {
+ super(ImageType.GIF);
+ }
+
+ @Override
+ public Dimension getDimension() {
+ return DIMENSIONS;
+ }
+
+ @Override
protected void readState(FacesContext context, NumericDataInputStream stream) {
super.readState(context, stream);
@@ -72,52 +69,52 @@
stream.writeIntColor(this.iconColor);
stream.writeIntColor(this.iconBorderColor);
}
-
- @Override
- protected void paint(Graphics2D g2d, Dimension dimension) {
-
- g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_OFF);
+
+ @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);
+ 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);
-
-
- }
+ 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:
root/framework/trunk/impl/src/main/java/org/richfaces/resource/Xcss2EcssConverter.java
===================================================================
---
root/framework/trunk/impl/src/main/java/org/richfaces/resource/Xcss2EcssConverter.java 2010-04-20
15:57:57 UTC (rev 16779)
+++
root/framework/trunk/impl/src/main/java/org/richfaces/resource/Xcss2EcssConverter.java 2010-04-20
16:12:31 UTC (rev 16780)
@@ -10,11 +10,15 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.Attributes;
+
import javax.xml.parsers.SAXParser;
-public class Xcss2EcssConverter {
+public final class Xcss2EcssConverter {
+ private Xcss2EcssConverter() {
+ }
+
public static void main(String[] args) {
// Create Handler
@@ -26,165 +30,174 @@
// Parse the XML file, handler generates the output
String string =
"E:/projs/richafces4/framework/trunk/impl/src/test/java/org/ajax4jsf/cache/extended.xcss";
parser.parse(string);
- }
+ }
}
+
class Handler extends DefaultHandler {
- private final String TEMPLATE = "template";
- private final String SELECTOR = "selector";
- private final String STYLE = "style";
- private final String RESOURCE = "resource";
- private final String ATTRIBBUTE = "attribute";
- private final String VERBATIM = "verbatim";
- private final String IMPORT = "importResource";
+ private static final String TEMPLATE = "template";
+ private static final String SELECTOR = "selector";
+ private static final String STYLE = "style";
+ private static final String RESOURCE = "resource";
+ private static final String ATTRIBBUTE = "attribute";
+ private static final String VERBATIM = "verbatim";
+ private static final String IMPORT = "importResource";
private StringBuilder ecssContent;
private boolean hasAttribbute = false;
- private boolean verbatim = false;;
+ private boolean verbatim = false;
+ ;
/**
* Receive notification of the start of an element.
+ *
* @param namespaceURI - The Namespace URI, or the empty string if the element has no
Namespace URI or if Namespace processing is not being performed.
- * @param localName - The local name (without prefix), or the empty string if
Namespace processing is not being performed.
- * @param qName - The qualified name (with prefix), or the empty string if qualified
names are not available.
- * @param atts - The attributes attached to the element. If there are no attributes,
it shall be an empty Attributes object.
+ * @param localName - The local name (without prefix), or the empty string if
Namespace processing is not being performed.
+ * @param qName - The qualified name (with prefix), or the empty string if
qualified names are not available.
+ * @param atts - The attributes attached to the element. If there are no
attributes, it shall be an empty Attributes object.
* @throws SAXException - Any SAX exception, possibly wrapping another exception.
*/
public void startElement(String namespaceURI, String localName, String qName,
Attributes atts)
throws SAXException {
- if (TEMPLATE.equals(localName)){
- ecssContent = new StringBuilder();
- }
- if (IMPORT.equals(localName)){
- String src = atts.getValue("src");
- ecssContent.append("@import url(#{resource['");
- ecssContent.append(src);
- ecssContent.append("']}\r\n");
- }
- if (VERBATIM.equals(localName)){
- verbatim = true;
- }
- if (SELECTOR.equals(localName)){
- String value = atts.getValue("name");
- if(null != value){
- ecssContent.append(value);
- ecssContent.append("{\r\n");
+
+ if (TEMPLATE.equals(localName)) {
+ ecssContent = new StringBuilder();
}
- }
- if (STYLE.equals(localName)){
- // Reset Order's values
- String name = atts.getValue("name");
- String skin = atts.getValue("skin");
- String value = atts.getValue("value");
- if(null != name){
- if(skin != null){
- ecssContent.append("\t");
- ecssContent.append(name);
- ecssContent.append(":");
- ecssContent.append("'#{richSkin.");
- ecssContent.append(skin);
- ecssContent.append("}'");
- }else if(value != null){
- ecssContent.append("\t");
- ecssContent.append(name);
- ecssContent.append(":");
- ecssContent.append(value);
- }else{
- ecssContent.append("\t");
- ecssContent.append(name);
- ecssContent.append(":");
- }
- }
- }
- if (RESOURCE.equals(localName)){
- String value = atts.getValue("f:key");
- if(null != value){
- ecssContent.append("'url(#{resource['");
- ecssContent.append(value);
-
- }
+ if (IMPORT.equals(localName)) {
+ String src = atts.getValue("src");
+ ecssContent.append("@import url(#{resource['");
+ ecssContent.append(src);
+ ecssContent.append("']}\r\n");
}
- if (ATTRIBBUTE.equals(localName)){
- if(!hasAttribbute){
- ecssContent.append("?");
- hasAttribbute = true;
- }
- String name = atts.getValue("name");
- String skin = atts.getValue("skin");
- String value = atts.getValue("value");
- if(null != name){
- if(skin != null){
- ecssContent.append(name);
- ecssContent.append("=");
- ecssContent.append("Skin.");
- ecssContent.append(skin);
- ecssContent.append("&");
- }else if(value != null){
- ecssContent.append(name);
- ecssContent.append("=");
- try {
- ecssContent.append(URLDecoder.decode(value, "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ if (VERBATIM.equals(localName)) {
+ verbatim = true;
+ }
+ if (SELECTOR.equals(localName)) {
+ String value = atts.getValue("name");
+ if (null != value) {
+ ecssContent.append(value);
+ ecssContent.append("{\r\n");
+ }
+ }
+ if (STYLE.equals(localName)) {
+ // Reset Order's values
+ String name = atts.getValue("name");
+ String skin = atts.getValue("skin");
+ String value = atts.getValue("value");
+ if (null != name) {
+ if (skin != null) {
+ ecssContent.append("\t");
+ ecssContent.append(name);
+ ecssContent.append(":");
+ ecssContent.append("'#{richSkin.");
+ ecssContent.append(skin);
+ ecssContent.append("}'");
+ } else if (value != null) {
+ ecssContent.append("\t");
+ ecssContent.append(name);
+ ecssContent.append(":");
+ ecssContent.append(value);
+ } else {
+ ecssContent.append("\t");
+ ecssContent.append(name);
+ ecssContent.append(":");
}
- ecssContent.append("&");
- }else{
- //ERROR
- }
- }
+ }
}
- }
+ if (RESOURCE.equals(localName)) {
+ String value = atts.getValue("f:key");
+ if (null != value) {
+ ecssContent.append("'url(#{resource['");
+ ecssContent.append(value);
+ }
+ }
+ if (ATTRIBBUTE.equals(localName)) {
+ if (!hasAttribbute) {
+ ecssContent.append("?");
+ hasAttribbute = true;
+ }
+ String name = atts.getValue("name");
+ String skin = atts.getValue("skin");
+ String value = atts.getValue("value");
+ if (null != name) {
+ if (skin != null) {
+ ecssContent.append(name);
+ ecssContent.append("=");
+ ecssContent.append("Skin.");
+ ecssContent.append(skin);
+ ecssContent.append("&");
+ } else if (value != null) {
+ ecssContent.append(name);
+ ecssContent.append("=");
+ try {
+ ecssContent.append(URLDecoder.decode(value, "UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ ecssContent.append("&");
+ } else {
+ //ERROR
+ }
+ }
+ }
+ }
+
/**
* Receive notification of character data inside an element.
- * @param ch - The characters.
- * @param start - The start position in the character array.
+ *
+ * @param ch - The characters.
+ * @param start - The start position in the character array.
* @param length - The number of characters to use from the character array.
* @throws SAXException - Any SAX exception, possibly wrapping another exception.
*/
public void characters(char[] ch, int start, int length)
throws SAXException {
- if ( verbatim ){
+
+ if (verbatim) {
String strValue = new String(ch, start, length);
ecssContent.append(strValue);
-
- }
+ }
+
}
/**
* Receive notification of the end of an element.
+ *
* @param namespaceURI - The Namespace URI, or the empty string if the element has no
Namespace URI or if Namespace processing is not being performed.
- * @param localName - The local name (without prefix), or the empty string if
Namespace processing is not being performed.
- * @param qName - The qualified name (with prefix), or the empty string if qualified
names are not available.
+ * @param localName - The local name (without prefix), or the empty string if
Namespace processing is not being performed.
+ * @param qName - The qualified name (with prefix), or the empty string if
qualified names are not available.
* @throws SAXException - Any SAX exception, possibly wrapping another exception.
*/
public void endElement(String namespaceURI, String localName, String qName)
throws SAXException {
- if (TEMPLATE.equals(localName)){
+
+ if (TEMPLATE.equals(localName)) {
System.out.println(ecssContent.toString().trim());
}
- if (VERBATIM.equals(localName)){
+ if (VERBATIM.equals(localName)) {
verbatim = false;
}
- if (SELECTOR.equals(localName)){
- ecssContent.append("}\r\n");
+ if (SELECTOR.equals(localName)) {
+ ecssContent.append("}\r\n");
}
- if (STYLE.equals(localName)){
+ if (STYLE.equals(localName)) {
ecssContent.append(";\r\n");
}
- if (RESOURCE.equals(localName)){
- if(hasAttribbute){
- ecssContent.setLength(ecssContent.length() -1);
+ if (RESOURCE.equals(localName)) {
+ if (hasAttribbute) {
+ ecssContent.setLength(ecssContent.length() - 1);
}
ecssContent.append("']})'");
hasAttribbute = false;
- }
- if (ATTRIBBUTE.equals(localName)){
- }
+ }
+ if (ATTRIBBUTE.equals(localName)) {
+ }
}
- }
+}
+
class CreateParser {
private DefaultHandler handler;
@@ -192,65 +205,69 @@
/**
* Constructor
+ *
* @param handler - DefaultHandler for the SAX parser
*/
public CreateParser(DefaultHandler handler) {
- this.handler = handler;
- create();
+ this.handler = handler;
+ create();
}
/**
* Create the SAX parser
*/
private void create() {
- try {
- // Obtain a new instance of a SAXParserFactory.
- SAXParserFactory factory = SAXParserFactory.newInstance();
- // Specifies that the parser produced by this code will provide support for XML
namespaces.
- factory.setNamespaceAware(true);
- // Specifies that the parser produced by this code will validate documents as
they are parsed.
- //factory.setValidating(true);
- // Creates a new instance of a SAXParser using the currently configured factory
parameters.
- saxParser = factory.newSAXParser();
- } catch (Throwable t) {
- t.printStackTrace();
- }
+ try {
+ // Obtain a new instance of a SAXParserFactory.
+ SAXParserFactory factory = SAXParserFactory.newInstance();
+ // Specifies that the parser produced by this code will provide support for
XML namespaces.
+ factory.setNamespaceAware(true);
+ // Specifies that the parser produced by this code will validate documents as
they are parsed.
+ //factory.setValidating(true);
+ // Creates a new instance of a SAXParser using the currently configured
factory parameters.
+ saxParser = factory.newSAXParser();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
}
/**
* Parse a File
+ *
* @param file - File
*/
- public void parse(File file){
- try{
- saxParser.parse(file,handler);
- } catch (Throwable t) {
- t.printStackTrace();
- }
+ public void parse(File file) {
+ try {
+ saxParser.parse(file, handler);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
}
/**
* Parse a URI
+ *
* @param uri - String
*/
- public void parse(String uri){
- try{
- saxParser.parse(uri,handler);
- } catch (Throwable t) {
- t.printStackTrace();
- }
+ public void parse(String uri) {
+ try {
+ saxParser.parse(uri, handler);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
}
/**
* Parse a Stream
+ *
* @param stream - InputStream
*/
- public void parse(InputStream stream){
- try{
- saxParser.parse(stream,handler);
- } catch (Throwable t) {
- t.printStackTrace();
- }
+ public void parse(InputStream stream) {
+ try {
+ saxParser.parse(stream, handler);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
}
- }
+}