X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=site%2Fj2s%2Fjssun%2Ffont%2FFontDesignMetrics.js;fp=site%2Fj2s%2Fjssun%2Ffont%2FFontDesignMetrics.js;h=735c47a59774271e95d3eaf92eaf8ede05d2b7cd;hp=6bf2670c65ddbfe971dc195f9afbeb008a656ae3;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/site/j2s/jssun/font/FontDesignMetrics.js b/site/j2s/jssun/font/FontDesignMetrics.js index 6bf2670..735c47a 100644 --- a/site/j2s/jssun/font/FontDesignMetrics.js +++ b/site/j2s/jssun/font/FontDesignMetrics.js @@ -1,122 +1,122 @@ -Clazz.declarePackage ("jssun.font"); -Clazz.load (["java.awt.FontMetrics", "java.util.Hashtable"], "jssun.font.FontDesignMetrics", ["java.lang.IndexOutOfBoundsException", "java.awt.Toolkit", "swingjs.JSToolkit"], function () { -c$ = Clazz.decorateAsClass (function () { -this.ascent = 0; -this.descent = 0; -this.leading = 0; -this.height = -1; -Clazz.instantialize (this, arguments); -}, jssun.font, "FontDesignMetrics", java.awt.FontMetrics); -c$.getMetrics = Clazz.defineMethod (c$, "getMetrics", -function (font) { -var m = null; -var r; -r = jssun.font.FontDesignMetrics.metricsCache.get (font); -if (r != null) { -m = r.get (); -}if (m == null) { -m = new jssun.font.FontDesignMetrics (font); -jssun.font.FontDesignMetrics.metricsCache.put (font, new jssun.font.FontDesignMetrics.KeyReference (font, m)); -}for (var i = 0; i < jssun.font.FontDesignMetrics.recentMetrics.length; i++) { -if (jssun.font.FontDesignMetrics.recentMetrics[i] === m) { -return m; -}} -{ -jssun.font.FontDesignMetrics.recentMetrics[jssun.font.FontDesignMetrics.recentIndex++] = m; -if (jssun.font.FontDesignMetrics.recentIndex == 5) { -jssun.font.FontDesignMetrics.recentIndex = 0; -}}return m; -}, "java.awt.Font"); -Clazz.makeConstructor (c$, - function (font) { -Clazz.superConstructor (this, jssun.font.FontDesignMetrics, [font]); -this.font = font; -this.initMatrixAndMetrics (); -}, "java.awt.Font"); -Clazz.defineMethod (c$, "initMatrixAndMetrics", - function () { -{ -//need to calculate ascent, descent, leading, and maxAdvance -}}); -Clazz.defineMethod (c$, "charWidth", -function (ch) { -var s = ""; -{ -s = "" + ch; -}return this.stringWidth (s); -}, "~S"); -Clazz.overrideMethod (c$, "stringWidth", -function (str) { -return Clazz.doubleToInt (0.5 + this.getWidth (str)); -}, "~S"); -Clazz.defineMethod (c$, "getWidth", - function (str) { -return swingjs.JSToolkit.getStringWidth (null, this.font, str); -}, "~S"); -Clazz.overrideMethod (c$, "charsWidth", -function (data, off, len) { -var width = 0; -if (len < 0) { -throw new IndexOutOfBoundsException ("len=" + len); -}var limit = off + len; -for (var i = off; i < limit; i++) { -var ch = data[i]; -width += this.stringWidth ("" + ch); -} -return Clazz.doubleToInt (0.5 + width); -}, "~A,~N,~N"); -Clazz.overrideMethod (c$, "getWidths", -function () { -var widths = Clazz.newIntArray (256, 0); -return widths; -}); -Clazz.defineMethod (c$, "getAscent", -function () { -if (this.ascent == 0) this.ascent = java.awt.Toolkit.getDefaultToolkit ().getFontMetrics (this.font).getAscent (); -return Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.ascent); -}); -Clazz.defineMethod (c$, "getDescent", -function () { -if (this.descent == 0) this.descent = java.awt.Toolkit.getDefaultToolkit ().getFontMetrics (this.font).getDescent (); -return Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent); -}); -Clazz.overrideMethod (c$, "getLeading", -function () { -return Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent + this.leading) - Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent); -}); -Clazz.overrideMethod (c$, "getHeight", -function () { -if (this.height < 0) { -this.height = this.getAscent () + Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent + this.leading); -}return this.height; -}); -Clazz.pu$h(self.c$); -c$ = Clazz.decorateAsClass (function () { -this.key = null; -this.val = null; -Clazz.instantialize (this, arguments); -}, jssun.font.FontDesignMetrics, "KeyReference"); -Clazz.makeConstructor (c$, -function (a, b) { -this.key = a; -this.val = b; -}, "~O,~O"); -Clazz.defineMethod (c$, "get", -function () { -return this.val; -}); -Clazz.defineMethod (c$, "dispose", -function () { -if (jssun.font.FontDesignMetrics.metricsCache.get (this.key) === this) { -jssun.font.FontDesignMetrics.metricsCache.remove (this.key); -}}); -c$ = Clazz.p0p (); -Clazz.defineStatics (c$, -"roundingUpValue", 0.95); -c$.metricsCache = c$.prototype.metricsCache = new java.util.Hashtable (); -Clazz.defineStatics (c$, -"MAXRECENT", 5); -c$.recentMetrics = c$.prototype.recentMetrics = new Array (5); -Clazz.defineStatics (c$, -"recentIndex", 0); -}); +Clazz.declarePackage ("jssun.font"); +Clazz.load (["java.awt.FontMetrics", "java.util.Hashtable"], "jssun.font.FontDesignMetrics", ["java.lang.IndexOutOfBoundsException", "java.awt.Toolkit", "swingjs.JSToolkit"], function () { +c$ = Clazz.decorateAsClass (function () { +this.ascent = 0; +this.descent = 0; +this.leading = 0; +this.height = -1; +Clazz.instantialize (this, arguments); +}, jssun.font, "FontDesignMetrics", java.awt.FontMetrics); +c$.getMetrics = Clazz.defineMethod (c$, "getMetrics", +function (font) { +var m = null; +var r; +r = jssun.font.FontDesignMetrics.metricsCache.get (font); +if (r != null) { +m = r.get (); +}if (m == null) { +m = new jssun.font.FontDesignMetrics (font); +jssun.font.FontDesignMetrics.metricsCache.put (font, new jssun.font.FontDesignMetrics.KeyReference (font, m)); +}for (var i = 0; i < jssun.font.FontDesignMetrics.recentMetrics.length; i++) { +if (jssun.font.FontDesignMetrics.recentMetrics[i] === m) { +return m; +}} +{ +jssun.font.FontDesignMetrics.recentMetrics[jssun.font.FontDesignMetrics.recentIndex++] = m; +if (jssun.font.FontDesignMetrics.recentIndex == 5) { +jssun.font.FontDesignMetrics.recentIndex = 0; +}}return m; +}, "java.awt.Font"); +Clazz.makeConstructor (c$, + function (font) { +Clazz.superConstructor (this, jssun.font.FontDesignMetrics, [font]); +this.font = font; +this.initMatrixAndMetrics (); +}, "java.awt.Font"); +Clazz.defineMethod (c$, "initMatrixAndMetrics", + function () { +{ +//need to calculate ascent, descent, leading, and maxAdvance +}}); +Clazz.defineMethod (c$, "charWidth", +function (ch) { +var s = ""; +{ +s = "" + ch; +}return this.stringWidth (s); +}, "~S"); +Clazz.overrideMethod (c$, "stringWidth", +function (str) { +return Clazz.doubleToInt (0.5 + this.getWidth (str)); +}, "~S"); +Clazz.defineMethod (c$, "getWidth", + function (str) { +return swingjs.JSToolkit.getStringWidth (null, this.font, str); +}, "~S"); +Clazz.overrideMethod (c$, "charsWidth", +function (data, off, len) { +var width = 0; +if (len < 0) { +throw new IndexOutOfBoundsException ("len=" + len); +}var limit = off + len; +for (var i = off; i < limit; i++) { +var ch = data[i]; +width += this.stringWidth ("" + ch); +} +return Clazz.doubleToInt (0.5 + width); +}, "~A,~N,~N"); +Clazz.overrideMethod (c$, "getWidths", +function () { +var widths = Clazz.newIntArray (256, 0); +return widths; +}); +Clazz.defineMethod (c$, "getAscent", +function () { +if (this.ascent == 0) this.ascent = java.awt.Toolkit.getDefaultToolkit ().getFontMetrics (this.font).getAscent (); +return Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.ascent); +}); +Clazz.defineMethod (c$, "getDescent", +function () { +if (this.descent == 0) this.descent = java.awt.Toolkit.getDefaultToolkit ().getFontMetrics (this.font).getDescent (); +return Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent); +}); +Clazz.overrideMethod (c$, "getLeading", +function () { +return Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent + this.leading) - Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent); +}); +Clazz.overrideMethod (c$, "getHeight", +function () { +if (this.height < 0) { +this.height = this.getAscent () + Clazz.floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent + this.leading); +}return this.height; +}); +Clazz.pu$h(self.c$); +c$ = Clazz.decorateAsClass (function () { +this.key = null; +this.val = null; +Clazz.instantialize (this, arguments); +}, jssun.font.FontDesignMetrics, "KeyReference"); +Clazz.makeConstructor (c$, +function (a, b) { +this.key = a; +this.val = b; +}, "~O,~O"); +Clazz.defineMethod (c$, "get", +function () { +return this.val; +}); +Clazz.defineMethod (c$, "dispose", +function () { +if (jssun.font.FontDesignMetrics.metricsCache.get (this.key) === this) { +jssun.font.FontDesignMetrics.metricsCache.remove (this.key); +}}); +c$ = Clazz.p0p (); +Clazz.defineStatics (c$, +"roundingUpValue", 0.95); +c$.metricsCache = c$.prototype.metricsCache = new java.util.Hashtable (); +Clazz.defineStatics (c$, +"MAXRECENT", 5); +c$.recentMetrics = c$.prototype.recentMetrics = new Array (5); +Clazz.defineStatics (c$, +"recentIndex", 0); +});