de.matthiasmann.twl.renderer
Class FontParameter

java.lang.Object
  extended by de.matthiasmann.twl.renderer.FontParameter

public final class FontParameter
extends java.lang.Object

An extensible typed map for font parameters.


Nested Class Summary
static class FontParameter.Parameter<T>
           
 
Field Summary
static FontParameter.Parameter<Color> COLOR
           
static FontParameter.Parameter<java.lang.Boolean> LINETHROUGH
           
static FontParameter.Parameter<java.lang.Boolean> UNDERLINE
           
 
Constructor Summary
FontParameter()
           
FontParameter(FontParameter base)
           
 
Method Summary
<T> T
get(FontParameter.Parameter<T> param)
          Returns the value of the specified parameter
static FontParameter.Parameter<?> getParameter(java.lang.String name)
          Returns the parameter instance for the given name
static FontParameter.Parameter[] getRegisteredParameter()
          Returns an array of all registered parameter
static
<T> FontParameter.Parameter<T>
newParameter(java.lang.String name, java.lang.Class<T> dataClass, T defaultValue)
          Registers a new parameter.
static
<T> FontParameter.Parameter<T>
newParameter(java.lang.String name, T defaultValue)
          Registers a new parameter.
<T> void
put(FontParameter.Parameter<T> param, T value)
          Sets a parameter value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLOR

public static final FontParameter.Parameter<Color> COLOR

UNDERLINE

public static final FontParameter.Parameter<java.lang.Boolean> UNDERLINE

LINETHROUGH

public static final FontParameter.Parameter<java.lang.Boolean> LINETHROUGH
Constructor Detail

FontParameter

public FontParameter()

FontParameter

public FontParameter(FontParameter base)
Method Detail

put

public <T> void put(FontParameter.Parameter<T> param,
                    T value)
Sets a parameter value

Type Parameters:
T - the type of the parameter
Parameters:
param - the parameter
value - the value or null to revert to it's default value

get

public <T> T get(FontParameter.Parameter<T> param)
Returns the value of the specified parameter

Type Parameters:
T - the type of the parameter
Parameters:
param - the parameter
Returns:
the parameter value or it's default value when the parameter was not set

getRegisteredParameter

public static FontParameter.Parameter[] getRegisteredParameter()
Returns an array of all registered parameter

Returns:
an array of all registered parameter

getParameter

public static FontParameter.Parameter<?> getParameter(java.lang.String name)
Returns the parameter instance for the given name

Parameters:
name - the name to look up
Returns:
the parameter instance or null when the name is not registered

newParameter

public static <T> FontParameter.Parameter<T> newParameter(java.lang.String name,
                                                          T defaultValue)
Registers a new parameter.

The data class is extracted from the default value.

If the name is already registered then the existing parameter is returned.

Type Parameters:
T - the data type of the parameter
Parameters:
name - the parameter name
defaultValue - the default value
Returns:
the parameter instance
Throws:
java.lang.NullPointerException - when one of the parameters is null
java.lang.IllegalStateException - when the name is already registered but with different dataClass or defaultValue

newParameter

public static <T> FontParameter.Parameter<T> newParameter(java.lang.String name,
                                                          java.lang.Class<T> dataClass,
                                                          T defaultValue)
Registers a new parameter.

If the name is already registered then the existing parameter is returned.

Type Parameters:
T - the data type of the parameter
Parameters:
name - the parameter name
dataClass - the data class
defaultValue - the default value - can be null.
Returns:
the parameter instance
Throws:
java.lang.NullPointerException - when name or dataClass is null
java.lang.IllegalStateException - when the name is already registered but with different dataClass or defaultValue