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