APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.javafx.css

public final Class StyleCache

extends Object
Class Inheritance
Imports
java.util.Arrays, .HashMap, .Map

A cache to store values from lookup. Consider that there are some number of StyleHelpers and that the StyleHelpers are shared. For a particular node, a style might come from its StyleHelper or the StyleHelper of one of its parents (ignoring Node.style for now). What makes a style unique is the set of StyleHelpers that go into its calculation. So, if node N has StyleHelper A and its parents have StyleHelper B and C, the opacity style (say) for N is going to be unique to the set of StyleHelpers [A B C]. Because StyleHelpers are chosen by the rules they match, and because StyleHelpers are shared, every node that has the set of StyleHelpers [A B C] will match the same selector for opacity (for a given pseudoclass state). Further, the value for opacity (in the given pseudoclass state) will not change for the given set of StyleHelpers. Therefore, rather than trying to cache a calculated value with an individual StyleHelper, the value can be cached with a key that uniquely identifies the set [A B C]. Subsequent lookups for the property do not need to be recalculated even if there are lookups in the value. Incidentally, resolved references will also be unique to a set of StyleHelpers and would only need to be resolved once (for a given pseudoclass state). Node.style puts a slight wrinkle in that the style might come from the Node rather than the cache. This can be handled in a relatively straight-forward manner. If Node.style is not empty or null and it contains the property, then that style should be used if the style compares less than the style that would have been applied. If there is some parent with Node.style that would affect the child Node's style, then the cached value can be used. The key is comprised of this helper's key, plus the keys of all this node's parents' helpers. The values in the cache styles that apply are determined by the node's state and the state of its parents. This unique combination of states reflects the state of the node and its parents at the time the style was first determined. Provided the node and its parents are in the same state, then the styles applied will be the same as what is in the cache. The value could be a Map, but there should not be a large number of entries. Computing the key from the long[], doing the lookup and resolving collisions is probably just as bad, if not worse, than finding the matching set of states by comparing the long[]. Since all StyleHelpers are relevant to a Scene, valueCache is created by StyleManager.StylesheetContainer and is passed in. Note that all StyleHelper instances within a given Scene all share the same valueCache!

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private Map<StyleCacheEntry.Key, StyleCacheEntry>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public StyleCacheEntry
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entriesback to summary
private Map<StyleCacheEntry.Key, StyleCacheEntry> entries

Constructor Detail

StyleCacheback to summary
public StyleCache()

Method Detail

addStyleCacheEntryback to summary
public void addStyleCacheEntry(StyleCacheEntry.Key key, StyleCacheEntry entry)
clearback to summary
public void clear()
getStyleCacheEntryback to summary
public StyleCacheEntry getStyleCacheEntry(StyleCacheEntry.Key key)
com.sun.javafx.css back to summary

public final Class StyleCache.Key

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private int
pack-priv final int[]

Constructor Summary

AccessConstructor and Description
public
Key(int[] styleMapIds, int count)

public

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

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

public int[]
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

hashback to summary
private int hash
styleMapIdsback to summary
pack-priv final int[] styleMapIds

Constructor Detail

Keyback to summary
public Key(int[] styleMapIds, int count)
Keyback to summary
public Key(StyleCache.Key other)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

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

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getStyleMapIdsback to summary
public int[] getStyleMapIds()
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
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override