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: 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 Canvas extends Element { toni@521: toni@521: public Canvas(String id) { toni@521: super(id); toni@521: } toni@521: toni@521: public void setHeight(int height) { toni@521: setAttribute(this, "height", height); toni@521: } toni@521: toni@521: public int getHeight() { toni@521: return (Integer) getAttribute(this, "height"); toni@521: } toni@521: toni@521: public void setWidth(int width) { toni@521: setAttribute(this, "width", width); toni@521: } toni@521: toni@521: public int getWidth() { toni@521: return (Integer) getAttribute(this, "width"); toni@521: } toni@521: toni@521: @JavaScriptBody( toni@521: args = {"el"}, jaroslav@592: body = "var e = window.document.getElementById(el._id());\n" toni@521: + "return e.getContext('2d');\n") toni@521: private native static Object getContextImpl(Canvas el); toni@521: toni@521: public GraphicsContext getContext() { toni@521: return new GraphicsContext(getContextImpl(this)); toni@521: } toni@521: toni@521: @Override toni@521: void dontSubclass() { toni@521: } toni@521: }