annotate src/samer/core_/util/swing/SilkyMetalTheme.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 SilkyMetalTheme 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
samer@0 18 private FontUIResource plainFont;
samer@0 19 private FontUIResource smallFont;
samer@0 20 private FontUIResource boldFont;
samer@0 21
samer@0 22 public String getName() { return "Silk"; }
samer@0 23
samer@0 24 public SilkyMetalTheme(Font font, Color bg, double hue)
samer@0 25 {
samer@0 26 System.err.println("Metal theme: base font is "+font);
samer@0 27
samer@0 28 plainFont = new FontUIResource(font);
samer@0 29 smallFont = new FontUIResource(font.deriveFont(0.8f*font.getSize2D()));
samer@0 30 boldFont = new FontUIResource(font.deriveFont(Font.BOLD));
samer@0 31
samer@0 32 primary3 = new ColorUIResource(Color.getHSBColor((float)hue,0.3f,1.0f));
samer@0 33 primary2 =new ColorUIResource(Color.getHSBColor((float)hue,0.4f,.9f));
samer@0 34 primary1 =new ColorUIResource(Color.getHSBColor((float)hue,0.3f,.3f));
samer@0 35
samer@0 36 secondary3 = new ColorUIResource(bg);
samer@0 37 secondary2 = new ColorUIResource(bg.darker());
samer@0 38 secondary1 = new ColorUIResource(bg.darker().darker());
samer@0 39 highlight = new ColorUIResource(bg.brighter());
samer@0 40
samer@0 41 red=new ColorUIResource(Color.red);
samer@0 42 blue=new ColorUIResource(Color.blue);
samer@0 43 green=new ColorUIResource(Color.green);
samer@0 44 yellow=new ColorUIResource(Color.yellow);
samer@0 45 }
samer@0 46
samer@0 47 public void addCustomEntriesToTable(UIDefaults table)
samer@0 48 {
samer@0 49 table.put( "Button.font", boldFont);
samer@0 50 table.put( "Label.foreground", getBlack());
samer@0 51 table.put( "TitledBorder.font", boldFont);
samer@0 52 table.put( "List.font", plainFont);
samer@0 53 }
samer@0 54
samer@0 55 public ColorUIResource getPrimary1() { return primary1; }
samer@0 56 public ColorUIResource getPrimary2() { return primary2; }
samer@0 57 public ColorUIResource getPrimary3() { return primary3; }
samer@0 58
samer@0 59 public ColorUIResource getSecondary1() { return secondary1; }
samer@0 60 public ColorUIResource getSecondary2() { return secondary2; }
samer@0 61 public ColorUIResource getSecondary3() { return secondary3; }
samer@0 62
samer@0 63 public FontUIResource getControlTextFont() { return plainFont;}
samer@0 64 public FontUIResource getSystemTextFont() { return plainFont;}
samer@0 65 public FontUIResource getUserTextFont() { return plainFont;}
samer@0 66 public FontUIResource getMenuTextFont() { return plainFont;}
samer@0 67 public FontUIResource getWindowTitleFont() { return boldFont;}
samer@0 68 public FontUIResource getSubTextFont() { return smallFont;}
samer@0 69
samer@0 70 // these are fore tweaking
samer@0 71
samer@0 72 public ColorUIResource getDesktopColor() { return getPrimary1(); }
samer@0 73
samer@0 74 public ColorUIResource getControl() { return getSecondary3(); }
samer@0 75 public ColorUIResource getControlShadow() { return getSecondary2(); }
samer@0 76 public ColorUIResource getControlDarkShadow() { return getSecondary1(); }
samer@0 77 // public ColorUIResource getControlInfo() { return getBlack(); }
samer@0 78 public ColorUIResource getControlHighlight() { return highlight; } // getWhite(); }
samer@0 79 // public ColorUIResource getControlDisabled() { return getSecondary2(); }
samer@0 80
samer@0 81 // public ColorUIResource getPrimaryControl() { return getPrimary3(); }
samer@0 82 // public ColorUIResource getPrimaryControlShadow() { return getPrimary2(); }
samer@0 83 // public ColorUIResource getPrimaryControlDarkShadow() { return getPrimary1(); }
samer@0 84 // public ColorUIResource getPrimaryControlInfo() { return getBlack(); }
samer@0 85 public ColorUIResource getPrimaryControlHighlight() { return highlight; } // getWhite(); }
samer@0 86
samer@0 87 // public ColorUIResource getSystemTextColor() { return getPrimary1(); }
samer@0 88 // public ColorUIResource getInactiveSystemTextColor() { return getSecondary2(); }
samer@0 89
samer@0 90 public ColorUIResource getSeparatorBackground() { return highlight; } // getWhite(); }
samer@0 91 public ColorUIResource getSeparatorForeground() { return getSecondary2(); } // getPrimary1(); }
samer@0 92 }