199d01314aa5625a76a07a9ba3e3a8ad9c06d10b
[jalviewjs.git] / site / j2s / javax / swing / border / LineBorder.js
1 Clazz.declarePackage ("javax.swing.border");
2 Clazz.load (["javax.swing.border.AbstractBorder"], "javax.swing.border.LineBorder", ["java.awt.Color", "$.Graphics2D", "$.Insets", "java.awt.geom.Path2D", "$.Rectangle2D", "$.RoundRectangle2D"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.thickness = 0;
5 this.lineColor = null;
6 this.roundedCorners = false;
7 Clazz.instantialize (this, arguments);
8 }, javax.swing.border, "LineBorder", javax.swing.border.AbstractBorder);
9 c$.createBlackLineBorder = Clazz.defineMethod (c$, "createBlackLineBorder", 
10 function () {
11 if (javax.swing.border.LineBorder.blackLine == null) {
12 javax.swing.border.LineBorder.blackLine =  new javax.swing.border.LineBorder (java.awt.Color.black, 1);
13 }return javax.swing.border.LineBorder.blackLine;
14 });
15 c$.createGrayLineBorder = Clazz.defineMethod (c$, "createGrayLineBorder", 
16 function () {
17 if (javax.swing.border.LineBorder.grayLine == null) {
18 javax.swing.border.LineBorder.grayLine =  new javax.swing.border.LineBorder (java.awt.Color.gray, 1);
19 }return javax.swing.border.LineBorder.grayLine;
20 });
21 Clazz.makeConstructor (c$, 
22 function (color) {
23 this.construct (color, 1, false);
24 }, "java.awt.Color");
25 Clazz.makeConstructor (c$, 
26 function (color, thickness) {
27 this.construct (color, thickness, false);
28 }, "java.awt.Color,~N");
29 Clazz.makeConstructor (c$, 
30 function (color, thickness, roundedCorners) {
31 Clazz.superConstructor (this, javax.swing.border.LineBorder, []);
32 this.lineColor = color;
33 this.thickness = thickness;
34 this.roundedCorners = roundedCorners;
35 }, "java.awt.Color,~N,~B");
36 Clazz.overrideMethod (c$, "paintBorder", 
37 function (c, g, x, y, width, height) {
38 if ((this.thickness > 0) && (Clazz.instanceOf (g, java.awt.Graphics2D))) {
39 var g2d = g;
40 var oldColor = g2d.getColor ();
41 g2d.setColor (this.lineColor);
42 var outer;
43 var inner;
44 var offs = this.thickness;
45 var size = offs + offs;
46 if (this.roundedCorners) {
47 var arc = offs + size;
48 outer =  new java.awt.geom.RoundRectangle2D.Float (x, y, width, height, arc, arc);
49 inner =  new java.awt.geom.RoundRectangle2D.Float (x + offs, y + offs, width - size, height - size, arc, arc);
50 } else {
51 outer =  new java.awt.geom.Rectangle2D.Float (x, y, width, height);
52 inner =  new java.awt.geom.Rectangle2D.Float (x + offs, y + offs, width - size, height - size);
53 }var path =  new java.awt.geom.Path2D.Float (0);
54 path.append (outer, false);
55 path.append (inner, false);
56 g2d.fill (path);
57 g2d.setColor (oldColor);
58 }}, "java.awt.Component,java.awt.Graphics,~N,~N,~N,~N");
59 Clazz.defineMethod (c$, "getBorderInsets", 
60 function (c) {
61 return  new java.awt.Insets (this.thickness, this.thickness, this.thickness, this.thickness);
62 }, "java.awt.Component");
63 Clazz.defineMethod (c$, "getBorderInsets", 
64 function (c, insets) {
65 insets.left = insets.top = insets.right = insets.bottom = this.thickness;
66 return insets;
67 }, "java.awt.Component,java.awt.Insets");
68 Clazz.defineMethod (c$, "getLineColor", 
69 function () {
70 return this.lineColor;
71 });
72 Clazz.defineMethod (c$, "getThickness", 
73 function () {
74 return this.thickness;
75 });
76 Clazz.defineMethod (c$, "getRoundedCorners", 
77 function () {
78 return this.roundedCorners;
79 });
80 Clazz.overrideMethod (c$, "isBorderOpaque", 
81 function () {
82 return !this.roundedCorners;
83 });
84 Clazz.defineStatics (c$,
85 "blackLine", null,
86 "grayLine", null);
87 });