| Method from javax.swing.plaf.synth.SynthLookAndFeel Detail: |
public static ComponentUI createUI(JComponent c) {
String key = c.getUIClassID().intern();
if (key == "ButtonUI") {
return SynthButtonUI.createUI(c);
}
else if (key == "CheckBoxUI") {
return SynthCheckBoxUI.createUI(c);
}
else if (key == "CheckBoxMenuItemUI") {
return SynthCheckBoxMenuItemUI.createUI(c);
}
else if (key == "ColorChooserUI") {
return SynthColorChooserUI.createUI(c);
}
else if (key == "ComboBoxUI") {
return SynthComboBoxUI.createUI(c);
}
else if (key == "DesktopPaneUI") {
return SynthDesktopPaneUI.createUI(c);
}
else if (key == "DesktopIconUI") {
return SynthDesktopIconUI.createUI(c);
}
else if (key == "EditorPaneUI") {
return SynthEditorPaneUI.createUI(c);
}
else if (key == "FileChooserUI") {
return SynthFileChooserUI.createUI(c);
}
else if (key == "FormattedTextFieldUI") {
return SynthFormattedTextFieldUI.createUI(c);
}
else if (key == "InternalFrameUI") {
return SynthInternalFrameUI.createUI(c);
}
else if (key == "LabelUI") {
return SynthLabelUI.createUI(c);
}
else if (key == "ListUI") {
return SynthListUI.createUI(c);
}
else if (key == "MenuBarUI") {
return SynthMenuBarUI.createUI(c);
}
else if (key == "MenuUI") {
return SynthMenuUI.createUI(c);
}
else if (key == "MenuItemUI") {
return SynthMenuItemUI.createUI(c);
}
else if (key == "OptionPaneUI") {
return SynthOptionPaneUI.createUI(c);
}
else if (key == "PanelUI") {
return SynthPanelUI.createUI(c);
}
else if (key == "PasswordFieldUI") {
return SynthPasswordFieldUI.createUI(c);
}
else if (key == "PopupMenuSeparatorUI") {
return SynthSeparatorUI.createUI(c);
}
else if (key == "PopupMenuUI") {
return SynthPopupMenuUI.createUI(c);
}
else if (key == "ProgressBarUI") {
return SynthProgressBarUI.createUI(c);
}
else if (key == "RadioButtonUI") {
return SynthRadioButtonUI.createUI(c);
}
else if (key == "RadioButtonMenuItemUI") {
return SynthRadioButtonMenuItemUI.createUI(c);
}
else if (key == "RootPaneUI") {
return SynthRootPaneUI.createUI(c);
}
else if (key == "ScrollBarUI") {
return SynthScrollBarUI.createUI(c);
}
else if (key == "ScrollPaneUI") {
return SynthScrollPaneUI.createUI(c);
}
else if (key == "SeparatorUI") {
return SynthSeparatorUI.createUI(c);
}
else if (key == "SliderUI") {
return SynthSliderUI.createUI(c);
}
else if (key == "SpinnerUI") {
return SynthSpinnerUI.createUI(c);
}
else if (key == "SplitPaneUI") {
return SynthSplitPaneUI.createUI(c);
}
else if (key == "TabbedPaneUI") {
return SynthTabbedPaneUI.createUI(c);
}
else if (key == "TableUI") {
return SynthTableUI.createUI(c);
}
else if (key == "TableHeaderUI") {
return SynthTableHeaderUI.createUI(c);
}
else if (key == "TextAreaUI") {
return SynthTextAreaUI.createUI(c);
}
else if (key == "TextFieldUI") {
return SynthTextFieldUI.createUI(c);
}
else if (key == "TextPaneUI") {
return SynthTextPaneUI.createUI(c);
}
else if (key == "ToggleButtonUI") {
return SynthToggleButtonUI.createUI(c);
}
else if (key == "ToolBarSeparatorUI") {
return SynthSeparatorUI.createUI(c);
}
else if (key == "ToolBarUI") {
return SynthToolBarUI.createUI(c);
}
else if (key == "ToolTipUI") {
return SynthToolTipUI.createUI(c);
}
else if (key == "TreeUI") {
return SynthTreeUI.createUI(c);
}
else if (key == "ViewportUI") {
return SynthViewportUI.createUI(c);
}
return null;
}
Creates the Synth look and feel ComponentUI for
the passed in JComponent. |
static int getComponentState(Component c) {
if (c.isEnabled()) {
if (c.isFocusOwner()) {
return SynthUI.ENABLED | SynthUI.FOCUSED;
}
return SynthUI.ENABLED;
}
return SynthUI.DISABLED;
}
Returns the component state for the specified component. This should
only be used for Components that don't have any special state beyond
that of ENABLED, DISABLED or FOCUSED. For example, buttons shouldn't
call into this method. |
public UIDefaults getDefaults() {
UIDefaults table = new UIDefaults(60, 0.75f);
Region.registerUIs(table);
table.setDefaultLocale(Locale.getDefault());
table.addResourceBundle(
"com.sun.swing.internal.plaf.basic.resources.basic" );
table.addResourceBundle("com.sun.swing.internal.plaf.synth.resources.synth");
// SynthTabbedPaneUI supports rollover on tabs, GTK does not
table.put("TabbedPane.isTabRollover", Boolean.TRUE);
// These need to be defined for JColorChooser to work.
table.put("ColorChooser.swatchesRecentSwatchSize",
new Dimension(10, 10));
table.put("ColorChooser.swatchesDefaultRecentColor", Color.RED);
table.put("ColorChooser.swatchesSwatchSize", new Dimension(10, 10));
// These are needed for PopupMenu.
table.put("PopupMenu.selectedWindowInputMapBindings", new Object[] {
"ESCAPE", "cancel",
"DOWN", "selectNext",
"KP_DOWN", "selectNext",
"UP", "selectPrevious",
"KP_UP", "selectPrevious",
"LEFT", "selectParent",
"KP_LEFT", "selectParent",
"RIGHT", "selectChild",
"KP_RIGHT", "selectChild",
"ENTER", "return",
"SPACE", "return"
});
table.put("PopupMenu.selectedWindowInputMapBindings.RightToLeft",
new Object[] {
"LEFT", "selectChild",
"KP_LEFT", "selectChild",
"RIGHT", "selectParent",
"KP_RIGHT", "selectParent",
});
// enabled antialiasing depending on desktop settings
flushUnreferenced();
Object aaTextInfo = getAATextInfo();
table.put(SwingUtilities2.AA_TEXT_PROPERTY_KEY, aaTextInfo);
new AATextListener(this);
if (defaultsMap != null) {
table.putAll(defaultsMap);
}
return table;
}
Returns the defaults for this SynthLookAndFeel. |
public String getDescription() {
return "Synth look and feel";
}
Returns a textual description of SynthLookAndFeel. |
public String getID() {
return "Synth";
}
Return a string that identifies this look and feel. |
public String getName() {
return "Synth look and feel";
}
Return a short string that identifies this look and feel. |
static Insets getPaintingInsets(SynthContext state,
Insets insets) {
if (state.isSubregion()) {
insets = state.getStyle().getInsets(state, insets);
}
else {
insets = state.getComponent().getInsets(insets);
}
return insets;
}
A convenience method to return where the foreground should be
painted for the Component identified by the passed in
AbstractSynthContext. |
public static Region getRegion(JComponent c) {
return Region.getRegion(c);
}
Returns the Region for the JComponent c. |
public static SynthStyle getStyle(JComponent c,
Region region) {
return getStyleFactory().getStyle(c, region);
}
Gets a SynthStyle for the specified region of the specified component.
This is not for general consumption, only custom UIs should call this
method. |
public static SynthStyleFactory getStyleFactory() {
synchronized(SynthLookAndFeel.class) {
if (!multipleApps) {
return lastFactory;
}
AppContext context = AppContext.getAppContext();
if (lastContext == context) {
return lastFactory;
}
lastContext = context;
lastFactory = (SynthStyleFactory)AppContext.getAppContext().get
(STYLE_FACTORY_KEY);
return lastFactory;
}
}
Returns the current SynthStyleFactory. |
static Object getUIOfType(ComponentUI ui,
Class klass) {
if (klass.isInstance(ui)) {
return ui;
}
return null;
}
Returns the ui that is of type klass, or null if
one can not be found. |
public void initialize() {
super.initialize();
DefaultLookup.setDefaultLookup(new SynthDefaultLookup());
setStyleFactory(factory);
KeyboardFocusManager.getCurrentKeyboardFocusManager().
addPropertyChangeListener(_handler);
}
Called by UIManager when this look and feel is installed. |
static boolean isLeftToRight(Component c) {
return c.getComponentOrientation().isLeftToRight();
}
|
public boolean isNativeLookAndFeel() {
return false;
}
Returns false, SynthLookAndFeel is not a native look and feel. |
public boolean isSupportedLookAndFeel() {
return true;
}
Returns true, SynthLookAndFeel is always supported. |
public void load(URL url) throws IOException, ParseException {
if (url == null) {
throw new IllegalArgumentException(
"You must supply a valid Synth set URL");
}
if (defaultsMap == null) {
defaultsMap = new HashMap();
}
InputStream input = url.openStream();
new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,
url, null, defaultsMap);
}
Loads the set of SynthStyles that will be used by
this SynthLookAndFeel. Path based resources are resolved
relatively to the specified URL of the style. For example
an Image would be resolved by
new URL(synthFile, path). Refer to
Synth File Format for more
information. |
public void load(InputStream input,
Class resourceBase) throws ParseException {
if (resourceBase == null) {
throw new IllegalArgumentException(
"You must supply a valid resource base Class");
}
if (defaultsMap == null) {
defaultsMap = new HashMap();
}
new SynthParser().parse(input, (DefaultSynthStyleFactory) factory,
null, resourceBase, defaultsMap);
}
Loads the set of SynthStyles that will be used by
this SynthLookAndFeel. resourceBase is
used to resolve any path based resources, for example an
Image would be resolved by
resourceBase.getResource(path). Refer to
Synth File Format
for more information. |
static void resetSelectedUI() {
selectedUI = null;
}
Clears out the selected UI that was last set in setSelectedUI. |
static void setSelectedUI(ComponentUI uix,
boolean selected,
boolean focused,
boolean enabled,
boolean rollover) {
selectedUI = uix;
selectedUIState = 0;
if (selected) {
selectedUIState = SynthConstants.SELECTED;
if (focused) {
selectedUIState |= SynthConstants.FOCUSED;
}
}
else if (rollover && enabled) {
selectedUIState |=
SynthConstants.MOUSE_OVER | SynthConstants.ENABLED;
if (focused) {
selectedUIState |= SynthConstants.FOCUSED;
}
}
else {
selectedUIState = SynthConstants.FOCUSED;
if (enabled) {
selectedUIState |= SynthConstants.ENABLED;
}
else {
selectedUIState |= SynthConstants.DISABLED;
}
}
}
Used by the renderers. For the most part the renderers are implemented
as Labels, which is problematic in so far as they are never selected.
To accomodate this SynthLabelUI checks if the current
UI matches that of selectedUI (which this methods sets), if
it does, then a state as set by this method is returned. This provides
a way for labels to have a state other than selected. |
public static void setStyleFactory(SynthStyleFactory cache) {
// We assume the setter is called BEFORE the getter has been invoked
// for a particular AppContext.
synchronized(SynthLookAndFeel.class) {
AppContext context = AppContext.getAppContext();
if (!multipleApps && context != lastContext &&
lastContext != null) {
multipleApps = true;
}
lastFactory = cache;
lastContext = context;
context.put(STYLE_FACTORY_KEY, cache);
}
}
Sets the SynthStyleFactory that the UI classes provided by
synth will use to obtain a SynthStyle. |
static boolean shouldUpdateStyle(PropertyChangeEvent event) {
String eName = event.getPropertyName();
if ("name" == eName) {
// Always update on a name change
return true;
}
else if ("componentOrientation" == eName) {
// Always update on a component orientation change
return true;
}
else if ("ancestor" == eName && event.getNewValue() != null) {
// Only update on an ancestor change when getting a valid
// parent and the LookAndFeel wants this.
LookAndFeel laf = UIManager.getLookAndFeel();
return (laf instanceof SynthLookAndFeel &&
((SynthLookAndFeel)laf).
shouldUpdateStyleOnAncestorChanged());
}
return false;
}
Returns true if the Style should be updated in response to the
specified PropertyChangeEvent. This forwards to
shouldUpdateStyleOnAncestorChanged as necessary. |
public boolean shouldUpdateStyleOnAncestorChanged() {
return false;
}
Returns whether or not the UIs should update their
SynthStyles from the SynthStyleFactory
when the ancestor of the JComponent changes. A subclass
that provided a SynthStyleFactory that based the
return value from getStyle off the containment hierarchy
would override this method to return true. |
public void uninitialize() {
KeyboardFocusManager.getCurrentKeyboardFocusManager().
removePropertyChangeListener(_handler);
// We should uninstall the StyleFactory here, but unfortunately
// there are a handful of things that retain references to the
// LookAndFeel and expect things to work
super.uninitialize();
}
Called by UIManager when this look and feel is uninstalled. |
static void update(SynthContext state,
Graphics g) {
paintRegion(state, g, null);
}
A convenience method that handles painting of the background.
All SynthUI implementations should override update and invoke
this method. |
static SynthStyle updateStyle(SynthContext context,
SynthUI ui) {
SynthStyle newStyle = getStyle(context.getComponent(),
context.getRegion());
SynthStyle oldStyle = context.getStyle();
if (newStyle != oldStyle) {
if (oldStyle != null) {
oldStyle.uninstallDefaults(context);
}
context.setStyle(newStyle);
newStyle.installDefaults(context, ui);
}
return newStyle;
}
A convience method that will reset the Style of StyleContext if
necessary. |
public static void updateStyles(Component c) {
_updateStyles(c);
c.repaint();
}
Updates the style associated with c, and all its children.
This is a lighter version of
SwingUtilities.updateComponentTreeUI. |
static void updateSubregion(SynthContext state,
Graphics g,
Rectangle bounds) {
paintRegion(state, g, bounds);
}
A convenience method that handles painting of the background for
subregions. All SynthUI's that have subregions should invoke
this method, than paint the foreground. |