Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / Frame.js
1 Clazz.declarePackage ("java.awt");
2 Clazz.load (["java.awt.Window"], "java.awt.Frame", ["java.lang.IllegalArgumentException", "java.awt.Cursor", "$.IllegalComponentStateException"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.maximizedBounds = null;
5 this.title = "Untitled";
6 this.resizable = true;
7 this.undecorated = false;
8 this.mbManagement = false;
9 this.$state = 0;
10 this.ownedWindows = null;
11 this.menuBar = null;
12 Clazz.instantialize (this, arguments);
13 }, java.awt, "Frame", java.awt.Window);
14 Clazz.makeConstructor (c$, 
15 function () {
16 this.construct ("");
17 });
18 Clazz.makeConstructor (c$, 
19 function (gc) {
20 this.construct ("", gc);
21 }, "java.awt.GraphicsConfiguration");
22 Clazz.makeConstructor (c$, 
23 function (title) {
24 Clazz.superConstructor (this, java.awt.Frame, []);
25 this.initFrame (title, null);
26 }, "~S");
27 Clazz.makeConstructor (c$, 
28 function (title, gc) {
29 Clazz.superConstructor (this, java.awt.Frame, [gc]);
30 this.initFrame (title, gc);
31 }, "~S,java.awt.GraphicsConfiguration");
32 Clazz.defineMethod (c$, "initFrame", 
33  function (title, gc) {
34 this.title = title;
35 }, "~S,java.awt.GraphicsConfiguration");
36 Clazz.overrideMethod (c$, "constructComponentName", 
37 function () {
38 {
39 return "frame" + java.awt.Frame.$nameCounter++;
40 }});
41 Clazz.defineMethod (c$, "addNotify", 
42 function () {
43 if (this.peer == null) {
44 this.peer = this.getToolkit ().createFrame (this);
45 }var p = this.peer;
46 p.setMaximizedBounds (this.maximizedBounds);
47 Clazz.superCall (this, java.awt.Frame, "addNotify", []);
48 });
49 Clazz.defineMethod (c$, "getTitle", 
50 function () {
51 return this.title;
52 });
53 Clazz.defineMethod (c$, "setTitle", 
54 function (title) {
55 var oldTitle = this.title;
56 if (title == null) {
57 title = "";
58 }{
59 this.title = title;
60 }this.firePropertyChangeObject ("title", oldTitle, title);
61 }, "~S");
62 Clazz.defineMethod (c$, "getIconImage", 
63 function () {
64 var icons = this.icons;
65 if (icons != null) {
66 if (icons.size () > 0) {
67 return icons.get (0);
68 }}return null;
69 });
70 Clazz.defineMethod (c$, "isResizable", 
71 function () {
72 return this.resizable;
73 });
74 Clazz.defineMethod (c$, "setResizable", 
75 function (resizable) {
76 var oldResizable = this.resizable;
77 {
78 this.resizable = resizable;
79 }this.firePropertyChangeBool ("resizable", oldResizable, resizable);
80 }, "~B");
81 Clazz.defineMethod (c$, "setState", 
82 function (state) {
83 var current = this.getExtendedState ();
84 if (state == 1 && (current & 1) == 0) {
85 this.setExtendedState (current | 1);
86 } else if (state == 0 && (current & 1) != 0) {
87 this.setExtendedState (current & -2);
88 }}, "~N");
89 Clazz.defineMethod (c$, "setExtendedState", 
90 function (state) {
91 if (!this.isFrameStateSupported (state)) {
92 return;
93 }this.$state = state;
94 }, "~N");
95 Clazz.defineMethod (c$, "isFrameStateSupported", 
96  function (state) {
97 if (!this.getToolkit ().isFrameStateSupported (state)) {
98 if (((state & 1) != 0) && !this.getToolkit ().isFrameStateSupported (1)) {
99 return false;
100 } else {
101 state &= -2;
102 }return this.getToolkit ().isFrameStateSupported (state);
103 }return true;
104 }, "~N");
105 Clazz.defineMethod (c$, "getState", 
106 function () {
107 return (this.getExtendedState () & 1) != 0 ? 1 : 0;
108 });
109 Clazz.defineMethod (c$, "getExtendedState", 
110 function () {
111 return this.$state;
112 });
113 Clazz.defineMethod (c$, "setMaximizedBounds", 
114 function (bounds) {
115 this.maximizedBounds = bounds;
116 }, "java.awt.Rectangle");
117 Clazz.defineMethod (c$, "getMaximizedBounds", 
118 function () {
119 return this.maximizedBounds;
120 });
121 Clazz.defineMethod (c$, "setUndecorated", 
122 function (undecorated) {
123 {
124 if (this.isDisplayable ()) {
125 throw  new java.awt.IllegalComponentStateException ("The frame is displayable.");
126 }this.undecorated = undecorated;
127 }}, "~B");
128 Clazz.defineMethod (c$, "isUndecorated", 
129 function () {
130 return this.undecorated;
131 });
132 Clazz.overrideMethod (c$, "removeNotify", 
133 function () {
134 });
135 Clazz.defineMethod (c$, "paramString", 
136 function () {
137 var str = Clazz.superCall (this, java.awt.Frame, "paramString", []);
138 if (this.title != null) {
139 str += ",title=" + this.title;
140 }if (this.resizable) {
141 str += ",resizable";
142 }this.getExtendedState ();
143 if (this.$state == 0) {
144 str += ",normal";
145 } else {
146 if ((this.$state & 1) != 0) {
147 str += ",iconified";
148 }if ((this.$state & 6) == 6) {
149 str += ",maximized";
150 } else if ((this.$state & 2) != 0) {
151 str += ",maximized_horiz";
152 } else if ((this.$state & 4) != 0) {
153 str += ",maximized_vert";
154 }}return str;
155 });
156 Clazz.defineMethod (c$, "setCursor", 
157 function (cursorType) {
158 if (cursorType < 0 || cursorType > 13) {
159 throw  new IllegalArgumentException ("illegal cursor type");
160 }this.setCursor (java.awt.Cursor.getPredefinedCursor (cursorType));
161 }, "~N");
162 Clazz.defineMethod (c$, "getCursorType", 
163 function () {
164 return (this.getCursor ().getType ());
165 });
166 c$.getFrames = Clazz.defineMethod (c$, "getFrames", 
167 function () {
168 var allWindows = java.awt.Window.getWindows ();
169 var frameCount = 0;
170 for (var w, $w = 0, $$w = allWindows; $w < $$w.length && ((w = $$w[$w]) || true); $w++) {
171 if (Clazz.instanceOf (w, java.awt.Frame)) {
172 frameCount++;
173 }}
174 var frames =  new Array (frameCount);
175 var c = 0;
176 for (var w, $w = 0, $$w = allWindows; $w < $$w.length && ((w = $$w[$w]) || true); $w++) {
177 if (Clazz.instanceOf (w, java.awt.Frame)) {
178 frames[c++] = w;
179 }}
180 return frames;
181 });
182 Clazz.defineStatics (c$,
183 "DEFAULT_CURSOR", 0,
184 "CROSSHAIR_CURSOR", 1,
185 "TEXT_CURSOR", 2,
186 "WAIT_CURSOR", 3,
187 "SW_RESIZE_CURSOR", 4,
188 "SE_RESIZE_CURSOR", 5,
189 "NW_RESIZE_CURSOR", 6,
190 "NE_RESIZE_CURSOR", 7,
191 "N_RESIZE_CURSOR", 8,
192 "S_RESIZE_CURSOR", 9,
193 "W_RESIZE_CURSOR", 10,
194 "E_RESIZE_CURSOR", 11,
195 "HAND_CURSOR", 12,
196 "MOVE_CURSOR", 13,
197 "NORMAL", 0,
198 "ICONIFIED", 1,
199 "MAXIMIZED_HORIZ", 2,
200 "MAXIMIZED_VERT", 4,
201 "MAXIMIZED_BOTH", 6,
202 "$base", "frame",
203 "$nameCounter", 0);
204 });