X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjava%2Fawt%2FFontMetrics.js;fp=site%2Fj2s%2Fjava%2Fawt%2FFontMetrics.js;h=5ed326b019406c3ab2de386610263b99808aba6a;hp=60bc6c5e2c4e5c8f8e5cbba499be0e5d4871d531;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/java/awt/FontMetrics.js b/site/j2s/java/awt/FontMetrics.js index 60bc6c5..5ed326b 100644 --- a/site/j2s/java/awt/FontMetrics.js +++ b/site/j2s/java/awt/FontMetrics.js @@ -1,97 +1,97 @@ -Clazz.declarePackage ("java.awt"); -Clazz.load (["java.awt.font.FontRenderContext"], "java.awt.FontMetrics", ["java.lang.Character"], function () { -c$ = Clazz.decorateAsClass (function () { -this.font = null; -Clazz.instantialize (this, arguments); -}, java.awt, "FontMetrics"); -Clazz.makeConstructor (c$, -function (font) { -this.font = font; -}, "java.awt.Font"); -Clazz.defineMethod (c$, "getFont", -function () { -return this.font; -}); -Clazz.defineMethod (c$, "getFontRenderContext", -function () { -return java.awt.FontMetrics.DEFAULT_FRC; -}); -Clazz.defineMethod (c$, "getLeading", -function () { -return 0; -}); -Clazz.defineMethod (c$, "getAscent", -function () { -return this.font.getSize (); -}); -Clazz.defineMethod (c$, "getDescent", -function () { -return 0; -}); -Clazz.defineMethod (c$, "getHeight", -function () { -return this.getLeading () + this.getAscent () + this.getDescent (); -}); -Clazz.defineMethod (c$, "getMaxAscent", -function () { -return this.getAscent (); -}); -Clazz.defineMethod (c$, "getMaxDescent", -function () { -return this.getDescent (); -}); -Clazz.defineMethod (c$, "getMaxDecent", -function () { -return this.getMaxDescent (); -}); -Clazz.defineMethod (c$, "getMaxAdvance", -function () { -return -1; -}); -Clazz.defineMethod (c$, "charWidth", -function (codePoint) { -if (!Character.isValidCodePoint (codePoint)) { -codePoint = 0xffff; -}if (codePoint < 256) { -return this.getWidths ()[codePoint]; -} else { -var buffer = Clazz.newCharArray (2, '\0'); -var len = Character.toChars (codePoint, buffer, 0); -return this.charsWidth (buffer, 0, len); -}}, "~N"); -Clazz.defineMethod (c$, "charWidth", -function (ch) { -if (ch.charCodeAt (0) < 256) { -return this.getWidths ()[ch.charCodeAt (0)]; -}var data = Clazz.newCharArray (-1, [ch]); -return this.charsWidth (data, 0, 1); -}, "~S"); -Clazz.defineMethod (c$, "stringWidth", -function (str) { -var len = str.length; -var data = Clazz.newCharArray (len, '\0'); -str.getChars (0, len, data, 0); -return this.charsWidth (data, 0, len); -}, "~S"); -Clazz.defineMethod (c$, "charsWidth", -function (data, off, len) { -return this.stringWidth ( String.instantialize (data, off, len)); -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "bytesWidth", -function (data, off, len) { -return this.stringWidth ( String.instantialize (data, 0, off, len)); -}, "~A,~N,~N"); -Clazz.defineMethod (c$, "getWidths", -function () { -var widths = Clazz.newIntArray (256, 0); -for (var ch = String.fromCharCode (0); ch.charCodeAt (0) < 256; ch = String.fromCharCode (ch.charCodeAt (0) + 1)) { -widths[ch.charCodeAt (0)] = this.charWidth (ch); -} -return widths; -}); -Clazz.overrideMethod (c$, "toString", -function () { -return this.getClass ().getName () + "[font=" + this.getFont () + "ascent=" + this.getAscent () + ", descent=" + this.getDescent () + ", height=" + this.getHeight () + "]"; -}); -c$.DEFAULT_FRC = c$.prototype.DEFAULT_FRC = new java.awt.font.FontRenderContext (null, false, false); -}); +Clazz.declarePackage ("java.awt"); +Clazz.load (["java.awt.font.FontRenderContext"], "java.awt.FontMetrics", ["java.lang.Character"], function () { +c$ = Clazz.decorateAsClass (function () { +this.font = null; +Clazz.instantialize (this, arguments); +}, java.awt, "FontMetrics"); +Clazz.makeConstructor (c$, +function (font) { +this.font = font; +}, "java.awt.Font"); +Clazz.defineMethod (c$, "getFont", +function () { +return this.font; +}); +Clazz.defineMethod (c$, "getFontRenderContext", +function () { +return java.awt.FontMetrics.DEFAULT_FRC; +}); +Clazz.defineMethod (c$, "getLeading", +function () { +return 0; +}); +Clazz.defineMethod (c$, "getAscent", +function () { +return this.font.getSize (); +}); +Clazz.defineMethod (c$, "getDescent", +function () { +return 0; +}); +Clazz.defineMethod (c$, "getHeight", +function () { +return this.getLeading () + this.getAscent () + this.getDescent (); +}); +Clazz.defineMethod (c$, "getMaxAscent", +function () { +return this.getAscent (); +}); +Clazz.defineMethod (c$, "getMaxDescent", +function () { +return this.getDescent (); +}); +Clazz.defineMethod (c$, "getMaxDecent", +function () { +return this.getMaxDescent (); +}); +Clazz.defineMethod (c$, "getMaxAdvance", +function () { +return -1; +}); +Clazz.defineMethod (c$, "charWidth", +function (codePoint) { +if (!Character.isValidCodePoint (codePoint)) { +codePoint = 0xffff; +}if (codePoint < 256) { +return this.getWidths ()[codePoint]; +} else { +var buffer = Clazz.newCharArray (2, '\0'); +var len = Character.toChars (codePoint, buffer, 0); +return this.charsWidth (buffer, 0, len); +}}, "~N"); +Clazz.defineMethod (c$, "charWidth", +function (ch) { +if (ch.charCodeAt (0) < 256) { +return this.getWidths ()[ch.charCodeAt (0)]; +}var data = Clazz.newCharArray (-1, [ch]); +return this.charsWidth (data, 0, 1); +}, "~S"); +Clazz.defineMethod (c$, "stringWidth", +function (str) { +var len = str.length; +var data = Clazz.newCharArray (len, '\0'); +str.getChars (0, len, data, 0); +return this.charsWidth (data, 0, len); +}, "~S"); +Clazz.defineMethod (c$, "charsWidth", +function (data, off, len) { +return this.stringWidth ( String.instantialize (data, off, len)); +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "bytesWidth", +function (data, off, len) { +return this.stringWidth ( String.instantialize (data, 0, off, len)); +}, "~A,~N,~N"); +Clazz.defineMethod (c$, "getWidths", +function () { +var widths = Clazz.newIntArray (256, 0); +for (var ch = String.fromCharCode (0); ch.charCodeAt (0) < 256; ch = String.fromCharCode (ch.charCodeAt (0) + 1)) { +widths[ch.charCodeAt (0)] = this.charWidth (ch); +} +return widths; +}); +Clazz.overrideMethod (c$, "toString", +function () { +return this.getClass ().getName () + "[font=" + this.getFont () + "ascent=" + this.getAscent () + ", descent=" + this.getDescent () + ", height=" + this.getHeight () + "]"; +}); +c$.DEFAULT_FRC = c$.prototype.DEFAULT_FRC = new java.awt.font.FontRenderContext (null, false, false); +});