# HG changeset patch # User Anton Epple # Date 1392189694 -3600 # Node ID 6e51eb226f449c71db441c60a43a5b947732025c # Parent 0660e56b5b3340b211255f73b8e80a69e0728e51 Some JavaDoc improvements. diff -r 0660e56b5b33 -r 6e51eb226f44 javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java --- a/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Tue Feb 11 15:42:12 2014 +0100 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Wed Feb 12 08:21:34 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; @@ -26,7 +26,7 @@ /** * A 2D Graphics Context similar to HTML5 or JavaFX GraphicsContext. Use this to - * paint on your Canvas.s + * paint on your Canvas * * @author antonepple */ @@ -440,6 +440,8 @@ // public double getShadowOffsetY() { // return graphicsEnvironmentImpl.getShadowOffsetY(); // } + + public String getLineCap() { return graphicsEnvironmentImpl.getLineCap(); } @@ -472,56 +474,151 @@ graphicsEnvironmentImpl.setMiterLimit(limit); } + /** + * Sets the fill style. Will be used when rendering something, e.g. calling one + * of the fillText Methods. + * @param style + */ public void setFillStyle(Style style) { Object nativeFillStyle = graphicsEnvironmentImpl.setFillStyle(style, style.getCached()); style.cache(nativeFillStyle); } + /** + * get the current font + * + * @return current Font. + * of the fillText Methods. + */ public String getFont() { return graphicsEnvironmentImpl.getFont(); } + /** + * Set the Font. Will be used when rendering Text, e.g. by calling one + * of the fillText Methods. + * + * @param font + */ public void setFont(String font) { graphicsEnvironmentImpl.setFont(font); } + /** + * sets the Style of the Stroke. + * + * @param style + */ public void setStrokeStyle(Style style) { Object nativeStrokeStyle = graphicsEnvironmentImpl.setStrokeStyle(style, style.getCached()); style.cache(nativeStrokeStyle); } + /** + * Gets the current TextAlignment attribute + * + * @return TextAlignment with values of left, center, right, or justify. + */ public String getTextAlign() { return graphicsEnvironmentImpl.getTextAlign(); } + /** + * Defines horizontal text alignment, relative to the text {@code x} origin. + *

+ * Let horizontal bounds represent the logical width of a single line of + * text. Where each line of text has a separate horizontal bounds. + *

+ * Then TextAlignment is specified as: + *

    + *
  • left: the left edge of the horizontal bounds will be at {@code x}. + *
  • center: the center, halfway between left and right edge, of the + * horizontal bounds will be at {@code x}. + *
  • right: the right edge of the horizontal bounds will be at {@code x}. + *
+ *

+ * + * Note: Canvas does not support line wrapping, therefore the text alignment + * Justify is identical to left aligned text. + *

+ * + * @param textAlign with values of left, center, right. + */ public void setTextAlign(String textAlign) { graphicsEnvironmentImpl.setTextAlign(textAlign); } + /** + * Gets the current Text Baseline attribute. + * + * @return baseline with values of top, center, baseline, or bottom + */ public String getTextBaseline() { return graphicsEnvironmentImpl.getTextBaseline(); } + /** + * Sets the current Text Baseline attribute. + * + * @param baseline with values of top, center, baseline, or bottom + */ public void setTextBaseline(String textbaseline) { graphicsEnvironmentImpl.setTextBaseline(textbaseline); } + /** + * Renders the indicated String with current fill. default is black. + * + * @param text the text to stroke + * @param x x coordinate of start position + * @param y y coordinate of start position + */ public void fillText(String text, double x, double y) { graphicsEnvironmentImpl.fillText(text, x, y); } + /** + * Renders the indicated String with current fill. default is black. + * + * @param text the text to stroke + * @param x x coordinate of start position + * @param y y coordinate of start position + * @param maxWidth maximum width of text + */ public void fillText(String text, double x, double y, double maxWidth) { graphicsEnvironmentImpl.fillText(text, x, y, maxWidth); } + /** + * Check the length of a text before writing it to the Canvas. Takes into + * account the current Font. + * + * @param text the text to measure + * @return the length in pixels + */ public Dimension measureText(String text) { return graphicsEnvironmentImpl.measureText(text); } + /** + * Renders the indicated String (with no fill) + * + * @param text the text to stroke + * @param x x coordinate of start position + * @param y y coordinate of start position + */ public void strokeText(String text, double x, double y) { graphicsEnvironmentImpl.strokeText(text, x, y); } + /** + * Renders the indicated String (with no fill) + * + * @param text the text to stroke + * @param x x coordinate of start position + * @param y y coordinate of start position + * @param maxWidth maximum width of text + */ public void strokeText(String text, double x, double y, double maxWidth) { graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth); } @@ -582,18 +679,52 @@ return graphicsEnvironmentImpl.getGlobalCompositeOperation(); } + /** + * Create a LinearGradient to use in Canvas. + * + * @param x0 x coordinate of start point + * @param y0 y coordinate of start point + * @param x1 x coordinate of end point + * @param y1 y coordinate of end point + * @return the gradient + */ public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) { return new Style.LinearGradient(x0, y0, x1, y1); } + /** + * Create an Image Pattern from a source Image and a repeat style. Possible + * Styles are repeat, repeat-x, repeat-y, or no-repeat. defaults to repeat + * + * @param image the Image + * @param repeat the repeat style + * @return the Pattern + */ public Pattern createPattern(Image image, String repeat) { return new Pattern(image, repeat); } + /** + * Create a RadialGradient + * + * @param x0 x Coordinate of starting circle + * @param y0 y Coordinate of starting circle + * @param r0 radius of starting circle + * @param x1 x coordinate of ending circle + * @param y1 y coordinate of ending circle + * @param r1 radius of ending circle + * @return the Gradient + */ public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) { return new RadialGradient(x0, y0, r0, x1, y1, r1); } + /** + * Convert this String Representation of a Color to a Color Object. + * + * @param webColor + * @return The Color represented by the input + */ public Color getWebColor(String webColor) { return new Style.Color(webColor); }