view src/samer/core_/util/swing/DarkMetalTheme.java @ 0:bf79fb79ee13

Initial Mercurial check in.
author samer
date Tue, 17 Jan 2012 17:50:20 +0000
parents
children
line wrap: on
line source
package samer.core.util.swing;

import javax.swing.plaf.*;
import javax.swing.*;
import java.awt.*;

public class DarkMetalTheme extends javax.swing.plaf.metal.MetalTheme {

	private ColorUIResource primary1;
	private ColorUIResource primary2;
	private ColorUIResource primary3;
	private ColorUIResource red, blue, yellow, green, highlight;

	private ColorUIResource secondary1;
	private ColorUIResource secondary2;
	private ColorUIResource secondary3;
	private ColorUIResource white;

	private FontUIResource plainFont;
	private FontUIResource smallFont;
	private FontUIResource boldFont;

	public String getName() { return "Silk"; }

	public DarkMetalTheme(Font font, Color bg, double hue, double sat)
	{
		System.err.println("Metal theme: base font is "+font);

		plainFont = new FontUIResource(font);
		smallFont = new FontUIResource(font.deriveFont(0.8f*font.getSize2D()));
		boldFont = new FontUIResource(font.deriveFont(Font.BOLD));

		primary3 = new ColorUIResource(Color.getHSBColor((float)hue,(float)sat,.5f));
		primary2 =new ColorUIResource(Color.getHSBColor((float)hue,(float)sat,.3f));
		primary1 =new ColorUIResource(Color.getHSBColor((float)hue,(float)sat,.1f));

		secondary3 = new ColorUIResource(bg);
		secondary2 = new ColorUIResource(bg.darker());
		secondary1 = new ColorUIResource(bg.darker().darker());
		highlight = new ColorUIResource(bg.brighter());


		white=new ColorUIResource(Color.white.darker());
		red=new ColorUIResource(Color.red);
		blue=new ColorUIResource(Color.blue);
		green=new ColorUIResource(Color.green);
		yellow=new ColorUIResource(Color.yellow);
	}

	public void addCustomEntriesToTable(UIDefaults table)
	{
		table.put( "Button.font", boldFont);
		table.put( "Label.foreground", getWhite());
		table.put( "TextField.background", secondary2);
		table.put( "TextField.foreground", getWhite());
		table.put( "TitledBorder.font", boldFont);
		table.put( "List.background", getBlack());
		table.put( "List.foreground", getWhite());
		table.put( "List.font", plainFont);
  	}

	public ColorUIResource getWhite() { return white; }
	public ColorUIResource getPrimary1() { return primary1; }
	public ColorUIResource getPrimary2() { return primary2; }
	public ColorUIResource getPrimary3() { return primary3; }

	public ColorUIResource getSecondary1() { return secondary1; }
	public ColorUIResource getSecondary2() { return secondary2; }
	public ColorUIResource getSecondary3() { return secondary3; }

	public FontUIResource getControlTextFont() { return plainFont;}
	public FontUIResource getSystemTextFont() { return plainFont;}
	public FontUIResource getUserTextFont() { return plainFont;}
	public FontUIResource getMenuTextFont() { return plainFont;}
	public FontUIResource getWindowTitleFont() { return boldFont;}
	public FontUIResource getSubTextFont() { return smallFont;}

	public ColorUIResource getMenuForeground() { return getWhite(); }
	public ColorUIResource getMenuSelectedForeground() { return getWhite(); }

	// these are for tweaking

	public ColorUIResource getDesktopColor() { return getPrimary1(); }

	public ColorUIResource getControl() { return getSecondary3(); }
	public ColorUIResource getControlShadow() { return getSecondary2(); }
	public ColorUIResource getControlDarkShadow() { return getSecondary1(); }
	public ColorUIResource getControlInfo() { return getWhite(); }
	public ColorUIResource getControlHighlight() { return highlight; } // getWhite(); }
//	public ColorUIResource getControlDisabled() { return getSecondary2(); }

//	public ColorUIResource getPrimaryControl() { return getPrimary3(); }
//	public ColorUIResource getPrimaryControlShadow() { return getPrimary2(); }
//	public ColorUIResource getPrimaryControlDarkShadow() { return getPrimary1(); }
	public ColorUIResource getPrimaryControlInfo() { return primary2; } // getWhite(); }
	public ColorUIResource getPrimaryControlHighlight() { return primary3; } // getWhite(); }

	public ColorUIResource getSystemTextColor() { return getWhite(); }
//	public ColorUIResource getInactiveSystemTextColor() { return getSecondary2(); }

	public ColorUIResource getSeparatorBackground() { return highlight; } // getWhite(); }
	public ColorUIResource getSeparatorForeground() { return getSecondary2(); } // getPrimary1(); }
}