- All Known Implementing Classes:
AbstractStyleDatabase
,AWTStyleDatabase
public interface StyleDatabase
CSS Style database.
To use CSS in practice, you need to have information about the target
rendering device: available fonts, page sizes, etc. This information is
supplied by an instance of the StyleDatabase
interface.
-
Method Summary
Modifier and TypeMethodDescriptionint
Gives the number of bits allocated to colors (excluding the alpha channel) in the output device.default String
Gets the real name of the default font.getDefaultGenericFontFamily
(String genericFamily) Gets the name of the default font used when a generic font family (serif, sans-serif, monospace, cursive, fantasy) is specified.float
Gets the height of the device, expressed in its natural unit.float
Gets the width of the device, expressed in its natural unit.default CSSValue
getEnvValue
(String envVarName) Get the value of the givenenv
variable.default float
getExSizeInPt
(String familyName, float size) Gives the size of the 'ex' unit, expressed in 'pt' (typographic points) unit.default float
getFontSizeFromIdentifier
(String familyName, String fontSizeIdentifier) Gets the font size from the given size identifier (small, medium, etc.), expressed in typographic points.Gives the initial (default) value for the 'color' property on this device.default short
Gets the identifier of the device's natural unit.default String
getSystemFontDeclaration
(String systemFontName) Gives the style declaration adequate to provide the given system font.getUsedFontFamily
(CSSComputedProperties computedStyle) Gets the used font family name according to the given style.default float
getWidthSize
(String widthIdentifier, float fontSize) Gets the size corresponding to the given identifier (thin, thick, medium), in typographic points.boolean
isFontFaceName
(String requestedFamily) IsrequestedFamily
an available font family loaded by a font face rule?void
Try to load the font family according to the given font face rule, and make it available to this object.void
setInitialColor
(String initialColor) Sets the initial (default) value for the 'color' property on this device.default boolean
supports
(SelectorList selectors) Does this agent support all of the given selectors?default boolean
Deprecated, for removal: This API element is subject to removal in a future version.default boolean
supports
(String property, LexicalUnit value) Does this medium support the given property-value pair?
-
Method Details
-
getInitialColor
CSSTypedValue getInitialColor()Gives the initial (default) value for the 'color' property on this device.- Returns:
- the default color value.
-
setInitialColor
Sets the initial (default) value for the 'color' property on this device.- Parameters:
initialColor
- the String representing default color value.
-
getDefaultGenericFontFamily
Gets the name of the default font used when a generic font family (serif, sans-serif, monospace, cursive, fantasy) is specified.- Parameters:
genericFamily
- the name of the logical font.- Returns:
- the name of the real font to which the generic name is mapped to, or null if none.
-
getDefaultGenericFontFamily
Gets the real name of the default font.For example, if the default generic font name is 'serif', this method should return the same as getDefaultGenericFontFamily("serif").
- Returns:
- the name of the default real font.
-
getUsedFontFamily
Gets the used font family name according to the given style.- Parameters:
computedStyle
- the computed style.- Returns:
- the name of the used font family.
-
getFontSizeFromIdentifier
default float getFontSizeFromIdentifier(String familyName, String fontSizeIdentifier) throws DOMException Gets the font size from the given size identifier (small, medium, etc.), expressed in typographic points.- Parameters:
familyName
- the font family name. Could be null.fontSizeIdentifier
- the font size identifier.- Returns:
- the font size.
- Throws:
DOMException
- if the identifier is unknown.
-
getSystemFontDeclaration
Gives the style declaration adequate to provide the given system font.- Parameters:
systemFontName
- the system font name.- Returns:
- the style declaration, or null if the system font name was not recognized.
-
isFontFaceName
IsrequestedFamily
an available font family loaded by a font face rule?- Parameters:
requestedFamily
- the font family name in lower case.- Returns:
true
if is an available font family,false
otherwise.
-
loadFontFaceRule
Try to load the font family according to the given font face rule, and make it available to this object.- Parameters:
rule
- the font face rule.
-
getNaturalUnit
default short getNaturalUnit()Gets the identifier of the device's natural unit.- Returns:
- the unit identifier as in
CSSUnit
.
-
getExSizeInPt
Gives the size of the 'ex' unit, expressed in 'pt' (typographic points) unit.Although this type of information really belongs to
CSSCanvas
, having even an approximate value here is helpful.- Parameters:
familyName
- the font family name.size
- the font size in 'pt' units.- Returns:
- the size of the 'ex' unit, in units of 'pt'.
-
getWidthSize
Gets the size corresponding to the given identifier (thin, thick, medium), in typographic points.- Parameters:
widthIdentifier
- the CSS width identifier.fontSize
- the font size used by the box, in typographic points.- Returns:
- the size.
- Throws:
DOMException
- if the identifier is unknown.
-
getColorDepth
int getColorDepth()Gives the number of bits allocated to colors (excluding the alpha channel) in the output device.If the device is not a color device, the value is zero.
From W3C's Screen interface.
- Returns:
- the number of bits allocated to colors, or zero if the output device does not support colors.
-
getDeviceHeight
float getDeviceHeight()Gets the height of the device, expressed in its natural unit.- Returns:
- the height of the rendering device.
-
getDeviceWidth
float getDeviceWidth()Gets the width of the device, expressed in its natural unit.- Returns:
- the width of the rendering device.
-
getEnvValue
Get the value of the givenenv
variable.- Parameters:
envVarName
- theenv
variable name.- Returns:
- the value, or
null
if that name has no value set.
-
supports
Does this agent support all of the given selectors?- Parameters:
selectors
- the selectors.- Returns:
true
if supported.
-
supports
Does this medium support the given property-value pair?- Parameters:
property
- the property name.value
- the optional property value to be tested against.- Returns:
true
if the property (with the given value, if any) is supported,false
otherwise.
-
supports
Deprecated, for removal: This API element is subject to removal in a future version.Does this medium support the given property-value pair?- Parameters:
property
- the property name.value
- the optional property value to be tested against.- Returns:
true
if the property (with the given value, if any) is supported,false
otherwise.
-
supports(String, LexicalUnit)
.