documentation canvas
authorAnton Epple <toni.epple@eppleton.de>
Thu, 26 Sep 2013 16:40:32 -0700
branchcanvas
changeset 13099ad100ab5432
parent 1307 62be3fb4294e
parent 1308 e8429fba8cce
child 1438 03cd1b3e2e70
documentation
     1.1 --- a/javaquery/canvas/src/main/java/net/java/html/canvas/Image.java	Fri Sep 27 00:49:48 2013 +0200
     1.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/Image.java	Thu Sep 26 16:40:32 2013 -0700
     1.3 @@ -29,8 +29,8 @@
     1.4  public final class Image {
     1.5  
     1.6      private String src;
     1.7 +    private int cacheHash;
     1.8      private Object cached;
     1.9 -    private int cacheHash;
    1.10  
    1.11      public static Image create(String src) {
    1.12          return new Image(src);
     2.1 --- a/javaquery/canvas/src/main/java/net/java/html/canvas/ImageData.java	Fri Sep 27 00:49:48 2013 +0200
     2.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/ImageData.java	Thu Sep 26 16:40:32 2013 -0700
     2.3 @@ -30,19 +30,19 @@
     2.4  
     2.5      public double getWidth();
     2.6  
     2.7 -    public int getR(double x, double y);
     2.8 +    public int getR(int x, int y);
     2.9  
    2.10 -    public int getG(double x, double y);
    2.11 +    public int getG(int x, int y);
    2.12  
    2.13 -    public int getB(double x, double y);
    2.14 +    public int getB(int x, int y);
    2.15  
    2.16 -    public int getA(double x, double y);
    2.17 +    public int getA(int x, int y);
    2.18  
    2.19 -    public void setR(double x, double y, int value);
    2.20 +    public void setR(int x, int y, int value);
    2.21  
    2.22 -    public void setG(double x, double y, int value);
    2.23 +    public void setG(int x, int y, int value);
    2.24  
    2.25 -    public void setB(double x, double y, int value);
    2.26 +    public void setB(int x, int y, int value);
    2.27  
    2.28      public void setA(double x, double y, int value);
    2.29  }
     3.1 --- a/javaquery/canvas/src/main/java/net/java/html/canvas/Style.java	Fri Sep 27 00:49:48 2013 +0200
     3.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/Style.java	Thu Sep 26 16:40:32 2013 -0700
     3.3 @@ -17,6 +17,7 @@
     3.4   */
     3.5  package net.java.html.canvas;
     3.6  
     3.7 +import java.util.Collection;
     3.8  import java.util.HashMap;
     3.9  import java.util.Objects;
    3.10  
    3.11 @@ -49,31 +50,42 @@
    3.12          return isCached() ? cached : null;
    3.13      }
    3.14  
    3.15 +    /**
    3.16 +     * A Fill Pattern using an Image Resource to create a fill style supporting 
    3.17 +     * different repeat styles repeat, repeat-x, repeat-y, or no-repeat. 
    3.18 +     * Default is repeat. 
    3.19 +     */
    3.20      public static final class Pattern extends Style {
    3.21  
    3.22 -        private Image imageResource;
    3.23 -        private String repeat;
    3.24 +        private final Image imageResource;
    3.25 +        private final String repeat;
    3.26  
    3.27 +        /**
    3.28 +         * 
    3.29 +         * @param imageResource the base image of thsi pattern
    3.30 +         * @param repeat the repeat pattern, possible values are repeat, repeat-x, repeat-y, or no-repeat.
    3.31 +         */
    3.32          public Pattern(Image imageResource, String repeat) {
    3.33              this.imageResource = imageResource;
    3.34              this.repeat = repeat;
    3.35          }
    3.36  
    3.37 +        /**
    3.38 +         * Get the base image of this pattern
    3.39 +         * @return the base image of this pattern
    3.40 +         */
    3.41          public Image getImageResource() {
    3.42              return imageResource;
    3.43          }
    3.44  
    3.45 -        public void setImageResource(Image imageResource) {
    3.46 -            this.imageResource = imageResource;
    3.47 -        }
    3.48 -
    3.49 +        /**
    3.50 +         * Get the repeat style for this pattern
    3.51 +         * @return return the repeat style
    3.52 +         */
    3.53          public String getRepeat() {
    3.54              return repeat;
    3.55          }
    3.56  
    3.57 -        public void setRepeat(String repeat) {
    3.58 -            this.repeat = repeat;
    3.59 -        }
    3.60      }
    3.61  
    3.62      public static final class Color extends Style {
    3.63 @@ -83,22 +95,38 @@
    3.64          /**
    3.65           * Creates an RGB color specified with an HTML or CSS attribute string.
    3.66           *
    3.67 -         * @param webColor Colordefined as
    3.68 +         * @param webColor Color defined as web color (e.g. #ff0000)
    3.69           */
    3.70          public Color(String webColor) {
    3.71              this.web = webColor;
    3.72          }
    3.73  
    3.74 +        /**
    3.75 +         * 
    3.76 +         * 
    3.77 +         * @return the Color value as a Web Color (e.g. #ff0000)
    3.78 +         */
    3.79          public String getAsString() {
    3.80              return web;
    3.81          }
    3.82      }
    3.83  
    3.84 +    /**
    3.85 +     * A Linear Gradient. The GRadient has a direction defined by two coordinates
    3.86 +     * and stops defining the Color at a specific position.
    3.87 +     */
    3.88      public static class LinearGradient extends Style {
    3.89  
    3.90          private HashMap<Double, String> stops;
    3.91          private double x0, y0, x1, y1;
    3.92  
    3.93 +        /**
    3.94 +         * 
    3.95 +         * @param x0 the x coordinate of the start point for this gradient
    3.96 +         * @param y0 the y coordinate of the start point for this gradient
    3.97 +         * @param x1 the x coordinate of the end point for this gradient
    3.98 +         * @param y1 the y coordinate of the end point for this gradient
    3.99 +         */
   3.100          LinearGradient(double x0, double y0, double x1, double y1) {
   3.101              this.x0 = x0;
   3.102              this.y0 = y0;
   3.103 @@ -106,6 +134,12 @@
   3.104              this.y1 = y1;
   3.105          }
   3.106  
   3.107 +        /**
   3.108 +         * Add a new Color stop. A color stop defines a fixed color at a position
   3.109 +         * along the coordinates.
   3.110 +         * @param position the position of this stop in percent [0.0-1.0]
   3.111 +         * @param color A Color defined in web format (e.g. #ff0000) 
   3.112 +         */
   3.113          void addColorStop(double position, String color) {
   3.114              if (stops == null) {
   3.115                  stops = new HashMap<>();
   3.116 @@ -113,14 +147,23 @@
   3.117              stops.put(position, color);
   3.118          }
   3.119  
   3.120 -        public HashMap<Double, String> getStops() {
   3.121 -            return stops;
   3.122 +        /**
   3.123 +         * Get the stops of this gradient. 
   3.124 +         * @return the stops of this gradient
   3.125 +         */
   3.126 +        public HashMap<Double, String> getStops(){
   3.127 +            return new HashMap<>(stops);
   3.128 +        }
   3.129 +        
   3.130 +        /**
   3.131 +         * Set the stops as Position/Color pairs 
   3.132 +         * @param stops the stops for thsi Gradient
   3.133 +         */
   3.134 +        public void setStops(HashMap<Double, String> stops) {     
   3.135 +            this.stops = new HashMap<>(stops);
   3.136          }
   3.137  
   3.138 -        public void setStops(HashMap<Double, String> stops) {
   3.139 -            this.stops = stops;
   3.140 -        }
   3.141 -
   3.142 +        
   3.143          public double getX0() {
   3.144              return x0;
   3.145          }
     4.1 --- a/javaquery/canvas/src/main/java/org/apidesign/html/canvas/impl/CnvsAccssr.java	Fri Sep 27 00:49:48 2013 +0200
     4.2 +++ b/javaquery/canvas/src/main/java/org/apidesign/html/canvas/impl/CnvsAccssr.java	Thu Sep 26 16:40:32 2013 -0700
     4.3 @@ -25,7 +25,7 @@
     4.4  import net.java.html.canvas.spi.GraphicsEnvironment;
     4.5  
     4.6  /**
     4.7 - *
     4.8 + * 
     4.9   * @author antonepple
    4.10   */
    4.11  public abstract class CnvsAccssr {