public abstract class Theme extends Object
A hash map returned by Theme#getThemeHash stores the theme
attributes. You can call
ResourceManager.getTheme(int) to obtain the
Theme instance based on the resource ID.
| 构造器 | 说明 |
|---|---|
Theme() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
abstract boolean |
getBooleanValue(String key,
boolean defValue) |
Obtains a boolean value of the attribute matching the
key in this Theme. |
abstract int |
getColorValue(String key) |
Obtains a color value of the attribute matching the
key in this Theme. |
abstract Theme |
getCombinedTheme(Theme child) |
Obtains a combined theme formed by this
Theme and another theme,
which will act as a child theme. |
abstract float |
getFloatValue(String key,
float defValue) |
Obtains a float value of the attribute matching the
key in this Theme. |
abstract int |
getIntegerValue(String key,
int defValue) |
Obtains an integer value of the attribute matching the
key in this Theme. |
abstract Resource |
getMediaValue(String key,
ResourceManager resManager) |
Obtains media resources matching the
key in this Theme. |
abstract Pattern |
getPatternValue(String key) |
|
abstract int |
getPixelValue(String key,
boolean truncate) |
Obtains the pixel value matching the
key in this Theme. |
abstract String |
getStringValue(String key) |
Obtains a string value of the attribute matching the
key in this Theme. |
abstract HashMap<String,TypedAttribute> |
getThemeHash() |
Obtains the hash map of this
Theme. |
abstract HashMap<String,TypedAttribute> |
getThemeHash(String[] selected) |
Obtains a hash map that contains selected attributes of this
Theme. |
abstract TypedAttribute |
getValue(String key) |
|
abstract void |
set(Theme theme) |
Sets this
Theme to hold all the attribute values of an existing Theme instance. |
abstract int |
size() |
Obtains the number of attributes in this
Theme. |
public abstract HashMap<String,TypedAttribute> getThemeHash()
Theme. The hash map stores the theme
attributes, containing theme names as keys and associated
TypedAttribute as values.Theme.public abstract Theme getCombinedTheme(Theme child)
Theme and another theme,
which will act as a child theme.
The attributes of the child theme will overwrite those of this Theme.
child - Indicates the child theme.public abstract void set(Theme theme)
Theme to hold all the attribute values of an existing Theme instance.theme - Indicates the Theme instance whose attribute values are to be assigned to this
Theme.public abstract HashMap<String,TypedAttribute> getThemeHash(String[] selected)
Theme.selected - Indicates the set of selected attribute names.Theme.public abstract String getStringValue(String key) throws IOException, NotExistException, WrongTypeException
key in this Theme.key - Indicates the key in the theme.key.NotExistException - Throws this exception if the key is not found, or the obtained value is null or
another invalid value.IOException - Throws this exception if an I/O error occurs.WrongTypeException - Throws this exception if the attribute value matching the key is not a string
value.public abstract boolean getBooleanValue(String key, boolean defValue) throws IOException, NotExistException, WrongTypeException
key in this Theme.key - Indicates the key in the theme.defValue - Indicates the default value.key if obtained; returns the default value if the
key is not found.NotExistException - Throws this exception if the obtained value is null or another invalid value.IOException - Throws this exception if an I/O error occurs.WrongTypeException - Throws this exception if the attribute value matching the key is not a boolean
value.public abstract int getColorValue(String key) throws IOException, NotExistException, WrongTypeException
key in this Theme.key - Indicates the key in the theme.key.NotExistException - Throws this exception if the key is not found, or the obtained value is null or
another invalid value.IOException - Throws this exception if an I/O error occurs.WrongTypeException - Throws this exception if the attribute value matching the key is not a color
value.public abstract int getIntegerValue(String key, int defValue) throws IOException, NotExistException, WrongTypeException
key in this Theme.key - Indicates the key in the theme.defValue - Indicates the default value.key if obtained; returns the default value if the
key is not found.NotExistException - Throws this exception if the obtained value is null or another invalid value.IOException - Throws this exception if an I/O error occurs.WrongTypeException - Throws this exception if the attribute value matching the key is not an
integer value.public abstract float getFloatValue(String key, float defValue) throws IOException, NotExistException, WrongTypeException
key in this Theme.key - Indicates the key in the theme.defValue - Indicates the default value.key if obtained; returns the default value if the
key is not found.NotExistException - Throws this exception if the obtained value is null or another invalid value.IOException - Throws this exception if an I/O error occurs.WrongTypeException - Throws this exception if the attribute value matching the key is not a float
value.public abstract int getPixelValue(String key, boolean truncate) throws IOException, NotExistException, WrongTypeException
key in this Theme. This method is equivalent to
getFloatValue(java.lang.String,float) except that its return value is an integer rounded from the original value.key - Indicates the key in the theme.truncate - Specifies whether the returned result is truncated. The value true indicates that the
decimal part of the float value is truncated, and false indicates that the float value is rounded off.key.NotExistException - Throws this exception if the key is not found, or the obtained value is null or
another invalid value.IOException - Throws this exception if an I/O error occurs.WrongTypeException - Throws this exception if the attribute value matching the key is not a pixel
value.public abstract Resource getMediaValue(String key, ResourceManager resManager) throws IOException, NotExistException, WrongTypeException
key in this Theme.key - Indicates the key in the theme.resManager - Indicates the ResourceManager instance used to obtain the media resource stream.key.NotExistException - Throws this exception if the key is not found, or the obtained value is null or
another invalid value.IOException - Throws this exception if an I/O error occurs.WrongTypeException - Throws this exception if the key does not match any media resources.public abstract TypedAttribute getValue(String key) throws NotExistException
key - Indicates the key in the theme.TypedAttribute instance.NotExistException - Throws this exception if the key is not found.public abstract int size()
Theme.public abstract Pattern getPatternValue(String key) throws IOException, NotExistException, WrongTypeException
key - Indicates the key in the theme.Pattern instance.NotExistException - Throws this exception if the key is not found, or the obtained value is null or
another invalid value.IOException - Throws this exception if an I/O error occurs.WrongTypeException - Throws this exception if the key does not match any
Pattern instance.