public class FXCollections
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static ObservableList |
EMPTY_OBSERVABLE_LIST |
private static ObservableMap |
EMPTY_OBSERVABLE_MAP |
private static ObservableSet |
EMPTY_OBSERVABLE_SET |
private static java.util.Random |
r |
Modifier | Constructor and Description |
---|---|
private |
FXCollections()
Not to be instantiated.
|
Modifier and Type | Method and Description |
---|---|
static <E> ObservableList<E> |
checkedObservableList(ObservableList<E> list,
java.lang.Class<E> type)
Creates and returns a typesafe wrapper on top of provided observable list.
|
static <K,V> ObservableMap<K,V> |
checkedObservableMap(ObservableMap<K,V> map,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Creates and returns a typesafe wrapper on top of provided observable map.
|
static <E> ObservableSet<E> |
checkedObservableSet(ObservableSet<E> set,
java.lang.Class<E> type)
Creates and returns a typesafe wrapper on top of provided observable set.
|
static <E> ObservableList<E> |
concat(ObservableList<E>... lists)
Concatenates more observable lists into one.
|
static <T> void |
copy(ObservableList<? super T> dest,
java.util.List<? extends T> src)
Copies elements from src to dest.
|
static <E> ObservableList<E> |
emptyObservableList()
Creates an empty unmodifiable observable list.
|
static <K,V> ObservableMap<K,V> |
emptyObservableMap()
Creates an empty unmodifiable observable map.
|
static <E> ObservableSet<E> |
emptyObservableSet()
Creates an empty unmodifiable observable set.
|
static <T> void |
fill(ObservableList<? super T> list,
T obj)
Fills the provided list with obj.
|
static <E> ObservableList<E> |
observableArrayList()
Creates a new empty observable list that is backed by an arraylist.
|
static <E> ObservableList<E> |
observableArrayList(<any> extractor)
Creates a new empty observable list backed by an arraylist.
|
static <E> ObservableList<E> |
observableArrayList(E... items)
Creates a new observable array list with
items added to it. |
static ObservableFloatArray |
observableFloatArray()
Creates a new empty observable float array.
|
static ObservableFloatArray |
observableFloatArray(float... values)
Creates a new observable float array with
values set to it. |
static ObservableFloatArray |
observableFloatArray(ObservableFloatArray array)
Creates a new observable float array with copy of elements in given
array . |
static <K,V> ObservableMap<K,V> |
observableHashMap()
Creates a new empty observable map that is backed by a HashMap.
|
static ObservableIntegerArray |
observableIntegerArray()
Creates a new empty observable integer array.
|
static ObservableIntegerArray |
observableIntegerArray(int... values)
Creates a new observable integer array with
values set to it. |
static ObservableIntegerArray |
observableIntegerArray(ObservableIntegerArray array)
Creates a new observable integer array with copy of elements in given
array . |
static <E> ObservableList<E> |
observableList(java.util.List<E> list)
Constructs an ObservableList that is backed by the specified list.
|
static <E> ObservableList<E> |
observableList(java.util.List<E> list,
<any> extractor)
Constructs an ObservableList that is backed by the specified list.
|
static <K,V> ObservableMap<K,V> |
observableMap(java.util.Map<K,V> map)
Constructs an ObservableMap that is backed by the specified map.
|
static <E> ObservableSet<E> |
observableSet(E... elements)
Constructs an ObservableSet backed by a HashSet
that contains all the specified elements.
|
static <E> ObservableSet<E> |
observableSet(java.util.Set<E> set)
Constructs an ObservableSet that is backed by the specified set.
|
static <T> boolean |
replaceAll(ObservableList<T> list,
T oldVal,
T newVal)
Replace all oldVal elements in the list with newVal element.
|
static void |
reverse(ObservableList list)
Reverse the order in the list
Fires only one change notification on the list.
|
static void |
rotate(ObservableList list,
int distance)
Rotates the list by distance.
|
static void |
shuffle(ObservableList<?> list)
Shuffles all elements in the observable list.
|
static void |
shuffle(ObservableList list,
java.util.Random rnd)
Shuffles all elements in the observable list.
|
static <E> ObservableList<E> |
singletonObservableList(E e)
Creates an unmodifiable observable list with single element.
|
static <T extends java.lang.Comparable<? super T>> |
sort(ObservableList<T> list)
Sorts the provided observable list.
|
static <T> void |
sort(ObservableList<T> list,
java.util.Comparator<? super T> c)
Sorts the provided observable list using the c comparator.
|
private static void |
swap(java.lang.Object[] arr,
int i,
int j) |
static <E> ObservableList<E> |
synchronizedObservableList(ObservableList<E> list)
Creates and returns a synchronized wrapper on top of provided observable list.
|
static <K,V> ObservableMap<K,V> |
synchronizedObservableMap(ObservableMap<K,V> map)
Creates and returns a synchronized wrapper on top of provided observable map.
|
static <E> ObservableSet<E> |
synchronizedObservableSet(ObservableSet<E> set)
Creates and returns a synchronized wrapper on top of provided observable set.
|
static <E> ObservableList<E> |
unmodifiableObservableList(ObservableList<E> list)
Creates and returns unmodifiable wrapper list on top of provided observable list.
|
static <K,V> ObservableMap<K,V> |
unmodifiableObservableMap(ObservableMap<K,V> map)
Constructs a read-only interface to the specified ObservableMap.
|
static <E> ObservableSet<E> |
unmodifiableObservableSet(ObservableSet<E> set)
Creates and returns unmodifiable wrapper on top of provided observable set.
|
private static ObservableMap EMPTY_OBSERVABLE_MAP
private static ObservableList EMPTY_OBSERVABLE_LIST
private static ObservableSet EMPTY_OBSERVABLE_SET
private static java.util.Random r
public static <E> ObservableList<E> observableList(java.util.List<E> list)
E
- The type of List to be wrappedlist
- a concrete List that backs this ObservableListpublic static <E> ObservableList<E> observableList(java.util.List<E> list, <any> extractor)
extractor
.
Observable objects returned by extractor (applied to each list element) are listened for changes
and transformed into "update" change of ListChangeListener.E
- The type of List to be wrappedlist
- a concrete List that backs this ObservableListextractor
- element to Observable[] convertorpublic static <K,V> ObservableMap<K,V> observableMap(java.util.Map<K,V> map)
K
- the type of the wrapped keyV
- the type of the wrapped valuemap
- a Map that backs this ObservableMappublic static <E> ObservableSet<E> observableSet(java.util.Set<E> set)
E
- The type of List to be wrappedset
- a Set that backs this ObservableSetpublic static <E> ObservableSet<E> observableSet(E... elements)
E
- The type of List to be wrappedelements
- elements that will be added into returned ObservableSetpublic static <K,V> ObservableMap<K,V> unmodifiableObservableMap(ObservableMap<K,V> map)
K
- the type of the wrapped keyV
- the type of the wrapped valuemap
- an ObservableMap that is to be monitored by this interfacepublic static <K,V> ObservableMap<K,V> checkedObservableMap(ObservableMap<K,V> map, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
K
- the type of the wrapped keyV
- the type of the wrapped valuemap
- an Observable map to be wrappedkeyType
- the type of key that map
is permitted to holdvalueType
- the type of value that map
is permitted to holdCollections.checkedMap(java.util.Map, java.lang.Class, java.lang.Class)
public static <K,V> ObservableMap<K,V> synchronizedObservableMap(ObservableMap<K,V> map)
K
- the type of the wrapped keyV
- the type of the wrapped valuemap
- the map to be "wrapped" in a synchronized map.Collections.synchronizedMap(java.util.Map)
public static <K,V> ObservableMap<K,V> emptyObservableMap()
K
- the type of the wrapped keyV
- the type of the wrapped valueCollections.emptyMap()
public static ObservableIntegerArray observableIntegerArray()
public static ObservableIntegerArray observableIntegerArray(int... values)
values
set to it.values
- the values that will be in the new observable integer arraypublic static ObservableIntegerArray observableIntegerArray(ObservableIntegerArray array)
array
.array
- observable integer array to copypublic static ObservableFloatArray observableFloatArray()
public static ObservableFloatArray observableFloatArray(float... values)
values
set to it.values
- the values that will be in the new observable float arraypublic static ObservableFloatArray observableFloatArray(ObservableFloatArray array)
array
.array
- observable float array to copypublic static <E> ObservableList<E> observableArrayList()
E
- The type of List to be wrappedobservableList(java.util.List)
public static <E> ObservableList<E> observableArrayList(<any> extractor)
E
- The type of List to be wrappedextractor
- element to Observable[] convertor. Observable objects are listened for changes on the element.#observableList(java.util.List, javafx.util.Callback)
public static <E> ObservableList<E> observableArrayList(E... items)
items
added to it.E
- The type of List to be wrappeditems
- the items that will be in the new observable ArrayListobservableArrayList()
public static <K,V> ObservableMap<K,V> observableHashMap()
K
- the type of the wrapped keyV
- the type of the wrapped valuepublic static <E> ObservableList<E> concat(ObservableList<E>... lists)
E
- The type of List to be wrappedlists
- lists to concatenatepublic static <E> ObservableList<E> unmodifiableObservableList(ObservableList<E> list)
E
- The type of List to be wrappedlist
- an ObservableList that is to be wrappedCollections.unmodifiableList(java.util.List)
public static <E> ObservableList<E> checkedObservableList(ObservableList<E> list, java.lang.Class<E> type)
E
- The type of List to be wrappedlist
- an Observable list to be wrappedtype
- the type of element that list
is permitted to holdCollections.checkedList(java.util.List, java.lang.Class)
public static <E> ObservableList<E> synchronizedObservableList(ObservableList<E> list)
E
- The type of List to be wrappedlist
- the list to be "wrapped" in a synchronized list.Collections.synchronizedList(java.util.List)
public static <E> ObservableList<E> emptyObservableList()
E
- The type of List to be wrappedCollections.emptyList()
public static <E> ObservableList<E> singletonObservableList(E e)
E
- The type of List to be wrappede
- the only elements that will be contained in this singleton observable listCollections.singletonList(java.lang.Object)
public static <E> ObservableSet<E> unmodifiableObservableSet(ObservableSet<E> set)
E
- The type of List to be wrappedset
- an ObservableSet that is to be wrappedCollections.unmodifiableSet(java.util.Set)
public static <E> ObservableSet<E> checkedObservableSet(ObservableSet<E> set, java.lang.Class<E> type)
E
- The type of List to be wrappedset
- an Observable set to be wrappedtype
- the type of element that set
is permitted to holdCollections.checkedSet(java.util.Set, java.lang.Class)
public static <E> ObservableSet<E> synchronizedObservableSet(ObservableSet<E> set)
E
- The type of List to be wrappedset
- the set to be "wrapped" in a synchronized set.Collections.synchronizedSet(java.util.Set)
public static <E> ObservableSet<E> emptyObservableSet()
E
- The type of List to be wrappedCollections.emptySet()
public static <T> void copy(ObservableList<? super T> dest, java.util.List<? extends T> src)
T
- The type of List to be wrappeddest
- the destination observable listsrc
- the source listCollections.copy(java.util.List, java.util.List)
public static <T> void fill(ObservableList<? super T> list, T obj)
T
- The type of List to be wrappedlist
- the list to fillobj
- the object to fill the list withCollections.fill(java.util.List, java.lang.Object)
public static <T> boolean replaceAll(ObservableList<T> list, T oldVal, T newVal)
T
- The type of List to be wrappedlist
- the list which will have it's elements replacedoldVal
- the element that is going to be replacenewVal
- the replacementCollections.replaceAll(java.util.List, java.lang.Object, java.lang.Object)
public static void reverse(ObservableList list)
list
- the list to be reversedCollections.reverse(java.util.List)
public static void rotate(ObservableList list, int distance)
list
- the list to be rotateddistance
- the distance of rotationCollections.rotate(java.util.List, int)
public static void shuffle(ObservableList<?> list)
list
- the list to shuffleCollections.shuffle(java.util.List)
public static void shuffle(ObservableList list, java.util.Random rnd)
list
- the list to be shuffledrnd
- the random generator used for shufflingCollections.shuffle(java.util.List, java.util.Random)
private static void swap(java.lang.Object[] arr, int i, int j)
public static <T extends java.lang.Comparable<? super T>> void sort(ObservableList<T> list)
T
- The type of List to be wrappedlist
- the list to be sortedCollections.sort(java.util.List)
public static <T> void sort(ObservableList<T> list, java.util.Comparator<? super T> c)
T
- The type of List to be wrappedlist
- the list to sortc
- comparator used for sorting. Null if natural ordering is required.Collections.sort(java.util.List, java.util.Comparator)