annotate src/samer/core_/util/swing/DarkMetalTheme.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
rev   line source
samer@0 1 package samer.core.util.swing;
samer@0 2
samer@0 3 import javax.swing.plaf.*;
samer@0 4 import javax.swing.*;
samer@0 5 import java.awt.*;
samer@0 6
samer@0 7 public class DarkMetalTheme extends javax.swing.plaf.metal.MetalTheme {
samer@0 8
samer@0 9 private ColorUIResource primary1;
samer@0 10 private ColorUIResource primary2;
samer@0 11 private ColorUIResource primary3;
samer@0 12 private ColorUIResource red, blue, yellow, green, highlight;
samer@0 13
samer@0 14 private ColorUIResource secondary1;
samer@0 15 private ColorUIResource secondary2;
samer@0 16 private ColorUIResource secondary3;
samer@0 17 private ColorUIResource white;
samer@0 18
samer@0 19 private FontUIResource plainFont;
samer@0 20 private FontUIResource smallFont;
samer@0 21 private FontUIResource boldFont;
samer@0 22
samer@0 23 public String getName() { return "Silk"; }
samer@0 24
samer@0 25 public DarkMetalTheme(Font font, Color bg, double hue, double sat)
samer@0 26 {
samer@0 27 System.err.println("Metal theme: base font is "+font);
samer@0 28
samer@0 29 plainFont = new FontUIResource(font);
samer@0 30 smallFont = new FontUIResource(font.deriveFont(0.8f*font.getSize2D()));
samer@0 31 boldFont = new FontUIResource(font.deriveFont(Font.BOLD));
samer@0 32
samer@0 33 primary3 = new ColorUIResource(Color.getHSBColor((float)hue,(float)sat,.5f));
samer@0 34 primary2 =new ColorUIResource(Color.getHSBColor((float)hue,(float)sat,.3f));
samer@0 35 primary1 =new ColorUIResource(Color.getHSBColor((float)hue,(float)sat,.1f));
samer@0 36
samer@0 37 secondary3 = new ColorUIResource(bg);
samer@0 38 secondary2 = new ColorUIResource(bg.darker());
samer@0 39 secondary1 = new ColorUIResource(bg.darker().darker());
samer@0 40 highlight = new ColorUIResource(bg.brighter());
samer@0 41
samer@0 42
samer@0 43 white=new ColorUIResource(Color.white.darker());
samer@0 44 red=new ColorUIResource(Color.red);
samer@0 45 blue=new ColorUIResource(Color.blue);
samer@0 46 green=new ColorUIResource(Color.green);
samer@0 47 yellow=new ColorUIResource(Color.yellow);
samer@0 48 }
samer@0 49
samer@0 50 public void addCustomEntriesToTable(UIDefaults table)
samer@0 51 {
samer@0 52 table.put( "Button.font", boldFont);
samer@0 53 table.put( "Label.foreground", getWhite());
samer@0 54 table.put( "TextField.background", secondary2);
samer@0 55 table.put( "TextField.foreground", getWhite());
samer@0 56 table.put( "TitledBorder.font", boldFont);
samer@0 57 table.put( "List.background", getBlack());
samer@0 58 table.put( "List.foreground", getWhite());
samer@0 59 table.put( "List.font", plainFont);
samer@0 60 }
samer@0 61
samer@0 62 public ColorUIResource getWhite() { return white; }
samer@0 63 public ColorUIResource getPrimary1() { return primary1; }
samer@0 64 public ColorUIResource getPrimary2() { return primary2; }
samer@0 65 public ColorUIResource getPrimary3() { return primary3; }
samer@0 66
samer@0 67 public ColorUIResource getSecondary1() { return secondary1; }
samer@0 68 public ColorUIResource getSecondary2() { return secondary2; }
samer@0 69 public ColorUIResource getSecondary3() { return secondary3; }
samer@0 70
samer@0 71 public FontUIResource getControlTextFont() { return plainFont;}
samer@0 72 public FontUIResource getSystemTextFont() { return plainFont;}
samer@0 73 public FontUIResource getUserTextFont() { return plainFont;}
samer@0 74 public FontUIResource getMenuTextFont() { return plainFont;}
samer@0 75 public FontUIResource getWindowTitleFont() { return boldFont;}
samer@0 76 public FontUIResource getSubTextFont() { return smallFont;}
samer@0 77
samer@0 78 public ColorUIResource getMenuForeground() { return getWhite(); }
samer@0 79 public ColorUIResource getMenuSelectedForeground() { return getWhite(); }
samer@0 80
samer@0 81 // these are for tweaking
samer@0 82
samer@0 83 public ColorUIResource getDesktopColor() { return getPrimary1(); }
samer@0 84
samer@0 85 public ColorUIResource getControl() { return getSecondary3(); }
samer@0 86 public ColorUIResource getControlShadow() { return getSecondary2(); }
samer@0 87 public ColorUIResource getControlDarkShadow() { return getSecondary1(); }
samer@0 88 public ColorUIResource getControlInfo() { return getWhite(); }
samer@0 89 public ColorUIResource getControlHighlight() { return highlight; } // getWhite(); }
samer@0 90 // public ColorUIResource getControlDisabled() { return getSecondary2(); }
samer@0 91
samer@0 92 // public ColorUIResource getPrimaryControl() { return getPrimary3(); }
samer@0 93 // public ColorUIResource getPrimaryControlShadow() { return getPrimary2(); }
samer@0 94 // public ColorUIResource getPrimaryControlDarkShadow() { return getPrimary1(); }
samer@0 95 public ColorUIResource getPrimaryControlInfo() { return primary2; } // getWhite(); }
samer@0 96 public ColorUIResource getPrimaryControlHighlight() { return primary3; } // getWhite(); }
samer@0 97
samer@0 98 public ColorUIResource getSystemTextColor() { return getWhite(); }
samer@0 99 // public ColorUIResource getInactiveSystemTextColor() { return getSecondary2(); }
samer@0 100
samer@0 101 public ColorUIResource getSeparatorBackground() { return highlight; } // getWhite(); }
samer@0 102 public ColorUIResource getSeparatorForeground() { return getSecondary2(); } // getPrimary1(); }
samer@0 103 }