diff -r e67363288df1 -r e8429fba8cce javaquery/canvas/src/main/java/net/java/html/canvas/Style.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/Style.java Thu Sep 26 14:20:18 2013 -0700 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/Style.java Thu Sep 26 16:33:04 2013 -0700 @@ -17,6 +17,7 @@ */ package net.java.html.canvas; +import java.util.Collection; import java.util.HashMap; import java.util.Objects; @@ -49,31 +50,42 @@ return isCached() ? cached : null; } + /** + * A Fill Pattern using an Image Resource to create a fill style supporting + * different repeat styles repeat, repeat-x, repeat-y, or no-repeat. + * Default is repeat. + */ public static final class Pattern extends Style { - private Image imageResource; - private String repeat; + private final Image imageResource; + private final String repeat; + /** + * + * @param imageResource the base image of thsi pattern + * @param repeat the repeat pattern, possible values are repeat, repeat-x, repeat-y, or no-repeat. + */ public Pattern(Image imageResource, String repeat) { this.imageResource = imageResource; this.repeat = repeat; } + /** + * Get the base image of this pattern + * @return the base image of this pattern + */ public Image getImageResource() { return imageResource; } - public void setImageResource(Image imageResource) { - this.imageResource = imageResource; - } - + /** + * Get the repeat style for this pattern + * @return return the repeat style + */ public String getRepeat() { return repeat; } - public void setRepeat(String repeat) { - this.repeat = repeat; - } } public static final class Color extends Style { @@ -83,22 +95,38 @@ /** * Creates an RGB color specified with an HTML or CSS attribute string. * - * @param webColor Colordefined as + * @param webColor Color defined as web color (e.g. #ff0000) */ public Color(String webColor) { this.web = webColor; } + /** + * + * + * @return the Color value as a Web Color (e.g. #ff0000) + */ public String getAsString() { return web; } } + /** + * A Linear Gradient. The GRadient has a direction defined by two coordinates + * and stops defining the Color at a specific position. + */ public static class LinearGradient extends Style { private HashMap stops; private double x0, y0, x1, y1; + /** + * + * @param x0 the x coordinate of the start point for this gradient + * @param y0 the y coordinate of the start point for this gradient + * @param x1 the x coordinate of the end point for this gradient + * @param y1 the y coordinate of the end point for this gradient + */ LinearGradient(double x0, double y0, double x1, double y1) { this.x0 = x0; this.y0 = y0; @@ -106,6 +134,12 @@ this.y1 = y1; } + /** + * Add a new Color stop. A color stop defines a fixed color at a position + * along the coordinates. + * @param position the position of this stop in percent [0.0-1.0] + * @param color A Color defined in web format (e.g. #ff0000) + */ void addColorStop(double position, String color) { if (stops == null) { stops = new HashMap<>(); @@ -113,14 +147,23 @@ stops.put(position, color); } - public HashMap getStops() { - return stops; + /** + * Get the stops of this gradient. + * @return the stops of this gradient + */ + public HashMap getStops(){ + return new HashMap<>(stops); + } + + /** + * Set the stops as Position/Color pairs + * @param stops the stops for thsi Gradient + */ + public void setStops(HashMap stops) { + this.stops = new HashMap<>(stops); } - public void setStops(HashMap stops) { - this.stops = stops; - } - + public double getX0() { return x0; }