toni@521: /** toni@521: * Back 2 Browser Bytecode Translator toni@521: * Copyright (C) 2012 Jaroslav Tulach toni@521: * toni@521: * This program is free software: you can redistribute it and/or modify toni@521: * it under the terms of the GNU General Public License as published by toni@521: * the Free Software Foundation, version 2 of the License. toni@521: * toni@521: * This program is distributed in the hope that it will be useful, toni@521: * but WITHOUT ANY WARRANTY; without even the implied warranty of toni@521: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the toni@521: * GNU General Public License for more details. toni@521: * toni@521: * You should have received a copy of the GNU General Public License toni@521: * along with this program. Look for COPYING file in the top folder. toni@521: * If not, see http://opensource.org/licenses/GPL-2.0. toni@521: */ toni@521: /* toni@521: * To change this template, choose Tools | Templates toni@521: * and open the template in the editor. toni@521: */ toni@521: package org.apidesign.bck2brwsr.htmlpage.api; toni@521: toni@521: import org.apidesign.bck2brwsr.core.JavaScriptBody; toni@521: toni@521: /** toni@521: * toni@521: * @author Anton Epple toni@521: */ toni@521: public class ImageData { toni@521: toni@521: private Object imageData; toni@521: private Data data; toni@521: toni@521: public ImageData(Object imageData) { toni@521: this.imageData = imageData; toni@521: } toni@521: toni@521: public Data getData(){ toni@521: if (data == null){ toni@521: data = new Data(getDataImpl(imageData)); toni@521: } toni@521: return data; toni@521: } toni@521: toni@521: @JavaScriptBody(args = {"imageData"}, body = "return imageData.data") toni@521: public native Object getDataImpl(Object imageData); toni@521: toni@521: public double getWidth() { toni@521: return getWidthImpl(imageData); toni@521: } toni@521: toni@521: @JavaScriptBody(args = {"imageData"}, body = "return imagedata.width;") toni@521: private static native double getWidthImpl(Object imageData); toni@521: toni@521: public double getHeight() { toni@521: return getHeightImpl(imageData); toni@521: } toni@521: toni@521: @JavaScriptBody(args = {"imageData"}, body = "return imagedata.height;") toni@521: private static native double getHeightImpl(Object imageData); toni@521: toni@521: Object object() { toni@521: return imageData; toni@521: } toni@521: toni@521: public static class Data { toni@521: toni@521: Object data; toni@521: toni@521: public Data(Object data) { toni@521: this.data = data; toni@521: } toni@521: toni@521: public int get(int index) { toni@521: return getImpl(data, index); toni@521: } toni@521: toni@521: public void set(int index, int value) { toni@521: setImpl(data, index, value); toni@521: } toni@521: toni@521: @JavaScriptBody(args = {"data", "index", "value"}, body = "data[index]=value;") toni@521: private static native void setImpl(Object data, int index, int value); toni@521: toni@521: @JavaScriptBody(args = {"imagedata", "index"}, body = "return data[index];") toni@521: private static native int getImpl(Object data, int index); toni@521: } toni@521: }