bibliothek.gui
Class DockUI

java.lang.Object
  extended by bibliothek.gui.DockUI

public class DockUI
extends Object

A list of icons, text and methods used by the framework.

Author:
Benjamin Sigg

Field Summary
static String OVERFLOW_MENU_ICON
          Key for an Icon stored in the IconManager for the action-overflow-menu.
 
Constructor Summary
protected DockUI()
          Creates a new DockUI
 
Method Summary
 void addLookAndFeelColorsListener(LookAndFeelColorsListener listener)
          Adds a listener which gets informed when a color of the current LookAndFeelColors changes.
static Color getColor(String key)
          Gets the color key where key is one of the keys specified in LookAndFeelColors.
 LookAndFeelColors getColors()
          Gets the current source of colors that depend on the LookAndFeel.
static DockUI getDefaultDockUI()
          Gets the default instance of DockUI.
 ThemeFactory getDefaultTheme()
          Gets the default-theme to be used by all DockControllers when nothing else is specified.
static JDesktopPane getDesktopPane(Component component)
          Searches the first JDesktopPane which either is component or a parent of component.
 ThemeFactory[] getThemes()
          Gets the list of all available themes.
static boolean isOverlapping(Component above, Component under)
          Tells whether above overlaps under.
 boolean isSecureEnvironment()
          Tells whether this application runs in a restricted environment or not.
 void registerColors(String lookAndFeelClassNameRegex, LookAndFeelColors colors)
          Registeres a new LookAndFeelColors.
<T extends DockTheme>
void
registerTheme(Class<T> theme)
          Registers a factory for theme.
 void registerTheme(ThemeFactory factory)
          Stores a new theme.
 void removeLookAndFeelColorsListener(LookAndFeelColorsListener listener)
          Removes a listener from this DockUI.
protected  LookAndFeelColors selectBestMatchingColors()
          Gets the LookAndFeelColors which matches the current LookAndFeel best.
 void setSecureEnvironment(boolean secureEnvironment)
          Overrides the result of isSecureEnvironment(), any future call of that method will return secureEnvironment.
 void unregisterTheme(ThemeFactory factory)
          Removes an earlier added factory from the set of theme-factories.
protected  void updateLookAndFeelColors()
          Updates the currently used LookAndFeelColors to the best matching colors.
static
<D extends DockStation,L>
void
updateTheme(D station, DockFactory<D,?,L> factory)
          Removes all children of station and then adds the children again.
protected  void updateUI()
          Called when the LookAndFeel changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OVERFLOW_MENU_ICON

public static final String OVERFLOW_MENU_ICON
Key for an Icon stored in the IconManager for the action-overflow-menu. This menu is shown if there are too many DockActions to show.

See Also:
Constant Field Values
Constructor Detail

DockUI

protected DockUI()
Creates a new DockUI

Method Detail

getDefaultDockUI

public static DockUI getDefaultDockUI()
Gets the default instance of DockUI.

Returns:
the instance

updateUI

protected void updateUI()
Called when the LookAndFeel changed.


getDefaultTheme

public ThemeFactory getDefaultTheme()
Gets the default-theme to be used by all DockControllers when nothing else is specified.

Returns:
the default-theme

getThemes

public ThemeFactory[] getThemes()
Gets the list of all available themes.

Returns:
the themes

registerTheme

public <T extends DockTheme> void registerTheme(Class<T> theme)
Registers a factory for theme.

Type Parameters:
T - the type of the DockTheme.
Parameters:
theme - A class which must have the annotation ThemeProperties

registerTheme

public void registerTheme(ThemeFactory factory)
Stores a new theme.

Parameters:
factory - the new theme

unregisterTheme

public void unregisterTheme(ThemeFactory factory)
Removes an earlier added factory from the set of theme-factories.

Parameters:
factory - the factory to remove

registerColors

public void registerColors(String lookAndFeelClassNameRegex,
                           LookAndFeelColors colors)
Registeres a new LookAndFeelColors. The lookAndFeelClassNameRegex is a regular expression. If a LookAndFeel is active whose class name matches lookAndFeelClassNameRegex, then colors becomes the selected source for colors. If more then one regex matches, the last one that was added to this DockUI is taken. So generally one would first add the most general regexes, and the more detailed ones later.

Parameters:
lookAndFeelClassNameRegex - a description of a class name
colors - the new set of colors

addLookAndFeelColorsListener

public void addLookAndFeelColorsListener(LookAndFeelColorsListener listener)
Adds a listener which gets informed when a color of the current LookAndFeelColors changes. This listener gets not informed about any changes when the LookAndFeel itself gets replaced. This listener will automatically be transfered when another LookAndFeelColors gets selected.

Parameters:
listener - the new listener, not null

removeLookAndFeelColorsListener

public void removeLookAndFeelColorsListener(LookAndFeelColorsListener listener)
Removes a listener from this DockUI.

Parameters:
listener - the listener to remove

updateLookAndFeelColors

protected void updateLookAndFeelColors()
Updates the currently used LookAndFeelColors to the best matching colors.


selectBestMatchingColors

protected LookAndFeelColors selectBestMatchingColors()
Gets the LookAndFeelColors which matches the current LookAndFeel best.

Returns:
the current set of colors

getColors

public LookAndFeelColors getColors()
Gets the current source of colors that depend on the LookAndFeel.

Returns:
the current source of colors

getColor

public static Color getColor(String key)
Gets the color key where key is one of the keys specified in LookAndFeelColors.

Parameters:
key - the name of the color
Returns:
the color or null

updateTheme

public static <D extends DockStation,L> void updateTheme(D station,
                                                         DockFactory<D,?,L> factory)
                        throws IOException
Removes all children of station and then adds the children again. Reading the children ensures that all components are build up again with the current theme of the station

Type Parameters:
D - the type of the station
L - the type of the layout needed to describe the contents of the station
Parameters:
station - the station to update
factory - a factory used to remove and to add the elements
Throws:
IOException - if the factory throws an exception

getDesktopPane

public static JDesktopPane getDesktopPane(Component component)
Searches the first JDesktopPane which either is component or a parent of component.

Parameters:
component - the component whose parent is searched
Returns:
the parent JDesktopPane or null if not found

isOverlapping

public static boolean isOverlapping(Component above,
                                    Component under)
Tells whether above overlaps under. This method assumes that both components have a mutual parent. The method checks the location and the z-order of both components.

Parameters:
above - the component that is supposed to be above under
under - the component that is supposed to be under above
Returns:
true is above is overlapping under

isSecureEnvironment

public boolean isSecureEnvironment()
Tells whether this application runs in a restricted environment or not. This method only makes a guess and may return a false result.

Returns:
whether this is a restricted environment

setSecureEnvironment

public void setSecureEnvironment(boolean secureEnvironment)
Overrides the result of isSecureEnvironment(), any future call of that method will return secureEnvironment.

Parameters:
secureEnvironment - Whether global AWTEventListeners are allowed or not, a value of true indicates that listeners are not allowed