1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/javaquery/canvas/src/main/java/net/java/html/canvas/GraphicsContext.java Wed May 22 16:37:51 2013 +0200
1.3 @@ -0,0 +1,346 @@
1.4 +/**
1.5 + * Back 2 Browser Bytecode Translator Copyright (C) 2012 Jaroslav Tulach
1.6 + * <jaroslav.tulach@apidesign.org>
1.7 + *
1.8 + * This program is free software: you can redistribute it and/or modify it under
1.9 + * the terms of the GNU General Public License as published by the Free Software
1.10 + * Foundation, version 2 of the License.
1.11 + *
1.12 + * This program is distributed in the hope that it will be useful, but WITHOUT
1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.14 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.15 + * details.
1.16 + *
1.17 + * You should have received a copy of the GNU General Public License along with
1.18 + * this program. Look for COPYING file in the top folder. If not, see
1.19 + * http://opensource.org/licenses/GPL-2.0.
1.20 + */
1.21 +package net.java.html.canvas;
1.22 +
1.23 +import java.awt.Dimension;
1.24 +
1.25 +/**
1.26 + *
1.27 + * @author antonepple
1.28 + */
1.29 +public final class GraphicsContext {
1.30 +
1.31 + GraphicsEnvironment graphicsEnvironmentImpl;
1.32 +
1.33 + public GraphicsContext(GraphicsEnvironment graphicsEnvironment) {
1.34 + this.graphicsEnvironmentImpl = graphicsEnvironment;
1.35 + }
1.36 +
1.37 + public void arc(double centerX,
1.38 + double centerY,
1.39 + double startAngle,
1.40 + double radius,
1.41 + double endAngle,
1.42 + boolean ccw) {
1.43 + graphicsEnvironmentImpl.arc(centerX, centerY, startAngle, radius, endAngle, ccw);
1.44 + }
1.45 +
1.46 + public void arcTo(double x1,
1.47 + double y1,
1.48 + double x2,
1.49 + double y2,
1.50 + double r) {
1.51 + graphicsEnvironmentImpl.arcTo(x1, y1, x2, y2, r);
1.52 + }
1.53 +
1.54 + public boolean isPointInPath(double x, double y) {
1.55 + return graphicsEnvironmentImpl.isPointInPath(x, y);
1.56 + }
1.57 +
1.58 + public void fill() {
1.59 + graphicsEnvironmentImpl.fill();
1.60 + }
1.61 +
1.62 + public void stroke() {
1.63 + graphicsEnvironmentImpl.stroke();
1.64 + }
1.65 +
1.66 + public void beginPath() {
1.67 + graphicsEnvironmentImpl.beginPath();
1.68 + }
1.69 +
1.70 + public void closePath(){
1.71 + graphicsEnvironmentImpl.closePath();
1.72 + }
1.73 +
1.74 + public void clip(){
1.75 + graphicsEnvironmentImpl.clip();
1.76 + }
1.77 +
1.78 + public void moveTo(double x, double y){
1.79 + graphicsEnvironmentImpl.moveTo(x, y);
1.80 + }
1.81 +
1.82 + public void lineTo(double x, double y){
1.83 + graphicsEnvironmentImpl.lineTo(x, y);
1.84 + }
1.85 +
1.86 + public void quadraticCurveTo(double cpx, double cpy, double x, double y){
1.87 + graphicsEnvironmentImpl.quadraticCurveTo(cpx, cpy, x, y);
1.88 + }
1.89 +
1.90 + public void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y){
1.91 + graphicsEnvironmentImpl.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
1.92 + }
1.93 +
1.94 + public void fillRect(double x, double y, double width, double height){
1.95 + graphicsEnvironmentImpl.fillRect(x, y, width, height);
1.96 + }
1.97 +
1.98 + public void strokeRect(double x, double y, double width, double height){
1.99 + graphicsEnvironmentImpl.strokeRect(x, y, width, height);
1.100 + }
1.101 +
1.102 + public void clearRect(double x, double y, double width, double height){
1.103 + graphicsEnvironmentImpl.clearRect(x, y, width, height);
1.104 + }
1.105 +
1.106 + public void rect(double x, double y, double width, double height){
1.107 + graphicsEnvironmentImpl.rect(x, y, width, height);
1.108 + }
1.109 +
1.110 + public void save(){
1.111 + graphicsEnvironmentImpl.save();
1.112 + }
1.113 +
1.114 + public void restore(){
1.115 + graphicsEnvironmentImpl.restore();
1.116 + }
1.117 +
1.118 + public void rotate(double angle){
1.119 + graphicsEnvironmentImpl.rotate(angle);
1.120 + }
1.121 +
1.122 + public void transform(double a, double b, double c, double d, double e, double f){
1.123 + graphicsEnvironmentImpl.transform(a, b, c, d, e, f);
1.124 + }
1.125 +
1.126 + public void setTransform(double a, double b, double c, double d, double e, double f){
1.127 + graphicsEnvironmentImpl.setTransform(a, b, c, d, e, f);
1.128 + }
1.129 +
1.130 + public void translate(double x, double y){
1.131 + graphicsEnvironmentImpl.translate(x, y);
1.132 + }
1.133 +
1.134 + public void scale(double x, double y){
1.135 + graphicsEnvironmentImpl.scale(x, y);
1.136 + }
1.137 +
1.138 + public void drawImage(ImageData image, double x, double y){
1.139 + graphicsEnvironmentImpl.drawImage(image, x, y);
1.140 + }
1.141 +
1.142 + public void drawImage(ImageData image, double x, double y, double width, double height){
1.143 + graphicsEnvironmentImpl.drawImage(image, x, y, width, height);
1.144 + }
1.145 +
1.146 + public void drawImage(ImageData image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height){
1.147 + graphicsEnvironmentImpl.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);
1.148 + }
1.149 +
1.150 + public void setFillStyle(String style){
1.151 + graphicsEnvironmentImpl.setFillStyle(style);
1.152 + }
1.153 +
1.154 + public String getFillStyle(){
1.155 + return graphicsEnvironmentImpl.getFillStyle();
1.156 + }
1.157 +
1.158 + public void setFillStyle(Pattern style){
1.159 + graphicsEnvironmentImpl.setFillStyle(style);
1.160 + }
1.161 +
1.162 + public void setStrokeStyle(String style){
1.163 + graphicsEnvironmentImpl.setStrokeStyle(style);
1.164 + }
1.165 +
1.166 + public void setStrokeStyle(Pattern style){
1.167 + graphicsEnvironmentImpl.setStrokeStyle(style);
1.168 + }
1.169 +
1.170 + public void setShadowColor(String color){
1.171 + graphicsEnvironmentImpl.setShadowColor(color);
1.172 + }
1.173 +
1.174 + public void setShadowBlur(double blur){
1.175 + graphicsEnvironmentImpl.setShadowBlur(blur);
1.176 + }
1.177 +
1.178 + public void setShadowOffsetX(double x){
1.179 + graphicsEnvironmentImpl.setShadowOffsetX(x);
1.180 + }
1.181 +
1.182 + public void setShadowOffsetY(double y){
1.183 + graphicsEnvironmentImpl.setShadowOffsetY(y);
1.184 + }
1.185 +
1.186 + public String getStrokeStyle(){
1.187 + return graphicsEnvironmentImpl.getStrokeStyle();
1.188 + }
1.189 +
1.190 + public String getShadowColor(){
1.191 + return graphicsEnvironmentImpl.getShadowColor();
1.192 + }
1.193 +
1.194 + public double getShadowBlur(){
1.195 + return graphicsEnvironmentImpl.getShadowBlur();
1.196 + }
1.197 +
1.198 + public double getShadowOffsetX(){
1.199 + return graphicsEnvironmentImpl.getShadowOffsetX();
1.200 + }
1.201 +
1.202 + public double getShadowOffsetY(){
1.203 + return graphicsEnvironmentImpl.getShadowOffsetY();
1.204 + }
1.205 +
1.206 + public String getLineCap(){
1.207 + return graphicsEnvironmentImpl.getLineCap();
1.208 + }
1.209 +
1.210 + public void setLineCap(String style){
1.211 + graphicsEnvironmentImpl.setLineCap(style);
1.212 + }
1.213 +
1.214 + public String getLineJoin(){
1.215 + return graphicsEnvironmentImpl.getLineJoin();
1.216 + }
1.217 +
1.218 + public void setLineJoin(String style){
1.219 + graphicsEnvironmentImpl.setLineJoin(style);
1.220 + }
1.221 +
1.222 + public double getLineWidth(){
1.223 + return graphicsEnvironmentImpl.getLineWidth();
1.224 + }
1.225 +
1.226 + public void setLineWidth(double width){
1.227 + graphicsEnvironmentImpl.setLineWidth(width);
1.228 + }
1.229 +
1.230 + public double getMiterLimit(){
1.231 + return graphicsEnvironmentImpl.getMiterLimit();
1.232 + }
1.233 +
1.234 + public void setMiterLimit(double limit){
1.235 + graphicsEnvironmentImpl.setMiterLimit(limit);
1.236 + }
1.237 +
1.238 + public String getFont(){
1.239 + return graphicsEnvironmentImpl.getFont();
1.240 + }
1.241 +
1.242 + public void setFont(String font){
1.243 + graphicsEnvironmentImpl.setFont(font);
1.244 + }
1.245 +
1.246 + public String getTextAlign(){
1.247 + return graphicsEnvironmentImpl.getTextAlign();
1.248 + }
1.249 +
1.250 + public void setTextAlign(String textAlign){
1.251 + graphicsEnvironmentImpl.setTextAlign(textAlign);
1.252 + }
1.253 +
1.254 + public String getTextBaseline(){
1.255 + return graphicsEnvironmentImpl.getTextBaseline();
1.256 + }
1.257 +
1.258 + public void setTextBaseline(String textbaseline){
1.259 + graphicsEnvironmentImpl.setTextBaseline(textbaseline);
1.260 + }
1.261 +
1.262 + public void fillText(String text, double x, double y){
1.263 + graphicsEnvironmentImpl.fillText(text, x, y);
1.264 + }
1.265 +
1.266 + public void fillText(String text, double x, double y, double maxWidth){
1.267 + graphicsEnvironmentImpl.fillText(text, x, y, maxWidth);
1.268 + }
1.269 +
1.270 + public Dimension measureText(String text){
1.271 + return graphicsEnvironmentImpl.measureText(text);
1.272 + }
1.273 +
1.274 + public void strokeText(String text, double x, double y){
1.275 + graphicsEnvironmentImpl.strokeText(text, x, y);
1.276 + }
1.277 +
1.278 + public void strokeText(String text, double x, double y, double maxWidth){
1.279 + graphicsEnvironmentImpl.strokeText(text, x, y, maxWidth);
1.280 + }
1.281 +
1.282 + public ImageData createImageData(double x, double y){
1.283 + return graphicsEnvironmentImpl.createImageData(x, y);
1.284 + }
1.285 +
1.286 + public ImageData createImageData(ImageData imageData){
1.287 + return graphicsEnvironmentImpl.createImageData(imageData);
1.288 + }
1.289 +
1.290 + public ImageData getImageData(double x, double y, double width, double height){
1.291 + return graphicsEnvironmentImpl.getImageData(x, y, width, height);
1.292 + }
1.293 +
1.294 + public void putImageData(ImageData imageData, double x, double y){
1.295 + graphicsEnvironmentImpl.putImageData(imageData, x, y);
1.296 + }
1.297 +
1.298 + public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight){
1.299 + graphicsEnvironmentImpl.putImageData(imageData, x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
1.300 + }
1.301 +
1.302 + public void setGlobalAlpha(double alpha){
1.303 + graphicsEnvironmentImpl.setGlobalAlpha(alpha);
1.304 + }
1.305 +
1.306 + public double getGlobalAlpha(){
1.307 + return graphicsEnvironmentImpl.getGlobalAlpha();
1.308 + }
1.309 +
1.310 + public void setGlobalCompositeOperation(String operation){
1.311 + graphicsEnvironmentImpl.setGlobalCompositeOperation(operation);
1.312 + }
1.313 +
1.314 + public String getGlobalCompositeOperation(){
1.315 + return graphicsEnvironmentImpl.getGlobalCompositeOperation();
1.316 + }
1.317 +
1.318 + public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1){
1.319 + return graphicsEnvironmentImpl.createLinearGradient(x0, y0, x1, y1);
1.320 + }
1.321 +
1.322 + public Pattern createPattern(ImageData image, String repeat){
1.323 + return graphicsEnvironmentImpl.createPattern(image, repeat);
1.324 + }
1.325 +
1.326 + public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1){
1.327 + return graphicsEnvironmentImpl.createRadialGradient(x0, y0, r0, x1, y1, r1);
1.328 + }
1.329 +
1.330 + public ImageData getImageForPath(String path){
1.331 + return graphicsEnvironmentImpl.getImageForPath(path);
1.332 + }
1.333 +
1.334 + public int getHeight(){
1.335 + return graphicsEnvironmentImpl.getHeight();
1.336 + }
1.337 +
1.338 + public int getWidth(){
1.339 + return graphicsEnvironmentImpl.getWidth();
1.340 + }
1.341 +
1.342 + public void setHeight(int height){
1.343 + graphicsEnvironmentImpl.setHeight(height);
1.344 + }
1.345 +
1.346 + public void setWidth(int width){
1.347 + graphicsEnvironmentImpl.setWidth(width);
1.348 + }
1.349 +}