# HG changeset patch # User toni.epple@eppleton.de # Date 1368785215 -7200 # Node ID 024b165f8f2107bc99bb15d1ae26968ded345de7 # Parent 8c88d0f187d8f30cbcfa16021ffafbdd1fb3194e Extracting interfaces from JavaQuery API. Removed first (automatic) refactoring attempt and redid it manually. diff -r 8c88d0f187d8 -r 024b165f8f21 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 Fri May 17 12:06:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +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 org.apidesign.bck2brwsr.core.JavaScriptBody; -import static org.apidesign.bck2brwsr.htmlpage.api.Element.getAttribute; - -/** - * - * @author Anton Epple - */ -public class Canvas extends Element { - - public Canvas(String id) { - super(id); - } - - public void setHeight(int height) { - setAttribute(this, "height", height); - } - - public int getHeight() { - Object ret = getAttribute(this, "height"); - return (ret instanceof Number) ? ((Number)ret).intValue(): Integer.MIN_VALUE; - } - - public void setWidth(int width) { - setAttribute(this, "width", width); - } - - 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 HTML5GraphicsContext getContext() { - return new HTML5GraphicsContext(getContextImpl(this)); - } - - @Override - void dontSubclass() { - } -} diff -r 8c88d0f187d8 -r 024b165f8f21 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Canvas.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Canvas.java Fri May 17 12:06:55 2013 +0200 @@ -0,0 +1,65 @@ +/** + * 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 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); + } + + public void setHeight(int height) { + setAttribute(this, "height", height); + } + + public int getHeight() { + Object ret = getAttribute(this, "height"); + return (ret instanceof Number) ? ((Number)ret).intValue(): Integer.MIN_VALUE; + } + + public void setWidth(int width) { + setAttribute(this, "width", width); + } + + 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); + + public HTML5GraphicsContext getContext() { + return new HTML5GraphicsContext(getContextImpl(this)); + } + + @Override + void dontSubclass() { + } +} diff -r 8c88d0f187d8 -r 024b165f8f21 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 Fri May 17 12:06:36 2013 +0200 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5GraphicsContext.java Fri May 17 12:06:55 2013 +0200 @@ -1,23 +1,29 @@ /** - * Back 2 Browser Bytecode Translator - * Copyright (C) 2012 Jaroslav Tulach + * 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 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. + * 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. + * 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; /** @@ -137,16 +143,19 @@ @Override public native void scale(double x, double y); + @Override public void drawImage(Image image, double x, double y) { - drawImageImpl(context, Element.getElementById(image), x, 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(image), x, y, width, 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(image), sx, sy, sWidth, sHeight, x, y, width, 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);") @@ -166,39 +175,44 @@ @Override public native String getFillStyle(); + @Override public void setFillStyle(LinearGradient style) { - setFillStyleImpl(context, style.object()); + setFillStyleImpl(context, ((HTML5LinearGradient)style).object()); } + @Override public void setFillStyle(RadialGradient style) { - setFillStyleImpl(context, style.object()); + setFillStyleImpl(context, ((HTML5RadialGradient)style).object()); } + @Override public void setFillStyle(Pattern style) { - setFillStyleImpl(context, style.object()); + setFillStyleImpl(context, ((HTML5Pattern)style).object()); } - @JavaScriptBody(args = {"context","obj"}, body = "context.fillStyle=obj;") + @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, style.object()); + setStrokeStyleImpl(context, ((HTML5LinearGradient)style).object()); } public void setStrokeStyle(RadialGradient style) { - setStrokeStyleImpl(context, style.object()); + setStrokeStyleImpl(context, ((HTML5RadialGradient)style).object()); } @JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style;") + @Override public void setStrokeStyle(Pattern style) { - setStrokeStyleImpl(context, style.object()); + setStrokeStyleImpl(context, ((HTML5LinearGradient)style).object()); } - @JavaScriptBody(args = {"context","obj"}, body = "context.strokeStyle=obj;") + @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();") @@ -208,7 +222,7 @@ @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); @@ -302,8 +316,9 @@ public void fillText(String text, double x, double y, double maxWidth) { } + @Override public TextMetrics measureText(String text) { - return new TextMetrics(measureTextImpl(text)); + return new HTML5TextMetrics(measureTextImpl(text)); } @JavaScriptBody(args = {"text"}, @@ -318,36 +333,41 @@ @Override public native void strokeText(String text, double x, double y, double maxWidth); + @Override public ImageData createImageData(double x, double y) { - return new ImageData(createImageDataImpl(x, 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 ImageData(createImageDataImpl(imageData.getWidth(), imageData.getHeight())); + return new HTML5ImageData(createImageDataImpl(imageData.getWidth(), imageData.getHeight())); } + @Override public ImageData getImageData(double x, double y, double width, double height) { - return new ImageData(getImageDataImpl(x, y, width, 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(imageData.object(), x, 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(imageData.object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight); + putImageDataImpl(((HTML5ImageData)imageData).object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight); } @JavaScriptBody(args = {"imageData", "x", "y", "dirtyx", "dirtyy", "dirtywidth", "dirtyheight"}, @@ -370,22 +390,25 @@ @Override public native String getGlobalCompositeOperation(); - public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) { - return new LinearGradient(createLinearGradientImpl(context, x0, y0, x1, y1)); + @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); + private native Object createLinearGradientImpl(Object context, double x0, double y0, double x1, double y1); + @Override public Pattern createPattern(Image image, String repeat) { - return new Pattern(createPatternImpl(context, image, 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); - 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)); + @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);") diff -r 8c88d0f187d8 -r 024b165f8f21 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Image.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Image.java Fri May 17 12:06:55 2013 +0200 @@ -0,0 +1,38 @@ +/** + * 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() { + } + +} diff -r 8c88d0f187d8 -r 024b165f8f21 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5ImageData.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5ImageData.java Fri May 17 12:06:55 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.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 8c88d0f187d8 -r 024b165f8f21 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5LinearGradient.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5LinearGradient.java Fri May 17 12:06:55 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 HTML5LinearGradient implements LinearGradient{ + + private final Object gradient; + + HTML5LinearGradient(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 8c88d0f187d8 -r 024b165f8f21 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Pattern.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5Pattern.java Fri May 17 12:06:55 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.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 8c88d0f187d8 -r 024b165f8f21 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5RadialGradient.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5RadialGradient.java Fri May 17 12:06:55 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 HTML5RadialGradient implements RadialGradient{ + + private Object gradient; + + public HTML5RadialGradient(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 8c88d0f187d8 -r 024b165f8f21 javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5TextMetrics.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/HTML5TextMetrics.java Fri May 17 12:06:55 2013 +0200 @@ -0,0 +1,49 @@ +/** + * 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); + + public double getWidth() { + return getWidth(textMetrics); + } + + public double getHeight() { + return getHeight(textMetrics); + + } +} diff -r 8c88d0f187d8 -r 024b165f8f21 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 Fri May 17 12:06:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +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; - -/** - * - * @author Anton Epple - */ -public class Image extends Element{ - - public Image(String id) { - super(id); - } - - - - @Override - void dontSubclass() { - } - -} diff -r 8c88d0f187d8 -r 024b165f8f21 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 Fri May 17 12:06:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +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 org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class ImageData { - - 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 8c88d0f187d8 -r 024b165f8f21 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 Fri May 17 12:06:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +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 org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class LinearGradient { - - private final Object gradient; - - LinearGradient(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 8c88d0f187d8 -r 024b165f8f21 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 Fri May 17 12:06:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +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; - -/** - * - * @author Anton Epple - */ -public class Pattern { - - private Object pattern; - - public Pattern(Object pattern) { - this.pattern = pattern; - } - - Object object() { - return pattern; - } -} diff -r 8c88d0f187d8 -r 024b165f8f21 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 Fri May 17 12:06:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +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 org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class RadialGradient { - - private Object gradient; - - public RadialGradient(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 8c88d0f187d8 -r 024b165f8f21 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 Fri May 17 12:06:36 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +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 org.apidesign.bck2brwsr.core.JavaScriptBody; - -/** - * - * @author Anton Epple - */ -public class TextMetrics { - - 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); - - public double getWidth() { - return getWidth(textMetrics); - } - - public double getHeight() { - return getHeight(textMetrics); - - } -}