1.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Tue Jan 22 13:56:27 2013 +0100
1.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/PageProcessor.java Tue Jan 22 17:54:09 2013 +0100
1.3 @@ -131,11 +131,17 @@
1.4 if (tag.equals("input")) {
1.5 return "Input";
1.6 }
1.7 + if (tag.equals("canvas")) {
1.8 + return "Canvas";
1.9 + }
1.10 + if (tag.equals("img")) {
1.11 + return "Image";
1.12 + }
1.13 return "Element";
1.14 }
1.15
1.16 private static String cnstnt(String id) {
1.17 - return id.toUpperCase(Locale.ENGLISH).replace('.', '_');
1.18 + return id.toUpperCase(Locale.ENGLISH).replace('.', '_').replace('-', '_');
1.19 }
1.20
1.21 private boolean initializeOnClick(TypeElement type, Writer w, ProcessPage pp) throws IOException {
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Canvas.java Tue Jan 22 17:54:09 2013 +0100
2.3 @@ -0,0 +1,61 @@
2.4 +/**
2.5 + * Back 2 Browser Bytecode Translator
2.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
2.7 + *
2.8 + * This program is free software: you can redistribute it and/or modify
2.9 + * it under the terms of the GNU General Public License as published by
2.10 + * the Free Software Foundation, version 2 of the License.
2.11 + *
2.12 + * This program is distributed in the hope that it will be useful,
2.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.15 + * GNU General Public License for more details.
2.16 + *
2.17 + * You should have received a copy of the GNU General Public License
2.18 + * along with this program. Look for COPYING file in the top folder.
2.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
2.20 + */
2.21 +package org.apidesign.bck2brwsr.htmlpage.api;
2.22 +
2.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
2.24 +
2.25 +/**
2.26 + *
2.27 + * @author Anton Epple <toni.epple@eppleton.de>
2.28 + */
2.29 +public class Canvas extends Element {
2.30 +
2.31 + public Canvas(String id) {
2.32 + super(id);
2.33 + }
2.34 +
2.35 + public void setHeight(int height) {
2.36 + setAttribute(this, "height", height);
2.37 + }
2.38 +
2.39 + public int getHeight() {
2.40 + return (Integer) getAttribute(this, "height");
2.41 + }
2.42 +
2.43 + public void setWidth(int width) {
2.44 + setAttribute(this, "width", width);
2.45 + }
2.46 +
2.47 + public int getWidth() {
2.48 + return (Integer) getAttribute(this, "width");
2.49 + }
2.50 +
2.51 + @JavaScriptBody(
2.52 + args = {"el"},
2.53 + body = "var e = window.document.getElementById(el.fld_id);\n"
2.54 + + "return e.getContext('2d');\n")
2.55 + private native static Object getContextImpl(Canvas el);
2.56 +
2.57 + public GraphicsContext getContext() {
2.58 + return new GraphicsContext(getContextImpl(this));
2.59 + }
2.60 +
2.61 + @Override
2.62 + void dontSubclass() {
2.63 + }
2.64 +}
3.1 --- a/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java Tue Jan 22 13:56:27 2013 +0100
3.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Element.java Tue Jan 22 17:54:09 2013 +0100
3.3 @@ -46,6 +46,12 @@
3.4 )
3.5 static native Object getAttribute(Element el, String property);
3.6
3.7 + @JavaScriptBody(
3.8 + args={"el"},
3.9 + body="return window.document.getElementById(el.fld_id);"
3.10 + )
3.11 + static native Object getElementById(Element el);
3.12 +
3.13 /** Executes given runnable when user performs a "click" on the given
3.14 * element.
3.15 * @param r the runnable to execute, never null
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/GraphicsContext.java Tue Jan 22 17:54:09 2013 +0100
4.3 @@ -0,0 +1,335 @@
4.4 +/**
4.5 + * Back 2 Browser Bytecode Translator
4.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
4.7 + *
4.8 + * This program is free software: you can redistribute it and/or modify
4.9 + * it under the terms of the GNU General Public License as published by
4.10 + * the Free Software Foundation, version 2 of the License.
4.11 + *
4.12 + * This program is distributed in the hope that it will be useful,
4.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
4.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4.15 + * GNU General Public License for more details.
4.16 + *
4.17 + * You should have received a copy of the GNU General Public License
4.18 + * along with this program. Look for COPYING file in the top folder.
4.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
4.20 + */
4.21 +package org.apidesign.bck2brwsr.htmlpage.api;
4.22 +
4.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
4.24 +
4.25 +/**
4.26 + *
4.27 + * @author Anton Epple <toni.epple@eppleton.de>
4.28 + */
4.29 +public class GraphicsContext {
4.30 +
4.31 + Object context;
4.32 +
4.33 + GraphicsContext(Object contextImpl) {
4.34 + this.context = contextImpl;
4.35 + }
4.36 +
4.37 + @JavaScriptBody(args = {"centerx", "centery", "radius", "startangle", "endangle", "ccw"},
4.38 + body = "this.fld_context.arc(centerx,centery, radius, startangle, endangle,ccw);")
4.39 + public native void arc(double centerX,
4.40 + double centerY,
4.41 + double startAngle,
4.42 + double radius,
4.43 + double endAngle,
4.44 + boolean ccw);
4.45 +
4.46 + @JavaScriptBody(args = {"x1", "y1", "x2", "y2", "r"},
4.47 + body = "this.fld_context.arcTo(x1,y1,x2,y2,r);")
4.48 + public native void arcTo(double x1,
4.49 + double y1,
4.50 + double x2,
4.51 + double y2,
4.52 + double r);
4.53 +
4.54 + @JavaScriptBody(args = {"x", "y"},
4.55 + body = "return this.fld_context.isPointInPath(x,y);")
4.56 + public native boolean isPointInPath(double x, double y);
4.57 +
4.58 + @JavaScriptBody(args = {}, body = "this.fld_context.fill();")
4.59 + public native void fill();
4.60 +
4.61 + @JavaScriptBody(args = {}, body = "this.fld_context.stroke();")
4.62 + public native void stroke();
4.63 +
4.64 + @JavaScriptBody(args = {}, body = "this.fld_context.beginPath();")
4.65 + public native void beginPath();
4.66 +
4.67 + @JavaScriptBody(args = {}, body = "this.fld_context.closePath();")
4.68 + public native void closePath();
4.69 +
4.70 + @JavaScriptBody(args = {}, body = "this.fld_context.clip();")
4.71 + public native void clip();
4.72 +
4.73 + @JavaScriptBody(args = {"x", "y"}, body = "this.fld_context.moveTo(x,y);")
4.74 + public native void moveTo(double x, double y);
4.75 +
4.76 + @JavaScriptBody(args = {"x", "y"}, body = "this.fld_context.lineTo(x,y);")
4.77 + public native void lineTo(double x, double y);
4.78 +
4.79 + @JavaScriptBody(args = {"cpx", "cpy", "x", "y"}, body = "this.fld_context.quadraticCurveTo(cpx,cpy,x,y);")
4.80 + public native void quadraticCurveTo(double cpx, double cpy, double x, double y);
4.81 +
4.82 + @JavaScriptBody(args = {"cp1x", "cp1y", "cp2x", "cp2y", "x", "y"},
4.83 + body = "this.fld_context.bezierCurveTo(cp1x,cp1y,cp2x,cp2y,x,y);")
4.84 + public native void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
4.85 +
4.86 + @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this.fld_context.fillRect(x,y,width,height);")
4.87 + public native void fillRect(double x, double y, double width, double height);
4.88 +
4.89 + @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this.fld_context.strokeRect(x,y,width,height);")
4.90 + public native void strokeRect(double x, double y, double width, double height);
4.91 +
4.92 + @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this.fld_context.clearRect(x,y,width,height);")
4.93 + public native void clearRect(double x, double y, double width, double height);
4.94 +
4.95 + @JavaScriptBody(args = {"x", "y", "width", "height"}, body = "this.fld_context.rectect(x,y,width,height);")
4.96 + public native void rect(double x, double y, double width, double height);
4.97 +
4.98 + @JavaScriptBody(args = {}, body = "this.fld_context.save();")
4.99 + public native void save();
4.100 +
4.101 + @JavaScriptBody(args = {}, body = "this.fld_context.restore();")
4.102 + public native void restore();
4.103 +
4.104 + @JavaScriptBody(args = {"angle"}, body = "this.fld_context.rotate(angle);")
4.105 + public native void rotate(double angle);
4.106 +
4.107 + @JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this.fld_context.transform(a,b,c,d,e,f);")
4.108 + public native void transform(double a, double b, double c, double d, double e, double f);
4.109 +
4.110 + @JavaScriptBody(args = {"a", "b", "c", "d", "e", "f"}, body = "this.fld_context.setTransform(a,b,c,d,e,f);")
4.111 + public native void setTransform(double a, double b, double c, double d, double e, double f);
4.112 +
4.113 + @JavaScriptBody(args = {"x", "y"}, body = "this.fld_context.translate(x,y);")
4.114 + public native void translate(double x, double y);
4.115 +
4.116 + @JavaScriptBody(args = {"x", "y"}, body = "this.fld_context.scale(x,y);")
4.117 + public native void scale(double x, double y);
4.118 +
4.119 + public void drawImage(Image image, double x, double y) {
4.120 + drawImageImpl(context, Element.getElementById(image), x, y);
4.121 + }
4.122 +
4.123 + public void drawImage(Image image, double x, double y, double width, double height) {
4.124 + drawImageImpl(context, Element.getElementById(image), x, y, width, height);
4.125 + }
4.126 +
4.127 + public void drawImage(Image image, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height) {
4.128 + drawImageImpl(context, Element.getElementById(image), sx, sy, sWidth, sHeight, x, y, width, height);
4.129 + }
4.130 +
4.131 + @JavaScriptBody(args = {"ctx", "img", "x", "y", "width", "height"}, body = "ctx.drawImage(img,x,y,width,height);")
4.132 + private native static void drawImageImpl(Object ctx, Object img, double x, double y, double width, double height);
4.133 +
4.134 + @JavaScriptBody(args = {"ctx", "img", "sx", "sy", "swidth", "sheight", "x", "y", "width", "height"}, body = "ctx.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);")
4.135 + private native static void drawImageImpl(Object ctx, Object img, double sx, double sy, double sWidth, double sHeight, double x, double y, double width, double height);
4.136 +
4.137 + @JavaScriptBody(args = {"ctx", "img", "x", "y"}, body = "ctx.drawImage(img,x,y);")
4.138 + private native static void drawImageImpl(Object ctx, Object img, double x, double y);
4.139 +
4.140 + @JavaScriptBody(args = {"style"}, body = "this.fld_context.fillStyle=style;")
4.141 + public native void setFillStyle(String style);
4.142 +
4.143 + @JavaScriptBody(args = {}, body = "return this.fld_context.fillStyle;")
4.144 + public native String getFillStyle();
4.145 +
4.146 + public void setFillStyle(LinearGradient style) {
4.147 + setFillStyleImpl(context, style.object());
4.148 + }
4.149 +
4.150 + public void setFillStyle(RadialGradient style) {
4.151 + setFillStyleImpl(context, style.object());
4.152 + }
4.153 +
4.154 + public void setFillStyle(Pattern style) {
4.155 + setFillStyleImpl(context, style.object());
4.156 + }
4.157 +
4.158 + @JavaScriptBody(args = {"context","obj"}, body = "context.fillStyle=obj;")
4.159 + private native void setFillStyleImpl(Object context, Object obj);
4.160 +
4.161 + @JavaScriptBody(args = {"style"}, body = "this.fld_context.strokeStyle=style;")
4.162 + public native void setStrokeStyle(String style);
4.163 +
4.164 + public void setStrokeStyle(LinearGradient style) {
4.165 + setStrokeStyleImpl(context, style.object());
4.166 + }
4.167 +
4.168 + public void setStrokeStyle(RadialGradient style) {
4.169 + setStrokeStyleImpl(context, style.object());
4.170 + }
4.171 +
4.172 + @JavaScriptBody(args = {"style"}, body = "this.fld_context.fillStyle=style;")
4.173 + public void setStrokeStyle(Pattern style) {
4.174 + setStrokeStyleImpl(context, style.object());
4.175 + }
4.176 +
4.177 + @JavaScriptBody(args = {"context","obj"}, body = "context.strokeStyle=obj;")
4.178 + private native void setStrokeStyleImpl(Object context, Object obj);
4.179 +
4.180 + @JavaScriptBody(args = {"color"}, body = "this.fld_context.shadowColor=color;")
4.181 + public native void setShadowColor(String color);
4.182 +
4.183 + @JavaScriptBody(args = {"blur"}, body = "this.fld_context.shadowBlur=blur;")
4.184 + public native void setShadowBlur(double blur);
4.185 +
4.186 + @JavaScriptBody(args = {"x"}, body = "this.fld_context.shadowOffsetX=x;")
4.187 + public native void setShadowOffsetX(double x);
4.188 +
4.189 + @JavaScriptBody(args = {"y"}, body = "this.fld_context.shadowOffsetY=y;")
4.190 + public native void setShadowOffsetY(double y);
4.191 +
4.192 + @JavaScriptBody(args = {}, body = "return this.fld_context.strokeStyle;")
4.193 + public native String getStrokeStyle();
4.194 +
4.195 + @JavaScriptBody(args = {}, body = "return this.fld_context.shadowColor;")
4.196 + public native String getShadowColor();
4.197 +
4.198 + @JavaScriptBody(args = {}, body = "return this.fld_context.shadowBlur;")
4.199 + public native double getShadowBlur();
4.200 +
4.201 + @JavaScriptBody(args = {}, body = "return this.fld_context.shadowOffsetX;")
4.202 + public native double getShadowOffsetX();
4.203 +
4.204 + @JavaScriptBody(args = {}, body = "return this.fld_context.shadowOffsetY;")
4.205 + public native double getShadowOffsetY();
4.206 +
4.207 + @JavaScriptBody(args = {}, body = "return this.fld_context.lineCap;")
4.208 + public native String getLineCap();
4.209 +
4.210 + @JavaScriptBody(args = {"style"}, body = "this.fld_context.lineCap=style;")
4.211 + public native void setLineCap(String style);
4.212 +
4.213 + @JavaScriptBody(args = {}, body = "return this.fld_context.lineJoin;")
4.214 + public native String getLineJoin();
4.215 +
4.216 + @JavaScriptBody(args = {"style"}, body = "this.fld_context.lineJoin=style;")
4.217 + public native void setLineJoin(String style) ;
4.218 +
4.219 + @JavaScriptBody(args = {}, body = "return this.fld_context.lineWidth;")
4.220 + public native double getLineWidth();
4.221 +
4.222 + @JavaScriptBody(args = {"width"}, body = "this.fld_context.lineJoin=width;")
4.223 + public native void setLineWidth(double width);
4.224 +
4.225 + @JavaScriptBody(args = {}, body = "return this.fld_context.miterLimit;")
4.226 + public native double getMiterLimit();
4.227 +
4.228 + @JavaScriptBody(args = {"limit"}, body = "this.fld_context.miterLimit=limit;")
4.229 + public native void setMiterLimit(double limit);
4.230 +
4.231 + @JavaScriptBody(args = {}, body = "return this.fld_context.font;")
4.232 + public native String getFont();
4.233 +
4.234 + @JavaScriptBody(args = {"font"}, body = "this.fld_context.font=font;")
4.235 + public native void setFont(String font);
4.236 +
4.237 + @JavaScriptBody(args = {}, body = "return this.fld_context.textAlign;")
4.238 + public native String getTextAlign();
4.239 +
4.240 + @JavaScriptBody(args = {"textalign"}, body = "this.fld_context.textAlign=textalign;")
4.241 + public native void setTextAlign(String textAlign);
4.242 +
4.243 + @JavaScriptBody(args = {}, body = "return this.fld_context.textBaseline;")
4.244 + public native String getTextBaseline();
4.245 +
4.246 + @JavaScriptBody(args = {"textbaseline"}, body = "this.fld_context.textBaseline=textbaseline;")
4.247 + public native void setTextBaseline(String textbaseline);
4.248 +
4.249 + @JavaScriptBody(args = {"text", "x", "y"}, body = "this.fld_context.fillText(text,x,y);")
4.250 + public native void fillText(String text, double x, double y);
4.251 +
4.252 + @JavaScriptBody(args = {"text", "x", "y", "maxwidth"}, body = "this.fld_context.fillText(text,x,y,maxwidth);")
4.253 + public void fillText(String text, double x, double y, double maxWidth) {
4.254 + }
4.255 +
4.256 + public TextMetrics measureText(String text) {
4.257 + return new TextMetrics(measureTextImpl(text));
4.258 + }
4.259 +
4.260 + @JavaScriptBody(args = {"text"},
4.261 + body = "return this.fld_context.measureText(text);")
4.262 + private native Object measureTextImpl(String text);
4.263 +
4.264 + @JavaScriptBody(args = {"text", "x", "y"}, body = "this.fld_context.strokeText(text,x,y);")
4.265 + public native void strokeText(String text, double x, double y);
4.266 +
4.267 + @JavaScriptBody(args = {"text", "x", "y", "maxWidth"}, body = "this.fld_context.strokeText(text,x,y,maxWidth);")
4.268 + public native void strokeText(String text, double x, double y, double maxWidth) ;
4.269 +
4.270 + public ImageData createImageData(double x, double y) {
4.271 + return new ImageData(createImageDataImpl(x, y));
4.272 + }
4.273 +
4.274 + @JavaScriptBody(args = {"x", "y"},
4.275 + body = "return this.fld_context.createImageData(x,y);")
4.276 + private native Object createImageDataImpl(double x, double y);
4.277 +
4.278 + public ImageData createImageData(ImageData imageData) {
4.279 + return new ImageData(createImageDataImpl(imageData.getWidth(), imageData.getHeight()));
4.280 + }
4.281 +
4.282 + public ImageData getImageData(double x, double y, double width, double height) {
4.283 + return new ImageData(getImageDataImpl(x, y, width, height));
4.284 + }
4.285 +
4.286 + @JavaScriptBody(args = {"x", "y", "width", "height"},
4.287 + body = "return this.fld_context.getImageData(x,y,width,height);")
4.288 + private native Object getImageDataImpl(double x, double y, double width, double height);
4.289 +
4.290 + public void putImageData(ImageData imageData, double x, double y) {
4.291 + putImageDataImpl(imageData.object(), x, y);
4.292 + }
4.293 +
4.294 + @JavaScriptBody(args = {"imageData", "x", "y"},
4.295 + body = "this.fld_context.putImageData(imageData,x,y);")
4.296 + private native void putImageDataImpl(Object imageData, double x, double y);
4.297 +
4.298 + public void putImageData(ImageData imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight) {
4.299 + putImageDataImpl(imageData.object(), x, y, dirtyx, dirtyy, dirtywidth, dirtyheight);
4.300 + }
4.301 +
4.302 + @JavaScriptBody(args = {"imageData", "x", "y", "dirtyx", "dirtyy", "dirtywidth", "dirtyheight"},
4.303 + body = "this.fld_context.putImageData(imageData,x,y, dirtyx, dirtyy, dirtywidth,dirtyheight);")
4.304 + private native void putImageDataImpl(Object imageData, double x, double y, double dirtyx, double dirtyy, double dirtywidth, double dirtyheight);
4.305 +
4.306 + @JavaScriptBody(args = {"alpha"}, body = "this.fld_context.globalAlpha=alpha;")
4.307 + public native void setGlobalAlpha(double alpha) ;
4.308 +
4.309 + @JavaScriptBody(args = {}, body = "return this.fld_context.globalAlpha;")
4.310 + public native double getGlobalAlpha();
4.311 +
4.312 + @JavaScriptBody(args = {"operation"}, body = "this.fld_context.globalCompositeOperation=operation;")
4.313 + public native void setGlobalCompositeOperation(double alpha);
4.314 +
4.315 + @JavaScriptBody(args = {}, body = "return this.fld_context.globalCompositeOperation;")
4.316 + public native double getGlobalCompositeOperation();
4.317 +
4.318 + public LinearGradient createLinearGradient(double x0, double y0, double x1, double y1) {
4.319 + return new LinearGradient(createLinearGradientImpl(context, x0, y0, x1, y1));
4.320 + }
4.321 +
4.322 + @JavaScriptBody(args = {"context", "x0", "y0", "x1", "y1"}, body = "return context.createLinearGradient(x0,y0,x1,y1);")
4.323 + private native Object createLinearGradientImpl(Object context, double x0, double y0, double x1, double y1);
4.324 +
4.325 + public Pattern createPattern(Image image, String repeat) {
4.326 + return new Pattern(createPatternImpl(context, image, repeat));
4.327 + }
4.328 +
4.329 + @JavaScriptBody(args = {"context", "image", "repeat"}, body = "return context.createPattern(image, repeat);")
4.330 + private static native Object createPatternImpl(Object context, Image image, String repeat);
4.331 +
4.332 + public RadialGradient createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1) {
4.333 + return new RadialGradient(createRadialGradientImpl(context, x0, y0, r0, x1, y1, r1));
4.334 + }
4.335 +
4.336 + @JavaScriptBody(args = {"context", "x0", "y0", "r0", "x1", "y1", "r1"}, body = "return context.createRadialGradient(x0,y0,r0,x1,y1,r1);")
4.337 + private static native Object createRadialGradientImpl(Object context, double x0, double y0, double r0, double x1, double y1, double r1);
4.338 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Image.java Tue Jan 22 17:54:09 2013 +0100
5.3 @@ -0,0 +1,36 @@
5.4 +/**
5.5 + * Back 2 Browser Bytecode Translator
5.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
5.7 + *
5.8 + * This program is free software: you can redistribute it and/or modify
5.9 + * it under the terms of the GNU General Public License as published by
5.10 + * the Free Software Foundation, version 2 of the License.
5.11 + *
5.12 + * This program is distributed in the hope that it will be useful,
5.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
5.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.15 + * GNU General Public License for more details.
5.16 + *
5.17 + * You should have received a copy of the GNU General Public License
5.18 + * along with this program. Look for COPYING file in the top folder.
5.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
5.20 + */
5.21 +package org.apidesign.bck2brwsr.htmlpage.api;
5.22 +
5.23 +/**
5.24 + *
5.25 + * @author Anton Epple <toni.epple@eppleton.de>
5.26 + */
5.27 +public class Image extends Element{
5.28 +
5.29 + public Image(String id) {
5.30 + super(id);
5.31 + }
5.32 +
5.33 +
5.34 +
5.35 + @Override
5.36 + void dontSubclass() {
5.37 + }
5.38 +
5.39 +}
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/ImageData.java Tue Jan 22 17:54:09 2013 +0100
6.3 @@ -0,0 +1,89 @@
6.4 +/**
6.5 + * Back 2 Browser Bytecode Translator
6.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
6.7 + *
6.8 + * This program is free software: you can redistribute it and/or modify
6.9 + * it under the terms of the GNU General Public License as published by
6.10 + * the Free Software Foundation, version 2 of the License.
6.11 + *
6.12 + * This program is distributed in the hope that it will be useful,
6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.15 + * GNU General Public License for more details.
6.16 + *
6.17 + * You should have received a copy of the GNU General Public License
6.18 + * along with this program. Look for COPYING file in the top folder.
6.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
6.20 + */
6.21 +/*
6.22 + * To change this template, choose Tools | Templates
6.23 + * and open the template in the editor.
6.24 + */
6.25 +package org.apidesign.bck2brwsr.htmlpage.api;
6.26 +
6.27 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
6.28 +
6.29 +/**
6.30 + *
6.31 + * @author Anton Epple <toni.epple@eppleton.de>
6.32 + */
6.33 +public class ImageData {
6.34 +
6.35 + private Object imageData;
6.36 + private Data data;
6.37 +
6.38 + public ImageData(Object imageData) {
6.39 + this.imageData = imageData;
6.40 + }
6.41 +
6.42 + public Data getData(){
6.43 + if (data == null){
6.44 + data = new Data(getDataImpl(imageData));
6.45 + }
6.46 + return data;
6.47 + }
6.48 +
6.49 + @JavaScriptBody(args = {"imageData"}, body = "return imageData.data")
6.50 + public native Object getDataImpl(Object imageData);
6.51 +
6.52 + public double getWidth() {
6.53 + return getWidthImpl(imageData);
6.54 + }
6.55 +
6.56 + @JavaScriptBody(args = {"imageData"}, body = "return imagedata.width;")
6.57 + private static native double getWidthImpl(Object imageData);
6.58 +
6.59 + public double getHeight() {
6.60 + return getHeightImpl(imageData);
6.61 + }
6.62 +
6.63 + @JavaScriptBody(args = {"imageData"}, body = "return imagedata.height;")
6.64 + private static native double getHeightImpl(Object imageData);
6.65 +
6.66 + Object object() {
6.67 + return imageData;
6.68 + }
6.69 +
6.70 + public static class Data {
6.71 +
6.72 + Object data;
6.73 +
6.74 + public Data(Object data) {
6.75 + this.data = data;
6.76 + }
6.77 +
6.78 + public int get(int index) {
6.79 + return getImpl(data, index);
6.80 + }
6.81 +
6.82 + public void set(int index, int value) {
6.83 + setImpl(data, index, value);
6.84 + }
6.85 +
6.86 + @JavaScriptBody(args = {"data", "index", "value"}, body = "data[index]=value;")
6.87 + private static native void setImpl(Object data, int index, int value);
6.88 +
6.89 + @JavaScriptBody(args = {"imagedata", "index"}, body = "return data[index];")
6.90 + private static native int getImpl(Object data, int index);
6.91 + }
6.92 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/LinearGradient.java Tue Jan 22 17:54:09 2013 +0100
7.3 @@ -0,0 +1,45 @@
7.4 +/**
7.5 + * Back 2 Browser Bytecode Translator
7.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
7.7 + *
7.8 + * This program is free software: you can redistribute it and/or modify
7.9 + * it under the terms of the GNU General Public License as published by
7.10 + * the Free Software Foundation, version 2 of the License.
7.11 + *
7.12 + * This program is distributed in the hope that it will be useful,
7.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.15 + * GNU General Public License for more details.
7.16 + *
7.17 + * You should have received a copy of the GNU General Public License
7.18 + * along with this program. Look for COPYING file in the top folder.
7.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
7.20 + */
7.21 +package org.apidesign.bck2brwsr.htmlpage.api;
7.22 +
7.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
7.24 +
7.25 +/**
7.26 + *
7.27 + * @author Anton Epple <toni.epple@eppleton.de>
7.28 + */
7.29 +public class LinearGradient {
7.30 +
7.31 + private final Object gradient;
7.32 +
7.33 + LinearGradient(Object linearGradient) {
7.34 + this.gradient = linearGradient;
7.35 + }
7.36 +
7.37 + Object object() {
7.38 + return gradient;
7.39 + }
7.40 +
7.41 + public void addColorStop(double position, String color) {
7.42 + addColorStopImpl(gradient, position, color);
7.43 + }
7.44 +
7.45 + @JavaScriptBody(args = {"gradient", "position", "color"}, body =
7.46 + "gradient.addColorStop(position,color)")
7.47 + private static native void addColorStopImpl(Object gradient, double position, String color);
7.48 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Paint.java Tue Jan 22 17:54:09 2013 +0100
8.3 @@ -0,0 +1,30 @@
8.4 +/**
8.5 + * Back 2 Browser Bytecode Translator
8.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
8.7 + *
8.8 + * This program is free software: you can redistribute it and/or modify
8.9 + * it under the terms of the GNU General Public License as published by
8.10 + * the Free Software Foundation, version 2 of the License.
8.11 + *
8.12 + * This program is distributed in the hope that it will be useful,
8.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
8.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8.15 + * GNU General Public License for more details.
8.16 + *
8.17 + * You should have received a copy of the GNU General Public License
8.18 + * along with this program. Look for COPYING file in the top folder.
8.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
8.20 + */
8.21 +package org.apidesign.bck2brwsr.htmlpage.api;
8.22 +
8.23 +/**
8.24 + *
8.25 + * @author Anton Epple <toni.epple@eppleton.de>
8.26 + */
8.27 +public class Paint {
8.28 +
8.29 +
8.30 + String asString(){
8.31 + return "";
8.32 + }
8.33 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/Pattern.java Tue Jan 22 17:54:09 2013 +0100
9.3 @@ -0,0 +1,35 @@
9.4 +/**
9.5 + * Back 2 Browser Bytecode Translator
9.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
9.7 + *
9.8 + * This program is free software: you can redistribute it and/or modify
9.9 + * it under the terms of the GNU General Public License as published by
9.10 + * the Free Software Foundation, version 2 of the License.
9.11 + *
9.12 + * This program is distributed in the hope that it will be useful,
9.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
9.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9.15 + * GNU General Public License for more details.
9.16 + *
9.17 + * You should have received a copy of the GNU General Public License
9.18 + * along with this program. Look for COPYING file in the top folder.
9.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
9.20 + */
9.21 +package org.apidesign.bck2brwsr.htmlpage.api;
9.22 +
9.23 +/**
9.24 + *
9.25 + * @author Anton Epple <toni.epple@eppleton.de>
9.26 + */
9.27 +public class Pattern {
9.28 +
9.29 + private Object pattern;
9.30 +
9.31 + public Pattern(Object pattern) {
9.32 + this.pattern = pattern;
9.33 + }
9.34 +
9.35 + Object object() {
9.36 + return pattern;
9.37 + }
9.38 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/RadialGradient.java Tue Jan 22 17:54:09 2013 +0100
10.3 @@ -0,0 +1,45 @@
10.4 +/**
10.5 + * Back 2 Browser Bytecode Translator
10.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
10.7 + *
10.8 + * This program is free software: you can redistribute it and/or modify
10.9 + * it under the terms of the GNU General Public License as published by
10.10 + * the Free Software Foundation, version 2 of the License.
10.11 + *
10.12 + * This program is distributed in the hope that it will be useful,
10.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
10.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10.15 + * GNU General Public License for more details.
10.16 + *
10.17 + * You should have received a copy of the GNU General Public License
10.18 + * along with this program. Look for COPYING file in the top folder.
10.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
10.20 + */
10.21 +package org.apidesign.bck2brwsr.htmlpage.api;
10.22 +
10.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
10.24 +
10.25 +/**
10.26 + *
10.27 + * @author Anton Epple <toni.epple@eppleton.de>
10.28 + */
10.29 +public class RadialGradient {
10.30 +
10.31 + private Object gradient;
10.32 +
10.33 + public RadialGradient(Object radialGradient) {
10.34 + this.gradient = radialGradient;
10.35 + }
10.36 +
10.37 + public void addColorStop(double position, String color) {
10.38 + addColorStopImpl(gradient, position, color);
10.39 + }
10.40 +
10.41 + @JavaScriptBody(args = {"gradient", "position", "color"}, body =
10.42 + "gradient.addColorStop(position,color)")
10.43 + private static native void addColorStopImpl(Object gradient, double position, String color);
10.44 +
10.45 + Object object() {
10.46 + return gradient;
10.47 + }
10.48 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/javaquery/api/src/main/java/org/apidesign/bck2brwsr/htmlpage/api/TextMetrics.java Tue Jan 22 17:54:09 2013 +0100
11.3 @@ -0,0 +1,48 @@
11.4 +/**
11.5 + * Back 2 Browser Bytecode Translator
11.6 + * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
11.7 + *
11.8 + * This program is free software: you can redistribute it and/or modify
11.9 + * it under the terms of the GNU General Public License as published by
11.10 + * the Free Software Foundation, version 2 of the License.
11.11 + *
11.12 + * This program is distributed in the hope that it will be useful,
11.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
11.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11.15 + * GNU General Public License for more details.
11.16 + *
11.17 + * You should have received a copy of the GNU General Public License
11.18 + * along with this program. Look for COPYING file in the top folder.
11.19 + * If not, see http://opensource.org/licenses/GPL-2.0.
11.20 + */
11.21 +package org.apidesign.bck2brwsr.htmlpage.api;
11.22 +
11.23 +import org.apidesign.bck2brwsr.core.JavaScriptBody;
11.24 +
11.25 +/**
11.26 + *
11.27 + * @author Anton Epple <toni.epple@eppleton.de>
11.28 + */
11.29 +public class TextMetrics {
11.30 +
11.31 + private Object textMetrics;
11.32 +
11.33 + TextMetrics(Object measureTextImpl) {
11.34 + this.textMetrics = measureTextImpl;
11.35 + }
11.36 +
11.37 + @JavaScriptBody(args = {"textMetrics"}, body = "return textMetrics.width;")
11.38 + private native double getWidth(Object textMetrics);
11.39 +
11.40 + @JavaScriptBody(args = {"textMetrics"}, body = "return textMetrics.height;")
11.41 + private native double getHeight(Object textMetrics);
11.42 +
11.43 + public double getWidth() {
11.44 + return getWidth(textMetrics);
11.45 + }
11.46 +
11.47 + public double getHeight() {
11.48 + return getHeight(textMetrics);
11.49 +
11.50 + }
11.51 +}
12.1 --- a/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Tue Jan 22 13:56:27 2013 +0100
12.2 +++ b/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/Bck2BrwsrLauncher.java Tue Jan 22 17:54:09 2013 +0100
12.3 @@ -216,12 +216,12 @@
12.4 if (ch == -1) {
12.5 break;
12.6 }
12.7 - if (ch == '$') {
12.8 + if (ch == '$' && params.length > 0) {
12.9 int cnt = is.read() - '0';
12.10 if (cnt == 'U' - '0') {
12.11 os.write(baseURL.getBytes());
12.12 }
12.13 - if (cnt < params.length) {
12.14 + if (cnt >= 0 && cnt < params.length) {
12.15 os.write(params[cnt].getBytes());
12.16 }
12.17 } else {
12.18 @@ -360,17 +360,20 @@
12.19 r = r.substring(1);
12.20 }
12.21 }
12.22 + String[] replace = {};
12.23 if (r.endsWith(".html")) {
12.24 response.setContentType("text/html");
12.25 LOG.info("Content type text/html");
12.26 + replace = args;
12.27 }
12.28 if (r.endsWith(".xhtml")) {
12.29 response.setContentType("application/xhtml+xml");
12.30 LOG.info("Content type application/xhtml+xml");
12.31 + replace = args;
12.32 }
12.33 OutputStream os = response.getOutputStream();
12.34 try (InputStream is = res.get(r)) {
12.35 - copyStream(is, os, request.getRequestURL().toString(), args);
12.36 + copyStream(is, os, request.getRequestURL().toString(), replace);
12.37 } catch (IOException ex) {
12.38 response.setDetailMessage(ex.getLocalizedMessage());
12.39 response.setError();