Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / Font.js
index fa1caac..f6a344d 100644 (file)
-Clazz.declarePackage ("java.awt");\r
-Clazz.load (null, "java.awt.Font", ["java.awt.font.TextAttribute", "java.awt.geom.AffineTransform", "swingjs.JSToolkit"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.family = null;\r
-this.name = null;\r
-this.style = 0;\r
-this.size = 0;\r
-this.pointSize = 0;\r
-this.$hasLayoutAttributes = false;\r
-this.nonIdentityTx = false;\r
-this.hash = 0;\r
-Clazz.instantialize (this, arguments);\r
-}, java.awt, "Font");\r
-Clazz.makeConstructor (c$, \r
-function (name, style, size) {\r
-this.name = (name != null) ? name : "Default";\r
-this.style = (style & -4) == 0 ? style : 0;\r
-this.size = size;\r
-this.pointSize = size;\r
-}, "~S,~N,~N");\r
-Clazz.makeConstructor (c$, \r
- function (name, style, sizePts) {\r
-this.name = (name != null) ? name : "Default";\r
-this.style = (style & -4) == 0 ? style : 0;\r
-this.size = Clazz.doubleToInt (sizePts + 0.5);\r
-this.pointSize = sizePts;\r
-}, "~S,~N,~N");\r
-Clazz.makeConstructor (c$, \r
-function (font) {\r
-this.name = font.name;\r
-this.style = font.style;\r
-this.size = font.size;\r
-this.pointSize = font.pointSize;\r
-}, "java.awt.Font");\r
-Clazz.defineMethod (c$, "getTransform", \r
-function () {\r
-return  new java.awt.geom.AffineTransform ();\r
-});\r
-Clazz.defineMethod (c$, "getFamily", \r
-function () {\r
-return (this.family == null ? this.family = swingjs.JSToolkit.getFontFamily (this) : this.family);\r
-});\r
-Clazz.defineMethod (c$, "getName", \r
-function () {\r
-return this.name;\r
-});\r
-Clazz.defineMethod (c$, "getFontName", \r
-function () {\r
-return this.name;\r
-});\r
-Clazz.defineMethod (c$, "getStyle", \r
-function () {\r
-return this.style;\r
-});\r
-Clazz.defineMethod (c$, "getSize", \r
-function () {\r
-return this.size;\r
-});\r
-Clazz.defineMethod (c$, "getSize2D", \r
-function () {\r
-return this.pointSize;\r
-});\r
-Clazz.defineMethod (c$, "isPlain", \r
-function () {\r
-return this.style == 0;\r
-});\r
-Clazz.defineMethod (c$, "isBold", \r
-function () {\r
-return (this.style & 1) != 0;\r
-});\r
-Clazz.defineMethod (c$, "isItalic", \r
-function () {\r
-return (this.style & 2) != 0;\r
-});\r
-Clazz.defineMethod (c$, "isTransformed", \r
-function () {\r
-return this.nonIdentityTx;\r
-});\r
-Clazz.defineMethod (c$, "hasLayoutAttributes", \r
-function () {\r
-return this.$hasLayoutAttributes;\r
-});\r
-c$.getFont = Clazz.defineMethod (c$, "getFont", \r
-function (nm) {\r
-return java.awt.Font.getFont (nm, null);\r
-}, "~S");\r
-c$.decode = Clazz.defineMethod (c$, "decode", \r
-function (str) {\r
-var fontName = str;\r
-var styleName = "";\r
-var fontSize = 12;\r
-var fontStyle = 0;\r
-if (str == null) {\r
-return  new java.awt.Font ("Dialog", fontStyle, fontSize);\r
-}var lastHyphen = str.lastIndexOf ('-');\r
-var lastSpace = str.lastIndexOf (' ');\r
-var sepChar = (lastHyphen > lastSpace) ? '-' : ' ';\r
-var sizeIndex = str.lastIndexOf (sepChar);\r
-var styleIndex = str.lastIndexOf (sepChar, sizeIndex - 1);\r
-var strlen = str.length;\r
-if (sizeIndex > 0 && sizeIndex + 1 < strlen) {\r
-try {\r
-fontSize = Integer.$valueOf (str.substring (sizeIndex + 1)).intValue ();\r
-if (fontSize <= 0) {\r
-fontSize = 12;\r
-}} catch (e) {\r
-if (Clazz.exceptionOf (e, NumberFormatException)) {\r
-styleIndex = sizeIndex;\r
-sizeIndex = strlen;\r
-if (str.charAt (sizeIndex - 1) == sepChar) {\r
-sizeIndex--;\r
-}} else {\r
-throw e;\r
-}\r
-}\r
-}if (styleIndex >= 0 && styleIndex + 1 < strlen) {\r
-styleName = str.substring (styleIndex + 1, sizeIndex);\r
-styleName = styleName.toLowerCase ();\r
-if (styleName.equals ("bolditalic")) {\r
-fontStyle = 3;\r
-} else if (styleName.equals ("italic")) {\r
-fontStyle = 2;\r
-} else if (styleName.equals ("bold")) {\r
-fontStyle = 1;\r
-} else if (styleName.equals ("plain")) {\r
-fontStyle = 0;\r
-} else {\r
-styleIndex = sizeIndex;\r
-if (str.charAt (styleIndex - 1) == sepChar) {\r
-styleIndex--;\r
-}}fontName = str.substring (0, styleIndex);\r
-} else {\r
-var fontEnd = strlen;\r
-if (styleIndex > 0) {\r
-fontEnd = styleIndex;\r
-} else if (sizeIndex > 0) {\r
-fontEnd = sizeIndex;\r
-}if (fontEnd > 0 && str.charAt (fontEnd - 1) == sepChar) {\r
-fontEnd--;\r
-}fontName = str.substring (0, fontEnd);\r
-}return  new java.awt.Font (fontName, fontStyle, fontSize);\r
-}, "~S");\r
-c$.getFont = Clazz.defineMethod (c$, "getFont", \r
-function (nm, font) {\r
-var str = null;\r
-try {\r
-str = System.getProperty (nm);\r
-} catch (e) {\r
-if (Clazz.exceptionOf (e, SecurityException)) {\r
-} else {\r
-throw e;\r
-}\r
-}\r
-if (str == null) {\r
-return font;\r
-}return java.awt.Font.decode (str);\r
-}, "~S,java.awt.Font");\r
-Clazz.overrideMethod (c$, "hashCode", \r
-function () {\r
-if (this.hash == 0) {\r
-this.hash = this.name.hashCode () ^ this.style ^ this.size;\r
-}return this.hash;\r
-});\r
-Clazz.overrideMethod (c$, "equals", \r
-function (obj) {\r
-if (obj === this) {\r
-return true;\r
-}if (obj != null) {\r
-try {\r
-var font = obj;\r
-if (this.size == font.size && this.style == font.style && this.nonIdentityTx == font.nonIdentityTx && this.$hasLayoutAttributes == font.$hasLayoutAttributes && this.pointSize == font.pointSize && this.name.equals (font.name)) {\r
-return true;\r
-}} catch (e) {\r
-if (Clazz.exceptionOf (e, ClassCastException)) {\r
-} else {\r
-throw e;\r
-}\r
-}\r
-}return false;\r
-}, "~O");\r
-Clazz.overrideMethod (c$, "toString", \r
-function () {\r
-var strStyle;\r
-if (this.isBold ()) {\r
-strStyle = this.isItalic () ? "bolditalic" : "bold";\r
-} else {\r
-strStyle = this.isItalic () ? "italic" : "plain";\r
-}return this.getClass ().getName () + "[family=" + this.getFamily () + ",name=" + this.name + ",style=" + strStyle + ",size=" + this.size + "]";\r
-});\r
-Clazz.defineMethod (c$, "getAvailableAttributes", \r
-function () {\r
-var attributes =  Clazz.newArray (-1, [java.awt.font.TextAttribute.FAMILY, java.awt.font.TextAttribute.WEIGHT, java.awt.font.TextAttribute.WIDTH, java.awt.font.TextAttribute.SIZE, java.awt.font.TextAttribute.UNDERLINE, java.awt.font.TextAttribute.STRIKETHROUGH]);\r
-return attributes;\r
-});\r
-Clazz.defineMethod (c$, "deriveFont", \r
-function (style, size) {\r
-return  new java.awt.Font (this.name, style, size);\r
-}, "~N,~N");\r
-Clazz.defineMethod (c$, "deriveFont", \r
-function (size) {\r
-return  new java.awt.Font (this.name, this.style, size);\r
-}, "~N");\r
-Clazz.defineMethod (c$, "deriveFont", \r
-function (style) {\r
-return  new java.awt.Font (this.name, style, this.size);\r
-}, "~N");\r
-Clazz.defineMethod (c$, "hasUniformLineMetrics", \r
-function () {\r
-return false;\r
-});\r
-Clazz.overrideMethod (c$, "finalize", \r
-function () {\r
-});\r
-Clazz.defineStatics (c$,\r
-"DIALOG", "Dialog",\r
-"DIALOG_INPUT", "DialogInput",\r
-"SANS_SERIF", "SansSerif",\r
-"SERIF", "Serif",\r
-"MONOSPACED", "Monospaced",\r
-"PLAIN", 0,\r
-"BOLD", 1,\r
-"ITALIC", 2,\r
-"ROMAN_BASELINE", 0,\r
-"CENTER_BASELINE", 1,\r
-"HANGING_BASELINE", 2,\r
-"TRUETYPE_FONT", 0,\r
-"TYPE1_FONT", 1,\r
-"LAYOUT_LEFT_TO_RIGHT", 0,\r
-"LAYOUT_RIGHT_TO_LEFT", 1,\r
-"LAYOUT_NO_START_CONTEXT", 2,\r
-"LAYOUT_NO_LIMIT_CONTEXT", 4);\r
-});\r
+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.family = null;
+this.name = null;
+this.style = 0;
+this.size = 0;
+this.pointSize = 0;
+this.$hasLayoutAttributes = false;
+this.nonIdentityTx = false;
+this.hash = 0;
+Clazz.instantialize (this, arguments);
+}, java.awt, "Font");
+Clazz.makeConstructor (c$, 
+function (name, style, size) {
+this.name = (name != null) ? name : "Default";
+this.style = (style & -4) == 0 ? style : 0;
+this.size = size;
+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;
+this.size = font.size;
+this.pointSize = font.pointSize;
+}, "java.awt.Font");
+Clazz.defineMethod (c$, "getTransform", 
+function () {
+return  new java.awt.geom.AffineTransform ();
+});
+Clazz.defineMethod (c$, "getFamily", 
+function () {
+return (this.family == null ? this.family = swingjs.JSToolkit.getFontFamily (this) : this.family);
+});
+Clazz.defineMethod (c$, "getName", 
+function () {
+return this.name;
+});
+Clazz.defineMethod (c$, "getFontName", 
+function () {
+return this.name;
+});
+Clazz.defineMethod (c$, "getStyle", 
+function () {
+return this.style;
+});
+Clazz.defineMethod (c$, "getSize", 
+function () {
+return this.size;
+});
+Clazz.defineMethod (c$, "getSize2D", 
+function () {
+return this.pointSize;
+});
+Clazz.defineMethod (c$, "isPlain", 
+function () {
+return this.style == 0;
+});
+Clazz.defineMethod (c$, "isBold", 
+function () {
+return (this.style & 1) != 0;
+});
+Clazz.defineMethod (c$, "isItalic", 
+function () {
+return (this.style & 2) != 0;
+});
+Clazz.defineMethod (c$, "isTransformed", 
+function () {
+return this.nonIdentityTx;
+});
+Clazz.defineMethod (c$, "hasLayoutAttributes", 
+function () {
+return this.$hasLayoutAttributes;
+});
+c$.getFont = Clazz.defineMethod (c$, "getFont", 
+function (nm) {
+return java.awt.Font.getFont (nm, null);
+}, "~S");
+c$.decode = Clazz.defineMethod (c$, "decode", 
+function (str) {
+var fontName = str;
+var styleName = "";
+var fontSize = 12;
+var fontStyle = 0;
+if (str == null) {
+return  new java.awt.Font ("Dialog", fontStyle, fontSize);
+}var lastHyphen = str.lastIndexOf ('-');
+var lastSpace = str.lastIndexOf (' ');
+var sepChar = (lastHyphen > lastSpace) ? '-' : ' ';
+var sizeIndex = str.lastIndexOf (sepChar);
+var styleIndex = str.lastIndexOf (sepChar, sizeIndex - 1);
+var strlen = str.length;
+if (sizeIndex > 0 && sizeIndex + 1 < strlen) {
+try {
+fontSize = Integer.$valueOf (str.substring (sizeIndex + 1)).intValue ();
+if (fontSize <= 0) {
+fontSize = 12;
+}} catch (e) {
+if (Clazz.exceptionOf (e, NumberFormatException)) {
+styleIndex = sizeIndex;
+sizeIndex = strlen;
+if (str.charAt (sizeIndex - 1) == sepChar) {
+sizeIndex--;
+}} else {
+throw e;
+}
+}
+}if (styleIndex >= 0 && styleIndex + 1 < strlen) {
+styleName = str.substring (styleIndex + 1, sizeIndex);
+styleName = styleName.toLowerCase ();
+if (styleName.equals ("bolditalic")) {
+fontStyle = 3;
+} else if (styleName.equals ("italic")) {
+fontStyle = 2;
+} else if (styleName.equals ("bold")) {
+fontStyle = 1;
+} else if (styleName.equals ("plain")) {
+fontStyle = 0;
+} else {
+styleIndex = sizeIndex;
+if (str.charAt (styleIndex - 1) == sepChar) {
+styleIndex--;
+}}fontName = str.substring (0, styleIndex);
+} else {
+var fontEnd = strlen;
+if (styleIndex > 0) {
+fontEnd = styleIndex;
+} else if (sizeIndex > 0) {
+fontEnd = sizeIndex;
+}if (fontEnd > 0 && str.charAt (fontEnd - 1) == sepChar) {
+fontEnd--;
+}fontName = str.substring (0, fontEnd);
+}return  new java.awt.Font (fontName, fontStyle, fontSize);
+}, "~S");
+c$.getFont = Clazz.defineMethod (c$, "getFont", 
+function (nm, font) {
+var str = null;
+try {
+str = System.getProperty (nm);
+} catch (e) {
+if (Clazz.exceptionOf (e, SecurityException)) {
+} else {
+throw e;
+}
+}
+if (str == null) {
+return font;
+}return java.awt.Font.decode (str);
+}, "~S,java.awt.Font");
+Clazz.overrideMethod (c$, "hashCode", 
+function () {
+if (this.hash == 0) {
+this.hash = this.name.hashCode () ^ this.style ^ this.size;
+}return this.hash;
+});
+Clazz.overrideMethod (c$, "equals", 
+function (obj) {
+if (obj === this) {
+return true;
+}if (obj != null) {
+try {
+var font = obj;
+if (this.size == font.size && this.style == font.style && this.nonIdentityTx == font.nonIdentityTx && this.$hasLayoutAttributes == font.$hasLayoutAttributes && this.pointSize == font.pointSize && this.name.equals (font.name)) {
+return true;
+}} catch (e) {
+if (Clazz.exceptionOf (e, ClassCastException)) {
+} else {
+throw e;
+}
+}
+}return false;
+}, "~O");
+Clazz.overrideMethod (c$, "toString", 
+function () {
+var strStyle;
+if (this.isBold ()) {
+strStyle = this.isItalic () ? "bolditalic" : "bold";
+} else {
+strStyle = this.isItalic () ? "italic" : "plain";
+}return this.getClass ().getName () + "[family=" + this.getFamily () + ",name=" + this.name + ",style=" + strStyle + ",size=" + this.size + "]";
+});
+Clazz.defineMethod (c$, "getAvailableAttributes", 
+function () {
+var attributes =  Clazz.newArray (-1, [java.awt.font.TextAttribute.FAMILY, java.awt.font.TextAttribute.WEIGHT, java.awt.font.TextAttribute.WIDTH, java.awt.font.TextAttribute.SIZE, java.awt.font.TextAttribute.UNDERLINE, java.awt.font.TextAttribute.STRIKETHROUGH]);
+return attributes;
+});
+Clazz.defineMethod (c$, "deriveFont", 
+function (style, size) {
+return  new java.awt.Font (this.name, style, size);
+}, "~N,~N");
+Clazz.defineMethod (c$, "deriveFont", 
+function (size) {
+return  new java.awt.Font (this.name, this.style, size);
+}, "~N");
+Clazz.defineMethod (c$, "deriveFont", 
+function (style) {
+return  new java.awt.Font (this.name, style, this.size);
+}, "~N");
+Clazz.defineMethod (c$, "hasUniformLineMetrics", 
+function () {
+return false;
+});
+Clazz.overrideMethod (c$, "finalize", 
+function () {
+});
+Clazz.defineStatics (c$,
+"DIALOG", "Dialog",
+"DIALOG_INPUT", "DialogInput",
+"SANS_SERIF", "SansSerif",
+"SERIF", "Serif",
+"MONOSPACED", "Monospaced",
+"PLAIN", 0,
+"BOLD", 1,
+"ITALIC", 2,
+"ROMAN_BASELINE", 0,
+"CENTER_BASELINE", 1,
+"HANGING_BASELINE", 2,
+"TRUETYPE_FONT", 0,
+"TYPE1_FONT", 1,
+"LAYOUT_LEFT_TO_RIGHT", 0,
+"LAYOUT_RIGHT_TO_LEFT", 1,
+"LAYOUT_NO_START_CONTEXT", 2,
+"LAYOUT_NO_LIMIT_CONTEXT", 4);
+});