# HG changeset patch # User Anton Epple # Date 1392192860 -3600 # Node ID 3e3fb431d2b7ff0f50f139b6febbd48e408b35dd # Parent 619f507713a21e98566352ab7b4e27b5e57d5753 More JavaDoc improvements. diff -r 619f507713a2 -r 3e3fb431d2b7 javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Wed Feb 12 08:56:40 2014 +0100 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Wed Feb 12 09:14:20 2014 +0100 @@ -57,8 +57,9 @@ * * @param centerX the center x position of the arc. * @param centerY the center y position of the arc. + * @param startAngle the startAngle of the arc * @param radius the radius of the arc. - * @param endAngle teh endAngle of the arc + * @param endAngle the endAngle of the arc * @param ccw the direction of the arc (counterclockwise) */ public void arc(double centerX, @@ -185,8 +186,8 @@ * * @param x the X position of the upper left corner of the rectangle. * @param y the Y position of the upper left corner of the rectangle. - * @param w the width of the rectangle. - * @param h the height of the rectangle. + * @param width the width of the rectangle. + * @param height the height of the rectangle. */ public void fillRect(double x, double y, double width, double height) { graphicsEnvironmentImpl.fillRect(x, y, width, height); @@ -342,7 +343,7 @@ * Draws an image at the given x, y position using the width and height of * the given image. * - * @param img the image to be drawn. + * @param image the image to be drawn. * @param x the X coordinate on the destination for the upper left of the * image. * @param y the Y coordinate on the destination for the upper left of the @@ -357,7 +358,7 @@ * Draws an image into the given destination rectangle of the canvas. The * Image is scaled to fit into the destination rectagnle. * - * @param img the image to be drawn. + * @param image the image to be drawn. * @param x the X coordinate on the destination for the upper left of the * image. * @param y the Y coordinate on the destination for the upper left of the @@ -374,7 +375,7 @@ * Draws the current source rectangle of the given image to the given * destination rectangle of the Canvas. * - * @param img the image to be drawn. + * @param image the image to be drawn. * @param sx the source rectangle's X coordinate position. * @param sy the source rectangle's Y coordinate position. * @param sw the source rectangle's width. diff -r 619f507713a2 -r 3e3fb431d2b7 javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java Wed Feb 12 08:56:40 2014 +0100 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/spi/GraphicsEnvironment.java Wed Feb 12 09:14:20 2014 +0100 @@ -1,19 +1,19 @@ /** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach + * Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach + * * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 2 of the License. + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 2 of the License. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. * - * You should have received a copy of the GNU General Public License - * along with this program. Look for COPYING file in the top folder. - * If not, see http://opensource.org/licenses/GPL-2.0. + * You should have received a copy of the GNU General Public License along with + * this program. Look for COPYING file in the top folder. If not, see + * http://opensource.org/licenses/GPL-2.0. */ package net.java.html.canvas.spi; @@ -28,6 +28,16 @@ */ public interface GraphicsEnvironment { + /** + * Adds path elements to the current path to make an arc. + * + * @param centerX the center x position of the arc. + * @param centerY the center y position of the arc. + * @param startAngle the startAngle of the arc + * @param radius the radius of the arc. + * @param endAngle the endAngle of the arc + * @param ccw the direction of the arc (counterclockwise) + */ public void arc(double centerX, double centerY, double startAngle, @@ -35,62 +45,292 @@ double endAngle, boolean ccw); + /** + * Adds segments to the current path to make an arc. + * + * @param x1 the X coordinate of the first point of the arc. + * @param y1 the Y coordinate of the first point of the arc. + * @param x2 the X coordinate of the second point of the arc. + * @param y2 the Y coordinate of the second point of the arc. + * @param radius the radius of the arc in the range {0.0-positive infinity}. + */ public void arcTo(double x1, double y1, double x2, double y2, - double r); + double radius); + /** + * Returns true if the the given x,y point is inside the path. + * + * @param x the X coordinate to use for the check. + * @param y the Y coordinate to use for the check. + * @return true if the point given is inside the path, false otherwise. + */ public boolean isPointInPath(double x, double y); + /** + * Fills the path with the current fill paint. + */ public void fill(); + /** + * Strokes the path with the current stroke paint. + */ public void stroke(); + /** + * Starts a Path + */ public void beginPath(); + /** + * Closes the path. + */ public void closePath(); + /** + * Clips using the current path + */ public void clip(); + /** + * Issues a move command for the current path to the given x,y coordinate. + * + * @param x the X position for the move to command. + * @param y the Y position for the move to command. + */ public void moveTo(double x, double y); + /** + * Adds segments to the current path to make a line at the given x,y + * coordinate. + * + * @param x the X coordinate of the ending point of the line. + * @param y the Y coordinate of the ending point of the line. + */ public void lineTo(double x, double y); + /** + * Adds segments to the current path to make a quadratic curve. + * + * @param cpx the X coordinate of the control point + * @param cpy the Y coordinate of the control point + * @param x the X coordinate of the end point + * @param y the Y coordinate of the end point + */ public void quadraticCurveTo(double cpx, double cpy, double x, double y); + /** + * Adds segments to the current path to make a cubic bezier curve. + * + * @param cp1x the X coordinate of first bezier control point. + * @param cp1y the Y coordinate of the first bezier control point. + * @param cp2x the X coordinate of the second bezier control point. + * @param cp2y the Y coordinate of the second bezier control point. + * @param x the X coordinate of the end point. + * @param y the Y coordinate of the end point. + */ public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); + /** + * Fills a rectangle using the current fill paint. + * + * @param x the X position of the upper left corner of the rectangle. + * @param y the Y position of the upper left corner of the rectangle. + * @param width the width of the rectangle. + * @param height the height of the rectangle. + */ public void fillRect(double x, double y, double width, double height); + /** + * Strokes a rectangle using the current stroke paint. + * + * @param x the X position of the upper left corner of the rectangle. + * @param y the Y position of the upper left corner of the rectangle. + * @param width the width of the rectangle. + * @param height the height of the rectangle. + */ public void strokeRect(double x, double y, double width, double height); + /** + * Clears a portion of the canvas with a transparent color value. + * + * @param x X position of the upper left corner of the rectangle. + * @param y Y position of the upper left corner of the rectangle. + * @param width width of the rectangle. + * @param height height of the rectangle. + */ public void clearRect(double x, double y, double width, double height); + /** + * Clears a portion of the canvas with a transparent color value. + * + * @param x X position of the upper left corner of the rectangle. + * @param y Y position of the upper left corner of the rectangle. + * @param width width of the rectangle. + * @param height height of the rectangle. + */ public void rect(double x, double y, double width, double height); + /** + * Saves the following attributes onto a stack. + *
    + *
  • Global Alpha
  • + *
  • Global Blend Operation
  • + *
  • Transform
  • + *
  • Fill Paint
  • + *
  • Stroke Paint
  • + *
  • Line Width
  • + *
  • Line Cap
  • + *
  • Line Join
  • + *
  • Miter Limit
  • + *
  • Number of Clip Paths
  • + *
  • Font
  • + *
  • Text Align
  • + *
  • Text Baseline
  • + *
  • Effect
  • + *
  • Fill Rule
  • + *
+ * This method does NOT alter the current state in any way. Also, not that + * the current path is not saved. + */ public void save(); + /** + * Pops the state off of the stack, setting the following attributes to + * their value at the time when that state was pushed onto the stack. If the + * stack is empty then nothing is changed. + * + *
    + *
  • Global Alpha
  • + *
  • Global Blend Operation
  • + *
  • Transform
  • + *
  • Fill Paint
  • + *
  • Stroke Paint
  • + *
  • Line Width
  • + *
  • Line Cap
  • + *
  • Line Join
  • + *
  • Miter Limit
  • + *
  • Number of Clip Paths
  • + *
  • Font
  • + *
  • Text Align
  • + *
  • Text Baseline
  • + *
  • Effect
  • + *
  • Fill Rule
  • + *
+ */ public void restore(); + /** + * Rotates the current transform in degrees. + * + * @param angle value in degrees to rotate the current transform. + */ public void rotate(double angle); + /** + * Concatenates the input with the current transform. + * + * @param a - the X coordinate scaling element of the 3x4 matrix + * @param b - the Y coordinate shearing element of the 3x4 matrix + * @param c - the X coordinate shearing element of the 3x4 matrix + * @param d - the Y coordinate scaling element of the 3x4 matrix + * @param e - the X coordinate translation element of the 3x4 matrix + * @param f - the Y coordinate translation element of the 3x4 matrix + */ public void transform(double a, double b, double c, double d, double e, double f); + /** + * Concatenates the input with the current transform. + * + * @param a - the X coordinate scaling element of the 3x4 matrix + * @param b - the Y coordinate shearing element of the 3x4 matrix + * @param c - the X coordinate shearing element of the 3x4 matrix + * @param d - the Y coordinate scaling element of the 3x4 matrix + * @param e - the X coordinate translation element of the 3x4 matrix + * @param f - the Y coordinate translation element of the 3x4 matrix + */ public void setTransform(double a, double b, double c, double d, double e, double f); + /** + * Translates the current transform by x, y. + * + * @param x value to translate along the x axis. + * @param y value to translate along the y axis. + */ public void translate(double x, double y); + /** + * Scales the current transform by x, y. + * + * @param x value to scale in the x axis. + * @param y value to scale in the y axis. + */ public void scale(double x, double y); + /** + * Draws an image at the given x, y position using the width and height of + * the given image. + * + * @param image the image to be drawn. + * @param x the X coordinate on the destination for the upper left of the + * image. + * @param y the Y coordinate on the destination for the upper left of the + * image. + * @return the native Image for caching. + */ public Object drawImage(Image image, double x, double y, Object nativeImage); + /** + * Draws an image into the given destination rectangle of the canvas. The + * Image is scaled to fit into the destination rectagnle. + * + * @param image the image to be drawn. + * @param x the X coordinate on the destination for the upper left of the + * image. + * @param y the Y coordinate on the destination for the upper left of the + * image. + * @param width the width of the destination rectangle. + * @param height the height of the destination rectangle. + * @return the native Image for caching. + * + */ public Object drawImage(Image image, double x, double y, double width, double height, Object nativeImage); + /** + * Draws the current source rectangle of the given image to the given + * destination rectangle of the Canvas. + * + * @param image the image to be drawn. + * @param sx the source rectangle's X coordinate position. + * @param sy the source rectangle's Y coordinate position. + * @param sWidth the source rectangle's width. + * @param sHeight the source rectangle's height. + * @param x the destination rectangle's X coordinate position. + * @param y the destination rectangle's Y coordinate position. + * @param width the destination rectangle's width. + * @param height the destination rectangle's height. + * @return the native Image for caching. + */ public Object drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height, Object nativeImage); + /** + * Get the width of this Image + * + * @param image the image to measure + * @param nativeImage the cached native Image or null + * @return the width of the image + */ public int getWidth(Image image, Object nativeImage); + /** + * Get the height of this Image + * + * @param image the image to measure + * @param nativeImage the cached native Image or null + * @return the height of the image + */ public int getHeight(Image image, Object nativeImage); /** @@ -304,19 +544,55 @@ */ public void setGlobalAlpha(double alpha); + /** + * Get the global alpha of the current state. + * + * @return alpha value in the range {@code 0.0-1.0}. + */ public double getGlobalAlpha(); + /** + * Sets the global blend mode. + * + * @param operation the BlendMode that will be set. + */ public void setGlobalCompositeOperation(String operation); + /** + * Gets the global blend mode. + * + * @return the global BlendMode of the current state. + */ public String getGlobalCompositeOperation(); + /** + * Get the height of this GraphicsContext (which should be the same as the + * enclosing canvas height) + * + * @return the height of this GraphicsContext + */ public int getHeight(); + /** + * Get the width of this GraphicsContext (which should be the same as the + * enclosing canvas height) + * + * @return the width of this GraphicsContext + */ public int getWidth(); // public void setHeight(int height); // // public void setWidth(int width); - + /** + * Merges two images drawing one on top of the other and returning the + * result. + * + * @param a the lower Image + * @param b the upper Image + * @param cachedA the native cached Image, if available, or null. + * @param cachedB the native cached Image, if available, or null. + * @return + */ public Object mergeImages(Image a, Image b, Object cachedA, Object cachedB); }