# HG changeset patch # User toni.epple@eppleton.de # Date 1369145452 -7200 # Node ID a3d504d7e588d5912306cd535f3e2bf9700286af # Parent 4613a6fe2862cbe59073139776d0605ab7a966ef Refactored names to unpopular naming scheme, because (a) bck2brwsr Canvas implementation must be named Canvas due to mapping in bck2brwsr and I don't want interface and impl to have the same name. (b) with the "I" prefix at least it's consistent, even if nobody uses that anymore. (c) names are the same as in HTML5 Canvas Javascript API, so it's more familiar... diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/pom.xml --- a/javaquery/api/pom.xml Tue May 21 16:07:59 2013 +0200 +++ b/javaquery/api/pom.xml Tue May 21 16:10:52 2013 +0200 @@ -80,11 +80,11 @@ launcher.http ${project.version} test - + net.java.html canvas - ${project.version} - + 0.8-SNAPSHOT + diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Canvas.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Canvas.java Tue May 21 16:10:52 2013 +0200 @@ -0,0 +1,70 @@ +/** + * 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 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. + */ +package org.apidesign.bck2brwsr.htmlpage.api; + +import net.java.html.canvas.ICanvas; +import net.java.html.canvas.IGraphicsContext; +import org.apidesign.bck2brwsr.core.JavaScriptBody; +import static org.apidesign.bck2brwsr.htmlpage.api.Element.getAttribute; + +/** + * + * @author Anton Epple + */ +public class Canvas extends Element implements ICanvas{ + + public Canvas(String id) { + super(id); + } + + @Override + public void setHeight(int height) { + setAttribute(this, "height", height); + } + + @Override + public int getHeight() { + Object ret = getAttribute(this, "height"); + return (ret instanceof Number) ? ((Number)ret).intValue(): Integer.MIN_VALUE; + } + + @Override + public void setWidth(int width) { + setAttribute(this, "width", width); + } + + @Override + public int getWidth() { + Object ret = getAttribute(this, "width"); + return (ret instanceof Number) ? ((Number)ret).intValue(): Integer.MIN_VALUE; + } + + @JavaScriptBody( + args = {"el"}, + body = "var e = window.document.getElementById(el._id());\n" + + "return e.getContext('2d');\n") + private native static Object getContextImpl(Canvas el); + + public IGraphicsContext getContext() { + return new GraphicsContext(getContextImpl(this)); + } + + @Override + void dontSubclass() { + } +} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java Tue May 21 16:10:52 2013 +0200 @@ -0,0 +1,425 @@ +/** + * 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 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. + */ +package org.apidesign.bck2brwsr.htmlpage.api; + + +import net.java.html.canvas.IGraphicsContext; +import net.java.html.canvas.IImage; +import net.java.html.canvas.IImageData; +import net.java.html.canvas.ILinearGradient; +import net.java.html.canvas.IPattern; +import net.java.html.canvas.IRadialGradient; +import net.java.html.canvas.ITextMetrics; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + + +/** + * + * @author Anton Epple + */ +public class GraphicsContext implements IGraphicsContext { + + Object context; + + GraphicsContext(Object contextImpl) { + this.context = contextImpl; + } + + @JavaScriptBody(args = {"centerx", "centery", "radius", "startangle", "endangle", "ccw"}, + body = "this._context().arc(centerx,centery, radius, startangle, endangle,ccw);") + @Override + public native void arc(double centerX, + double centerY, + double startAngle, + double radius, + double endAngle, + boolean ccw); + + @JavaScriptBody(args = {"x1", "y1", "x2", "y2", "r"}, + body = "this._context().arcTo(x1,y1,x2,y2,r);") + @Override + public native void arcTo(double x1, + double y1, + double x2, + double y2, + double r); + + @JavaScriptBody(args = {"x", "y"}, + body = "return this._context().isPointInPath(x,y);") + @Override + public native boolean isPointInPath(double x, double y); + + @JavaScriptBody(args = {}, body = "this._context().fill();") + @Override + public native void fill(); + + @JavaScriptBody(args = {}, body = "this._context().stroke();") + @Override + public native void stroke(); + + @JavaScriptBody(args = {}, body = "this._context().beginPath();") + @Override + public native void beginPath(); + + @JavaScriptBody(args = {}, body = "this._context().closePath();") + @Override + public native void closePath(); + + @JavaScriptBody(args = {}, body = "this._context().clip();") + @Override + public native void clip(); + + @JavaScriptBody(args = {"x", "y"}, body = "this._context().moveTo(x,y);") + @Override + public native void moveTo(double x, double y); + + @JavaScriptBody(args = {"x", "y"}, body = "this._context().lineTo(x,y);") + @Override + public native void lineTo(double x, double y); + + @JavaScriptBody(args = {"cpx", "cpy", "x", "y"}, body = "this._context().quadraticCurveTo(cpx,cpy,x,y);") + @Override + public native void quadraticCurveTo(double cpx, double cpy, double x, double y); + + @JavaScriptBody(args = {"cp1x", "cp1y", "cp2x", "cp2y", "x", "y"}, + body = "this._context().bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y);") + @Override + public native void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); + + @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().fillRect(x,y,width,height);") + @Override + public native void fillRect(double x, double y, double width, double height); + + @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().strokeRect(x,y,width,height);") + @Override + public native void strokeRect(double x, double y, double width, double height); + + @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().clearRect(x,y,width,height);") + @Override + public native void clearRect(double x, double y, double width, double height); + + @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().rectect(x,y,width,height);") + @Override + public native void rect(double x, double y, double width, double height); + + @JavaScriptBody(args = {}, body = "this._context().save();") + @Override + public native void save(); + + @JavaScriptBody(args = {}, body = "this._context().restore();") + @Override + public native void restore(); + + @JavaScriptBody(args = {"angle"}, body = "this._context().rotate(angle);") + @Override + public native void rotate(double angle); + + @JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this._context().transform(a,b,c,d,e,f);") + @Override + public native void transform(double a, double b, double c, double d, double e, double f); + + @JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this._context().setTransform(a,b,c,d,e,f);") + @Override + public native void setTransform(double a, double b, double c, double d, double e, double f); + + @JavaScriptBody(args = {"x", "y"}, body = "this._context().translate(x,y);") + @Override + public native void translate(double x, double y); + + @JavaScriptBody(args = {"x", "y"}, body = "this._context().scale(x,y);") + @Override + public native void scale(double x, double y); + + @Override + public void drawImage(IImage image, double x, double y) { + drawImageImpl(context, Element.getElementById((Image) image), x, y); + } + + @Override + public void drawImage(IImage image, double x, double y, double width, double height) { + drawImageImpl(context, Element.getElementById((Image) image), x, y, width, height); + } + + @Override + public void drawImage(IImage image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) { + drawImageImpl(context, Element.getElementById((Image) image), sx, sy, sWidth, sHeight, x, y, width, height); + } + + @JavaScriptBody(args = {"ctx", "img", "x", "y", "width", "height"}, body = "ctx.drawImage(img,x,y,width,height);") + private native static void drawImageImpl(Object ctx, Object img, double x, double y, double width, double height); + + @JavaScriptBody(args = {"ctx", "img", "sx", "sy", "swidth", "sheight", "x", "y", "width", "height"}, body = "ctx.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);") + 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); + + @JavaScriptBody(args = {"ctx", "img", "x", "y"}, body = "ctx.drawImage(img,x,y);") + private native static void drawImageImpl(Object ctx, Object img, double x, double y); + + @JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style.valueOf();") + @Override + public native void setFillStyle(String style); + + @JavaScriptBody(args = {}, body = "return this._context().fillStyle;") + @Override + public native String getFillStyle(); + + @Override + public void setFillStyle(ILinearGradient style) { + setFillStyleImpl(context, ((LinearGradient) style).object()); + } + + @Override + public void setFillStyle(IRadialGradient style) { + setFillStyleImpl(context, ((RadialGradient) style).object()); + } + + @Override + public void setFillStyle(IPattern style) { + setFillStyleImpl(context, ((Pattern) style).object()); + } + + @JavaScriptBody(args = {"context", "obj"}, body = "context.fillStyle=obj;") + private native void setFillStyleImpl(Object context, Object obj); + + @JavaScriptBody(args = {"style"}, body = "this._context().strokeStyle=style.valueOf();") + @Override + public native void setStrokeStyle(String style); + + @Override + public void setStrokeStyle(ILinearGradient style) { + setStrokeStyleImpl(context, ((LinearGradient) style).object()); + } + + @Override + public void setStrokeStyle(IRadialGradient style) { + setStrokeStyleImpl(context, ((RadialGradient) style).object()); + } + + @JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style;") + @Override + public void setStrokeStyle(IPattern style) { + setStrokeStyleImpl(context, ((LinearGradient) style).object()); + } + + @JavaScriptBody(args = {"context", "obj"}, body = "context.strokeStyle=obj;") + private native void setStrokeStyleImpl(Object context, Object obj); + + @JavaScriptBody(args = {"color"}, body = "this._context().shadowColor=color.valueOf();") + @Override + public native void setShadowColor(String color); + + @JavaScriptBody(args = {"blur"}, body = "this._context().shadowBlur=blur;") + @Override + public native void setShadowBlur(double blur); + + @JavaScriptBody(args = {"x"}, body = "this._context().shadowOffsetX=x;") + @Override + public native void setShadowOffsetX(double x); + + @JavaScriptBody(args = {"y"}, body = "this._context().shadowOffsetY=y;") + @Override + public native void setShadowOffsetY(double y); + + @JavaScriptBody(args = {}, body = "return this._context().strokeStyle;") + @Override + public native String getStrokeStyle(); + + @JavaScriptBody(args = {}, body = "return this._context().shadowColor;") + @Override + public native String getShadowColor(); + + @JavaScriptBody(args = {}, body = "return this._context().shadowBlur;") + @Override + public native double getShadowBlur(); + + @JavaScriptBody(args = {}, body = "return this._context().shadowOffsetX;") + @Override + public native double getShadowOffsetX(); + + @JavaScriptBody(args = {}, body = "return this._context().shadowOffsetY;") + @Override + public native double getShadowOffsetY(); + + @JavaScriptBody(args = {}, body = "return this._context().lineCap;") + @Override + public native String getLineCap(); + + @JavaScriptBody(args = {"style"}, body = "this._context().lineCap=style.valueOf();") + @Override + public native void setLineCap(String style); + + @JavaScriptBody(args = {}, body = "return this._context().lineJoin;") + @Override + public native String getLineJoin(); + + @JavaScriptBody(args = {"style"}, body = "this._context().lineJoin=style.valueOf();") + @Override + public native void setLineJoin(String style); + + @JavaScriptBody(args = {}, body = "return this._context().lineWidth;") + @Override + public native double getLineWidth(); + + @JavaScriptBody(args = {"width"}, body = "this._context().lineWidth=width;") + @Override + public native void setLineWidth(double width); + + @JavaScriptBody(args = {}, body = "return this._context().miterLimit;") + @Override + public native double getMiterLimit(); + + @JavaScriptBody(args = {"limit"}, body = "this._context().miterLimit=limit;") + @Override + public native void setMiterLimit(double limit); + + @JavaScriptBody(args = {}, body = "return this._context().font;") + @Override + public native String getFont(); + + @JavaScriptBody(args = {"font"}, body = "this._context().font=font.valueOf();") + @Override + public native void setFont(String font); + + @JavaScriptBody(args = {}, body = "return this._context().textAlign;") + @Override + public native String getTextAlign(); + + @JavaScriptBody(args = {"textalign"}, body = "this._context().textAlign=textalign.valueOf();") + @Override + public native void setTextAlign(String textAlign); + + @JavaScriptBody(args = {}, body = "return this._context().textBaseline;") + @Override + public native String getTextBaseline(); + + @JavaScriptBody(args = {"textbaseline"}, body = "this._context().textBaseline=textbaseline.valueOf();") + @Override + public native void setTextBaseline(String textbaseline); + + @JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().fillText(text,x,y);") + @Override + public native void fillText(String text, double x, double y); + + @JavaScriptBody(args = {"text", "x", "y", "maxwidth"}, body = "this._context().fillText(text,x,y,maxwidth);") + @Override + public void fillText(String text, double x, double y, double maxWidth) { + } + + @Override + public ITextMetrics measureText(String text) { + return new TextMetrics(measureTextImpl(text)); + } + + @JavaScriptBody(args = {"text"}, + body = "return this._context().measureText(text);") + private native Object measureTextImpl(String text); + + @JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().strokeText(text,x,y);") + @Override + public native void strokeText(String text, double x, double y); + + @JavaScriptBody(args = {"text", "x", "y", "maxWidth"}, body = "this._context().strokeText(text,x,y,maxWidth);") + @Override + public native void strokeText(String text, double x, double y, double maxWidth); + + @Override + public IImageData createImageData(double x, double y) { + return new ImageData(createImageDataImpl(x, y)); + } + + @JavaScriptBody(args = {"x", "y"}, + body = "return this._context().createImageData(x,y);") + private native Object createImageDataImpl(double x, double y); + + @Override + public IImageData createImageData(IImageData imageData) { + return new ImageData(createImageDataImpl(imageData.getWidth(), imageData.getHeight())); + } + + @Override + public IImageData getImageData(double x, double y, double width, double height) { + return new ImageData(getImageDataImpl(x, y, width, height)); + } + + @JavaScriptBody(args = {"x", "y", "width", "height"}, + body = "return this._context().getImageData(x,y,width,height);") + private native Object getImageDataImpl(double x, double y, double width, double height); + + @Override + public void putImageData(IImageData imageData, double x, double y) { + putImageDataImpl(((ImageData) imageData).object(), x, y); + } + + @JavaScriptBody(args = {"imageData", "x", "y"}, + body = "this._context().putImageData(imageData,x,y);") + private native void putImageDataImpl(Object imageData, double x, double y); + + @Override + public void putImageData(IImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) { + putImageDataImpl(((ImageData) imageData).object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight); + } + + @JavaScriptBody(args = {"imageData", "x", "y", "dirtyx", "dirtyy", "dirtywidth", "dirtyheight"}, + body = "this._context().putImageData(imageData,x,y, dirtyx, dirtyy, dirtywidth,dirtyheight);") + private native void putImageDataImpl(Object imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight); + + @JavaScriptBody(args = {"alpha"}, body = "this._context().globalAlpha=alpha;") + @Override + public native void setGlobalAlpha(double alpha); + + @JavaScriptBody(args = {}, body = "return this._context().globalAlpha;") + @Override + public native double getGlobalAlpha(); + + @JavaScriptBody(args = {"operation"}, body = "this._context().globalCompositeOperation=operation.valueOf();") + @Override + public native void setGlobalCompositeOperation(String operation); + + @JavaScriptBody(args = {}, body = "return this._context().globalCompositeOperation;") + @Override + public native String getGlobalCompositeOperation(); + + @Override + public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) { + return new LinearGradient(createLinearGradientImpl(context, x0, y0, x1, y1)); + } + + @JavaScriptBody(args = {"context", "x0", "y0", "x1", "y1"}, body = "return context.createLinearGradient(x0,y0,x1,y1);") + private native Object createLinearGradientImpl(Object context, double x0, double y0, double x1, double y1); + + @Override + public IPattern createPattern(IImage image, String repeat) { + return new Pattern(createPatternImpl(context, image, repeat)); + } + + @JavaScriptBody(args = {"context", "image", "repeat"}, body = "return context.createPattern(image, repeat);") + private static native Object createPatternImpl(Object context, IImage image, String repeat); + + @Override + public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) { + return new RadialGradient(createRadialGradientImpl(context, x0, y0, r0, x1, y1, r1)); + } + + @JavaScriptBody(args = {"context", "x0", "y0", "r0", "x1", "y1", "r1"}, body = "return context.createRadialGradient(x0,y0,r0,x1,y1,r1);") + private static native Object createRadialGradientImpl(Object context, double x0, double y0, double r0, double x1, double y1, double r1); + + @JavaScriptBody(args = {"path"}, body = "var b = new Image(); b.src=path; return b;") + @Override + public IImage getImageForPath(String path) { + throw new UnsupportedOperationException("getImageForPath is not yet supported"); + } +} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Canvas.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Canvas.java Tue May 21 16:07:59 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -/** - * 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 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. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import net.java.html.canvas.Canvas; -import net.java.html.canvas.GraphicsContext; -import org.apidesign.bck2brwsr.core.JavaScriptBody; -import static org.apidesign.bck2brwsr.htmlpage.api.Element.getAttribute; - -/** - * - * @author Anton Epple - */ -public class HTML5Canvas extends Element implements Canvas{ - - public HTML5Canvas(String id) { - super(id); - } - - @Override - public void setHeight(int height) { - setAttribute(this, "height", height); - } - - @Override - public int getHeight() { - Object ret = getAttribute(this, "height"); - return (ret instanceof Number) ? ((Number)ret).intValue(): Integer.MIN_VALUE; - } - - @Override - public void setWidth(int width) { - setAttribute(this, "width", width); - } - - @Override - public int getWidth() { - Object ret = getAttribute(this, "width"); - return (ret instanceof Number) ? ((Number)ret).intValue(): Integer.MIN_VALUE; - } - - @JavaScriptBody( - args = {"el"}, - body = "var e = window.document.getElementById(el._id());\n" - + "return e.getContext('2d');\n") - private native static Object getContextImpl(HTML5Canvas el); - - @Override - public GraphicsContext getContext() { - return new HTML5GraphicsContext(getContextImpl(this)); - } - - @Override - void dontSubclass() { - } -} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5GraphicsContext.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5GraphicsContext.java Tue May 21 16:07:59 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,423 +0,0 @@ -/** - * 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 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. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import net.java.html.canvas.GraphicsContext; -import net.java.html.canvas.Image; -import net.java.html.canvas.ImageData; -import net.java.html.canvas.LinearGradient; -import net.java.html.canvas.Pattern; -import net.java.html.canvas.RadialGradient; -import net.java.html.canvas.TextMetrics; -import org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class HTML5GraphicsContext implements GraphicsContext { - - Object context; - - HTML5GraphicsContext(Object contextImpl) { - this.context = contextImpl; - } - - @JavaScriptBody(args = {"centerx", "centery", "radius", "startangle", "endangle", "ccw"}, - body = "this._context().arc(centerx,centery, radius, startangle, endangle,ccw);") - @Override - public native void arc(double centerX, - double centerY, - double startAngle, - double radius, - double endAngle, - boolean ccw); - - @JavaScriptBody(args = {"x1", "y1", "x2", "y2", "r"}, - body = "this._context().arcTo(x1,y1,x2,y2,r);") - @Override - public native void arcTo(double x1, - double y1, - double x2, - double y2, - double r); - - @JavaScriptBody(args = {"x", "y"}, - body = "return this._context().isPointInPath(x,y);") - @Override - public native boolean isPointInPath(double x, double y); - - @JavaScriptBody(args = {}, body = "this._context().fill();") - @Override - public native void fill(); - - @JavaScriptBody(args = {}, body = "this._context().stroke();") - @Override - public native void stroke(); - - @JavaScriptBody(args = {}, body = "this._context().beginPath();") - @Override - public native void beginPath(); - - @JavaScriptBody(args = {}, body = "this._context().closePath();") - @Override - public native void closePath(); - - @JavaScriptBody(args = {}, body = "this._context().clip();") - @Override - public native void clip(); - - @JavaScriptBody(args = {"x", "y"}, body = "this._context().moveTo(x,y);") - @Override - public native void moveTo(double x, double y); - - @JavaScriptBody(args = {"x", "y"}, body = "this._context().lineTo(x,y);") - @Override - public native void lineTo(double x, double y); - - @JavaScriptBody(args = {"cpx", "cpy", "x", "y"}, body = "this._context().quadraticCurveTo(cpx,cpy,x,y);") - @Override - public native void quadraticCurveTo(double cpx, double cpy, double x, double y); - - @JavaScriptBody(args = {"cp1x", "cp1y", "cp2x", "cp2y", "x", "y"}, - body = "this._context().bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y);") - @Override - public native void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); - - @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().fillRect(x,y,width,height);") - @Override - public native void fillRect(double x, double y, double width, double height); - - @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().strokeRect(x,y,width,height);") - @Override - public native void strokeRect(double x, double y, double width, double height); - - @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().clearRect(x,y,width,height);") - @Override - public native void clearRect(double x, double y, double width, double height); - - @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this._context().rectect(x,y,width,height);") - @Override - public native void rect(double x, double y, double width, double height); - - @JavaScriptBody(args = {}, body = "this._context().save();") - @Override - public native void save(); - - @JavaScriptBody(args = {}, body = "this._context().restore();") - @Override - public native void restore(); - - @JavaScriptBody(args = {"angle"}, body = "this._context().rotate(angle);") - @Override - public native void rotate(double angle); - - @JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this._context().transform(a,b,c,d,e,f);") - @Override - public native void transform(double a, double b, double c, double d, double e, double f); - - @JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this._context().setTransform(a,b,c,d,e,f);") - @Override - public native void setTransform(double a, double b, double c, double d, double e, double f); - - @JavaScriptBody(args = {"x", "y"}, body = "this._context().translate(x,y);") - @Override - public native void translate(double x, double y); - - @JavaScriptBody(args = {"x", "y"}, body = "this._context().scale(x,y);") - @Override - public native void scale(double x, double y); - - @Override - public void drawImage(Image image, double x, double y) { - drawImageImpl(context, Element.getElementById((HTML5Image) image), x, y); - } - - @Override - public void drawImage(Image image, double x, double y, double width, double height) { - drawImageImpl(context, Element.getElementById((HTML5Image) image), x, y, width, height); - } - - @Override - public void drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) { - drawImageImpl(context, Element.getElementById((HTML5Image) image), sx, sy, sWidth, sHeight, x, y, width, height); - } - - @JavaScriptBody(args = {"ctx", "img", "x", "y", "width", "height"}, body = "ctx.drawImage(img,x,y,width,height);") - private native static void drawImageImpl(Object ctx, Object img, double x, double y, double width, double height); - - @JavaScriptBody(args = {"ctx", "img", "sx", "sy", "swidth", "sheight", "x", "y", "width", "height"}, body = "ctx.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);") - 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); - - @JavaScriptBody(args = {"ctx", "img", "x", "y"}, body = "ctx.drawImage(img,x,y);") - private native static void drawImageImpl(Object ctx, Object img, double x, double y); - - @JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style.valueOf();") - @Override - public native void setFillStyle(String style); - - @JavaScriptBody(args = {}, body = "return this._context().fillStyle;") - @Override - public native String getFillStyle(); - - @Override - public void setFillStyle(LinearGradient style) { - setFillStyleImpl(context, ((HTML5LinearGradient) style).object()); - } - - @Override - public void setFillStyle(RadialGradient style) { - setFillStyleImpl(context, ((HTML5RadialGradient) style).object()); - } - - @Override - public void setFillStyle(Pattern style) { - setFillStyleImpl(context, ((HTML5Pattern) style).object()); - } - - @JavaScriptBody(args = {"context", "obj"}, body = "context.fillStyle=obj;") - private native void setFillStyleImpl(Object context, Object obj); - - @JavaScriptBody(args = {"style"}, body = "this._context().strokeStyle=style.valueOf();") - @Override - public native void setStrokeStyle(String style); - - @Override - public void setStrokeStyle(LinearGradient style) { - setStrokeStyleImpl(context, ((HTML5LinearGradient) style).object()); - } - - @Override - public void setStrokeStyle(RadialGradient style) { - setStrokeStyleImpl(context, ((HTML5RadialGradient) style).object()); - } - - @JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style;") - @Override - public void setStrokeStyle(Pattern style) { - setStrokeStyleImpl(context, ((HTML5LinearGradient) style).object()); - } - - @JavaScriptBody(args = {"context", "obj"}, body = "context.strokeStyle=obj;") - private native void setStrokeStyleImpl(Object context, Object obj); - - @JavaScriptBody(args = {"color"}, body = "this._context().shadowColor=color.valueOf();") - @Override - public native void setShadowColor(String color); - - @JavaScriptBody(args = {"blur"}, body = "this._context().shadowBlur=blur;") - @Override - public native void setShadowBlur(double blur); - - @JavaScriptBody(args = {"x"}, body = "this._context().shadowOffsetX=x;") - @Override - public native void setShadowOffsetX(double x); - - @JavaScriptBody(args = {"y"}, body = "this._context().shadowOffsetY=y;") - @Override - public native void setShadowOffsetY(double y); - - @JavaScriptBody(args = {}, body = "return this._context().strokeStyle;") - @Override - public native String getStrokeStyle(); - - @JavaScriptBody(args = {}, body = "return this._context().shadowColor;") - @Override - public native String getShadowColor(); - - @JavaScriptBody(args = {}, body = "return this._context().shadowBlur;") - @Override - public native double getShadowBlur(); - - @JavaScriptBody(args = {}, body = "return this._context().shadowOffsetX;") - @Override - public native double getShadowOffsetX(); - - @JavaScriptBody(args = {}, body = "return this._context().shadowOffsetY;") - @Override - public native double getShadowOffsetY(); - - @JavaScriptBody(args = {}, body = "return this._context().lineCap;") - @Override - public native String getLineCap(); - - @JavaScriptBody(args = {"style"}, body = "this._context().lineCap=style.valueOf();") - @Override - public native void setLineCap(String style); - - @JavaScriptBody(args = {}, body = "return this._context().lineJoin;") - @Override - public native String getLineJoin(); - - @JavaScriptBody(args = {"style"}, body = "this._context().lineJoin=style.valueOf();") - @Override - public native void setLineJoin(String style); - - @JavaScriptBody(args = {}, body = "return this._context().lineWidth;") - @Override - public native double getLineWidth(); - - @JavaScriptBody(args = {"width"}, body = "this._context().lineWidth=width;") - @Override - public native void setLineWidth(double width); - - @JavaScriptBody(args = {}, body = "return this._context().miterLimit;") - @Override - public native double getMiterLimit(); - - @JavaScriptBody(args = {"limit"}, body = "this._context().miterLimit=limit;") - @Override - public native void setMiterLimit(double limit); - - @JavaScriptBody(args = {}, body = "return this._context().font;") - @Override - public native String getFont(); - - @JavaScriptBody(args = {"font"}, body = "this._context().font=font.valueOf();") - @Override - public native void setFont(String font); - - @JavaScriptBody(args = {}, body = "return this._context().textAlign;") - @Override - public native String getTextAlign(); - - @JavaScriptBody(args = {"textalign"}, body = "this._context().textAlign=textalign.valueOf();") - @Override - public native void setTextAlign(String textAlign); - - @JavaScriptBody(args = {}, body = "return this._context().textBaseline;") - @Override - public native String getTextBaseline(); - - @JavaScriptBody(args = {"textbaseline"}, body = "this._context().textBaseline=textbaseline.valueOf();") - @Override - public native void setTextBaseline(String textbaseline); - - @JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().fillText(text,x,y);") - @Override - public native void fillText(String text, double x, double y); - - @JavaScriptBody(args = {"text", "x", "y", "maxwidth"}, body = "this._context().fillText(text,x,y,maxwidth);") - @Override - public void fillText(String text, double x, double y, double maxWidth) { - } - - @Override - public TextMetrics measureText(String text) { - return new HTML5TextMetrics(measureTextImpl(text)); - } - - @JavaScriptBody(args = {"text"}, - body = "return this._context().measureText(text);") - private native Object measureTextImpl(String text); - - @JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().strokeText(text,x,y);") - @Override - public native void strokeText(String text, double x, double y); - - @JavaScriptBody(args = {"text", "x", "y", "maxWidth"}, body = "this._context().strokeText(text,x,y,maxWidth);") - @Override - public native void strokeText(String text, double x, double y, double maxWidth); - - @Override - public ImageData createImageData(double x, double y) { - return new HTML5ImageData(createImageDataImpl(x, y)); - } - - @JavaScriptBody(args = {"x", "y"}, - body = "return this._context().createImageData(x,y);") - private native Object createImageDataImpl(double x, double y); - - @Override - public ImageData createImageData(ImageData imageData) { - return new HTML5ImageData(createImageDataImpl(imageData.getWidth(), imageData.getHeight())); - } - - @Override - public ImageData getImageData(double x, double y, double width, double height) { - return new HTML5ImageData(getImageDataImpl(x, y, width, height)); - } - - @JavaScriptBody(args = {"x", "y", "width", "height"}, - body = "return this._context().getImageData(x,y,width,height);") - private native Object getImageDataImpl(double x, double y, double width, double height); - - @Override - public void putImageData(ImageData imageData, double x, double y) { - putImageDataImpl(((HTML5ImageData) imageData).object(), x, y); - } - - @JavaScriptBody(args = {"imageData", "x", "y"}, - body = "this._context().putImageData(imageData,x,y);") - private native void putImageDataImpl(Object imageData, double x, double y); - - @Override - public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) { - putImageDataImpl(((HTML5ImageData) imageData).object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight); - } - - @JavaScriptBody(args = {"imageData", "x", "y", "dirtyx", "dirtyy", "dirtywidth", "dirtyheight"}, - body = "this._context().putImageData(imageData,x,y, dirtyx, dirtyy, dirtywidth,dirtyheight);") - private native void putImageDataImpl(Object imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight); - - @JavaScriptBody(args = {"alpha"}, body = "this._context().globalAlpha=alpha;") - @Override - public native void setGlobalAlpha(double alpha); - - @JavaScriptBody(args = {}, body = "return this._context().globalAlpha;") - @Override - public native double getGlobalAlpha(); - - @JavaScriptBody(args = {"operation"}, body = "this._context().globalCompositeOperation=operation.valueOf();") - @Override - public native void setGlobalCompositeOperation(String operation); - - @JavaScriptBody(args = {}, body = "return this._context().globalCompositeOperation;") - @Override - public native String getGlobalCompositeOperation(); - - @Override - public HTML5LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) { - return new HTML5LinearGradient(createLinearGradientImpl(context, x0, y0, x1, y1)); - } - - @JavaScriptBody(args = {"context", "x0", "y0", "x1", "y1"}, body = "return context.createLinearGradient(x0,y0,x1,y1);") - private native Object createLinearGradientImpl(Object context, double x0, double y0, double x1, double y1); - - @Override - public Pattern createPattern(Image image, String repeat) { - return new HTML5Pattern(createPatternImpl(context, image, repeat)); - } - - @JavaScriptBody(args = {"context", "image", "repeat"}, body = "return context.createPattern(image, repeat);") - private static native Object createPatternImpl(Object context, Image image, String repeat); - - @Override - public HTML5RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) { - return new HTML5RadialGradient(createRadialGradientImpl(context, x0, y0, r0, x1, y1, r1)); - } - - @JavaScriptBody(args = {"context", "x0", "y0", "r0", "x1", "y1", "r1"}, body = "return context.createRadialGradient(x0,y0,r0,x1,y1,r1);") - private static native Object createRadialGradientImpl(Object context, double x0, double y0, double r0, double x1, double y1, double r1); - - @JavaScriptBody(args = {"path"}, body = "var b = new Image(); b.src=path; return b;") - @Override - public Image getImageForPath(String path) { - throw new UnsupportedOperationException("getImageForPath is not yet supported"); - } -} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Image.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Image.java Tue May 21 16:07:59 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/** - * 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 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. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import net.java.html.canvas.Image; - -/** - * - * @author Anton Epple - */ -public class HTML5Image extends Element implements Image{ - - public HTML5Image(String id) { - super(id); - } - - @Override - void dontSubclass() { - } - - @Override - public int getHeight() { - return (int) super.getAttribute("height"); - } - - @Override - public int getWidth() { - return (int) super.getAttribute("width"); - } - -} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5ImageData.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5ImageData.java Tue May 21 16:07:59 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/** - * 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 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. - */ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import net.java.html.canvas.ImageData; -import org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class HTML5ImageData implements ImageData{ - - private Object imageData; - private Data data; - - public HTML5ImageData(Object imageData) { - this.imageData = imageData; - } - - public Data getData(){ - if (data == null){ - data = new Data(getDataImpl(imageData)); - } - return data; - } - - @JavaScriptBody(args = {"imageData"}, body = "return imageData.data") - public native Object getDataImpl(Object imageData); - - public double getWidth() { - return getWidthImpl(imageData); - } - - @JavaScriptBody(args = {"imageData"}, body = "return imagedata.width;") - private static native double getWidthImpl(Object imageData); - - public double getHeight() { - return getHeightImpl(imageData); - } - - @JavaScriptBody(args = {"imageData"}, body = "return imagedata.height;") - private static native double getHeightImpl(Object imageData); - - Object object() { - return imageData; - } - - public static class Data { - - Object data; - - public Data(Object data) { - this.data = data; - } - - public int get(int index) { - return getImpl(data, index); - } - - public void set(int index, int value) { - setImpl(data, index, value); - } - - @JavaScriptBody(args = {"data", "index", "value"}, body = "data[index]=value;") - private static native void setImpl(Object data, int index, int value); - - @JavaScriptBody(args = {"imagedata", "index"}, body = "return data[index];") - private static native int getImpl(Object data, int index); - } -} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5LinearGradient.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5LinearGradient.java Tue May 21 16:07:59 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/** - * 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 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. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import net.java.html.canvas.LinearGradient; -import org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class HTML5LinearGradient implements LinearGradient{ - - private final Object gradient; - - HTML5LinearGradient(Object linearGradient) { - this.gradient = linearGradient; - } - - Object object() { - return gradient; - } - - @Override - public void addColorStop(double position, String color) { - addColorStopImpl(gradient, position, color); - } - - @JavaScriptBody(args = {"gradient", "position", "color"}, body = - "gradient.addColorStop(position,color)") - private static native void addColorStopImpl(Object gradient, double position, String color); -} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Pattern.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Pattern.java Tue May 21 16:07:59 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/** - * 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 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. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import net.java.html.canvas.Pattern; - -/** - * - * @author Anton Epple - */ -public class HTML5Pattern implements Pattern{ - - private Object pattern; - - public HTML5Pattern(Object pattern) { - this.pattern = pattern; - } - - Object object() { - return pattern; - } -} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5RadialGradient.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5RadialGradient.java Tue May 21 16:07:59 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/** - * 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 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. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import net.java.html.canvas.RadialGradient; -import org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class HTML5RadialGradient implements RadialGradient{ - - private Object gradient; - - public HTML5RadialGradient(Object radialGradient) { - this.gradient = radialGradient; - } - - @Override - public void addColorStop(double position, String color) { - addColorStopImpl(gradient, position, color); - } - - @JavaScriptBody(args = {"gradient", "position", "color"}, body = - "gradient.addColorStop(position,color)") - private static native void addColorStopImpl(Object gradient, double position, String color); - - Object object() { - return gradient; - } -} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5TextMetrics.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5TextMetrics.java Tue May 21 16:07:59 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/** - * 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 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. - */ -package org.apidesign.bck2brwsr.htmlpage.api; - -import net.java.html.canvas.TextMetrics; -import org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class HTML5TextMetrics implements TextMetrics{ - - private Object textMetrics; - - HTML5TextMetrics(Object measureTextImpl) { - this.textMetrics = measureTextImpl; - } - - @JavaScriptBody(args = {"textMetrics"}, body = "return textMetrics.width;") - private native double getWidth(Object textMetrics); - - @JavaScriptBody(args = {"textMetrics"}, body = "return textMetrics.height;") - private native double getHeight(Object textMetrics); - - @Override - public double getWidth() { - return getWidth(textMetrics); - } - - @Override - public double getHeight() { - return getHeight(textMetrics); - - } -} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Image.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Image.java Tue May 21 16:10:52 2013 +0200 @@ -0,0 +1,46 @@ +/** + * 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 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. + */ +package org.apidesign.bck2brwsr.htmlpage.api; + +import net.java.html.canvas.IImage; + +/** + * + * @author Anton Epple + */ +public class Image extends Element implements IImage{ + + public Image(String id) { + super(id); + } + + @Override + void dontSubclass() { + } + + @Override + public int getHeight() { + return (int) super.getAttribute("height"); + } + + @Override + public int getWidth() { + return (int) super.getAttribute("width"); + } + +} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageData.java Tue May 21 16:10:52 2013 +0200 @@ -0,0 +1,90 @@ +/** + * 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 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. + */ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.apidesign.bck2brwsr.htmlpage.api; + +import net.java.html.canvas.IImageData; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * + * @author Anton Epple + */ +public class ImageData implements IImageData{ + + private Object imageData; + private Data data; + + public ImageData(Object imageData) { + this.imageData = imageData; + } + + public Data getData(){ + if (data == null){ + data = new Data(getDataImpl(imageData)); + } + return data; + } + + @JavaScriptBody(args = {"imageData"}, body = "return imageData.data") + public native Object getDataImpl(Object imageData); + + public double getWidth() { + return getWidthImpl(imageData); + } + + @JavaScriptBody(args = {"imageData"}, body = "return imagedata.width;") + private static native double getWidthImpl(Object imageData); + + public double getHeight() { + return getHeightImpl(imageData); + } + + @JavaScriptBody(args = {"imageData"}, body = "return imagedata.height;") + private static native double getHeightImpl(Object imageData); + + Object object() { + return imageData; + } + + public static class Data { + + Object data; + + public Data(Object data) { + this.data = data; + } + + public int get(int index) { + return getImpl(data, index); + } + + public void set(int index, int value) { + setImpl(data, index, value); + } + + @JavaScriptBody(args = {"data", "index", "value"}, body = "data[index]=value;") + private static native void setImpl(Object data, int index, int value); + + @JavaScriptBody(args = {"imagedata", "index"}, body = "return data[index];") + private static native int getImpl(Object data, int index); + } +} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/LinearGradient.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/LinearGradient.java Tue May 21 16:10:52 2013 +0200 @@ -0,0 +1,47 @@ +/** + * 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 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. + */ +package org.apidesign.bck2brwsr.htmlpage.api; + +import net.java.html.canvas.ILinearGradient; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * + * @author Anton Epple + */ +public class LinearGradient implements ILinearGradient{ + + private final Object gradient; + + LinearGradient(Object linearGradient) { + this.gradient = linearGradient; + } + + Object object() { + return gradient; + } + + @Override + public void addColorStop(double position, String color) { + addColorStopImpl(gradient, position, color); + } + + @JavaScriptBody(args = {"gradient", "position", "color"}, body = + "gradient.addColorStop(position,color)") + private static native void addColorStopImpl(Object gradient, double position, String color); +} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Pattern.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Pattern.java Tue May 21 16:10:52 2013 +0200 @@ -0,0 +1,37 @@ +/** + * 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 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. + */ +package org.apidesign.bck2brwsr.htmlpage.api; + +import net.java.html.canvas.IPattern; + +/** + * + * @author Anton Epple + */ +public class Pattern implements IPattern{ + + private Object pattern; + + public Pattern(Object pattern) { + this.pattern = pattern; + } + + Object object() { + return pattern; + } +} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/RadialGradient.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/RadialGradient.java Tue May 21 16:10:52 2013 +0200 @@ -0,0 +1,47 @@ +/** + * 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 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. + */ +package org.apidesign.bck2brwsr.htmlpage.api; + +import net.java.html.canvas.IRadialGradient; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * + * @author Anton Epple + */ +public class RadialGradient implements IRadialGradient{ + + private Object gradient; + + public RadialGradient(Object radialGradient) { + this.gradient = radialGradient; + } + + @Override + public void addColorStop(double position, String color) { + addColorStopImpl(gradient, position, color); + } + + @JavaScriptBody(args = {"gradient", "position", "color"}, body = + "gradient.addColorStop(position,color)") + private static native void addColorStopImpl(Object gradient, double position, String color); + + Object object() { + return gradient; + } +} diff -r 4613a6fe2862 -r a3d504d7e588 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/TextMetrics.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/TextMetrics.java Tue May 21 16:10:52 2013 +0200 @@ -0,0 +1,51 @@ +/** + * 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 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. + */ +package org.apidesign.bck2brwsr.htmlpage.api; + +import net.java.html.canvas.ITextMetrics; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * + * @author Anton Epple + */ +public class TextMetrics implements ITextMetrics{ + + private Object textMetrics; + + TextMetrics(Object measureTextImpl) { + this.textMetrics = measureTextImpl; + } + + @JavaScriptBody(args = {"textMetrics"}, body = "return textMetrics.width;") + private native double getWidth(Object textMetrics); + + @JavaScriptBody(args = {"textMetrics"}, body = "return textMetrics.height;") + private native double getHeight(Object textMetrics); + + @Override + public double getWidth() { + return getWidth(textMetrics); + } + + @Override + public double getHeight() { + return getHeight(textMetrics); + + } +}