Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / swingjs / j2s / javax / swing / border / TitledBorder.js
index e9a9766..5e7f4c6 100644 (file)
-Clazz.declarePackage ("javax.swing.border");\r
-Clazz.load (["javax.swing.border.AbstractBorder", "java.awt.Point"], "javax.swing.border.TitledBorder", ["java.lang.IllegalArgumentException", "$.NullPointerException", "java.awt.Component", "$.Dimension", "$.Font", "$.Insets", "$.Rectangle", "javax.swing.JComponent", "$.UIManager", "jssun.swing.SwingUtilities2"], function () {\r
-c$ = Clazz.decorateAsClass (function () {\r
-this.title = null;\r
-this.border = null;\r
-this.titlePosition = 0;\r
-this.titleJustification = 0;\r
-this.titleFont = null;\r
-this.titleColor = null;\r
-this.textLoc = null;\r
-Clazz.instantialize (this, arguments);\r
-}, javax.swing.border, "TitledBorder", javax.swing.border.AbstractBorder);\r
-Clazz.prepareFields (c$, function () {\r
-this.textLoc =  new java.awt.Point ();\r
-});\r
-Clazz.makeConstructor (c$, \r
-function (title) {\r
-this.construct (null, title, 4, 0, null, null);\r
-}, "~S");\r
-Clazz.makeConstructor (c$, \r
-function (border) {\r
-this.construct (border, "", 4, 0, null, null);\r
-}, "javax.swing.border.Border");\r
-Clazz.makeConstructor (c$, \r
-function (border, title) {\r
-this.construct (border, title, 4, 0, null, null);\r
-}, "javax.swing.border.Border,~S");\r
-Clazz.makeConstructor (c$, \r
-function (border, title, titleJustification, titlePosition) {\r
-this.construct (border, title, titleJustification, titlePosition, null, null);\r
-}, "javax.swing.border.Border,~S,~N,~N");\r
-Clazz.makeConstructor (c$, \r
-function (border, title, titleJustification, titlePosition, titleFont) {\r
-this.construct (border, title, titleJustification, titlePosition, titleFont, null);\r
-}, "javax.swing.border.Border,~S,~N,~N,java.awt.Font");\r
-Clazz.makeConstructor (c$, \r
-function (border, title, titleJustification, titlePosition, titleFont, titleColor) {\r
-Clazz.superConstructor (this, javax.swing.border.TitledBorder, []);\r
-this.title = title;\r
-this.border = border;\r
-this.titleFont = titleFont;\r
-this.titleColor = titleColor;\r
-this.setTitleJustification (titleJustification);\r
-this.setTitlePosition (titlePosition);\r
-}, "javax.swing.border.Border,~S,~N,~N,java.awt.Font,java.awt.Color");\r
-Clazz.overrideMethod (c$, "paintBorder", \r
-function (c, g, x, y, width, height) {\r
-var border = this.getBorder ();\r
-if (this.getTitle () == null || this.getTitle ().equals ("")) {\r
-if (border != null) {\r
-border.paintBorder (c, g, x, y, width, height);\r
-}return;\r
-}var grooveRect =  new java.awt.Rectangle (x + 2, y + 2, width - (4), height - (4));\r
-var font = g.getFont ();\r
-var color = g.getColor ();\r
-g.setFont (this.getFont (c));\r
-var jc = (Clazz.instanceOf (c, javax.swing.JComponent)) ? c : null;\r
-var fm = jssun.swing.SwingUtilities2.getFontMetrics (jc, g);\r
-var fontHeight = fm.getHeight ();\r
-var descent = fm.getDescent ();\r
-var ascent = fm.getAscent ();\r
-var diff;\r
-var stringWidth = jssun.swing.SwingUtilities2.stringWidth (jc, fm, this.getTitle ());\r
-var insets;\r
-if (border != null) {\r
-insets = border.getBorderInsets (c);\r
-} else {\r
-insets =  new java.awt.Insets (0, 0, 0, 0);\r
-}var titlePos = this.getTitlePosition ();\r
-switch (titlePos) {\r
-case 1:\r
-diff = ascent + descent + (Math.max (2, 4) - 2);\r
-grooveRect.y += diff;\r
-grooveRect.height -= diff;\r
-this.textLoc.y = grooveRect.y - (descent + 2);\r
-break;\r
-case 2:\r
-case 0:\r
-diff = Math.max (0, ((Clazz.doubleToInt (ascent / 2)) + 2) - 2);\r
-grooveRect.y += diff;\r
-grooveRect.height -= diff;\r
-this.textLoc.y = (grooveRect.y - descent) + Clazz.doubleToInt ((insets.top + ascent + descent) / 2);\r
-break;\r
-case 3:\r
-this.textLoc.y = grooveRect.y + insets.top + ascent + 2;\r
-break;\r
-case 4:\r
-this.textLoc.y = (grooveRect.y + grooveRect.height) - (insets.bottom + descent + 2);\r
-break;\r
-case 5:\r
-grooveRect.height -= Clazz.doubleToInt (fontHeight / 2);\r
-this.textLoc.y = ((grooveRect.y + grooveRect.height) - descent) + Clazz.doubleToInt (((ascent + descent) - insets.bottom) / 2);\r
-break;\r
-case 6:\r
-grooveRect.height -= fontHeight;\r
-this.textLoc.y = grooveRect.y + grooveRect.height + ascent + 2;\r
-break;\r
-}\r
-var justification = this.getTitleJustification ();\r
-if (javax.swing.border.AbstractBorder.isLeftToRight (c)) {\r
-if (justification == 4 || justification == 0) {\r
-justification = 1;\r
-} else if (justification == 5) {\r
-justification = 3;\r
-}} else {\r
-if (justification == 4 || justification == 0) {\r
-justification = 3;\r
-} else if (justification == 5) {\r
-justification = 1;\r
-}}switch (justification) {\r
-case 1:\r
-this.textLoc.x = grooveRect.x + 5 + insets.left;\r
-break;\r
-case 3:\r
-this.textLoc.x = (grooveRect.x + grooveRect.width) - (stringWidth + 5 + insets.right);\r
-break;\r
-case 2:\r
-this.textLoc.x = grooveRect.x + (Clazz.doubleToInt ((grooveRect.width - stringWidth) / 2));\r
-break;\r
-}\r
-if (border != null) {\r
-if (((titlePos == 2 || titlePos == 0) && (grooveRect.y > this.textLoc.y - ascent)) || (titlePos == 5 && (grooveRect.y + grooveRect.height < this.textLoc.y + descent))) {\r
-var clipRect =  new java.awt.Rectangle ();\r
-var saveClip = g.getClipBounds ();\r
-clipRect.setBounds (saveClip);\r
-if (javax.swing.border.TitledBorder.computeIntersection (clipRect, x, y, this.textLoc.x - 1 - x, height)) {\r
-g.setClip (clipRect);\r
-border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);\r
-}clipRect.setBounds (saveClip);\r
-if (javax.swing.border.TitledBorder.computeIntersection (clipRect, this.textLoc.x + stringWidth + 1, y, x + width - (this.textLoc.x + stringWidth + 1), height)) {\r
-g.setClip (clipRect);\r
-border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);\r
-}if (titlePos == 2 || titlePos == 0) {\r
-clipRect.setBounds (saveClip);\r
-if (javax.swing.border.TitledBorder.computeIntersection (clipRect, this.textLoc.x - 1, this.textLoc.y + descent, stringWidth + 2, y + height - this.textLoc.y - descent)) {\r
-g.setClip (clipRect);\r
-border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);\r
-}} else {\r
-clipRect.setBounds (saveClip);\r
-if (javax.swing.border.TitledBorder.computeIntersection (clipRect, this.textLoc.x - 1, y, stringWidth + 2, this.textLoc.y - ascent - y)) {\r
-g.setClip (clipRect);\r
-border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);\r
-}}g.setClip (saveClip);\r
-} else {\r
-border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);\r
-}}g.setColor (this.getTitleColor ());\r
-jssun.swing.SwingUtilities2.drawString (jc, g, this.getTitle (), this.textLoc.x, this.textLoc.y);\r
-g.setFont (font);\r
-g.setColor (color);\r
-}, "java.awt.Component,java.awt.Graphics,~N,~N,~N,~N");\r
-Clazz.defineMethod (c$, "getBorderInsets", \r
-function (c) {\r
-return this.getBorderInsets (c,  new java.awt.Insets (0, 0, 0, 0));\r
-}, "java.awt.Component");\r
-Clazz.defineMethod (c$, "getBorderInsets", \r
-function (c, insets) {\r
-var fm;\r
-var descent = 0;\r
-var ascent = 16;\r
-var height = 16;\r
-var border = this.getBorder ();\r
-if (border != null) {\r
-if (Clazz.instanceOf (border, javax.swing.border.AbstractBorder)) {\r
-(border).getBorderInsets (c, insets);\r
-} else {\r
-var i = border.getBorderInsets (c);\r
-insets.top = i.top;\r
-insets.right = i.right;\r
-insets.bottom = i.bottom;\r
-insets.left = i.left;\r
-}} else {\r
-insets.left = insets.top = insets.right = insets.bottom = 0;\r
-}insets.left += 4;\r
-insets.right += 4;\r
-insets.top += 4;\r
-insets.bottom += 4;\r
-if (c == null || this.getTitle () == null || this.getTitle ().equals ("")) {\r
-return insets;\r
-}var font = this.getFont (c);\r
-fm = c.getFontMetrics (font);\r
-if (fm != null) {\r
-descent = fm.getDescent ();\r
-ascent = fm.getAscent ();\r
-height = fm.getHeight ();\r
-}switch (this.getTitlePosition ()) {\r
-case 1:\r
-insets.top += ascent + descent + (Math.max (2, 4) - 2);\r
-break;\r
-case 2:\r
-case 0:\r
-insets.top += ascent + descent;\r
-break;\r
-case 3:\r
-insets.top += ascent + descent + 2;\r
-break;\r
-case 4:\r
-insets.bottom += ascent + descent + 2;\r
-break;\r
-case 5:\r
-insets.bottom += ascent + descent;\r
-break;\r
-case 6:\r
-insets.bottom += height;\r
-break;\r
-}\r
-return insets;\r
-}, "java.awt.Component,java.awt.Insets");\r
-Clazz.overrideMethod (c$, "isBorderOpaque", \r
-function () {\r
-return false;\r
-});\r
-Clazz.defineMethod (c$, "getTitle", \r
-function () {\r
-return this.title;\r
-});\r
-Clazz.defineMethod (c$, "getBorder", \r
-function () {\r
-var b = this.border;\r
-if (b == null) b = javax.swing.UIManager.getBorder ("TitledBorder.border");\r
-return b;\r
-});\r
-Clazz.defineMethod (c$, "getTitlePosition", \r
-function () {\r
-if (this.titlePosition == 0) {\r
-var value = javax.swing.UIManager.get ("TitledBorder.position");\r
-if (Clazz.instanceOf (value, String)) {\r
-var s = value;\r
-if ("ABOVE_TOP".equalsIgnoreCase (s)) {\r
-return 1;\r
-} else if ("TOP".equalsIgnoreCase (s)) {\r
-return 2;\r
-} else if ("BELOW_TOP".equalsIgnoreCase (s)) {\r
-return 3;\r
-} else if ("ABOVE_BOTTOM".equalsIgnoreCase (s)) {\r
-return 4;\r
-} else if ("BOTTOM".equalsIgnoreCase (s)) {\r
-return 5;\r
-} else if ("BELOW_BOTTOM".equalsIgnoreCase (s)) {\r
-return 6;\r
-}} else if (Clazz.instanceOf (value, Integer)) {\r
-var i = (value).intValue ();\r
-if (i >= 0 && i <= 6) {\r
-return i;\r
-}}}return this.titlePosition;\r
-});\r
-Clazz.defineMethod (c$, "getTitleJustification", \r
-function () {\r
-return this.titleJustification;\r
-});\r
-Clazz.defineMethod (c$, "getTitleFont", \r
-function () {\r
-var f = this.titleFont;\r
-if (f == null) f = javax.swing.UIManager.getFont ("TitledBorder.font");\r
-return f;\r
-});\r
-Clazz.defineMethod (c$, "getTitleColor", \r
-function () {\r
-var c = this.titleColor;\r
-if (c == null) c = javax.swing.UIManager.getColor ("TitledBorder.titleColor");\r
-return c;\r
-});\r
-Clazz.defineMethod (c$, "setTitle", \r
-function (title) {\r
-this.title = title;\r
-}, "~S");\r
-Clazz.defineMethod (c$, "setBorder", \r
-function (border) {\r
-this.border = border;\r
-}, "javax.swing.border.Border");\r
-Clazz.defineMethod (c$, "setTitlePosition", \r
-function (titlePosition) {\r
-switch (titlePosition) {\r
-case 1:\r
-case 2:\r
-case 3:\r
-case 4:\r
-case 5:\r
-case 6:\r
-case 0:\r
-this.titlePosition = titlePosition;\r
-break;\r
-default:\r
-throw  new IllegalArgumentException (titlePosition + " is not a valid title position.");\r
-}\r
-}, "~N");\r
-Clazz.defineMethod (c$, "setTitleJustification", \r
-function (titleJustification) {\r
-switch (titleJustification) {\r
-case 0:\r
-case 1:\r
-case 2:\r
-case 3:\r
-case 4:\r
-case 5:\r
-this.titleJustification = titleJustification;\r
-break;\r
-default:\r
-throw  new IllegalArgumentException (titleJustification + " is not a valid title justification.");\r
-}\r
-}, "~N");\r
-Clazz.defineMethod (c$, "setTitleFont", \r
-function (titleFont) {\r
-this.titleFont = titleFont;\r
-}, "java.awt.Font");\r
-Clazz.defineMethod (c$, "setTitleColor", \r
-function (titleColor) {\r
-this.titleColor = titleColor;\r
-}, "java.awt.Color");\r
-Clazz.defineMethod (c$, "getMinimumSize", \r
-function (c) {\r
-var insets = this.getBorderInsets (c);\r
-var minSize =  new java.awt.Dimension (insets.right + insets.left, insets.top + insets.bottom);\r
-var font = this.getFont (c);\r
-var fm = c.getFontMetrics (font);\r
-var jc = (Clazz.instanceOf (c, javax.swing.JComponent)) ? c : null;\r
-switch (this.getTitlePosition ()) {\r
-case 1:\r
-case 6:\r
-minSize.width = Math.max (jssun.swing.SwingUtilities2.stringWidth (jc, fm, this.getTitle ()), minSize.width);\r
-break;\r
-case 3:\r
-case 4:\r
-case 2:\r
-case 5:\r
-case 0:\r
-default:\r
-minSize.width += jssun.swing.SwingUtilities2.stringWidth (jc, fm, this.getTitle ());\r
-}\r
-return minSize;\r
-}, "java.awt.Component");\r
-Clazz.overrideMethod (c$, "getBaseline", \r
-function (c, width, height) {\r
-if (c == null) {\r
-throw  new NullPointerException ("Must supply non-null component");\r
-}if (height < 0) {\r
-throw  new IllegalArgumentException ("Height must be >= 0");\r
-}var title = this.getTitle ();\r
-if (title != null && !"".equals (title)) {\r
-var font = this.getFont (c);\r
-var border2 = this.getBorder ();\r
-var borderInsets;\r
-if (border2 != null) {\r
-borderInsets = border2.getBorderInsets (c);\r
-} else {\r
-borderInsets =  new java.awt.Insets (0, 0, 0, 0);\r
-}var fm = c.getFontMetrics (font);\r
-var fontHeight = fm.getHeight ();\r
-var descent = fm.getDescent ();\r
-var ascent = fm.getAscent ();\r
-var y = 2;\r
-var h = height - 4;\r
-var diff;\r
-switch (this.getTitlePosition ()) {\r
-case 1:\r
-diff = ascent + descent + (Math.max (2, 4) - 2);\r
-return y + diff - (descent + 2);\r
-case 2:\r
-case 0:\r
-diff = Math.max (0, ((Clazz.doubleToInt (ascent / 2)) + 2) - 2);\r
-return (y + diff - descent) + Clazz.doubleToInt ((borderInsets.top + ascent + descent) / 2);\r
-case 3:\r
-return y + borderInsets.top + ascent + 2;\r
-case 4:\r
-return (y + h) - (borderInsets.bottom + descent + 2);\r
-case 5:\r
-h -= Clazz.doubleToInt (fontHeight / 2);\r
-return ((y + h) - descent) + Clazz.doubleToInt (((ascent + descent) - borderInsets.bottom) / 2);\r
-case 6:\r
-h -= fontHeight;\r
-return y + h + ascent + 2;\r
-}\r
-}return -1;\r
-}, "java.awt.Component,~N,~N");\r
-Clazz.defineMethod (c$, "getBaselineResizeBehavior", \r
-function (c) {\r
-Clazz.superCall (this, javax.swing.border.TitledBorder, "getBaselineResizeBehavior", [c]);\r
-switch (this.getTitlePosition ()) {\r
-case 1:\r
-case 2:\r
-case 0:\r
-case 3:\r
-return java.awt.Component.BaselineResizeBehavior.CONSTANT_ASCENT;\r
-case 4:\r
-case 5:\r
-case 6:\r
-return java.awt.Component.BaselineResizeBehavior.CONSTANT_DESCENT;\r
-}\r
-return java.awt.Component.BaselineResizeBehavior.OTHER;\r
-}, "java.awt.Component");\r
-Clazz.defineMethod (c$, "getFont", \r
-function (c) {\r
-var font;\r
-if ((font = this.getTitleFont ()) != null) {\r
-return font;\r
-} else if (c != null && (font = c.getFont ()) != null) {\r
-return font;\r
-}return  new java.awt.Font ("Dialog", 0, 12);\r
-}, "java.awt.Component");\r
-c$.computeIntersection = Clazz.defineMethod (c$, "computeIntersection", \r
- function (dest, rx, ry, rw, rh) {\r
-var x1 = Math.max (rx, dest.x);\r
-var x2 = Math.min (rx + rw, dest.x + dest.width);\r
-var y1 = Math.max (ry, dest.y);\r
-var y2 = Math.min (ry + rh, dest.y + dest.height);\r
-dest.x = x1;\r
-dest.y = y1;\r
-dest.width = x2 - x1;\r
-dest.height = y2 - y1;\r
-if (dest.width <= 0 || dest.height <= 0) {\r
-return false;\r
-}return true;\r
-}, "java.awt.Rectangle,~N,~N,~N,~N");\r
-Clazz.defineStatics (c$,\r
-"DEFAULT_POSITION", 0,\r
-"ABOVE_TOP", 1,\r
-"TOP", 2,\r
-"BELOW_TOP", 3,\r
-"ABOVE_BOTTOM", 4,\r
-"BOTTOM", 5,\r
-"BELOW_BOTTOM", 6,\r
-"DEFAULT_JUSTIFICATION", 0,\r
-"LEFT", 1,\r
-"CENTER", 2,\r
-"RIGHT", 3,\r
-"LEADING", 4,\r
-"TRAILING", 5,\r
-"EDGE_SPACING", 2,\r
-"TEXT_SPACING", 2,\r
-"TEXT_INSET_H", 5);\r
-});\r
+Clazz.declarePackage ("javax.swing.border");
+Clazz.load (["javax.swing.border.AbstractBorder", "java.awt.Point"], "javax.swing.border.TitledBorder", ["java.lang.IllegalArgumentException", "$.NullPointerException", "java.awt.Component", "$.Dimension", "$.Font", "$.Insets", "$.Rectangle", "javax.swing.JComponent", "$.UIManager", "jssun.swing.SwingUtilities2"], function () {
+c$ = Clazz.decorateAsClass (function () {
+this.title = null;
+this.border = null;
+this.titlePosition = 0;
+this.titleJustification = 0;
+this.titleFont = null;
+this.titleColor = null;
+this.textLoc = null;
+Clazz.instantialize (this, arguments);
+}, javax.swing.border, "TitledBorder", javax.swing.border.AbstractBorder);
+Clazz.prepareFields (c$, function () {
+this.textLoc =  new java.awt.Point ();
+});
+Clazz.makeConstructor (c$, 
+function (title) {
+this.construct (null, title, 4, 0, null, null);
+}, "~S");
+Clazz.makeConstructor (c$, 
+function (border) {
+this.construct (border, "", 4, 0, null, null);
+}, "javax.swing.border.Border");
+Clazz.makeConstructor (c$, 
+function (border, title) {
+this.construct (border, title, 4, 0, null, null);
+}, "javax.swing.border.Border,~S");
+Clazz.makeConstructor (c$, 
+function (border, title, titleJustification, titlePosition) {
+this.construct (border, title, titleJustification, titlePosition, null, null);
+}, "javax.swing.border.Border,~S,~N,~N");
+Clazz.makeConstructor (c$, 
+function (border, title, titleJustification, titlePosition, titleFont) {
+this.construct (border, title, titleJustification, titlePosition, titleFont, null);
+}, "javax.swing.border.Border,~S,~N,~N,java.awt.Font");
+Clazz.makeConstructor (c$, 
+function (border, title, titleJustification, titlePosition, titleFont, titleColor) {
+Clazz.superConstructor (this, javax.swing.border.TitledBorder, []);
+this.title = title;
+this.border = border;
+this.titleFont = titleFont;
+this.titleColor = titleColor;
+this.setTitleJustification (titleJustification);
+this.setTitlePosition (titlePosition);
+}, "javax.swing.border.Border,~S,~N,~N,java.awt.Font,java.awt.Color");
+Clazz.overrideMethod (c$, "paintBorder", 
+function (c, g, x, y, width, height) {
+var border = this.getBorder ();
+if (this.getTitle () == null || this.getTitle ().equals ("")) {
+if (border != null) {
+border.paintBorder (c, g, x, y, width, height);
+}return;
+}var grooveRect =  new java.awt.Rectangle (x + 2, y + 2, width - (4), height - (4));
+var font = g.getFont ();
+var color = g.getColor ();
+g.setFont (this.getFont (c));
+var jc = (Clazz.instanceOf (c, javax.swing.JComponent)) ? c : null;
+var fm = jssun.swing.SwingUtilities2.getFontMetrics (jc, g);
+var fontHeight = fm.getHeight ();
+var descent = fm.getDescent ();
+var ascent = fm.getAscent ();
+var diff;
+var stringWidth = jssun.swing.SwingUtilities2.stringWidth (jc, fm, this.getTitle ());
+var insets;
+if (border != null) {
+insets = border.getBorderInsets (c);
+} else {
+insets =  new java.awt.Insets (0, 0, 0, 0);
+}var titlePos = this.getTitlePosition ();
+switch (titlePos) {
+case 1:
+diff = ascent + descent + (Math.max (2, 4) - 2);
+grooveRect.y += diff;
+grooveRect.height -= diff;
+this.textLoc.y = grooveRect.y - (descent + 2);
+break;
+case 2:
+case 0:
+diff = Math.max (0, ((Clazz.doubleToInt (ascent / 2)) + 2) - 2);
+grooveRect.y += diff;
+grooveRect.height -= diff;
+this.textLoc.y = (grooveRect.y - descent) + Clazz.doubleToInt ((insets.top + ascent + descent) / 2);
+break;
+case 3:
+this.textLoc.y = grooveRect.y + insets.top + ascent + 2;
+break;
+case 4:
+this.textLoc.y = (grooveRect.y + grooveRect.height) - (insets.bottom + descent + 2);
+break;
+case 5:
+grooveRect.height -= Clazz.doubleToInt (fontHeight / 2);
+this.textLoc.y = ((grooveRect.y + grooveRect.height) - descent) + Clazz.doubleToInt (((ascent + descent) - insets.bottom) / 2);
+break;
+case 6:
+grooveRect.height -= fontHeight;
+this.textLoc.y = grooveRect.y + grooveRect.height + ascent + 2;
+break;
+}
+var justification = this.getTitleJustification ();
+if (javax.swing.border.AbstractBorder.isLeftToRight (c)) {
+if (justification == 4 || justification == 0) {
+justification = 1;
+} else if (justification == 5) {
+justification = 3;
+}} else {
+if (justification == 4 || justification == 0) {
+justification = 3;
+} else if (justification == 5) {
+justification = 1;
+}}switch (justification) {
+case 1:
+this.textLoc.x = grooveRect.x + 5 + insets.left;
+break;
+case 3:
+this.textLoc.x = (grooveRect.x + grooveRect.width) - (stringWidth + 5 + insets.right);
+break;
+case 2:
+this.textLoc.x = grooveRect.x + (Clazz.doubleToInt ((grooveRect.width - stringWidth) / 2));
+break;
+}
+if (border != null) {
+if (((titlePos == 2 || titlePos == 0) && (grooveRect.y > this.textLoc.y - ascent)) || (titlePos == 5 && (grooveRect.y + grooveRect.height < this.textLoc.y + descent))) {
+var clipRect =  new java.awt.Rectangle ();
+var saveClip = g.getClipBounds ();
+clipRect.setBounds (saveClip);
+if (javax.swing.border.TitledBorder.computeIntersection (clipRect, x, y, this.textLoc.x - 1 - x, height)) {
+g.setClip (clipRect);
+border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);
+}clipRect.setBounds (saveClip);
+if (javax.swing.border.TitledBorder.computeIntersection (clipRect, this.textLoc.x + stringWidth + 1, y, x + width - (this.textLoc.x + stringWidth + 1), height)) {
+g.setClip (clipRect);
+border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);
+}if (titlePos == 2 || titlePos == 0) {
+clipRect.setBounds (saveClip);
+if (javax.swing.border.TitledBorder.computeIntersection (clipRect, this.textLoc.x - 1, this.textLoc.y + descent, stringWidth + 2, y + height - this.textLoc.y - descent)) {
+g.setClip (clipRect);
+border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);
+}} else {
+clipRect.setBounds (saveClip);
+if (javax.swing.border.TitledBorder.computeIntersection (clipRect, this.textLoc.x - 1, y, stringWidth + 2, this.textLoc.y - ascent - y)) {
+g.setClip (clipRect);
+border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);
+}}g.setClip (saveClip);
+} else {
+border.paintBorder (c, g, grooveRect.x, grooveRect.y, grooveRect.width, grooveRect.height);
+}}g.setColor (this.getTitleColor ());
+jssun.swing.SwingUtilities2.drawString (jc, g, this.getTitle (), this.textLoc.x, this.textLoc.y);
+g.setFont (font);
+g.setColor (color);
+}, "java.awt.Component,java.awt.Graphics,~N,~N,~N,~N");
+Clazz.defineMethod (c$, "getBorderInsets", 
+function (c) {
+return this.getBorderInsets (c,  new java.awt.Insets (0, 0, 0, 0));
+}, "java.awt.Component");
+Clazz.defineMethod (c$, "getBorderInsets", 
+function (c, insets) {
+var fm;
+var descent = 0;
+var ascent = 16;
+var height = 16;
+var border = this.getBorder ();
+if (border != null) {
+if (Clazz.instanceOf (border, javax.swing.border.AbstractBorder)) {
+(border).getBorderInsets (c, insets);
+} else {
+var i = border.getBorderInsets (c);
+insets.top = i.top;
+insets.right = i.right;
+insets.bottom = i.bottom;
+insets.left = i.left;
+}} else {
+insets.left = insets.top = insets.right = insets.bottom = 0;
+}insets.left += 4;
+insets.right += 4;
+insets.top += 4;
+insets.bottom += 4;
+if (c == null || this.getTitle () == null || this.getTitle ().equals ("")) {
+return insets;
+}var font = this.getFont (c);
+fm = c.getFontMetrics (font);
+if (fm != null) {
+descent = fm.getDescent ();
+ascent = fm.getAscent ();
+height = fm.getHeight ();
+}switch (this.getTitlePosition ()) {
+case 1:
+insets.top += ascent + descent + (Math.max (2, 4) - 2);
+break;
+case 2:
+case 0:
+insets.top += ascent + descent;
+break;
+case 3:
+insets.top += ascent + descent + 2;
+break;
+case 4:
+insets.bottom += ascent + descent + 2;
+break;
+case 5:
+insets.bottom += ascent + descent;
+break;
+case 6:
+insets.bottom += height;
+break;
+}
+return insets;
+}, "java.awt.Component,java.awt.Insets");
+Clazz.overrideMethod (c$, "isBorderOpaque", 
+function () {
+return false;
+});
+Clazz.defineMethod (c$, "getTitle", 
+function () {
+return this.title;
+});
+Clazz.defineMethod (c$, "getBorder", 
+function () {
+var b = this.border;
+if (b == null) b = javax.swing.UIManager.getBorder ("TitledBorder.border");
+return b;
+});
+Clazz.defineMethod (c$, "getTitlePosition", 
+function () {
+if (this.titlePosition == 0) {
+var value = javax.swing.UIManager.get ("TitledBorder.position");
+if (Clazz.instanceOf (value, String)) {
+var s = value;
+if ("ABOVE_TOP".equalsIgnoreCase (s)) {
+return 1;
+} else if ("TOP".equalsIgnoreCase (s)) {
+return 2;
+} else if ("BELOW_TOP".equalsIgnoreCase (s)) {
+return 3;
+} else if ("ABOVE_BOTTOM".equalsIgnoreCase (s)) {
+return 4;
+} else if ("BOTTOM".equalsIgnoreCase (s)) {
+return 5;
+} else if ("BELOW_BOTTOM".equalsIgnoreCase (s)) {
+return 6;
+}} else if (Clazz.instanceOf (value, Integer)) {
+var i = (value).intValue ();
+if (i >= 0 && i <= 6) {
+return i;
+}}}return this.titlePosition;
+});
+Clazz.defineMethod (c$, "getTitleJustification", 
+function () {
+return this.titleJustification;
+});
+Clazz.defineMethod (c$, "getTitleFont", 
+function () {
+var f = this.titleFont;
+if (f == null) f = javax.swing.UIManager.getFont ("TitledBorder.font");
+return f;
+});
+Clazz.defineMethod (c$, "getTitleColor", 
+function () {
+var c = this.titleColor;
+if (c == null) c = javax.swing.UIManager.getColor ("TitledBorder.titleColor");
+return c;
+});
+Clazz.defineMethod (c$, "setTitle", 
+function (title) {
+this.title = title;
+}, "~S");
+Clazz.defineMethod (c$, "setBorder", 
+function (border) {
+this.border = border;
+}, "javax.swing.border.Border");
+Clazz.defineMethod (c$, "setTitlePosition", 
+function (titlePosition) {
+switch (titlePosition) {
+case 1:
+case 2:
+case 3:
+case 4:
+case 5:
+case 6:
+case 0:
+this.titlePosition = titlePosition;
+break;
+default:
+throw  new IllegalArgumentException (titlePosition + " is not a valid title position.");
+}
+}, "~N");
+Clazz.defineMethod (c$, "setTitleJustification", 
+function (titleJustification) {
+switch (titleJustification) {
+case 0:
+case 1:
+case 2:
+case 3:
+case 4:
+case 5:
+this.titleJustification = titleJustification;
+break;
+default:
+throw  new IllegalArgumentException (titleJustification + " is not a valid title justification.");
+}
+}, "~N");
+Clazz.defineMethod (c$, "setTitleFont", 
+function (titleFont) {
+this.titleFont = titleFont;
+}, "java.awt.Font");
+Clazz.defineMethod (c$, "setTitleColor", 
+function (titleColor) {
+this.titleColor = titleColor;
+}, "java.awt.Color");
+Clazz.defineMethod (c$, "getMinimumSize", 
+function (c) {
+var insets = this.getBorderInsets (c);
+var minSize =  new java.awt.Dimension (insets.right + insets.left, insets.top + insets.bottom);
+var font = this.getFont (c);
+var fm = c.getFontMetrics (font);
+var jc = (Clazz.instanceOf (c, javax.swing.JComponent)) ? c : null;
+switch (this.getTitlePosition ()) {
+case 1:
+case 6:
+minSize.width = Math.max (jssun.swing.SwingUtilities2.stringWidth (jc, fm, this.getTitle ()), minSize.width);
+break;
+case 3:
+case 4:
+case 2:
+case 5:
+case 0:
+default:
+minSize.width += jssun.swing.SwingUtilities2.stringWidth (jc, fm, this.getTitle ());
+}
+return minSize;
+}, "java.awt.Component");
+Clazz.overrideMethod (c$, "getBaseline", 
+function (c, width, height) {
+if (c == null) {
+throw  new NullPointerException ("Must supply non-null component");
+}if (height < 0) {
+throw  new IllegalArgumentException ("Height must be >= 0");
+}var title = this.getTitle ();
+if (title != null && !"".equals (title)) {
+var font = this.getFont (c);
+var border2 = this.getBorder ();
+var borderInsets;
+if (border2 != null) {
+borderInsets = border2.getBorderInsets (c);
+} else {
+borderInsets =  new java.awt.Insets (0, 0, 0, 0);
+}var fm = c.getFontMetrics (font);
+var fontHeight = fm.getHeight ();
+var descent = fm.getDescent ();
+var ascent = fm.getAscent ();
+var y = 2;
+var h = height - 4;
+var diff;
+switch (this.getTitlePosition ()) {
+case 1:
+diff = ascent + descent + (Math.max (2, 4) - 2);
+return y + diff - (descent + 2);
+case 2:
+case 0:
+diff = Math.max (0, ((Clazz.doubleToInt (ascent / 2)) + 2) - 2);
+return (y + diff - descent) + Clazz.doubleToInt ((borderInsets.top + ascent + descent) / 2);
+case 3:
+return y + borderInsets.top + ascent + 2;
+case 4:
+return (y + h) - (borderInsets.bottom + descent + 2);
+case 5:
+h -= Clazz.doubleToInt (fontHeight / 2);
+return ((y + h) - descent) + Clazz.doubleToInt (((ascent + descent) - borderInsets.bottom) / 2);
+case 6:
+h -= fontHeight;
+return y + h + ascent + 2;
+}
+}return -1;
+}, "java.awt.Component,~N,~N");
+Clazz.defineMethod (c$, "getBaselineResizeBehavior", 
+function (c) {
+Clazz.superCall (this, javax.swing.border.TitledBorder, "getBaselineResizeBehavior", [c]);
+switch (this.getTitlePosition ()) {
+case 1:
+case 2:
+case 0:
+case 3:
+return java.awt.Component.BaselineResizeBehavior.CONSTANT_ASCENT;
+case 4:
+case 5:
+case 6:
+return java.awt.Component.BaselineResizeBehavior.CONSTANT_DESCENT;
+}
+return java.awt.Component.BaselineResizeBehavior.OTHER;
+}, "java.awt.Component");
+Clazz.defineMethod (c$, "getFont", 
+function (c) {
+var font;
+if ((font = this.getTitleFont ()) != null) {
+return font;
+} else if (c != null && (font = c.getFont ()) != null) {
+return font;
+}return  new java.awt.Font ("Dialog", 0, 12);
+}, "java.awt.Component");
+c$.computeIntersection = Clazz.defineMethod (c$, "computeIntersection", 
+ function (dest, rx, ry, rw, rh) {
+var x1 = Math.max (rx, dest.x);
+var x2 = Math.min (rx + rw, dest.x + dest.width);
+var y1 = Math.max (ry, dest.y);
+var y2 = Math.min (ry + rh, dest.y + dest.height);
+dest.x = x1;
+dest.y = y1;
+dest.width = x2 - x1;
+dest.height = y2 - y1;
+if (dest.width <= 0 || dest.height <= 0) {
+return false;
+}return true;
+}, "java.awt.Rectangle,~N,~N,~N,~N");
+Clazz.defineStatics (c$,
+"DEFAULT_POSITION", 0,
+"ABOVE_TOP", 1,
+"TOP", 2,
+"BELOW_TOP", 3,
+"ABOVE_BOTTOM", 4,
+"BOTTOM", 5,
+"BELOW_BOTTOM", 6,
+"DEFAULT_JUSTIFICATION", 0,
+"LEFT", 1,
+"CENTER", 2,
+"RIGHT", 3,
+"LEADING", 4,
+"TRAILING", 5,
+"EDGE_SPACING", 2,
+"TEXT_SPACING", 2,
+"TEXT_INSET_H", 5);
+});