# HG changeset patch # User Anton Epple # Date 1369296134 -7200 # Node ID 0a2190f2a210fc428205714661f2320913bce1c9 # Parent 0ae830f00e0c982f0df22f4203a5f44230139117 temporarily disabled ImageData before we found a nice solution. Maybe introduce PixelReader PixelWriter for GraphicsContext. diff -r 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Canvas.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Canvas.java Thu May 23 09:56:49 2013 +0200 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Canvas.java Thu May 23 10:02:14 2013 +0200 @@ -17,8 +17,7 @@ */ package org.apidesign.bck2brwsr.htmlpage.api; -import net.java.html.canvas.ICanvas; -import net.java.html.canvas.IGraphicsContext; +import net.java.html.canvas.GraphicsContext; import org.apidesign.bck2brwsr.core.JavaScriptBody; import static org.apidesign.bck2brwsr.htmlpage.api.Element.getAttribute; @@ -26,29 +25,25 @@ * * @author Anton Epple */ -public class Canvas extends Element implements ICanvas{ +public class Canvas extends Element { 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; @@ -60,8 +55,8 @@ + "return e.getContext('2d');\n") private native static Object getContextImpl(Canvas el); - public IGraphicsContext getContext() { - return new GraphicsContext(getContextImpl(this)); + public GraphicsContext getContext() { + return new GraphicsContext(new HTML5GraphicsEnvironment(getContextImpl(this), this)); } @Override diff -r 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java Thu May 23 09:56:49 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,425 +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.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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5GraphicsEnvironment.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5GraphicsEnvironment.java Thu May 23 10:02:14 2013 +0200 @@ -0,0 +1,464 @@ +/** + * 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 java.awt.Dimension; +import java.util.HashMap; +import java.util.Set; +import net.java.html.canvas.GraphicsEnvironment; +import net.java.html.canvas.Image; +import net.java.html.canvas.LinearGradient; +import net.java.html.canvas.Pattern; +import net.java.html.canvas.RadialGradient; +import net.java.html.canvas.Style; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * + * @author Anton Epple + */ +public class HTML5GraphicsEnvironment implements GraphicsEnvironment { + + Object context; + Canvas canvas; + HTML5GraphicsEnvironment(Object contextImpl, Canvas canvas) { + this.context = contextImpl; + this.canvas = canvas; + } + + @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((ImageWrapper) image), x, y); + } + + @Override + public void drawImage(Image image, double x, double y, double width, double height) { + drawImageImpl(context, Element.getElementById((ImageWrapper) 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((ImageWrapper) 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(Style style) { + setFillStyleImpl(context, createFillStyle(style)); + } + + private Object createFillStyle(Style style) { + if (style instanceof RadialGradient) { + RadialGradientWrapper gradient = createRadialGradientWrapper( + ((RadialGradient) style).getX0(), + ((RadialGradient) style).getY0(), + ((RadialGradient) style).getR0(), + ((RadialGradient) style).getX1(), + ((RadialGradient) style).getY1(), + ((RadialGradient) style).getR1()); + HashMap stops = ((LinearGradient) style).getStops(); + Set keySet = stops.keySet(); + for (Double double1 : keySet) { + addColorStopImpl(style, double1, stops.get(double1)); + } + return gradient; + + + } else if (style instanceof LinearGradient) { + LinearGradientWrapper gradient = createLinearGradientWrapper( + ((LinearGradient) style).getX0(), + ((LinearGradient) style).getY0(), + ((LinearGradient) style).getX1(), + ((LinearGradient) style).getY1()); + HashMap stops = ((LinearGradient) style).getStops(); + Set keySet = stops.keySet(); + for (Double double1 : keySet) { + addColorStopImpl(style, double1, stops.get(double1)); + } + return gradient; + } else if (style instanceof Pattern) { + return createPatternWrapper(((Pattern) style).getImageData(), ((Pattern) style).getRepeat()); + } + return null; + } + + + @JavaScriptBody(args = {"gradient", "position", "color"}, body = + "gradient.addColorStop(position,color)") + private static native void addColorStopImpl(Object gradient, double position, String color); + + @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(Style style) { + setStrokeStyleImpl(context, createFillStyle(style)); + } + + @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 Dimension measureText(String text) { + TextMetrics textMetrics = new TextMetrics(measureTextImpl(text)); + return new Dimension((int) textMetrics.getWidth(), (int) textMetrics.getHeight()); + } + + @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 Image createImageData(double x, double y) { +// return new ImageDataWrapper(createImageDataImpl(x, y)); +// } +// +// @JavaScriptBody(args = {"x", "y"}, +// body = "return this._context().createImageData(x,y);") +// private native Object createImageDataImpl(double x, double y); +// +// @Override +// public Image createImageData(Image imageData) { +// return new ImageDataWrapper(createImageDataImpl(imageData.getWidth(), imageData.getHeight())); +// } +// +// @Override +// public Image getImageData(double x, double y, double width, double height) { +// return new ImageDataWrapper(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(Image imageData, double x, double y) { +// putImageDataImpl(((ImageDataWrapper) 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(Image imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) { +// putImageDataImpl(((ImageDataWrapper) 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(); + + public LinearGradientWrapper createLinearGradientWrapper(double x0, double y0, double x1, double y1) { + return new LinearGradientWrapper(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); + + public PatternWrapper createPatternWrapper(Image image, String repeat) { + return new PatternWrapper(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); + + public RadialGradientWrapper createRadialGradientWrapper(double x0, double y0, double r0, double x1, double y1, double r1) { + return new RadialGradientWrapper(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;") + public native ImageWrapper getImageForPath(String path); + + + + @Override + public int getHeight() { + return canvas.getHeight(); + } + + @Override + public int getWidth() { + return canvas.getWidth(); + } + + @Override + public void setHeight(int height) { + canvas.setHeight(height); + } + + @Override + public void setWidth(int width) { + canvas.setWidth(width); + } + +} diff -r 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Image.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Image.java Thu May 23 09:56:49 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.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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageData.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageData.java Thu May 23 09:56:49 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.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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageDataWrapper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageDataWrapper.java Thu May 23 10:02:14 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 org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * + * @author Anton Epple + */ +public class ImageDataWrapper { + + private Object imageData; + private Data data; + + public ImageDataWrapper(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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageWrapper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageWrapper.java Thu May 23 10:02:14 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.Image; + +/** + * + * @author Anton Epple + */ +public class ImageWrapper extends Element implements Image{ + + public ImageWrapper(String id) { + super(id); + } + + @Override + void dontSubclass() { + } + + @Override + public double getHeight() { + return (double) super.getAttribute("height"); + } + + @Override + public double getWidth() { + return (double) super.getAttribute("width"); + } + +} diff -r 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/LinearGradient.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/LinearGradient.java Thu May 23 09:56:49 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.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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/LinearGradientWrapper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/LinearGradientWrapper.java Thu May 23 10:02:14 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.LinearGradient; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * + * @author Anton Epple + */ +public class LinearGradientWrapper{ + + private final Object gradient; + + LinearGradientWrapper(Object linearGradient) { + this.gradient = linearGradient; + } + + Object object() { + return gradient; + } + + 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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Pattern.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Pattern.java Thu May 23 09:56:49 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.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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/PatternWrapper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/PatternWrapper.java Thu May 23 10:02:14 2013 +0200 @@ -0,0 +1,35 @@ +/** + * 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; + +/** + * + * @author Anton Epple + */ +public class PatternWrapper { + + private Object pattern; + + public PatternWrapper(Object pattern) { + this.pattern = pattern; + } + + Object object() { + return pattern; + } +} diff -r 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/RadialGradient.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/RadialGradient.java Thu May 23 09:56:49 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.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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/RadialGradientWrapper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/RadialGradientWrapper.java Thu May 23 10:02:14 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.RadialGradient; +import org.apidesign.bck2brwsr.core.JavaScriptBody; + +/** + * + * @author Anton Epple + */ +public class RadialGradientWrapper { + + private Object gradient; + + public RadialGradientWrapper(Object radialGradient) { + this.gradient = radialGradient; + } + + 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 0ae830f00e0c -r 0a2190f2a210 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/TextMetrics.java --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/TextMetrics.java Thu May 23 09:56:49 2013 +0200 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/TextMetrics.java Thu May 23 10:02:14 2013 +0200 @@ -17,14 +17,13 @@ */ 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{ +public class TextMetrics { private Object textMetrics; @@ -38,14 +37,11 @@ @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); - } }