package usda.weru.weps;

import java.awt.Font;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.plaf.FontUIResource;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.MetalTheme;
import javax.swing.plaf.metal.OceanTheme;

/**
 *
 * @author Mark Haas <mark.haas@ars.usda.gov>
 */

//public class WepsTheme extends DefaultMetalTheme {
public class WepsTheme extends OceanTheme {
    
    FontUIResource wepsFontResource;
    FontUIResource wepsFontControlText;
    FontUIResource wepsFontMenuText;
    FontUIResource wepsFontSubText;
    FontUIResource wepsFontSystemText;
    FontUIResource wepsFontUserText;
    FontUIResource wepsFontWindowText;
    
    public WepsTheme () {
        wepsFontControlText = new FontUIResource("Lucida Sans", Font.BOLD, 12);
        wepsFontMenuText = new FontUIResource("Lucida Sans", Font.BOLD, 12);
        wepsFontSubText = new FontUIResource("Lucida Sans", Font.PLAIN, 10);
        wepsFontSystemText = new FontUIResource("Lucida Sans", Font.PLAIN, 12);
        wepsFontUserText = new FontUIResource("Lucida Sans", Font.PLAIN, 12);
        wepsFontWindowText = new FontUIResource("Lucida Sans", Font.BOLD, 12);
        
    }
    
    public void setThisTheme () throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {

//        printDefFontInfo("System font info");
        MetalLookAndFeel.setCurrentTheme (this);
        //String lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
        String lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";
        UIManager.setLookAndFeel(lookAndFeel);
//        printDefFontInfo("Weps font info");

        MetalTheme theme = MetalLookAndFeel.getCurrentTheme();

        if (theme != this) {
            System.err.println("WepsTheme NOT set.");
            throw new UnsupportedLookAndFeelException("WepsTheme NOT set.");
        }
    }
    
    protected void printDefFontInfo (String message) {
        MetalTheme theme = MetalLookAndFeel.getCurrentTheme();
        
        if (message != null) {
            System.err.println(message);
        }
        printFontInfo (theme.getControlTextFont(), "ControlTextFont" );
        printFontInfo (theme.getMenuTextFont(), "MenuTextFont" );
        printFontInfo (theme.getSubTextFont(), "SubTextFont" );
        printFontInfo (theme.getSystemTextFont(), "SystemTextFont" );
        printFontInfo (theme.getUserTextFont(), "UserTextFont" );
        printFontInfo (theme.getWindowTitleFont(), "WindowTitleTextFont" );
    }
    
    protected void printFontInfo (FontUIResource fontRes, String refStr) {
        System.err.println (refStr + "    font:" + fontRes.getFontName() + " size:" + fontRes.getSize());
    }
    
    
    @Override
    public String getName () {
        return "Weps Custom DefaultMetalTheme";
    }
    
    @Override
    public FontUIResource getControlTextFont() {
        return wepsFontControlText;
    }
    
    @Override
    public FontUIResource getMenuTextFont() {
        return wepsFontMenuText;
    }
    
    @Override
    public FontUIResource getSubTextFont() {
        return wepsFontSubText;
    }
    
    @Override
    public FontUIResource getSystemTextFont() {
        return wepsFontSystemText;
    }
    
    @Override
    public FontUIResource getUserTextFont() {
        return wepsFontUserText;
    }
    
    @Override
    public FontUIResource getWindowTitleFont() {
        return wepsFontWindowText;
    }
    
    
}
