@@ -63,11 +63,6 @@ public class ManagerTabs extends Box {
63
63
// amount of margin on the left/right for the text on the tab
64
64
static final int MARGIN = Toolkit .zoom (14 );
65
65
66
- static final int ICON_WIDTH = Toolkit .zoom (16 );
67
- static final int ICON_HEIGHT = Toolkit .zoom (16 );
68
- static final int ICON_TOP = Toolkit .zoom (7 );
69
- static final int ICON_MARGIN = Toolkit .zoom (7 );
70
-
71
66
static final int UNSELECTED = 0 ;
72
67
static final int SELECTED = 1 ;
73
68
@@ -81,8 +76,6 @@ public class ManagerTabs extends Box {
81
76
Font font ;
82
77
int fontAscent ;
83
78
84
- Image gradient ;
85
-
86
79
JPanel cardPanel ;
87
80
CardLayout cardLayout ;
88
81
Controller controller ;
@@ -117,32 +110,20 @@ public ManagerTabs(Base base) {
117
110
}
118
111
119
112
120
- /** Add a panel with no icon. */
121
- public void addPanel (Component comp , String name ) {
122
- addPanel (comp , name , null );
123
- }
124
-
125
-
126
113
/**
127
- * Add a panel with a name and icon .
114
+ * Add a panel with a name.
128
115
* @param comp Component that will be shown when this tab is selected
129
116
* @param name Title to appear on the tab itself
130
- * @param icon Prefix of the file name for the icon
131
117
*/
132
- public void addPanel (Component comp , String name , String icon ) {
118
+ public void addPanel (Component comp , String name ) {
133
119
if (tabList .isEmpty ()) {
134
120
currentPanel = comp ;
135
121
}
136
- tabList .add (new Tab (comp , name , icon ));
122
+ tabList .add (new Tab (comp , name ));
137
123
cardPanel .add (name , comp );
138
124
}
139
125
140
126
141
- // public void setPanel(int index) {
142
- // cardLayout.show(cardPanel, tabs.get(index).name);
143
- // }
144
-
145
-
146
127
public void setPanel (Component comp ) {
147
128
for (Tab tab : tabList ) {
148
129
if (tab .comp == comp ) {
@@ -159,16 +140,6 @@ public Component getPanel() {
159
140
}
160
141
161
142
162
- public void setNotification (Component comp , boolean note ) {
163
- for (Tab tab : tabList ) {
164
- if (tab .comp == comp ) {
165
- tab .notification = note ;
166
- repaint ();
167
- }
168
- }
169
- }
170
-
171
-
172
143
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
173
144
174
145
@@ -212,32 +183,19 @@ public void paintComponent(Graphics g) {
212
183
tab .textWidth = (int )
213
184
font .getStringBounds (tab .name , g2 .getFontRenderContext ()).getWidth ();
214
185
}
215
-
216
- placeTabs (0 );
186
+ placeTabs ();
217
187
// now actually draw the tabs
218
188
drawTabs (g2 );
219
189
}
220
190
221
191
222
- /**
223
- * @param left starting position from the left
224
- */
225
- private void placeTabs (int left ) { //, Graphics2D g) {
226
- int x = left ;
227
-
192
+ private void placeTabs () {
193
+ int x = 0 ;
228
194
for (Tab tab : tabList ) {
229
195
tab .left = x ;
230
196
x += MARGIN ;
231
- if (tab .hasIcon ()) {
232
- x += ICON_WIDTH + MARGIN ;
233
- }
234
197
x += tab .textWidth + MARGIN ;
235
198
tab .right = x ;
236
-
237
- // // if drawing and not just placing
238
- // if (g != null) {
239
- // tab.draw(g);
240
- // }
241
199
x += TAB_BETWEEN ;
242
200
}
243
201
// Align the final tab (the "updates") to the right-hand side
@@ -279,24 +237,13 @@ class Tab {
279
237
Component comp ;
280
238
boolean notification ;
281
239
282
- Image enabledIcon ;
283
- Image selectedIcon ;
284
-
285
240
int left ;
286
241
int right ;
287
242
int textWidth ;
288
243
289
- Tab (Component comp , String name , String icon ) {
244
+ Tab (Component comp , String name ) {
290
245
this .comp = comp ;
291
246
this .name = name ;
292
-
293
- if (icon != null ) {
294
- enabledIcon = mode .loadImageX (icon + "-enabled" );
295
- selectedIcon = mode .loadImageX (icon + "-selected" );
296
- if (selectedIcon == null ) {
297
- selectedIcon = enabledIcon ; // use this as the default
298
- }
299
- }
300
247
}
301
248
302
249
boolean contains (int x ) {
@@ -319,36 +266,20 @@ boolean hasRightNotch() {
319
266
}
320
267
321
268
int getTextLeft () {
322
- int links = left ;
323
- if (enabledIcon != null ) {
324
- links += ICON_WIDTH + ICON_MARGIN ;
325
- }
326
- return links + ((right - links ) - textWidth ) / 2 ;
327
- }
328
-
329
- boolean hasIcon () {
330
- return enabledIcon != null ;
269
+ return left + ((right - left ) - textWidth ) / 2 ;
331
270
}
332
271
333
272
void draw (Graphics g ) {
334
273
int state = isCurrent () ? SELECTED : UNSELECTED ;
335
274
g .setColor (tabColor [state ]);
336
275
337
276
Graphics2D g2 = (Graphics2D ) g ;
338
- // g2.fill(Toolkit.createRoundRect(left, TAB_TOP, right, TAB_BOTTOM, 0, 0,
339
- // isLast() ? CURVE_RADIUS : 0,
340
- // hastLeftCurve() ? CURVE_RADIUS : 0));
341
277
g2 .fill (Toolkit .createRoundRect (left , TAB_TOP ,
342
278
right , TAB_BOTTOM ,
343
279
hasLeftNotch () ? CURVE_RADIUS : 0 ,
344
280
hasRightNotch () ? CURVE_RADIUS : 0 ,
345
281
0 , 0 ));
346
282
347
- if (hasIcon ()) {
348
- Image icon = (isCurrent () || notification ) ? selectedIcon : enabledIcon ;
349
- g .drawImage (icon , left + MARGIN , ICON_TOP , ICON_WIDTH , ICON_HEIGHT , null );
350
- }
351
-
352
283
int textLeft = getTextLeft ();
353
284
if (notification && state == UNSELECTED ) {
354
285
g .setColor (textColor [SELECTED ]);
0 commit comments