📄 compiereplaf.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.plaf;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.util.*;
import javax.swing.*;
import javax.swing.plaf.*;
import javax.swing.plaf.metal.*;
import java.lang.reflect.*;
import org.compiere.util.Ini;
import org.compiere.util.ValueNamePair;
import org.compiere.swing.*;
/**
* Variable Pluggable Look And Feel.
* Provides an easy access to the required currently active PLAF information
*
* @author Jorg Janke
* @version $Id: CompierePLAF.java,v 1.30 2002/09/01 22:34:37 jjanke Exp $
*/
public final class CompierePLAF
{
/** Version tag */
public static final String VERSION = "R1.2.0";
/** Key of Client Property to paint in CompiereColor */
public static final String BACKGROUND = "CompiereBackground";
/** Key of Client Property for Rectangle Items - if exists, the standard background is used */
public static final String BACKGROUND_FILL = "CompiereBackgroundFill";
/** Key of Client Property for CPanel */
public static final String TABLEVEL = "CompiereTabLevel";
/****** Background *******************************************************/
/**
* Return Normal field background color "text".
* Windows = white
* @return Color
*/
public static Color getFieldBackground_Normal()
{
// window => white
return ColorBlind.getDichromatColor(UIManager.getColor("text"));
} // getFieldBackground_Normal
/**
* Return Error field background (CompiereTheme)
* @return Color
*/
public static Color getFieldBackground_Error()
{
return ColorBlind.getDichromatColor(CompiereTheme.error);
} // getFieldBackground_Error
/**
* Return Mandatory field background color (CompiereTheme)
* @return Color
*/
public static Color getFieldBackground_Mandatory()
{
return ColorBlind.getDichromatColor(CompiereTheme.mandatory);
} // getFieldBackground_Mandatory
/**
* Return Inactive field background color (CompiereTheme)
* @return Color
*/
public static Color getFieldBackground_Inactive()
{
return ColorBlind.getDichromatColor(CompiereTheme.inactive);
} // getFieldBackground_Inactive
/**
* Return form background color "control".
* Windows = lightGray
* @return Color
*/
public static Color getFormBackground()
{
return ColorBlind.getDichromatColor(UIManager.getColor("control"));
} // getFormBackground
/**
* Info Background Color "info"
* Windows = info (light yellow)
* @return Color
*/
public static Color getInfoBackground()
{
return ColorBlind.getDichromatColor(CompiereTheme.info);
} // getInfoBackground
/****** Text *************************************************************/
/**
* Normal field text foreground color "textText"
* Windows = black
* @return Color
*/
public static Color getTextColor_Normal()
{
return ColorBlind.getDichromatColor(UIManager.getColor("textText"));
} // getText_Normal
/**
* OK Text Foreground Color (Theme)
* @return Color
*/
public static Color getTextColor_OK()
{
return ColorBlind.getDichromatColor(CompiereTheme.txt_ok);
} // getText_OK
/**
* Issue Text Foreground Color (Theme)
* @return Color
*/
public static Color getTextColor_Issue()
{
return ColorBlind.getDichromatColor(CompiereTheme.txt_error);
} // getText_Issue
/**
* Label Text foreground Color "controlText"
* Windows = black
* @return Color
*/
public static Color getTextColor_Label()
{
return ColorBlind.getDichromatColor(UIManager.getColor("controlText"));
} // getTextColor_Label
public static Color getPrimary1()
{
return ColorBlind.getDichromatColor(CompiereTheme.primary1);
}
public static Color getPrimary2()
{
return ColorBlind.getDichromatColor(CompiereTheme.primary2);
}
public static Color getPrimary3()
{
return ColorBlind.getDichromatColor(CompiereTheme.primary3);
}
public static Color getSecondary1()
{
return ColorBlind.getDichromatColor(CompiereTheme.secondary1);
}
public static Color getSecondary2()
{
return ColorBlind.getDichromatColor(CompiereTheme.secondary2);
}
public static Color getSecondary3()
{
return ColorBlind.getDichromatColor(CompiereTheme.secondary3);
}
/****** Fonts ************************************************************/
/**
* Get Header Font (window/label font)
* @return font
*/
public static Font getFont_Header()
{
return CompiereTheme.windowFont;
// return UIManager.getFont("Label.font");
} // getFont_Header
/**
* Get Field Font
* @return font
*/
public static Font getFont_Field()
{
return CompiereTheme.userFont;
// return UIManager.getFont("TextField.font");
} // getFont_Field
/**
* Get Label Font
* @return font
*/
public static Font getFont_Label()
{
return CompiereTheme.controlFont;
// return UIManager.getFont("Label.font");
} // setFont_Label
/**
* Get Small (report) Font
* @return font
*/
public static Font getFont_Small()
{
return CompiereTheme.smallFont;
} // setFont_Small
/****** Available L&F ****************************************************/
/** Default PLAF Name */
public static final String DEFAULT_PLAF = CompiereLookAndFeel.NAME;
/** Default Theme Name */
public static final String DEFAULT_THEME = "";
/** Availablle Looks */
private static ValueNamePair[] s_looks = null;
/** Default PLAF */
private static ValueNamePair s_defaultPLAF = null;
/** Availablle Themes */
private static ValueNamePair[] s_themes = null;
private static ValueNamePair s_vp_compiereTheme = null;
private static ValueNamePair s_vp_metalTheme = null;
private static ValueNamePair s_vp_kunststoffTheme = null;
/** PLAF class list
com.sun.java.swing.plaf.windows.WindowsLookAndFeel
com.sun.java.swing.plaf.motif.MotifLookAndFeel
javax.swing.plaf.metal.MetalLookAndFeel
/**
* Static Initializer.
* - Fill available PLAFs and Themes
*/
static
{
ArrayList plafList = new ArrayList();
ValueNamePair vp = new ValueNamePair("org.compiere.plaf.CompiereLookAndFeel", CompiereLookAndFeel.NAME);
plafList.add (vp);
// Themes
ArrayList themeList = new ArrayList();
vp = new ValueNamePair("org.compiere.plaf.CompiereTheme", CompiereTheme.NAME);
themeList.add (vp);
s_vp_compiereTheme = vp;
vp = new ValueNamePair("javax.swing.plaf.metal.DefaultMetalTheme", "Steel");
s_vp_metalTheme = vp;
themeList.add (vp);
// Discover and Install - Kuststoff
try
{
Class c = Class.forName("com.incors.plaf.kunststoff.KunststoffLookAndFeel");
vp = new ValueNamePair("com.incors.plaf.kunststoff.KunststoffLookAndFeel", "Kunststoff");
plafList.add(vp);
vp = new ValueNamePair("com.incors.plaf.kunststoff.KunststoffTheme", "Kuststoff");
themeList.add(vp);
s_vp_kunststoffTheme = vp;
}
catch (Exception e)
{
// System.err.println("CompierePLAF - Kuststoff not found");
}
/** // Discover and Install - jGoodies
try
{
Class c = Class.forName("com.jgoodies.plaf.metal.ExtMetalLookAndFeel");
com.jgoodies.plaf.metal.ExtMetalLookAndFeel jGoodies = (com.jgoodies.plaf.metal.ExtMetalLookAndFeel)c.newInstance();
vp = new ValueNamePair("com.jgoodies.plaf.metal.ExtMetalLookAndFeel", "Extended Metal");
// System.out.println("Added PLAF: " + vp.toStringX());
plafList.add(vp);
vp = new ValueNamePair("com.jgoodies.plaf.metal.dimension3.ExtMetalLookAndFeel3D", "Extended Metal 3D");
// System.out.println("Added PLAF: " + vp.toStringX());
plafList.add(vp);
vp = new ValueNamePair("com.jgoodies.plaf.windows.ExtWindowsLookAndFeel", "Extended Windows");
// System.out.println("Added PLAF: " + vp.toStringX());
plafList.add(vp);
// jGoodies Looks
java.util.List thList = jGoodies.getInstalledThemes();
Iterator it = thList.iterator();
while (it.hasNext())
{
MetalTheme theme = (MetalTheme)it.next();
vp = new ValueNamePair(theme.getClass().getName(), theme.getName());
// System.out.println("Added jGoodies Theme: " + vp.toStringX());
themeList.add(vp);
}
}
catch (Exception e)
{
// System.err.println("CompierePLAF - jGoodies not found");
}
**/
// Install discovered PLAFs
for (int i = 0; i < plafList.size(); i++)
{
vp = (ValueNamePair)plafList.get(i);
UIManager.installLookAndFeel(vp.getName(), vp.getValue());
}
// Fill Available PLAFs
plafList = new ArrayList();
UIManager.LookAndFeelInfo[] lfInfo = UIManager.getInstalledLookAndFeels();
for (int i = 0; i < lfInfo.length; i++)
{
vp = new ValueNamePair (lfInfo[i].getClassName(), lfInfo[i].getName());
plafList.add(vp);
if (lfInfo[i].getName().equals(DEFAULT_PLAF))
s_defaultPLAF = vp;
}
s_looks = new ValueNamePair[plafList.size()];
plafList.toArray(s_looks);
// Fill Available Themes
s_themes = new ValueNamePair[themeList.size()];
themeList.toArray(s_themes);
//
// printPLAFDefaults();
} // static Initializer
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -