# HG changeset patch # User Anton Epple # Date 1380238384 25200 # Node ID e8429fba8ccea147ef9414a5799b279a8c3e8b10 # Parent 304e6ee678620de12c962f5dd4200895837ae0d2 documentation diff -r 304e6ee67862 -r e8429fba8cce javaquery/canvas/src/main/java/net/java/html/canvas/Image.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/Image.java Fri Sep 27 00:41:07 2013 +0200 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/Image.java Thu Sep 26 16:33:04 2013 -0700 @@ -29,8 +29,8 @@ public final class Image { private String src; + private int cacheHash; private Object cached; - private int cacheHash; public static Image create(String src) { return new Image(src); diff -r 304e6ee67862 -r e8429fba8cce javaquery/canvas/src/main/java/net/java/html/canvas/ImageData.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/ImageData.java Fri Sep 27 00:41:07 2013 +0200 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/ImageData.java Thu Sep 26 16:33:04 2013 -0700 @@ -30,19 +30,19 @@ public double getWidth(); - public int getR(double x, double y); + public int getR(int x, int y); - public int getG(double x, double y); + public int getG(int x, int y); - public int getB(double x, double y); + public int getB(int x, int y); - public int getA(double x, double y); + public int getA(int x, int y); - public void setR(double x, double y, int value); + public void setR(int x, int y, int value); - public void setG(double x, double y, int value); + public void setG(int x, int y, int value); - public void setB(double x, double y, int value); + public void setB(int x, int y, int value); public void setA(double x, double y, int value); } diff -r 304e6ee67862 -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 Fri Sep 27 00:41:07 2013 +0200 +++ 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; } diff -r 304e6ee67862 -r e8429fba8cce javaquery/canvas/src/main/java/org/apidesign/html/canvas/impl/CnvsAccssr.java --- a/javaquery/canvas/src/main/java/org/apidesign/html/canvas/impl/CnvsAccssr.java Fri Sep 27 00:41:07 2013 +0200 +++ b/javaquery/canvas/src/main/java/org/apidesign/html/canvas/impl/CnvsAccssr.java Thu Sep 26 16:33:04 2013 -0700 @@ -25,7 +25,7 @@ import net.java.html.canvas.spi.GraphicsEnvironment; /** - * + * * @author antonepple */ public abstract class CnvsAccssr {