1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45:
46: import ;
47: import ;
48:
49:
52: public class MetalIconFactory implements Serializable
53: {
54:
55:
56: public static final boolean DARK = false;
57:
58:
59: public static final boolean LIGHT = true;
60:
61:
65: public static class FileIcon16 implements Icon, Serializable
66: {
67:
72: public int getIconWidth()
73: {
74: return 16;
75: }
76:
77:
82: public int getIconHeight()
83: {
84: return 16;
85: }
86:
87:
95: public void paintIcon(Component c, Graphics g, int x, int y)
96: {
97:
98: g.setColor(Color.black);
99: g.drawLine(x, y, x + 9, y);
100: g.drawLine(x, y + 1, x, y + 15);
101: g.drawLine(x, y + 15, x + 12, y + 15);
102: g.drawLine(x + 12, y + 15, x + 12, y + 6);
103: g.drawLine(x + 12, y + 6, x + 9, y);
104:
105: g.drawLine(x + 7, y + 2, x + 11, y + 6);
106: g.drawLine(x + 8, y + 1, x + 9, y + 1);
107:
108: g.setColor(new Color(204, 204, 255));
109: g.drawLine(x + 1, y + 1, x + 7, y + 1);
110: g.drawLine(x + 1, y + 1, x + 1, y + 14);
111: g.drawLine(x + 1, y + 14, x + 11, y + 14);
112: g.drawLine(x + 11, y + 14, x + 11, y + 7);
113: g.drawLine(x + 8, y + 2, x + 10, y + 4);
114: }
115:
116:
121: public int getAdditionalHeight()
122: {
123: return 0;
124: }
125:
126:
131: public int getShift()
132: {
133: return 0;
134: }
135:
136: }
137:
138:
141: public static class FolderIcon16 implements Icon, Serializable
142: {
143:
148: public int getIconWidth() {
149: return 16;
150: }
151:
152:
157: public int getIconHeight()
158: {
159: return 16;
160: }
161:
162:
170: public void paintIcon(Component c, Graphics g, int x, int y)
171: {
172:
173: g.setColor(Color.black);
174: g.drawLine(x, y + 3, x, y + 12);
175: g.drawLine(x, y + 12, x + 15, y + 12);
176: g.drawLine(x + 15, y + 12, x + 15, y + 2);
177: g.drawLine(x + 14, y + 3, x + 9, y + 3);
178: g.drawLine(x + 8, y + 2, x + 1, y + 2);
179: g.setColor(new Color(204, 204, 255));
180: g.fillRect(x + 2, y + 4, 7, 8);
181: g.fillRect(x + 9, y + 5, 6, 7);
182: g.setColor(new Color(102, 102, 153));
183: g.drawLine(x + 9, y + 2, x + 14, y + 2);
184: g.setColor(new Color(50, 50, 120));
185: g.drawLine(x + 9, y + 1, x + 15, y + 1);
186: g.drawLine(x + 10, y, x + 15, y);
187: }
188:
189:
194: public int getAdditionalHeight()
195: {
196: return 0;
197: }
198:
199:
204: public int getShift()
205: {
206: return 0;
207: }
208:
209: }
210:
211:
215: private static class HorizontalSliderThumbIcon
216: implements Icon, Serializable
217: {
218:
219:
222: public HorizontalSliderThumbIcon()
223: {
224: }
225:
226:
231: public int getIconWidth()
232: {
233: return 15;
234: }
235:
236:
241: public int getIconHeight()
242: {
243: return 16;
244: }
245:
246:
255: public void paintIcon(Component c, Graphics g, int x, int y)
256: {
257: boolean focus = false;
258: if (c != null)
259: focus = c.hasFocus();
260:
261:
262:
263: g.setColor(Color.black);
264: g.drawLine(x + 1, y, x + 13, y);
265: g.drawLine(x + 14, y + 1, x + 14, y + 7);
266: g.drawLine(x + 14, y + 8, x + 7, y + 15);
267: g.drawLine(x + 6, y + 14, x, y + 8);
268: g.drawLine(x, y + 7, x, y + 1);
269:
270:
271: g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204));
272: g.fillRect(x + 2, y + 2, 12, 7);
273: g.drawLine(x + 2, y + 9, x + 12, y + 9);
274: g.drawLine(x + 3, y + 10, x + 11, y + 10);
275: g.drawLine(x + 4, y + 11, x + 10, y + 11);
276: g.drawLine(x + 5, y + 12, x + 9, y + 12);
277: g.drawLine(x + 6, y + 13, x + 8, y + 13);
278: g.drawLine(x + 7, y + 14, x + 7, y + 14);
279:
280:
281: g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255));
282: g.drawLine(x + 1, y + 1, x + 13, y + 1);
283: g.drawLine(x + 1, y + 2, x + 1, y + 8);
284: g.drawLine(x + 2, y + 2, x + 2, y + 2);
285: g.drawLine(x + 6, y + 2, x + 6, y + 2);
286: g.drawLine(x + 10, y + 2, x + 10, y + 2);
287:
288: g.drawLine(x + 4, y + 4, x + 4, y + 4);
289: g.drawLine(x + 8, y + 4, x + 8, y + 4);
290:
291: g.drawLine(x + 2, y + 6, x + 2, y + 6);
292: g.drawLine(x + 6, y + 6, x + 6, y + 6);
293: g.drawLine(x + 10, y + 6, x + 10, y + 6);
294:
295:
296: g.setColor(focus ? new Color(102, 102, 153) : Color.black);
297: g.drawLine(x + 3, y + 3, x + 3, y + 3);
298: g.drawLine(x + 7, y + 3, x + 7, y + 3);
299: g.drawLine(x + 11, y + 3, x + 11, y + 3);
300:
301: g.drawLine(x + 5, y + 5, x + 5, y + 5);
302: g.drawLine(x + 9, y + 5, x + 9, y + 5);
303:
304: g.drawLine(x + 3, y + 7, x + 3, y + 7);
305: g.drawLine(x + 7, y + 7, x + 7, y + 7);
306: g.drawLine(x + 11, y + 7, x + 11, y + 7);
307:
308: }
309: }
310:
311:
315: private static class VerticalSliderThumbIcon implements Icon, Serializable
316: {
317:
320: public VerticalSliderThumbIcon()
321: {
322: }
323:
324:
329: public int getIconWidth()
330: {
331: return 16;
332: }
333:
334:
339: public int getIconHeight()
340: {
341: return 15;
342: }
343:
344:
354: public void paintIcon(Component c, Graphics g, int x, int y)
355: {
356: boolean focus = false;
357: if (c != null)
358: focus = c.hasFocus();
359:
360:
361:
362: g.setColor(Color.black);
363: g.drawLine(x + 1, y, x + 7, y);
364: g.drawLine(x + 8, y, x + 15, y + 7);
365: g.drawLine(x + 14, y + 8, x + 8, y + 14);
366: g.drawLine(x + 8, y + 14, x + 1, y + 14);
367: g.drawLine(x, y + 13, x, y + 1);
368:
369:
370: g.setColor(focus ? new Color(153, 153, 204) : new Color(204, 204, 204));
371: g.fillRect(x + 2, y + 2, 7, 12);
372: g.drawLine(x + 9, y + 2, x + 9, y + 12);
373: g.drawLine(x + 10, y + 3, x + 10, y + 11);
374: g.drawLine(x + 11, y + 4, x + 11, y + 10);
375: g.drawLine(x + 12, y + 5, x + 12, y + 9);
376: g.drawLine(x + 13, y + 6, x + 13, y + 8);
377: g.drawLine(x + 14, y + 7, x + 14, y + 7);
378:
379:
380: g.setColor(focus ? new Color(204, 204, 255) : new Color(255, 255, 255));
381: g.drawLine(x + 1, y + 1, x + 8, y + 1);
382: g.drawLine(x + 1, y + 2, x + 1, y + 13);
383: g.drawLine(x + 2, y + 2, x + 2, y + 2);
384: g.drawLine(x + 2, y + 6, x + 2, y + 6);
385: g.drawLine(x + 2, y + 10, x + 2, y + 10);
386:
387: g.drawLine(x + 4, y + 4, x + 4, y + 4);
388: g.drawLine(x + 4, y + 8, x + 4, y + 8);
389:
390: g.drawLine(x + 6, y + 2, x + 6, y + 2);
391: g.drawLine(x + 6, y + 6, x + 6, y + 6);
392: g.drawLine(x + 6, y + 10, x + 6, y + 10);
393:
394:
395: g.setColor(focus ? new Color(102, 102, 153) : Color.black);
396: g.drawLine(x + 3, y + 3, x + 3, y + 3);
397: g.drawLine(x + 3, y + 7, x + 3, y + 7);
398: g.drawLine(x + 3, y + 11, x + 3, y + 11);
399:
400: g.drawLine(x + 5, y + 5, x + 5, y + 5);
401: g.drawLine(x + 5, y + 9, x + 5, y + 9);
402:
403: g.drawLine(x + 7, y + 3, x + 7, y + 3);
404: g.drawLine(x + 7, y + 7, x + 7, y + 7);
405: g.drawLine(x + 7, y + 11, x + 7, y + 11);
406: }
407: }
408:
409:
413: public static class TreeControlIcon implements Icon, Serializable
414: {
415:
416:
417: protected boolean isLight;
418:
419:
420: private boolean collapsed;
421:
422:
428: public TreeControlIcon(boolean isCollapsed)
429: {
430: collapsed = isCollapsed;
431: }
432:
433:
438: public int getIconWidth()
439: {
440: return 18;
441: }
442:
447: public int getIconHeight()
448: {
449: return 18;
450: }
451:
452:
460: public void paintIcon(Component c, Graphics g, int x, int y)
461: {
462: x = x + 5;
463: y = y + 5;
464: if (collapsed)
465: {
466:
467: g.setColor(Color.black);
468: g.drawLine(x + 2, y, x + 5, y);
469: g.drawLine(x + 6, y + 1, x + 7, y + 2);
470: g.fillRect(x + 7, y + 3, 5, 2);
471: g.drawLine(x + 7, y + 5, x + 6, y + 6);
472: g.drawLine(x + 1, y + 1, x + 1, y + 1);
473: g.drawLine(x, y + 2, x, y + 5);
474: g.drawLine(x + 1, y + 6, x + 1, y + 6);
475: g.drawLine(x + 2, y + 7, x + 5, y + 7);
476: g.fillRect(x + 3, y + 3, 2, 2);
477:
478: g.setColor(new Color(204, 204, 255));
479: g.drawLine(x + 3, y + 2, x + 4, y + 2);
480: g.drawLine(x + 2, y + 3, x + 2, y + 4);
481: g.drawLine(x + 3, y + 5, x + 3, y + 5);
482: g.drawLine(x + 5, y + 3, x + 5, y + 3);
483:
484: g.setColor(new Color(153, 153, 204));
485: g.drawLine(x + 2, y + 2, x + 2, y + 2);
486: g.drawLine(x + 2, y + 5, x + 2, y + 5);
487: g.drawLine(x + 2, y + 6, x + 5, y + 6);
488: g.drawLine(x + 5, y + 2, x + 5, y + 2);
489: g.drawLine(x + 6, y + 2, x + 6, y + 5);
490:
491: g.setColor(new Color(102, 102, 153));
492: g.drawLine(x + 2, y + 1, x + 5, y + 1);
493: g.drawLine(x + 1, y + 2, x + 1, y + 5);
494: }
495: else
496: {
497:
498: g.setColor(Color.black);
499: g.drawLine(x + 2, y, x + 5, y);
500: g.drawLine(x + 6, y + 1, x + 7, y + 2);
501: g.drawLine(x + 7, y + 2, x + 7, y + 5);
502: g.fillRect(x + 3, y + 7, 2, 5);
503: g.drawLine(x + 7, y + 5, x + 6, y + 6);
504: g.drawLine(x + 1, y + 1, x + 1, y + 1);
505: g.drawLine(x, y + 2, x, y + 5);
506: g.drawLine(x + 1, y + 6, x + 1, y + 6);
507: g.drawLine(x + 2, y + 7, x + 5, y + 7);
508: g.fillRect(x + 3, y + 3, 2, 2);
509:
510: g.setColor(new Color(204, 204, 255));
511: g.drawLine(x + 3, y + 2, x + 4, y + 2);
512: g.drawLine(x + 2, y + 3, x + 2, y + 4);
513: g.drawLine(x + 3, y + 5, x + 3, y + 5);
514: g.drawLine(x + 5, y + 3, x + 5, y + 3);
515:
516: g.setColor(new Color(153, 153, 204));
517: g.drawLine(x + 2, y + 2, x + 2, y + 2);
518: g.drawLine(x + 2, y + 5, x + 2, y + 5);
519: g.drawLine(x + 2, y + 6, x + 5, y + 6);
520: g.drawLine(x + 5, y + 2, x + 5, y + 2);
521: g.drawLine(x + 6, y + 2, x + 6, y + 5);
522:
523: g.setColor(new Color(102, 102, 153));
524: g.drawLine(x + 2, y + 1, x + 5, y + 1);
525: g.drawLine(x + 1, y + 2, x + 1, y + 5);
526: }
527: }
528:
529:
537: public void paintMe(Component c, Graphics g, int x, int y)
538: {
539: paintIcon(c, g, x, y);
540: }
541: }
542:
543:
546: public static class TreeFolderIcon extends FolderIcon16
547: {
548:
551: public TreeFolderIcon()
552: {
553: }
554:
555:
560: public int getAdditionalHeight()
561: {
562: return 2;
563: }
564:
565:
570: public int getShift()
571: {
572: return -1;
573: }
574: }
575:
576:
579: public static class TreeLeafIcon extends FileIcon16
580: {
581:
584: public TreeLeafIcon()
585: {
586: }
587:
588:
593: public int getAdditionalHeight()
594: {
595: return 4;
596: }
597:
598:
603: public int getShift()
604: {
605: return 2;
606: }
607: }
608:
609:
613: public MetalIconFactory()
614: {
615: }
616:
617:
623: public static Icon getHorizontalSliderThumbIcon()
624: {
625: return new HorizontalSliderThumbIcon();
626: }
627:
628:
634: public static Icon getVerticalSliderThumbIcon()
635: {
636: return new VerticalSliderThumbIcon();
637: }
638:
639:
644: public static Icon getTreeFolderIcon()
645: {
646: return new TreeFolderIcon();
647: }
648:
649:
654: public static Icon getTreeLeafIcon()
655: {
656: return new TreeLeafIcon();
657: }
658:
659:
667: public static Icon getTreeControlIcon(boolean isCollapsed)
668: {
669: return new TreeControlIcon(isCollapsed);
670: }
671:
672: }