001: /*
002: * Copyright (c) 2005-2008 Substance Kirill Grouchnikov. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions are met:
006: *
007: * o Redistributions of source code must retain the above copyright notice,
008: * this list of conditions and the following disclaimer.
009: *
010: * o Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: *
014: * o Neither the name of Substance Kirill Grouchnikov nor the names of
015: * its contributors may be used to endorse or promote products derived
016: * from this software without specific prior written permission.
017: *
018: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
020: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
021: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
022: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
023: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
024: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
025: * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026: * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
027: * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
028: * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029: */
030: package org.jvnet.substance.skin;
031:
032: import java.awt.Color;
033:
034: import org.jvnet.substance.border.FlatBorderPainter;
035: import org.jvnet.substance.button.ClassicButtonShaper;
036: import org.jvnet.substance.color.ColorScheme;
037: import org.jvnet.substance.painter.SimplisticSoftBorderReverseGradientPainter;
038: import org.jvnet.substance.painter.SubduedGradientPainter;
039: import org.jvnet.substance.painter.decoration.*;
040: import org.jvnet.substance.painter.highlight.ClassicHighlightPainter;
041: import org.jvnet.substance.theme.SubstanceComplexTheme;
042: import org.jvnet.substance.theme.SubstanceTheme;
043: import org.jvnet.substance.theme.SubstanceTheme.ThemeKind;
044: import org.jvnet.substance.utils.ComponentState;
045: import org.jvnet.substance.watermark.SubstanceNullWatermark;
046:
047: /**
048: * <code>Nebula</code> skin. This class is part of officially supported API.
049: *
050: * @author Kirill Grouchnikov
051: * @since version 4.0
052: */
053: public class NebulaSkin extends SubstanceAbstractSkin {
054: /**
055: * Display name for <code>this</code> skin.
056: */
057: public static String NAME = "Nebula";
058:
059: /**
060: * Color scheme for active visual state.
061: *
062: * @author Kirill Grouchnikov
063: */
064: protected static class ActiveScheme implements ColorScheme {
065: /**
066: * The main ultra-light color.
067: */
068: private static final Color mainUltraLightColor = Color
069: .decode("#F6F8FA");
070:
071: /**
072: * The main extra-light color.
073: */
074: private static final Color mainExtraLightColor = Color
075: .decode("#DFE6ED");
076:
077: /**
078: * The main light color.
079: */
080: private static final Color mainLightColor = Color
081: .decode("#C1D6E9");
082:
083: /**
084: * The main medium color.
085: */
086: private static final Color mainMidColor = Color
087: .decode("#A3B8CB");
088:
089: /**
090: * The main dark color.
091: */
092: private static final Color mainDarkColor = Color
093: .decode("#62778A");
094:
095: /**
096: * The main ultra-dark color.
097: */
098: private static final Color mainUltraDarkColor = Color
099: .decode("#42576A");
100:
101: /**
102: * The foreground color.
103: */
104: private static final Color foregroundColor = Color
105: .decode("#000000");
106:
107: /*
108: * (non-Javadoc)
109: *
110: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
111: */
112: public Color getForegroundColor() {
113: return ActiveScheme.foregroundColor;
114: }
115:
116: /*
117: * (non-Javadoc)
118: *
119: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
120: */
121: public Color getUltraLightColor() {
122: return ActiveScheme.mainUltraLightColor;
123: }
124:
125: /*
126: * (non-Javadoc)
127: *
128: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
129: */
130: public Color getExtraLightColor() {
131: return ActiveScheme.mainExtraLightColor;
132: }
133:
134: /*
135: * (non-Javadoc)
136: *
137: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
138: */
139: public Color getLightColor() {
140: return ActiveScheme.mainLightColor;
141: }
142:
143: /*
144: * (non-Javadoc)
145: *
146: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
147: */
148: public Color getMidColor() {
149: return ActiveScheme.mainMidColor;
150: }
151:
152: /*
153: * (non-Javadoc)
154: *
155: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
156: */
157: public Color getDarkColor() {
158: return ActiveScheme.mainDarkColor;
159: }
160:
161: /*
162: * (non-Javadoc)
163: *
164: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
165: */
166: public Color getUltraDarkColor() {
167: return ActiveScheme.mainUltraDarkColor;
168: }
169: }
170:
171: /**
172: * Color scheme for default visual state.
173: *
174: * @author Kirill Grouchnikov
175: */
176: protected static class DefaultScheme implements ColorScheme {
177: /**
178: * The main ultra-light color.
179: */
180: private static final Color mainUltraLightColor = Color
181: .decode("#FBFBFC");
182:
183: /**
184: * The main extra-light color.
185: */
186: private static final Color mainExtraLightColor = Color
187: .decode("#F4F7FC");
188:
189: /**
190: * The main light color.
191: */
192: private static final Color mainLightColor = Color
193: .decode("#F1F2F4");
194:
195: /**
196: * The main medium color.
197: */
198: private static final Color mainMidColor = Color
199: .decode("#D6D9DF");
200:
201: /**
202: * The main dark color.
203: */
204: private static final Color mainDarkColor = Color
205: .decode("#95989E");
206:
207: /**
208: * The main ultra-dark color.
209: */
210: private static final Color mainUltraDarkColor = Color
211: .decode("#75787E");
212:
213: /**
214: * The foreground color.
215: */
216: private static final Color foregroundColor = Color
217: .decode("#2A2E36");
218:
219: /*
220: * (non-Javadoc)
221: *
222: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
223: */
224: public Color getForegroundColor() {
225: return DefaultScheme.foregroundColor;
226: }
227:
228: /*
229: * (non-Javadoc)
230: *
231: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
232: */
233: public Color getUltraLightColor() {
234: return DefaultScheme.mainUltraLightColor;
235: }
236:
237: /*
238: * (non-Javadoc)
239: *
240: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
241: */
242: public Color getExtraLightColor() {
243: return DefaultScheme.mainExtraLightColor;
244: }
245:
246: /*
247: * (non-Javadoc)
248: *
249: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
250: */
251: public Color getLightColor() {
252: return DefaultScheme.mainLightColor;
253: }
254:
255: /*
256: * (non-Javadoc)
257: *
258: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
259: */
260: public Color getMidColor() {
261: return DefaultScheme.mainMidColor;
262: }
263:
264: /*
265: * (non-Javadoc)
266: *
267: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
268: */
269: public Color getDarkColor() {
270: return DefaultScheme.mainDarkColor;
271: }
272:
273: /*
274: * (non-Javadoc)
275: *
276: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
277: */
278: public Color getUltraDarkColor() {
279: return DefaultScheme.mainUltraDarkColor;
280: }
281: }
282:
283: /**
284: * Color scheme for default visual state.
285: *
286: * @author Kirill Grouchnikov
287: */
288: protected static class DisabledScheme implements ColorScheme {
289: /**
290: * The main ultra-light color.
291: */
292: private static final Color mainUltraLightColor = Color
293: .decode("#E3EFE9");
294:
295: /**
296: * The main extra-light color.
297: */
298: private static final Color mainExtraLightColor = Color
299: .decode("#DFE2E6");
300:
301: /**
302: * The main light color.
303: */
304: private static final Color mainLightColor = Color
305: .decode("#DADDE3");
306:
307: /**
308: * The main medium color.
309: */
310: private static final Color mainMidColor = Color
311: .decode("#D6D9DF");
312:
313: /**
314: * The main dark color.
315: */
316: private static final Color mainDarkColor = Color
317: .decode("#C9CCD2");
318:
319: /**
320: * The main ultra-dark color.
321: */
322: private static final Color mainUltraDarkColor = Color
323: .decode("#BCBFC5");
324:
325: /**
326: * The foreground color.
327: */
328: private static final Color foregroundColor = Color
329: .decode("#848B98");
330:
331: /*
332: * (non-Javadoc)
333: *
334: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
335: */
336: public Color getForegroundColor() {
337: return DisabledScheme.foregroundColor;
338: }
339:
340: /*
341: * (non-Javadoc)
342: *
343: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
344: */
345: public Color getUltraLightColor() {
346: return DisabledScheme.mainUltraLightColor;
347: }
348:
349: /*
350: * (non-Javadoc)
351: *
352: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
353: */
354: public Color getExtraLightColor() {
355: return DisabledScheme.mainExtraLightColor;
356: }
357:
358: /*
359: * (non-Javadoc)
360: *
361: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
362: */
363: public Color getLightColor() {
364: return DisabledScheme.mainLightColor;
365: }
366:
367: /*
368: * (non-Javadoc)
369: *
370: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
371: */
372: public Color getMidColor() {
373: return DisabledScheme.mainMidColor;
374: }
375:
376: /*
377: * (non-Javadoc)
378: *
379: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
380: */
381: public Color getDarkColor() {
382: return DisabledScheme.mainDarkColor;
383: }
384:
385: /*
386: * (non-Javadoc)
387: *
388: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
389: */
390: public Color getUltraDarkColor() {
391: return DisabledScheme.mainUltraDarkColor;
392: }
393: }
394:
395: /**
396: * Color scheme for {@link ComponentState#ROLLOVER_UNSELECTED} state.
397: *
398: * @author Kirill Grouchnikov
399: */
400: protected static class RolloverUnselectedScheme implements
401: ColorScheme {
402: /**
403: * The main ultra-light color.
404: */
405: private static final Color mainUltraLightColor = Color
406: .decode("#FFFFFF");
407:
408: /**
409: * The main extra-light color.
410: */
411: private static final Color mainExtraLightColor = Color
412: .decode("#FDFDFE");
413:
414: /**
415: * The main light color.
416: */
417: private static final Color mainLightColor = Color
418: .decode("#F7F8FA");
419:
420: /**
421: * The main medium color.
422: */
423: private static final Color mainMidColor = Color
424: .decode("#E9ECF2");
425:
426: /**
427: * The main dark color.
428: */
429: private static final Color mainDarkColor = Color
430: .decode("#7A7E86");
431:
432: /**
433: * The main ultra-dark color.
434: */
435: private static final Color mainUltraDarkColor = Color
436: .decode("#55585E");
437:
438: /**
439: * The foreground color.
440: */
441: private static final Color foregroundColor = Color
442: .decode("#2A2E36");
443:
444: /*
445: * (non-Javadoc)
446: *
447: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
448: */
449: public Color getForegroundColor() {
450: return RolloverUnselectedScheme.foregroundColor;
451: }
452:
453: /*
454: * (non-Javadoc)
455: *
456: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
457: */
458: public Color getUltraLightColor() {
459: return RolloverUnselectedScheme.mainUltraLightColor;
460: }
461:
462: /*
463: * (non-Javadoc)
464: *
465: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
466: */
467: public Color getExtraLightColor() {
468: return RolloverUnselectedScheme.mainExtraLightColor;
469: }
470:
471: /*
472: * (non-Javadoc)
473: *
474: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
475: */
476: public Color getLightColor() {
477: return RolloverUnselectedScheme.mainLightColor;
478: }
479:
480: /*
481: * (non-Javadoc)
482: *
483: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
484: */
485: public Color getMidColor() {
486: return RolloverUnselectedScheme.mainMidColor;
487: }
488:
489: /*
490: * (non-Javadoc)
491: *
492: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
493: */
494: public Color getDarkColor() {
495: return RolloverUnselectedScheme.mainDarkColor;
496: }
497:
498: /*
499: * (non-Javadoc)
500: *
501: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
502: */
503: public Color getUltraDarkColor() {
504: return RolloverUnselectedScheme.mainUltraDarkColor;
505: }
506: }
507:
508: /**
509: * Color scheme for {@link ComponentState#ROLLOVER_SELECTED} state.
510: *
511: * @author Kirill Grouchnikov
512: */
513: protected static class RolloverSelectedTheme implements ColorScheme {
514: /**
515: * The main ultra-light color.
516: */
517: private static final Color mainUltraLightColor = Color
518: .decode("#F8FAFC");
519:
520: /**
521: * The main extra-light color.
522: */
523: private static final Color mainExtraLightColor = Color
524: .decode("#E8FDFF");
525:
526: /**
527: * The main light color.
528: */
529: private static final Color mainLightColor = Color
530: .decode("#D4E9FC");
531:
532: /**
533: * The main medium color.
534: */
535: private static final Color mainMidColor = Color
536: .decode("#B6CBDE");
537:
538: /**
539: * The main dark color.
540: */
541: private static final Color mainDarkColor = Color
542: .decode("#3B556D");
543:
544: /**
545: * The main ultra-dark color.
546: */
547: private static final Color mainUltraDarkColor = Color
548: .decode("#00051D");
549:
550: /**
551: * The foreground color.
552: */
553: private static final Color foregroundColor = Color
554: .decode("#000000");
555:
556: /*
557: * (non-Javadoc)
558: *
559: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
560: */
561: public Color getForegroundColor() {
562: return RolloverSelectedTheme.foregroundColor;
563: }
564:
565: /*
566: * (non-Javadoc)
567: *
568: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
569: */
570: public Color getUltraLightColor() {
571: return RolloverSelectedTheme.mainUltraLightColor;
572: }
573:
574: /*
575: * (non-Javadoc)
576: *
577: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
578: */
579: public Color getExtraLightColor() {
580: return RolloverSelectedTheme.mainExtraLightColor;
581: }
582:
583: /*
584: * (non-Javadoc)
585: *
586: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
587: */
588: public Color getLightColor() {
589: return RolloverSelectedTheme.mainLightColor;
590: }
591:
592: /*
593: * (non-Javadoc)
594: *
595: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
596: */
597: public Color getMidColor() {
598: return RolloverSelectedTheme.mainMidColor;
599: }
600:
601: /*
602: * (non-Javadoc)
603: *
604: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
605: */
606: public Color getDarkColor() {
607: return RolloverSelectedTheme.mainDarkColor;
608: }
609:
610: /*
611: * (non-Javadoc)
612: *
613: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
614: */
615: public Color getUltraDarkColor() {
616: return RolloverSelectedTheme.mainUltraDarkColor;
617: }
618: }
619:
620: /**
621: * Color scheme for {@link ComponentState#PRESSED_SELECTED} and
622: * {@link ComponentState#PRESSED_UNSELECTED} states.
623: *
624: * @author Kirill Grouchnikov
625: */
626: protected static class PressedTheme implements ColorScheme {
627: /**
628: * The main ultra-light color.
629: */
630: private static final Color mainUltraLightColor = Color
631: .decode("#8FA9C0");
632:
633: /**
634: * The main extra-light color.
635: */
636: private static final Color mainExtraLightColor = Color
637: .decode("#7695B2");
638:
639: /**
640: * The main light color.
641: */
642: private static final Color mainLightColor = Color
643: .decode("#5B89B4");
644:
645: /**
646: * The main medium color.
647: */
648: private static final Color mainMidColor = Color
649: .decode("#33628C");
650:
651: /**
652: * The main dark color.
653: */
654: private static final Color mainDarkColor = Color
655: .decode("#1C3851");
656:
657: /**
658: * The main ultra-dark color.
659: */
660: private static final Color mainUltraDarkColor = Color
661: .decode("#000000");
662:
663: /**
664: * The foreground color.
665: */
666: private static final Color foregroundColor = Color
667: .decode("#FFFFFF");
668:
669: /*
670: * (non-Javadoc)
671: *
672: * @see org.jvnet.substance.color.ColorScheme#getForegroundColor()
673: */
674: public Color getForegroundColor() {
675: return PressedTheme.foregroundColor;
676: }
677:
678: /*
679: * (non-Javadoc)
680: *
681: * @see org.jvnet.substance.color.ColorScheme#getUltraLightColor()
682: */
683: public Color getUltraLightColor() {
684: return PressedTheme.mainUltraLightColor;
685: }
686:
687: /*
688: * (non-Javadoc)
689: *
690: * @see org.jvnet.substance.color.ColorScheme#getExtraLightColor()
691: */
692: public Color getExtraLightColor() {
693: return PressedTheme.mainExtraLightColor;
694: }
695:
696: /*
697: * (non-Javadoc)
698: *
699: * @see org.jvnet.substance.color.ColorScheme#getLightColor()
700: */
701: public Color getLightColor() {
702: return PressedTheme.mainLightColor;
703: }
704:
705: /*
706: * (non-Javadoc)
707: *
708: * @see org.jvnet.substance.color.ColorScheme#getMidColor()
709: */
710: public Color getMidColor() {
711: return PressedTheme.mainMidColor;
712: }
713:
714: /*
715: * (non-Javadoc)
716: *
717: * @see org.jvnet.substance.color.ColorScheme#getDarkColor()
718: */
719: public Color getDarkColor() {
720: return PressedTheme.mainDarkColor;
721: }
722:
723: /*
724: * (non-Javadoc)
725: *
726: * @see org.jvnet.substance.color.ColorScheme#getUltraDarkColor()
727: */
728: public Color getUltraDarkColor() {
729: return PressedTheme.mainUltraDarkColor;
730: }
731: }
732:
733: /**
734: * Creates a new <code>Nebula</code> skin.
735: */
736: public NebulaSkin() {
737: SubstanceTheme activeTheme = new SubstanceTheme(
738: new ActiveScheme(), "Nebula Active", ThemeKind.COLD);
739: SubstanceTheme defaultTheme = new SubstanceTheme(
740: new DefaultScheme(), "Nebula Default", ThemeKind.COLD);
741: SubstanceTheme rolloverUnselectedTheme = new SubstanceTheme(
742: new RolloverUnselectedScheme(),
743: "Nebula Rollover Unselected", ThemeKind.COLD);
744: SubstanceTheme pressedTheme = new SubstanceTheme(
745: new PressedTheme(), "Nebula Pressed", ThemeKind.DARK);
746: SubstanceTheme rolloverSelectedTheme = new SubstanceTheme(
747: new RolloverSelectedTheme(),
748: "Nebula Rollover Selected", ThemeKind.COLD);
749: SubstanceTheme disabledTheme = new SubstanceTheme(
750: new DisabledScheme(), "Nebula Disabled", ThemeKind.COLD);
751: SubstanceTheme activeTitleTheme = activeTheme.getDefaultTheme();
752:
753: SubstanceComplexTheme theme = new SubstanceComplexTheme(NAME,
754: ThemeKind.COLD, activeTheme, defaultTheme,
755: disabledTheme, activeTitleTheme);
756: theme.registerComponentStateTheme(rolloverUnselectedTheme,
757: false, ComponentState.ROLLOVER_UNSELECTED);
758: theme.registerComponentStateTheme(rolloverSelectedTheme, false,
759: ComponentState.ROLLOVER_SELECTED);
760: theme.registerComponentStateTheme(pressedTheme, true,
761: ComponentState.PRESSED_SELECTED,
762: ComponentState.PRESSED_UNSELECTED);
763:
764: theme.registerComponentHighlightStateTheme(pressedTheme, 0.6f,
765: ComponentState.ROLLOVER_UNSELECTED);
766: theme.registerComponentHighlightStateTheme(pressedTheme, 0.8f,
767: ComponentState.SELECTED);
768: theme.registerComponentHighlightStateTheme(pressedTheme, 0.95f,
769: ComponentState.ROLLOVER_SELECTED);
770: theme.registerComponentHighlightStateTheme(pressedTheme, 0.8f,
771: ComponentState.ARMED, ComponentState.ROLLOVER_ARMED);
772:
773: theme.registerDecorationAreaTheme(activeTitleTheme, false,
774: DecorationAreaType.PRIMARY_TITLE_PANE,
775: DecorationAreaType.SECONDARY_TITLE_PANE,
776: DecorationAreaType.HEADER, DecorationAreaType.GENERAL);
777:
778: theme
779: .setNonActivePainter(new SimplisticSoftBorderReverseGradientPainter());
780: theme.setSelectedTabFadeStart(0.1);
781: theme.setSelectedTabFadeEnd(0.3);
782:
783: theme.setPaintingToolbarDropShadows();
784:
785: this .theme = theme;
786:
787: this .buttonShaper = new ClassicButtonShaper();
788: this .watermark = new SubstanceNullWatermark();
789: this .gradientPainter = new SubduedGradientPainter();
790: // this.titlePainter = new FlatTitlePainter();
791:
792: MarbleNoiseDecorationPainter decorationPainter = new MarbleNoiseDecorationPainter();
793: decorationPainter.setPaintingSeparators(true);
794: decorationPainter
795: .setBaseDecorationPainter(new ArcDecorationPainter());
796: decorationPainter.setTextureAlpha(0.3f);
797: this .decorationPainter = decorationPainter;
798:
799: this .highlightPainter = new ClassicHighlightPainter();
800:
801: this .borderPainter = new FlatBorderPainter();
802: // this.tabBackgroundComposite = new
803: // AlphaControlBackgroundComposite(0.75f);
804: }
805:
806: /*
807: * (non-Javadoc)
808: *
809: * @see org.jvnet.substance.skin.SubstanceSkin#getDisplayName()
810: */
811: public String getDisplayName() {
812: return NAME;
813: }
814: }
|