toni@1111: /** toni@1111: * Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach toni@1111: * toni@1111: * toni@1111: * This program is free software: you can redistribute it and/or modify it under toni@1111: * the terms of the GNU General Public License as published by the Free Software toni@1111: * Foundation, version 2 of the License. toni@1111: * toni@1111: * This program is distributed in the hope that it will be useful, but WITHOUT toni@1111: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS toni@1111: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more toni@1111: * details. toni@1111: * toni@1111: * You should have received a copy of the GNU General Public License along with toni@1111: * this program. Look for COPYING file in the top folder. If not, see toni@1111: * http://opensource.org/licenses/GPL-2.0. toni@521: */ toni@1109: package net.java.html.canvas; toni@521: toni@1150: import net.java.html.canvas.Style.Color; toni@1150: import net.java.html.canvas.Style.LinearGradient; toni@1150: import net.java.html.canvas.Style.Pattern; toni@1150: import net.java.html.canvas.Style.RadialGradient; toni@1136: import net.java.html.canvas.spi.GraphicsEnvironment; toni@1302: import org.apidesign.html.canvas.impl.CnvsAccssr; toni@521: toni@521: /** toni@1302: * A 2D Graphics Context similar to HTML5 or JavaFX GraphicsContext. Use this to toni@1302: * paint on your Canvas.s toni@1302: * toni@1109: * @author antonepple toni@521: */ toni@1128: public final class GraphicsContext { toni@1128: toni@1128: GraphicsEnvironment graphicsEnvironmentImpl; toni@1128: toni@1302: static { toni@1302: CnvsAccssr cnvsAccssr = new CnvsAccssr() { toni@1302: @Override toni@1302: public GraphicsContext create(GraphicsEnvironment environment) { toni@1302: return new GraphicsContext(environment); toni@1302: } toni@1302: }; toni@1302: } toni@1302: toni@1302: GraphicsContext(GraphicsEnvironment graphicsEnvironment) { toni@1128: this.graphicsEnvironmentImpl = graphicsEnvironment; toni@1128: } toni@521: toni@1302: /** toni@1302: * Adds path elements to the current path to make an arc. toni@1302: * toni@1302: * @param centerX the center x position of the arc. toni@1302: * @param centerY the center y position of the arc. toni@1302: * @param radius the radius of the arc. toni@1302: * @param endAngle teh endAngle of the arc toni@1302: * @param ccw the direction of the arc (counterclockwise) toni@1302: */ toni@1111: public void arc(double centerX, toni@1111: double centerY, toni@1111: double startAngle, toni@1111: double radius, toni@1111: double endAngle, toni@1128: boolean ccw) { toni@1128: graphicsEnvironmentImpl.arc(centerX, centerY, startAngle, radius, endAngle, ccw); toni@1128: } toni@521: toni@1302: /** toni@1302: * Adds segments to the current path to make an arc. toni@1302: * toni@1302: * @param x1 the X coordinate of the first point of the arc. toni@1302: * @param y1 the Y coordinate of the first point of the arc. toni@1302: * @param x2 the X coordinate of the second point of the arc. toni@1302: * @param y2 the Y coordinate of the second point of the arc. toni@1302: * @param radius the radius of the arc in the range {0.0-positive infinity}. toni@1302: */ toni@1111: public void arcTo(double x1, toni@1111: double y1, toni@1111: double x2, toni@1111: double y2, toni@1302: double radius) { toni@1302: graphicsEnvironmentImpl.arcTo(x1, y1, x2, y2, radius); toni@1128: } toni@521: toni@1302: /** toni@1302: * Returns true if the the given x,y point is inside the path. toni@1302: * toni@1302: * @param x the X coordinate to use for the check. toni@1302: * @param y the Y coordinate to use for the check. toni@1302: * @return true if the point given is inside the path, false otherwise. toni@1302: */ toni@1128: public boolean isPointInPath(double x, double y) { toni@1128: return graphicsEnvironmentImpl.isPointInPath(x, y); toni@1128: } toni@521: toni@1302: /** toni@1302: * Fills the path with the current fill paint. toni@1302: */ toni@1128: public void fill() { toni@1128: graphicsEnvironmentImpl.fill(); toni@1128: } toni@521: toni@1302: /** toni@1302: * Strokes the path with the current stroke paint. toni@1302: */ toni@1128: public void stroke() { toni@1128: graphicsEnvironmentImpl.stroke(); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Starts a Path toni@1302: */ toni@1128: public void beginPath() { toni@1128: graphicsEnvironmentImpl.beginPath(); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Closes the path. toni@1302: */ toni@1302: public void closePath() { toni@1128: graphicsEnvironmentImpl.closePath(); toni@1128: } toni@521: toni@1302: /** toni@1302: * Clips using the current path toni@1302: */ toni@1302: public void clip() { toni@1128: graphicsEnvironmentImpl.clip(); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Issues a move command for the current path to the given x,y coordinate. toni@1302: * toni@1302: * @param x0 the X position for the move to command. toni@1302: * @param y0 the Y position for the move to command. toni@1302: */ toni@1302: public void moveTo(double x, double y) { toni@1128: graphicsEnvironmentImpl.moveTo(x, y); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Adds segments to the current path to make a line at the given x,y toni@1302: * coordinate. toni@1302: * toni@1302: * @param x1 the X coordinate of the ending point of the line. toni@1302: * @param y1 the Y coordinate of the ending point of the line. toni@1302: */ toni@1302: public void lineTo(double x, double y) { toni@1128: graphicsEnvironmentImpl.lineTo(x, y); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Adds segments to the current path to make a quadratic curve. toni@1302: * toni@1302: * @param cpx the X coordinate of the control point toni@1302: * @param cpy the Y coordinate of the control point toni@1302: * @param x the X coordinate of the end point toni@1302: * @param y the Y coordinate of the end point toni@1302: */ toni@1302: public void quadraticCurveTo(double cpx, double cpy, double x, double y) { toni@1302: graphicsEnvironmentImpl.quadraticCurveTo(cpx, cpy, x, y); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Adds segments to the current path to make a cubic bezier curve. toni@1302: * toni@1302: * @param cp1x the X coordinate of first bezier control point. toni@1302: * @param cp1y the Y coordinate of the first bezier control point. toni@1302: * @param cp2x the X coordinate of the second bezier control point. toni@1302: * @param cp2y the Y coordinate of the second bezier control point. toni@1302: * @param x the X coordinate of the end point. toni@1302: * @param y the Y coordinate of the end point. toni@1302: */ toni@1302: public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y) { toni@1128: graphicsEnvironmentImpl.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Fills a rectangle using the current fill paint. toni@1302: * toni@1302: * @param x the X position of the upper left corner of the rectangle. toni@1302: * @param y the Y position of the upper left corner of the rectangle. toni@1302: * @param w the width of the rectangle. toni@1302: * @param h the height of the rectangle. toni@1302: */ toni@1302: public void fillRect(double x, double y, double width, double height) { toni@1128: graphicsEnvironmentImpl.fillRect(x, y, width, height); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Strokes a rectangle using the current stroke paint. toni@1302: * toni@1302: * @param x the X position of the upper left corner of the rectangle. toni@1302: * @param y the Y position of the upper left corner of the rectangle. toni@1302: * @param width the width of the rectangle. toni@1302: * @param height the height of the rectangle. toni@1302: */ toni@1302: public void strokeRect(double x, double y, double width, double height) { toni@1302: graphicsEnvironmentImpl.strokeRect(x, y, width, height); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Clears a portion of the canvas with a transparent color value. toni@1302: * toni@1302: * @param x X position of the upper left corner of the rectangle. toni@1302: * @param y Y position of the upper left corner of the rectangle. toni@1302: * @param width width of the rectangle. toni@1302: * @param height height of the rectangle. toni@1302: */ toni@1302: public void clearRect(double x, double y, double width, double height) { toni@1128: graphicsEnvironmentImpl.clearRect(x, y, width, height); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Clears a portion of the canvas with a transparent color value. toni@1302: * toni@1302: * @param x X position of the upper left corner of the rectangle. toni@1302: * @param y Y position of the upper left corner of the rectangle. toni@1302: * @param width width of the rectangle. toni@1302: * @param height height of the rectangle. toni@1302: */ toni@1302: public void rect(double x, double y, double width, double height) { toni@1128: graphicsEnvironmentImpl.rect(x, y, width, height); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Saves the following attributes onto a stack. toni@1302: * toni@1302: * This method does NOT alter the current state in any way. Also, not that toni@1302: * the current path is not saved. toni@1302: */ toni@1302: public void save() { toni@1128: graphicsEnvironmentImpl.save(); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Pops the state off of the stack, setting the following attributes to toni@1302: * their value at the time when that state was pushed onto the stack. If the toni@1302: * stack is empty then nothing is changed. toni@1302: * toni@1302: * toni@1302: */ toni@1302: public void restore() { toni@1128: graphicsEnvironmentImpl.restore(); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Rotates the current transform in degrees. toni@1302: * toni@1302: * @param angle value in degrees to rotate the current transform. toni@1302: */ toni@1302: public void rotate(double angle) { toni@1128: graphicsEnvironmentImpl.rotate(angle); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Concatenates the input with the current transform. toni@1302: * toni@1302: * @param mxx - the X coordinate scaling element of the 3x4 matrix toni@1302: * @param myx - the Y coordinate shearing element of the 3x4 matrix toni@1302: * @param mxy - the X coordinate shearing element of the 3x4 matrix toni@1302: * @param myy - the Y coordinate scaling element of the 3x4 matrix toni@1302: * @param mxt - the X coordinate translation element of the 3x4 matrix toni@1302: * @param myt - the Y coordinate translation element of the 3x4 matrix toni@1302: */ toni@1302: public void transform(double mxx, double myx, double mxy, double myy, double mxt, double myt) { toni@1302: graphicsEnvironmentImpl.transform(mxx, myx, mxy, myy, mxt, myt); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Concatenates the input with the current transform. toni@1302: * toni@1302: * @param mxx - the X coordinate scaling element of the 3x4 matrix toni@1302: * @param myx - the Y coordinate shearing element of the 3x4 matrix toni@1302: * @param mxy - the X coordinate shearing element of the 3x4 matrix toni@1302: * @param myy - the Y coordinate scaling element of the 3x4 matrix toni@1302: * @param mxt - the X coordinate translation element of the 3x4 matrix toni@1302: * @param myt - the Y coordinate translation element of the 3x4 matrix toni@1302: */ toni@1302: public void setTransform(double mxx, double myx, double mxy, double myy, double mxt, double myt) { toni@1302: graphicsEnvironmentImpl.setTransform(mxx, myx, mxy, myy, mxt, myt); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Translates the current transform by x, y. toni@1302: * toni@1302: * @param x value to translate along the x axis. toni@1302: * @param y value to translate along the y axis. toni@1302: */ toni@1302: public void translate(double x, double y) { toni@1128: graphicsEnvironmentImpl.translate(x, y); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Scales the current transform by x, y. toni@1302: * toni@1302: * @param x value to scale in the x axis. toni@1302: * @param y value to scale in the y axis. toni@1302: */ toni@1302: public void scale(double x, double y) { toni@1128: graphicsEnvironmentImpl.scale(x, y); toni@1128: } toni@1109: toni@1302: /** toni@1302: * Draws an image at the given x, y position using the width and height of toni@1302: * the given image. toni@1302: * toni@1302: * @param img the image to be drawn. toni@1302: * @param x the X coordinate on the destination for the upper left of the toni@1302: * image. toni@1302: * @param y the Y coordinate on the destination for the upper left of the toni@1302: * image. toni@1302: */ toni@1302: public void drawImage(Image image, double x, double y) { toni@1144: Object nativeImage = graphicsEnvironmentImpl.drawImage(image, x, y, image.getCached()); toni@1144: image.cache(nativeImage); toni@1144: } toni@1144: toni@1302: /** toni@1302: * Draws an image into the given destination rectangle of the canvas. The toni@1302: * Image is scaled to fit into the destination rectagnle. toni@1302: * toni@1302: * @param img the image to be drawn. toni@1302: * @param x the X coordinate on the destination for the upper left of the toni@1302: * image. toni@1302: * @param y the Y coordinate on the destination for the upper left of the toni@1302: * image. toni@1302: * @param width the width of the destination rectangle. toni@1302: * @param height the height of the destination rectangle. toni@1302: */ toni@1302: public void drawImage(Image image, double x, double y, double width, double height) { toni@1144: Object nativeImage = graphicsEnvironmentImpl.drawImage(image, x, y, width, height, image.getCached()); toni@1144: image.cache(nativeImage); toni@1144: } toni@1144: toni@1302: /** toni@1302: * Draws the current source rectangle of the given image to the given toni@1302: * destination rectangle of the Canvas. toni@1302: * toni@1302: * @param img the image to be drawn. toni@1302: * @param sx the source rectangle's X coordinate position. toni@1302: * @param sy the source rectangle's Y coordinate position. toni@1302: * @param sw the source rectangle's width. toni@1302: * @param sh the source rectangle's height. toni@1302: * @param dx the destination rectangle's X coordinate position. toni@1302: * @param dy the destination rectangle's Y coordinate position. toni@1302: * @param dw the destination rectangle's width. toni@1302: * @param dh the destination rectangle's height. toni@1302: */ toni@1302: public void drawImage(Image image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh) { toni@1302: Object nativeImage = graphicsEnvironmentImpl.drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh, image.getCached()); toni@1144: image.cache(nativeImage); toni@1144: } toni@1302: toni@1302: /** toni@1302: * Merges two images drawing one on top of the other and returning the toni@1302: * result. toni@1302: * toni@1302: * @param a the lower Image toni@1302: * @param b the upper Image toni@1302: * @return toni@1302: */ toni@1302: public Image merge(Image a, Image b) { toni@1302: if (a.getCached() == null) { toni@1263: drawImage(a, 0, 0); toni@1263: } toni@1302: if (b.getCached() == null) { toni@1263: drawImage(b, 0, 0); toni@1263: } toni@1302: Object nativeImage = graphicsEnvironmentImpl.mergeImages(a, b, a.getCached(), b.getCached()); toni@1263: Image merged = Image.create("should add real path here"); toni@1263: merged.cache(nativeImage); toni@1263: return merged; toni@1263: } toni@1109: toni@1302: // public void setShadowColor(String color) { toni@1302: // graphicsEnvironmentImpl.setShadowColor(color); toni@1302: // } toni@1302: // toni@1302: // public void setShadowBlur(double blur) { toni@1302: // graphicsEnvironmentImpl.setShadowBlur(blur); toni@1302: // } toni@1302: // toni@1302: // public void setShadowOffsetX(double x) { toni@1302: // graphicsEnvironmentImpl.setShadowOffsetX(x); toni@1302: // } toni@1302: // toni@1302: // public void setShadowOffsetY(double y) { toni@1302: // graphicsEnvironmentImpl.setShadowOffsetY(y); toni@1302: // } toni@1302: // toni@1302: // public String getShadowColor() { toni@1302: // return graphicsEnvironmentImpl.getShadowColor(); toni@1302: // } toni@1302: // toni@1302: // public double getShadowBlur() { toni@1302: // return graphicsEnvironmentImpl.getShadowBlur(); toni@1302: // } toni@1302: // toni@1302: // public double getShadowOffsetX() { toni@1302: // return graphicsEnvironmentImpl.getShadowOffsetX(); toni@1302: // } toni@1302: // toni@1302: // public double getShadowOffsetY() { toni@1302: // return graphicsEnvironmentImpl.getShadowOffsetY(); toni@1302: // } toni@1302: public String getLineCap() { toni@1128: return graphicsEnvironmentImpl.getLineCap(); toni@1128: } toni@1109: toni@1302: public void setLineCap(String style) { toni@1128: graphicsEnvironmentImpl.setLineCap(style); toni@1128: } toni@1109: toni@1302: public String getLineJoin() { toni@1128: return graphicsEnvironmentImpl.getLineJoin(); toni@1128: } toni@1109: toni@1302: public void setLineJoin(String style) { toni@1128: graphicsEnvironmentImpl.setLineJoin(style); toni@1128: } toni@1109: toni@1302: public double getLineWidth() { toni@1128: return graphicsEnvironmentImpl.getLineWidth(); toni@1128: } toni@1109: toni@1302: public void setLineWidth(double width) { toni@1128: graphicsEnvironmentImpl.setLineWidth(width); toni@1128: } toni@1109: toni@1302: public double getMiterLimit() { toni@1128: return graphicsEnvironmentImpl.getMiterLimit(); toni@1128: } toni@1109: toni@1302: public void setMiterLimit(double limit) { toni@1128: graphicsEnvironmentImpl.setMiterLimit(limit); toni@1128: } toni@1302: toni@1302: public void setFillStyle(Style style) { toni@1141: Object nativeFillStyle = graphicsEnvironmentImpl.setFillStyle(style, style.getCached()); toni@1141: style.cache(nativeFillStyle); toni@1141: } toni@1109: toni@1302: public String getFont() { toni@1128: return graphicsEnvironmentImpl.getFont(); toni@1128: } toni@1109: toni@1302: public void setFont(String font) { toni@1128: graphicsEnvironmentImpl.setFont(font); toni@1128: } toni@1302: toni@1302: public void setStrokeStyle(Style style) { toni@1141: Object nativeStrokeStyle = graphicsEnvironmentImpl.setStrokeStyle(style, style.getCached()); toni@1141: style.cache(nativeStrokeStyle); toni@1141: } toni@1109: toni@1302: public String getTextAlign() { toni@1128: return graphicsEnvironmentImpl.getTextAlign(); toni@1128: } toni@521: toni@1302: public void setTextAlign(String textAlign) { toni@1128: graphicsEnvironmentImpl.setTextAlign(textAlign); toni@1128: } toni@521: toni@1302: public String getTextBaseline() { toni@1128: return graphicsEnvironmentImpl.getTextBaseline(); toni@1128: } toni@521: toni@1302: public void setTextBaseline(String textbaseline) { toni@1128: graphicsEnvironmentImpl.setTextBaseline(textbaseline); toni@1128: } toni@521: toni@1302: public void fillText(String text, double x, double y) { toni@1128: graphicsEnvironmentImpl.fillText(text, x, y); toni@1128: } toni@521: toni@1302: public void fillText(String text, double x, double y, double maxWidth) { toni@1128: graphicsEnvironmentImpl.fillText(text, x, y, maxWidth); toni@1128: } toni@521: toni@1302: public Dimension measureText(String text) { toni@1128: return graphicsEnvironmentImpl.measureText(text); toni@1128: } toni@1111: toni@1302: public void strokeText(String text, double x, double y) { toni@1128: graphicsEnvironmentImpl.strokeText(text, x, y); toni@1128: } toni@1111: toni@1302: public void strokeText(String text, double x, double y, double maxWidth) { toni@1128: graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth); toni@1128: } toni@1111: toni@1302: // public ImageData createPixelMap(double x, double y) { toni@1302: // return graphicsEnvironmentImpl.createPixelMap(x, y); toni@1302: // } toni@1302: // toni@1302: // public ImageData createPixelMap(ImageData pixelMap) { toni@1302: // return graphicsEnvironmentImpl.createPixelMap(pixelMap); toni@1302: // } toni@1302: // toni@1302: // public ImageData getSnapshot(double x, double y, double width, double height) { toni@1302: // return graphicsEnvironmentImpl.getPixelMap(x, y, width, height); toni@1302: // } toni@1302: // toni@1302: // public void drawPixelMap(ImageData pixelMap, double x, double y) { toni@1302: // graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y); toni@1302: // } toni@1302: // toni@1302: // public void drawPixelMap(ImageData pixelMap, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) { toni@1302: // graphicsEnvironmentImpl.putPixelMap(pixelMap, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight); toni@1302: // } toni@1302: /** toni@1302: * Sets the global alpha of the current state. toni@1302: * toni@1302: * @param alpha value in the range {@code 0.0-1.0}. The value is clamped if toni@1302: * it is out of range. toni@1302: */ toni@1302: public void setGlobalAlpha(double alpha) { toni@1128: graphicsEnvironmentImpl.setGlobalAlpha(alpha); toni@1128: } toni@1111: toni@1302: /** toni@1302: * Gets the current global alpha. toni@1302: * toni@1302: * @return the current global alpha. toni@1302: */ toni@1302: public double getGlobalAlpha() { toni@1128: return graphicsEnvironmentImpl.getGlobalAlpha(); toni@1128: } toni@1111: toni@1302: /** toni@1302: * Sets the global blend mode. toni@1302: * toni@1302: * @param op the BlendMode that will be set. toni@1302: */ toni@1302: public void setGlobalCompositeOperation(String operation) { toni@1128: graphicsEnvironmentImpl.setGlobalCompositeOperation(operation); toni@1128: } toni@1111: toni@1302: /** toni@1302: * Gets the global blend mode. toni@1302: * toni@1302: * @return the global BlendMode of the current state. toni@1302: */ toni@1302: public String getGlobalCompositeOperation() { toni@1128: return graphicsEnvironmentImpl.getGlobalCompositeOperation(); toni@1128: } toni@1111: toni@1302: public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) { toni@1150: return new Style.LinearGradient(x0, y0, x1, y1); toni@1128: } toni@1111: toni@1302: public Pattern createPattern(Image image, String repeat) { toni@1144: return new Pattern(image, repeat); toni@1144: } toni@1111: toni@1302: public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) { toni@1131: return new RadialGradient(x0, y0, r0, x1, y1, r1); toni@1128: } toni@1302: toni@1302: public Color getWebColor(String webColor) { toni@1150: return new Style.Color(webColor); toni@1150: } toni@1111: toni@1302: /** toni@1302: * Get the height of this GraphicsContext (which should be the same as the toni@1302: * enclosing canvas height) toni@1302: * toni@1302: * @return the height of this GraphicsContext toni@1302: */ toni@1302: public int getHeight() { toni@1128: return graphicsEnvironmentImpl.getHeight(); toni@1128: } toni@1111: toni@1302: /** toni@1302: * Get the width of this GraphicsContext (which should be the same as the toni@1302: * enclosing canvas height) toni@1302: * toni@1302: * @return the width of this GraphicsContext toni@1302: */ toni@1302: public int getWidth() { toni@1128: return graphicsEnvironmentImpl.getWidth(); toni@1128: } toni@1111: toni@1302: // public void setHeight(int height) { toni@1302: // graphicsEnvironmentImpl.setHeight(height); toni@1302: // } toni@1302: // toni@1302: // public void setWidth(int width) { toni@1302: // graphicsEnvironmentImpl.setWidth(width); toni@1302: // } toni@1302: /** toni@1302: * Fill a circle with a center position of centerX, centerY and the toni@1302: * specified radius. toni@1302: * toni@1302: * @param centerX toni@1302: * @param centerY toni@1302: * @param radius toni@1302: */ toni@1302: public void fillCircle(float centerX, float centerY, float radius) { toni@1302: graphicsEnvironmentImpl.arc(centerX, centerY, radius, 0, Math.PI * 2, false); toni@1128: } toni@1128: toni@1302: /** toni@1302: * Fills a polygon with the given points using the currently set fill paint. toni@1302: * toni@1302: * @param x_coord array containing the x coordinates of the polygon's toni@1302: * points. toni@1302: * @param y_coord array containing the y coordinates of the polygon's toni@1302: * points. toni@1302: * @param vertexCount the number of points that make the polygon. toni@1302: */ toni@1263: public void fillPolygon(double[] x_coord, double[] y_coord, int vertexCount) { toni@1302: if (vertexCount >= 1 && x_coord != null && x_coord.length >= vertexCount && y_coord != null && y_coord.length >= vertexCount) { toni@1302: graphicsEnvironmentImpl.beginPath(); toni@1302: } toni@1263: graphicsEnvironmentImpl.moveTo(x_coord[0], y_coord[0]); toni@1263: for (int i = 1; i < vertexCount; i++) { toni@1263: graphicsEnvironmentImpl.lineTo(x_coord[i], y_coord[i]); toni@1302: toni@1263: } toni@1263: graphicsEnvironmentImpl.closePath(); toni@1263: graphicsEnvironmentImpl.fill(); toni@1263: graphicsEnvironmentImpl.stroke(); toni@1263: } toni@521: }