Some JavaDoc improvements. canvas
authorAnton Epple <toni.epple@eppleton.de>
Wed, 12 Feb 2014 08:21:34 +0100
branchcanvas
changeset 14436e51eb226f44
parent 1442 0660e56b5b33
child 1444 8cb57e6c7012
Some JavaDoc improvements.
javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java
     1.1 --- a/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java	Tue Feb 11 15:42:12 2014 +0100
     1.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java	Wed Feb 12 08:21:34 2014 +0100
     1.3 @@ -1,19 +1,19 @@
     1.4  /**
     1.5 - * Back 2 Browser Bytecode Translator
     1.6 - * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.7 + * Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach
     1.8 + * <jaroslav.tulach@apidesign.org>
     1.9   *
    1.10 - * This program is free software: you can redistribute it and/or modify
    1.11 - * it under the terms of the GNU General Public License as published by
    1.12 - * the Free Software Foundation, version 2 of the License.
    1.13 + * This program is free software: you can redistribute it and/or modify it under
    1.14 + * the terms of the GNU General Public License as published by the Free Software
    1.15 + * Foundation, version 2 of the License.
    1.16   *
    1.17 - * This program is distributed in the hope that it will be useful,
    1.18 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.19 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.20 - * GNU General Public License for more details.
    1.21 + * This program is distributed in the hope that it will be useful, but WITHOUT
    1.22 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.23 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1.24 + * details.
    1.25   *
    1.26 - * You should have received a copy of the GNU General Public License
    1.27 - * along with this program. Look for COPYING file in the top folder.
    1.28 - * If not, see http://opensource.org/licenses/GPL-2.0.
    1.29 + * You should have received a copy of the GNU General Public License along with
    1.30 + * this program. Look for COPYING file in the top folder. If not, see
    1.31 + * http://opensource.org/licenses/GPL-2.0.
    1.32   */
    1.33  package net.java.html.canvas;
    1.34  
    1.35 @@ -26,7 +26,7 @@
    1.36  
    1.37  /**
    1.38   * A 2D Graphics Context similar to HTML5 or JavaFX GraphicsContext. Use this to
    1.39 - * paint on your Canvas.s
    1.40 + * paint on your Canvas
    1.41   *
    1.42   * @author antonepple
    1.43   */
    1.44 @@ -440,6 +440,8 @@
    1.45  //    public double getShadowOffsetY() {
    1.46  //        return graphicsEnvironmentImpl.getShadowOffsetY();
    1.47  //    }
    1.48 +    
    1.49 +    
    1.50      public String getLineCap() {
    1.51          return graphicsEnvironmentImpl.getLineCap();
    1.52      }
    1.53 @@ -472,56 +474,151 @@
    1.54          graphicsEnvironmentImpl.setMiterLimit(limit);
    1.55      }
    1.56  
    1.57 +    /**
    1.58 +     * Sets the fill style. Will be used when rendering something, e.g. calling one
    1.59 +     * of the fillText Methods.
    1.60 +     * @param style 
    1.61 +     */
    1.62      public void setFillStyle(Style style) {
    1.63          Object nativeFillStyle = graphicsEnvironmentImpl.setFillStyle(style, style.getCached());
    1.64          style.cache(nativeFillStyle);
    1.65      }
    1.66  
    1.67 +    /**
    1.68 +     * get the current font
    1.69 +     *
    1.70 +     * @return current Font. 
    1.71 +     * of the fillText Methods.
    1.72 +     */
    1.73      public String getFont() {
    1.74          return graphicsEnvironmentImpl.getFont();
    1.75      }
    1.76  
    1.77 +    /**
    1.78 +     * Set the Font. Will be used when rendering Text, e.g. by calling one
    1.79 +     * of the fillText Methods.
    1.80 +     *
    1.81 +     * @param font
    1.82 +     */
    1.83      public void setFont(String font) {
    1.84          graphicsEnvironmentImpl.setFont(font);
    1.85      }
    1.86  
    1.87 +    /**
    1.88 +     * sets the Style of the Stroke.
    1.89 +     *
    1.90 +     * @param style
    1.91 +     */
    1.92      public void setStrokeStyle(Style style) {
    1.93          Object nativeStrokeStyle = graphicsEnvironmentImpl.setStrokeStyle(style, style.getCached());
    1.94          style.cache(nativeStrokeStyle);
    1.95      }
    1.96  
    1.97 +    /**
    1.98 +     * Gets the current TextAlignment attribute
    1.99 +     *
   1.100 +     * @return TextAlignment with values of left, center, right, or justify.
   1.101 +     */
   1.102      public String getTextAlign() {
   1.103          return graphicsEnvironmentImpl.getTextAlign();
   1.104      }
   1.105  
   1.106 +    /**
   1.107 +     * Defines horizontal text alignment, relative to the text {@code x} origin.
   1.108 +     * <p>
   1.109 +     * Let horizontal bounds represent the logical width of a single line of
   1.110 +     * text. Where each line of text has a separate horizontal bounds.
   1.111 +     * <p>
   1.112 +     * Then TextAlignment is specified as:
   1.113 +     * <ul>
   1.114 +     * <li>left: the left edge of the horizontal bounds will be at {@code x}.
   1.115 +     * <li>center: the center, halfway between left and right edge, of the
   1.116 +     * horizontal bounds will be at {@code x}.
   1.117 +     * <li>right: the right edge of the horizontal bounds will be at {@code x}.
   1.118 +     * </ul>
   1.119 +     * <p>
   1.120 +     *
   1.121 +     * Note: Canvas does not support line wrapping, therefore the text alignment
   1.122 +     * Justify is identical to left aligned text.
   1.123 +     * <p>
   1.124 +     *
   1.125 +     * @param textAlign with values of left, center, right.
   1.126 +     */
   1.127      public void setTextAlign(String textAlign) {
   1.128          graphicsEnvironmentImpl.setTextAlign(textAlign);
   1.129      }
   1.130  
   1.131 +    /**
   1.132 +     * Gets the current Text Baseline attribute.
   1.133 +     *
   1.134 +     * @return baseline with values of top, center, baseline, or bottom
   1.135 +     */
   1.136      public String getTextBaseline() {
   1.137          return graphicsEnvironmentImpl.getTextBaseline();
   1.138      }
   1.139  
   1.140 +    /**
   1.141 +     * Sets the current Text Baseline attribute.
   1.142 +     *
   1.143 +     * @param baseline with values of top, center, baseline, or bottom
   1.144 +     */
   1.145      public void setTextBaseline(String textbaseline) {
   1.146          graphicsEnvironmentImpl.setTextBaseline(textbaseline);
   1.147      }
   1.148  
   1.149 +    /**
   1.150 +     * Renders the indicated String with current fill. default is black.
   1.151 +     *
   1.152 +     * @param text the text to stroke
   1.153 +     * @param x x coordinate of start position
   1.154 +     * @param y y coordinate of start position
   1.155 +     */
   1.156      public void fillText(String text, double x, double y) {
   1.157          graphicsEnvironmentImpl.fillText(text, x, y);
   1.158      }
   1.159  
   1.160 +    /**
   1.161 +     * Renders the indicated String with current fill. default is black.
   1.162 +     *
   1.163 +     * @param text the text to stroke
   1.164 +     * @param x x coordinate of start position
   1.165 +     * @param y y coordinate of start position
   1.166 +     * @param maxWidth maximum width of text
   1.167 +     */
   1.168      public void fillText(String text, double x, double y, double maxWidth) {
   1.169          graphicsEnvironmentImpl.fillText(text, x, y, maxWidth);
   1.170      }
   1.171  
   1.172 +    /**
   1.173 +     * Check the length of a text before writing it to the Canvas. Takes into
   1.174 +     * account the current Font.
   1.175 +     *
   1.176 +     * @param text the text to measure
   1.177 +     * @return the length in pixels
   1.178 +     */
   1.179      public Dimension measureText(String text) {
   1.180          return graphicsEnvironmentImpl.measureText(text);
   1.181      }
   1.182  
   1.183 +    /**
   1.184 +     * Renders the indicated String (with no fill)
   1.185 +     *
   1.186 +     * @param text the text to stroke
   1.187 +     * @param x x coordinate of start position
   1.188 +     * @param y y coordinate of start position
   1.189 +     */
   1.190      public void strokeText(String text, double x, double y) {
   1.191          graphicsEnvironmentImpl.strokeText(text, x, y);
   1.192      }
   1.193  
   1.194 +    /**
   1.195 +     * Renders the indicated String (with no fill)
   1.196 +     *
   1.197 +     * @param text the text to stroke
   1.198 +     * @param x x coordinate of start position
   1.199 +     * @param y y coordinate of start position
   1.200 +     * @param maxWidth maximum width of text
   1.201 +     */
   1.202      public void strokeText(String text, double x, double y, double maxWidth) {
   1.203          graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth);
   1.204      }
   1.205 @@ -582,18 +679,52 @@
   1.206          return graphicsEnvironmentImpl.getGlobalCompositeOperation();
   1.207      }
   1.208  
   1.209 +    /**
   1.210 +     * Create a LinearGradient to use in Canvas.
   1.211 +     *
   1.212 +     * @param x0 x coordinate of start point
   1.213 +     * @param y0 y coordinate of start point
   1.214 +     * @param x1 x coordinate of end point
   1.215 +     * @param y1 y coordinate of end point
   1.216 +     * @return the gradient
   1.217 +     */
   1.218      public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) {
   1.219          return new Style.LinearGradient(x0, y0, x1, y1);
   1.220      }
   1.221  
   1.222 +    /**
   1.223 +     * Create an Image Pattern from a source Image and a repeat style. Possible
   1.224 +     * Styles are repeat, repeat-x, repeat-y, or no-repeat. defaults to repeat
   1.225 +     *
   1.226 +     * @param image the Image
   1.227 +     * @param repeat the repeat style
   1.228 +     * @return the Pattern
   1.229 +     */
   1.230      public Pattern createPattern(Image image, String repeat) {
   1.231          return new Pattern(image, repeat);
   1.232      }
   1.233  
   1.234 +    /**
   1.235 +     * Create a RadialGradient
   1.236 +     *
   1.237 +     * @param x0 x Coordinate of starting circle
   1.238 +     * @param y0 y Coordinate of starting circle
   1.239 +     * @param r0 radius of starting circle
   1.240 +     * @param x1 x coordinate of ending circle
   1.241 +     * @param y1 y coordinate of ending circle
   1.242 +     * @param r1 radius of ending circle
   1.243 +     * @return the Gradient
   1.244 +     */
   1.245      public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) {
   1.246          return new RadialGradient(x0, y0, r0, x1, y1, r1);
   1.247      }
   1.248  
   1.249 +    /**
   1.250 +     * Convert this String Representation of a Color to a Color Object.
   1.251 +     *
   1.252 +     * @param webColor
   1.253 +     * @return The Color represented by the input
   1.254 +     */
   1.255      public Color getWebColor(String webColor) {
   1.256          return new Style.Color(webColor);
   1.257      }