java.lang.Object
org.proto4j.swing.core.GlobalDesc
public final class GlobalDesc
extends java.lang.Object
This class wraps general and utility methods on providing the option
namespace. At initialization this manager will look up the /META-INF/options
directory in order to retrieve all defined options.
- Since:
- 1.0
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DESC_PATH_PROPERTY
static java.lang.String
OPTIONS_PREFIX
The standard directory name for the defined options. -
Constructor Summary
Constructors Constructor Description GlobalDesc()
-
Method Summary
Modifier and Type Method Description static void
ensureOptionsInitialized()
static java.awt.Color
getColor(java.lang.String value)
Tries to locate the given color name.static LayoutDesc
getLayoutDesc(java.lang.Class<?> cls, ComponentDesc parent)
Resolves the givenLayoutManager
class to the relatedLayoutDesc
type.static LayoutDesc
getLayoutDesc(java.lang.Class<?> cls, ComponentDesc parent, java.lang.String... packageNames)
Resolves the givenLayoutManager
class to the relatedLayoutDesc
type.static MarginDesc
getMarginDesc(java.lang.Class<?> cls)
Resolves the givenBorder
class to the relatedMarginDesc
type.static MarginDesc
getMarginDesc(java.lang.Class<?> cls, java.lang.String... packageNames)
Resolves the givenBorder
class to the relatedMarginDesc
type.static java.util.Properties
getSharedOption(java.lang.Class<?> cls)
Tries to locate all options defined for the given class.static java.util.Properties
getSharedOption(java.lang.String className)
Tries to locate all options defined for the given class name.
-
Field Details
-
OPTIONS_PREFIX
public static final java.lang.String OPTIONS_PREFIXThe standard directory name for the defined options.- See Also:
- Constant Field Values
-
DESC_PATH_PROPERTY
public static final java.lang.String DESC_PATH_PROPERTY- See Also:
- Constant Field Values
-
-
Constructor Details
-
GlobalDesc
public GlobalDesc()
-
-
Method Details
-
getSharedOption
public static java.util.Properties getSharedOption(java.lang.Class<?> cls) throws java.lang.NullPointerExceptionTries to locate all options defined for the given class.- Parameters:
cls
- the given class- Returns:
null
if no options are registered to that class name; aProperties
instance otherwise.- Throws:
java.lang.NullPointerException
- the given class isnull
-
getSharedOption
public static java.util.Properties getSharedOption(java.lang.String className) throws java.lang.NullPointerExceptionTries to locate all options defined for the given class name.- Parameters:
className
- the class name the options are mapped to- Returns:
null
if no options are registered to that class name; aProperties
instance otherwise.- Throws:
java.lang.NullPointerException
- the given name isnull
-
getMarginDesc
public static MarginDesc getMarginDesc(java.lang.Class<?> cls) throws java.lang.NullPointerExceptionResolves the givenBorder
class to the relatedMarginDesc
type. This method uses theClass.forName(String)
method to retrieve the class instance for theMarginDesc
.- Parameters:
cls
- the border type- Returns:
- a new instance of the qualified
MarginDesc
- Throws:
java.lang.NullPointerException
- if the border type wasnull
-
getMarginDesc
public static MarginDesc getMarginDesc(java.lang.Class<?> cls, java.lang.String... packageNames) throws java.lang.NullPointerExceptionResolves the givenBorder
class to the relatedMarginDesc
type. This method uses theClass.forName(String)
method to retrieve the class instance for theMarginDesc
.- Parameters:
cls
- the border typepackageNames
- the root packages where the corresponding Desc-class are located- Returns:
- a new instance of the qualified
MarginDesc
- Throws:
java.lang.NullPointerException
- if the border type wasnull
-
getLayoutDesc
public static LayoutDesc getLayoutDesc(java.lang.Class<?> cls, ComponentDesc parent) throws java.lang.NullPointerExceptionResolves the givenLayoutManager
class to the relatedLayoutDesc
type. This method uses theClass.forName(String)
method to retrieve the class instance for theLayoutDesc
.- Parameters:
cls
- the layout manager type- Returns:
- a new instance of the qualified
LayoutDesc
- Throws:
java.lang.NullPointerException
- if the layout manager type wasnull
-
getLayoutDesc
public static LayoutDesc getLayoutDesc(java.lang.Class<?> cls, ComponentDesc parent, java.lang.String... packageNames) throws java.lang.NullPointerExceptionResolves the givenLayoutManager
class to the relatedLayoutDesc
type. This method uses theClass.forName(String)
method to retrieve the class instance for theLayoutDesc
.- Parameters:
cls
- the layout manager typeparent
- the component descriptionpackageNames
- the root packages where the corresponding Desc-class are located- Returns:
- a new instance of the qualified
LayoutDesc
- Throws:
java.lang.NullPointerException
- if the layout manager type wasnull
-
getColor
public static java.awt.Color getColor(java.lang.String value)Tries to locate the given color name.RGB values can be represented through three numbers separated by a
,
. It is also possible to query a color that has been added to theUIDefaults
of the currentLookAndFeel
. To do that, just put theOption.Query.indicator
in font of the color's name.- Parameters:
value
- the color's name- Returns:
- a new
Color
object representing the color
-
ensureOptionsInitialized
public static void ensureOptionsInitialized()
-