Clazz_declarePackage ("java.awt");
Clazz_load (null, "java.awt.Font", ["java.awt.font.TextAttribute", "java.awt.geom.AffineTransform", "swingjs.JSToolkit"], function () {
c$ = Clazz_decorateAsClass (function () {
+this.fm = null;
this.family = null;
this.name = null;
this.style = 0;
this.hash = 0;
Clazz_instantialize (this, arguments);
}, java.awt, "Font");
+Clazz_defineMethod (c$, "getFontMetrics",
+function () {
+return this.fm;
+});
+Clazz_defineMethod (c$, "setFontMetrics",
+function (fm) {
+this.fm = fm;
+}, "java.awt.FontMetrics");
Clazz_makeConstructor (c$,
function (name, style, size) {
this.name = (name != null) ? name : "Default";
this.pointSize = size;
}, "~S,~N,~N");
Clazz_makeConstructor (c$,
- function (name, style, sizePts) {
-this.name = (name != null) ? name : "Default";
-this.style = (style & -4) == 0 ? style : 0;
-this.size = Clazz_doubleToInt (sizePts + 0.5);
-this.pointSize = sizePts;
-}, "~S,~N,~N");
-Clazz_makeConstructor (c$,
function (font) {
this.name = font.name;
this.style = font.style;
return attributes;
});
Clazz_defineMethod (c$, "deriveFont",
-function (style, size) {
-return new java.awt.Font (this.name, style, size);
+function (style, sizePts) {
+var f = new java.awt.Font (this.name, style, Clazz_doubleToInt (sizePts + 0.5));
+f.pointSize = sizePts;
+return f;
}, "~N,~N");
Clazz_defineMethod (c$, "deriveFont",
-function (size) {
-return new java.awt.Font (this.name, this.style, size);
+function (sizePts) {
+var f = new java.awt.Font (this.name, this.style, Clazz_doubleToInt (sizePts + 0.5));
+f.pointSize = sizePts;
+return f;
}, "~N");
Clazz_defineMethod (c$, "deriveFont",
function (style) {
}return clipRect.intersects (x, y, width, height);
}, "~N,~N,~N,~N");
Clazz_declarePackage ("jssun.font");
-Clazz_load (["java.awt.FontMetrics", "java.util.Hashtable"], "jssun.font.FontDesignMetrics", ["java.lang.IndexOutOfBoundsException", "java.awt.Toolkit", "swingjs.JSToolkit"], function () {
+Clazz_load (["java.awt.FontMetrics", "java.util.Hashtable"], "jssun.font.FontDesignMetrics", ["java.lang.Character", "$.IndexOutOfBoundsException", "java.awt.Toolkit", "swingjs.JSToolkit"], function () {
c$ = Clazz_decorateAsClass (function () {
this.ascent = 0;
this.descent = 0;
this.height = this.getAscent () + Clazz_floatToInt (jssun.font.FontDesignMetrics.roundingUpValue + this.descent + this.leading);
}return this.height;
});
+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_pu$h(self.c$);
c$ = Clazz_decorateAsClass (function () {
this.key = null;
"recentIndex", 0);
});
Clazz_declarePackage ("java.awt");
-Clazz_load (["java.awt.font.FontRenderContext"], "java.awt.FontMetrics", ["java.lang.Character"], function () {
+Clazz_load (["java.awt.font.FontRenderContext"], "java.awt.FontMetrics", null, function () {
c$ = Clazz_decorateAsClass (function () {
this.font = null;
Clazz_instantialize (this, arguments);
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 ();
function () {
return this.getDescent ();
});
-Clazz_defineMethod (c$, "getMaxDecent",
-function () {
-return this.getMaxDescent ();
-});
Clazz_defineMethod (c$, "getMaxAdvance",
function () {
-return -1;
+return this.charWidth ('M');
});
-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));
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 () + "]";
return lines;
}, "~S,~S");
Clazz_declarePackage ("swingjs");
-Clazz_load (["jssun.awt.SunToolkit"], "swingjs.JSToolkit", ["java.io.BufferedInputStream", "$.ByteArrayInputStream", "$.InputStream", "java.lang.Boolean", "$.Thread", "java.util.Hashtable", "JU.AU", "$.Rdr", "$.SB", "java.awt.Dimension", "java.awt.image.ColorModel", "javax.swing.UIManager", "jssun.awt.AppContext", "swingjs.JSComponentPeer", "$.JSImage", "swingjs.api.Interface"], function () {
+Clazz_load (["jssun.awt.SunToolkit"], "swingjs.JSToolkit", ["java.io.BufferedInputStream", "$.ByteArrayInputStream", "$.InputStream", "java.lang.Boolean", "$.Thread", "java.util.Hashtable", "JU.AU", "$.Rdr", "$.SB", "java.awt.Dimension", "java.awt.image.ColorModel", "javax.swing.UIManager", "jssun.awt.AppContext", "swingjs.JSComponentPeer", "swingjs.api.Interface"], function () {
c$ = Clazz_decorateAsClass (function () {
this.imageKit = null;
Clazz_instantialize (this, arguments);
}, "java.awt.Font");
Clazz_overrideMethod (c$, "getFontMetrics",
function (font) {
-var fm = swingjs.JSToolkit.getInstance ("swingjs.JSFontMetrics");
-fm.setFont (font);
-return fm;
+var fm = font.getFontMetrics ();
+if (fm == null) {
+fm = swingjs.JSToolkit.getInstance ("swingjs.JSFontMetrics");
+(fm).setFont (font);
+font.setFontMetrics (fm);
+}return fm;
}, "java.awt.Font");
c$.getCSSColor = Clazz_defineMethod (c$, "getCSSColor",
function (c) {
}, "java.net.URL");
Clazz_defineMethod (c$, "createImage",
function (data, imageoffset, imagelength) {
-if (data == null) {
-var width = imageoffset;
-var height = imagelength;
-return new swingjs.JSImage (null, width, height);
-}return this.getImagekit ().createImageFromBytes (data, imageoffset, imagelength);
+return this.getImagekit ().createImageFromBytes (data, imageoffset, imagelength);
}, "~A,~N,~N");
Clazz_overrideMethod (c$, "checkImage",
function (image, width, height, observer) {
Clazz_declarePackage ("swingjs");
Clazz_load (["java.awt.FontMetrics"], "swingjs.JSFontMetrics", ["swingjs.JSToolkit"], function () {
c$ = Clazz_decorateAsClass (function () {
-this.widths = null;
+this.fwidths = null;
this.iwidths = null;
+this.FIRST_PRINTABLE = 32;
Clazz_instantialize (this, arguments);
}, swingjs, "JSFontMetrics", java.awt.FontMetrics);
Clazz_makeConstructor (c$,
});
Clazz_defineMethod (c$, "charWidth",
function (pt) {
-return (pt.charCodeAt (0) < 256 ? Clazz_floatToInt (this.getWidthsFloat ()[pt.charCodeAt (0)]) : this.stringWidth ("" + pt));
-}, "~S");
-Clazz_defineMethod (c$, "charWidth",
-function (pt) {
-return (pt < 256 ? Clazz_floatToInt (this.getWidthsFloat ()[pt]) : this.stringWidth ("" + String.fromCharCode (pt)));
-}, "~N");
+{
+var spt;
+return ((pt + 0 == pt ? pt : (pt = (spt = pt).charCodeAt(0))) < 256 ?
+Clazz_floatToInt(this.getWidthsFloat()[pt])
+: this.stringWidth(isChar ? spt : String.fromCharCode (pt)));
+}}, "~N");
Clazz_overrideMethod (c$, "stringWidth",
function (s) {
return Clazz_floatToInt (swingjs.JSToolkit.getStringWidth (null, this.font, s));
if (this.iwidths != null) return this.iwidths;
this.iwidths = Clazz_newIntArray (256, 0);
this.getWidthsFloat ();
-for (var ch = 0; ch < 256; ch++) {
-this.iwidths[ch] = Clazz_floatToInt (this.widths[ch]);
+for (var ch = this.FIRST_PRINTABLE; ch < 256; ch++) {
+this.iwidths[ch] = Clazz_floatToInt (this.fwidths[ch]);
}
return this.iwidths;
});
Clazz_defineMethod (c$, "getWidthsFloat",
function () {
-if (this.widths != null) return this.widths;
-this.widths = Clazz_newFloatArray (256, 0);
-for (var ch = 0; ch < 256; ch++) {
-this.widths[ch] = swingjs.JSToolkit.getStringWidth (null, this.font, "" + String.fromCharCode (ch));
+if (this.fwidths != null) return this.fwidths;
+this.fwidths = Clazz_newFloatArray (256, 0);
+for (var ch = this.FIRST_PRINTABLE; ch < 256; ch++) {
+this.fwidths[ch] = swingjs.JSToolkit.getStringWidth (null, this.font, "" + String.fromCharCode (ch));
}
-return this.widths;
+return this.fwidths;
});
});
Clazz_declarePackage ("swingjs");