Top Description Fields Constructors Methods
javafx.css

public Class Stylesheet

extends Object
Class Inheritance
Imports
javafx.css.StyleConverter.StringStore, javafx.collections.ListChangeListener.Change, .ObservableList, com.sun.javafx.collections.TrackableObservableList, com.sun.javafx.css.FontFaceImpl, .RuleHelper, java.io.BufferedInputStream, .ByteArrayOutputStream, .DataInputStream, .DataOutputStream, .File, .FileNotFoundException, .FileOutputStream, .IOException, .InputStream, java.net.URI, .URL, java.util.ArrayList, .List

A stylesheet which can apply properties to a tree of objects. A stylesheet is a collection of zero or more Rules, each of which is applied to each object in the tree. Typically the selector will examine the object to determine whether or not it is applicable, and if so it will apply certain property values to the object.
Since
9

Field Summary

Modifier and TypeField and Description
pack-priv static final int
BINARY_CSS_VERSION

Version number of binary CSS format.

private final List<FontFace>
fontFaces

List of all font faces

private StyleOrigin
origin

Specifies the origin of this Stylesheet.

private final ObservableList<Rule>
rules

All the rules contained in the stylesheet in the order they are in the file

private String[]
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
Stylesheet()

Constructs a stylesheet with the base URI defaulting to the root path of the application.

pack-priv
Stylesheet(String
the base URI for this stylesheet
url
)

Constructs a Stylesheet using the given URL as the base URI.

Method Summary

Modifier and TypeMethod and Description
public static void
convertToBinary(File
the JavaFX compliant css file to convert
source
,
File
the file to which the binary formatted data is written
destination
)

Converts the css file referenced by source to binary format and writes it to destination.

public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether this Stylesheet is "equal to" some other object.

public List<FontFace>

Returns:

a list of font faces used by this Stylesheet
getFontFaces
()

Returns the font faces used by this Stylesheet.

public StyleOrigin

Returns:

the origin of this Stylesheet
getOrigin
()

Returns the origin of this Stylesheet.

public List<Rule>

Returns:

a list of rules used by this Stylesheet
getRules
()

Returns the rules that are defined in this Stylesheet.

pack-priv final String[]
public String

Returns:

A String representation of the URL from which the stylesheet was loaded, or null if the stylesheet was created from an inline style.
getUrl
()

The URL from which this Stylesheet was loaded.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv void
importStylesheet(Stylesheet importedStylesheet)

public static Stylesheet

Returns:

the loaded Stylesheet
loadBinary
(URL
the URL from which the Stylesheet will be loaded
url
)

Loads a binary stylesheet from a URL.

public static Stylesheet

Returns:

the loaded Stylesheet
loadBinary
(InputStream
the input stream
stream
)

Loads a binary stylesheet from a stream.

private static Stylesheet
pack-priv final void
readBinary(int bssVersion, DataInputStream is, String[] strings)

public void
setOrigin(StyleOrigin
the origin of this Stylesheet
origin
)

Sets the origin of this Stylesheet.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of this object.

pack-priv final void
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

BINARY_CSS_VERSIONback to summary
pack-priv static final int BINARY_CSS_VERSION

Version number of binary CSS format. The value is incremented whenever the format of the binary stream changes. This number does not correlate with JavaFX versions. Version 5: persist @font-face Version 6: converter classes moved to public package Version 7: media queries

fontFacesback to summary
private final List<FontFace> fontFaces

List of all font faces

originback to summary
private StyleOrigin origin

Specifies the origin of this Stylesheet. We need to know this so that we can make user important styles have higher priority than author styles.

rulesback to summary
private final ObservableList<Rule> rules

All the rules contained in the stylesheet in the order they are in the file

stringStoreback to summary
private String[] stringStore
urlback to summary
private final String url

Constructor Detail

Stylesheetback to summary
pack-priv Stylesheet()

Constructs a stylesheet with the base URI defaulting to the root path of the application.

Stylesheetback to summary
pack-priv Stylesheet(String url)

Constructs a Stylesheet using the given URL as the base URI. The parameter may not be null.

Parameters
url:String

the base URI for this stylesheet

Method Detail

convertToBinaryback to summary
public static void convertToBinary(File source, File destination) throws IOException

Converts the css file referenced by source to binary format and writes it to destination.

Parameters
source:File

the JavaFX compliant css file to convert

destination:File

the file to which the binary formatted data is written

Exceptions
IOException:
if the destination file can not be created or if an I/O error occurs
IllegalArgumentException:
if either parameter is null, if source and destination are the same, if source cannot be read, or if destination cannot be written
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether this Stylesheet is "equal to" some other object. Equality of two Stylesheets is based on the equality of their URL as defined by getUrl().

Annotations
@Override
getFontFacesback to summary
public List<FontFace> getFontFaces()

Returns the font faces used by this Stylesheet.

Returns:List<FontFace>

a list of font faces used by this Stylesheet

getOriginback to summary
public StyleOrigin getOrigin()

Returns the origin of this Stylesheet.

Returns:StyleOrigin

the origin of this Stylesheet

getRulesback to summary
public List<Rule> getRules()

Returns the rules that are defined in this Stylesheet.

Returns:List<Rule>

a list of rules used by this Stylesheet

getStringStoreback to summary
pack-priv final String[] getStringStore()
getUrlback to summary
public String getUrl()

The URL from which this Stylesheet was loaded.

Returns:String

A String representation of the URL from which the stylesheet was loaded, or null if the stylesheet was created from an inline style.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
importStylesheetback to summary
pack-priv void importStylesheet(Stylesheet importedStylesheet)
loadBinaryback to summary
public static Stylesheet loadBinary(URL url) throws IOException

Loads a binary stylesheet from a URL.

Parameters
url:URL

the URL from which the Stylesheet will be loaded

Returns:Stylesheet

the loaded Stylesheet

Exceptions
IOException:
if the binary stream corresponds to a more recent binary css version or if an I/O error occurs while reading from the stream
loadBinaryback to summary
public static Stylesheet loadBinary(InputStream stream) throws IOException

Loads a binary stylesheet from a stream.

Parameters
stream:InputStream

the input stream

Returns:Stylesheet

the loaded Stylesheet

Exceptions
IOException:
if the binary stream corresponds to a more recent binary css version or if an I/O error occurs while reading from the stream
Since
17
loadBinaryback to summary
private static Stylesheet loadBinary(InputStream stream, String uri) throws IOException
readBinaryback to summary
pack-priv final void readBinary(int bssVersion, DataInputStream is, String[] strings) throws IOException
setOriginback to summary
public void setOrigin(StyleOrigin origin)

Sets the origin of this Stylesheet.

Parameters
origin:StyleOrigin

the origin of this Stylesheet

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this object.

Annotations
@Override
writeBinaryback to summary
pack-priv final void writeBinary(final DataOutputStream os, final StyleConverter.StringStore stringStore) throws IOException