X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=site%2Fj2s%2Fswingjs%2FJSGraphicsEnvironment.js;fp=site%2Fj2s%2Fswingjs%2FJSGraphicsEnvironment.js;h=5344425fb34e9523d61351691c1001d081f641e1;hb=4231d40261fef32ce4570a6bbad0d35df44e8baf;hp=0000000000000000000000000000000000000000;hpb=c07eb2c5794833bd0241000d6844d783fe10cb82;p=jalview.git diff --git a/site/j2s/swingjs/JSGraphicsEnvironment.js b/site/j2s/swingjs/JSGraphicsEnvironment.js new file mode 100644 index 0000000..5344425 --- /dev/null +++ b/site/j2s/swingjs/JSGraphicsEnvironment.js @@ -0,0 +1,48 @@ +Clazz.declarePackage ("swingjs"); +Clazz.load (["java.awt.GraphicsEnvironment"], "swingjs.JSGraphicsEnvironment", ["swingjs.JSGraphics2D", "$.JSToolkit", "swingjs.api.DOMNode"], function () { +c$ = Clazz.declareType (swingjs, "JSGraphicsEnvironment", java.awt.GraphicsEnvironment); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, swingjs.JSGraphicsEnvironment, []); +System.out.println ("JSGraphicsEnvironment initialized"); +}); +Clazz.overrideMethod (c$, "createGraphics", +function (img) { +return this.createGraphicsSized (img, img.getWidth (), img.getHeight ()); +}, "java.awt.image.BufferedImage"); +Clazz.defineMethod (c$, "createGraphicsSized", +function (img, width, height) { +var g = null; +{ +g = img._g; +}if (g == null) { +var canvas = swingjs.api.DOMNode.createElement ("canvas", "img" + System.currentTimeMillis ()); +{ +canvas.width = width; +canvas.height = height; +img._canvas = canvas; +}g = new swingjs.JSGraphics2D (canvas); +{ +img._g = g; +}}return g; +}, "~O,~N,~N"); +Clazz.overrideMethod (c$, "getAllFonts", +function () { +return null; +}); +Clazz.defineMethod (c$, "getAvailableFontFamilyNames", +function () { +return null; +}); +Clazz.defineMethod (c$, "getAvailableFontFamilyNames", +function (l) { +return null; +}, "java.util.Locale"); +Clazz.overrideMethod (c$, "getDefaultScreenDevice", +function () { +if (swingjs.JSGraphicsEnvironment.device == null) swingjs.JSGraphicsEnvironment.device = swingjs.JSToolkit.getInstance ("swingjs.JSScreenDevice"); +return swingjs.JSGraphicsEnvironment.device; +}); +Clazz.defineStatics (c$, +"device", null); +});