javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/HTML5GraphicsEnvironment.java
1.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/HTML5GraphicsEnvironment.java Thu May 23 15:33:14 2013 +0200
1.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/HTML5GraphicsEnvironment.java Fri May 24 07:37:46 2013 +0200
1.3 @@ -17,19 +17,16 @@
1.4 */
1.5 package org.apidesign.bck2brwsr.htmlpage;
1.6
1.7 -import java.awt.Dimension;
1.8 import java.util.HashMap;
1.9 import java.util.Set;
1.10 -import net.java.html.canvas.GraphicsEnvironment;
1.11 -import net.java.html.canvas.ImageData;
1.12 +import net.java.html.canvas.Dimension;
1.13 import net.java.html.canvas.LinearGradient;
1.14 import net.java.html.canvas.Pattern;
1.15 import net.java.html.canvas.RadialGradient;
1.16 import net.java.html.canvas.Style;
1.17 +import net.java.html.canvas.spi.GraphicsEnvironment;
1.18 import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.19 import org.apidesign.bck2brwsr.htmlpage.api.Canvas;
1.20 -import org.apidesign.bck2brwsr.htmlpage.api.Element;
1.21 -import org.apidesign.bck2brwsr.htmlpage.api.Image;
1.22
1.23 /**
1.24 *
1.25 @@ -149,29 +146,29 @@
1.26 @Override
1.27 public native void scale(double x, double y);
1.28
1.29 - @Override
1.30 - public void drawImage(ImageData image, double x, double y) {
1.31 - drawImageImpl(context, Element.getElementById((Image) image), x, y);
1.32 - }
1.33 -
1.34 - @Override
1.35 - public void drawImage(ImageData image, double x, double y, double width, double height) {
1.36 - drawImageImpl(context, Element.getElementById((Image) image), x, y, width, height);
1.37 - }
1.38 -
1.39 - @Override
1.40 - public void drawImage(ImageData image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) {
1.41 - drawImageImpl(context, Element.getElementById((Image) image), sx, sy, sWidth, sHeight, x, y, width, height);
1.42 - }
1.43 -
1.44 - @JavaScriptBody(args = {"ctx", "img", "x", "y", "width", "height"}, body = "ctx.drawImage(img,x,y,width,height);")
1.45 - private native static void drawImageImpl(Object ctx, Object img, double x, double y, double width, double height);
1.46 -
1.47 - @JavaScriptBody(args = {"ctx", "img", "sx", "sy", "swidth", "sheight", "x", "y", "width", "height"}, body = "ctx.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);")
1.48 - private native static void drawImageImpl(Object ctx, Object img, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height);
1.49 -
1.50 - @JavaScriptBody(args = {"ctx", "img", "x", "y"}, body = "ctx.drawImage(img,x,y);")
1.51 - private native static void drawImageImpl(Object ctx, Object img, double x, double y);
1.52 +//// @Override
1.53 +//// public void drawImage(Image image, double x, double y) {
1.54 +//// drawImageImpl(context, Element.getElementById((Image) image), x, y);
1.55 +//// }
1.56 +////
1.57 +//// @Override
1.58 +//// public void drawImage(Image image, double x, double y, double width, double height) {
1.59 +//// drawImageImpl(context, Element.getElementById((Image) image), x, y, width, height);
1.60 +//// }
1.61 +////
1.62 +//// @Override
1.63 +//// public void drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) {
1.64 +//// drawImageImpl(context, Element.getElementById((Image) image), sx, sy, sWidth, sHeight, x, y, width, height);
1.65 +//// }
1.66 +//
1.67 +//// @JavaScriptBody(args = {"ctx", "img", "x", "y", "width", "height"}, body = "ctx.drawImage(img,x,y,width,height);")
1.68 +//// private native static void drawImageImpl(Object ctx, Object img, double x, double y, double width, double height);
1.69 +////
1.70 +//// @JavaScriptBody(args = {"ctx", "img", "sx", "sy", "swidth", "sheight", "x", "y", "width", "height"}, body = "ctx.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);")
1.71 +//// private native static void drawImageImpl(Object ctx, Object img, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height);
1.72 +////
1.73 +//// @JavaScriptBody(args = {"ctx", "img", "x", "y"}, body = "ctx.drawImage(img,x,y);")
1.74 +//// private native static void drawImageImpl(Object ctx, Object img, double x, double y);
1.75
1.76 @JavaScriptBody(args = {"style"}, body = "this._context().fillStyle=style.valueOf();")
1.77 @Override
1.78 @@ -215,8 +212,9 @@
1.79 addColorStopImpl(style, double1, stops.get(double1));
1.80 }
1.81 return gradient;
1.82 - } else if (style instanceof Pattern) {
1.83 - return createPatternWrapper(((Pattern) style).getImageData(), ((Pattern) style).getRepeat());
1.84 + }
1.85 + else if (style instanceof Pattern) {
1.86 +// return createPatternWrapper(((Pattern) style).getImage(), ((Pattern) style).getRepeat());
1.87 }
1.88 return null;
1.89 }
1.90 @@ -334,6 +332,7 @@
1.91 public native void setTextBaseline(String textbaseline);
1.92
1.93 @JavaScriptBody(args = {"text", "x", "y"}, body = "this._context().fillText(text,x,y);")
1.94 +// @JavaScriptBody(args = {"text", "x", "y"}, body = "console.log(text);")
1.95 @Override
1.96 public native void fillText(String text, double x, double y);
1.97
1.98 @@ -344,8 +343,8 @@
1.99
1.100 @Override
1.101 public Dimension measureText(String text) {
1.102 - TextMetrics textMetrics = new TextMetrics(measureTextImpl(text));
1.103 - return new Dimension((int) textMetrics.getWidth(), (int) textMetrics.getHeight());
1.104 + measureTextImpl(text);
1.105 + return new Dimension(1,1);
1.106 }
1.107
1.108 @JavaScriptBody(args = {"text"},
1.109 @@ -360,42 +359,42 @@
1.110 @Override
1.111 public native void strokeText(String text, double x, double y, double maxWidth);
1.112
1.113 -// @Override
1.114 -// public ImageData createImageData(double x, double y) {
1.115 -// return new ImageDataWrapper(createImageDataImpl(x, y));
1.116 -// }
1.117 +//// @Override
1.118 +//// public ImageData createImageData(double x, double y) {
1.119 +//// return new ImageDataWrapper(createImageDataImpl(x, y));
1.120 +//// }
1.121 +////
1.122 +//// @JavaScriptBody(args = {"x", "y"},
1.123 +//// body = "return this._context().createImageData(x,y);")
1.124 +//// private native Object createImageDataImpl(double x, double y);
1.125 +////
1.126 +//// @Override
1.127 +//// public ImageData createImageData(ImageData imageData) {
1.128 +//// return new ImageDataWrapper(createImageDataImpl(imageData.getWidth(), imageData.getHeight()));
1.129 +//// }
1.130 +////
1.131 +//// @Override
1.132 +//// public ImageData getImageData(double x, double y, double width, double height) {
1.133 +//// return new ImageDataWrapper(getImageDataImpl(x, y, width, height));
1.134 +//// }
1.135 //
1.136 -// @JavaScriptBody(args = {"x", "y"},
1.137 -// body = "return this._context().createImageData(x,y);")
1.138 -// private native Object createImageDataImpl(double x, double y);
1.139 +// @JavaScriptBody(args = {"x", "y", "width", "height"},
1.140 +// body = "return this._context().getImageData(x,y,width,height);")
1.141 +// private native Object getImageDataImpl(double x, double y, double width, double height);
1.142 //
1.143 -// @Override
1.144 -// public ImageData createImageData(ImageData imageData) {
1.145 -// return new ImageDataWrapper(createImageDataImpl(imageData.getWidth(), imageData.getHeight()));
1.146 -// }
1.147 -//
1.148 -// @Override
1.149 -// public ImageData getImageData(double x, double y, double width, double height) {
1.150 -// return new ImageDataWrapper(getImageDataImpl(x, y, width, height));
1.151 -// }
1.152 -
1.153 - @JavaScriptBody(args = {"x", "y", "width", "height"},
1.154 - body = "return this._context().getImageData(x,y,width,height);")
1.155 - private native Object getImageDataImpl(double x, double y, double width, double height);
1.156 -
1.157 -// @Override
1.158 -// public void putImageData(ImageData imageData, double x, double y) {
1.159 -// putImageDataImpl(((ImageDataWrapper) imageData).object(), x, y);
1.160 -// }
1.161 -//
1.162 -// @JavaScriptBody(args = {"imageData", "x", "y"},
1.163 -// body = "this._context().putImageData(imageData,x,y);")
1.164 -// private native void putImageDataImpl(Object imageData, double x, double y);
1.165 -//
1.166 -// @Override
1.167 -// public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) {
1.168 -// putImageDataImpl(((ImageDataWrapper) imageData).object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
1.169 -// }
1.170 +//// @Override
1.171 +//// public void putImageData(ImageData imageData, double x, double y) {
1.172 +//// putImageDataImpl(((ImageDataWrapper) imageData).object(), x, y);
1.173 +//// }
1.174 +////
1.175 +//// @JavaScriptBody(args = {"imageData", "x", "y"},
1.176 +//// body = "this._context().putImageData(imageData,x,y);")
1.177 +//// private native void putImageDataImpl(Object imageData, double x, double y);
1.178 +////
1.179 +//// @Override
1.180 +//// public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) {
1.181 +//// putImageDataImpl(((ImageDataWrapper) imageData).object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
1.182 +//// }
1.183
1.184 @JavaScriptBody(args = {"imageData", "x", "y", "dirtyx", "dirtyy", "dirtywidth", "dirtyheight"},
1.185 body = "this._context().putImageData(imageData,x,y, dirtyx, dirtyy, dirtywidth,dirtyheight);")
1.186 @@ -424,12 +423,12 @@
1.187 @JavaScriptBody(args = {"context", "x0", "y0", "x1", "y1"}, body = "return context.createLinearGradient(x0,y0,x1,y1);")
1.188 private native Object createLinearGradientImpl(Object context, double x0, double y0, double x1, double y1);
1.189
1.190 - public PatternWrapper createPatternWrapper(ImageData image, String repeat) {
1.191 - return new PatternWrapper(createPatternImpl(context, image, repeat));
1.192 - }
1.193 -
1.194 - @JavaScriptBody(args = {"context", "image", "repeat"}, body = "return context.createPattern(image, repeat);")
1.195 - private static native Object createPatternImpl(Object context, ImageData image, String repeat);
1.196 +// public PatternWrapper createPatternWrapper(Image image, String repeat) {
1.197 +// return new PatternWrapper(createPatternImpl(context, image, repeat));
1.198 +// }
1.199 +//
1.200 +// @JavaScriptBody(args = {"context", "image", "repeat"}, body = "return context.createPattern(image, repeat);")
1.201 +// private static native Object createPatternImpl(Object context, Image image, String repeat);
1.202
1.203 public RadialGradientWrapper createRadialGradientWrapper(double x0, double y0, double r0, double x1, double y1, double r1) {
1.204 return new RadialGradientWrapper(createRadialGradientImpl(context, x0, y0, r0, x1, y1, r1));
1.205 @@ -438,9 +437,9 @@
1.206 @JavaScriptBody(args = {"context", "x0", "y0", "r0", "x1", "y1", "r1"}, body = "return context.createRadialGradient(x0,y0,r0,x1,y1,r1);")
1.207 private static native Object createRadialGradientImpl(Object context, double x0, double y0, double r0, double x1, double y1, double r1);
1.208
1.209 -//
1.210 -// @JavaScriptBody(args = {"path"}, body = "var b = new Image(); b.src=path; return b;")
1.211 -// public native Image getImageForPath(String path);
1.212 +////
1.213 +//// @JavaScriptBody(args = {"path"}, body = "var b = new Image(); b.src=path; return b;")
1.214 +//// public native Image getImageForPath(String path);
1.215
1.216
1.217