本文整理汇总了Java中javafx.collections.ObservableSet类的典型用法代码示例。如果您正苦于以下问题:Java ObservableSet类的具体用法?Java ObservableSet怎么用?Java ObservableSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObservableSet类属于javafx.collections包,在下文中一共展示了ObservableSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TimeGraphDrawnEventLayer
import javafx.collections.ObservableSet; //导入依赖的package包/类
public TimeGraphDrawnEventLayer(TimeGraphWidget widget, Group parentGroup) {
super(widget, parentGroup);
ObservableSet<TimeGraphDrawnEventProvider> providers = TimeGraphDrawnEventProviderManager.instance().getRegisteredProviders();
/* Populate with the initial values */
providers.forEach(this::trackEventProvider);
/* Add listeners to track registered/deregistered providers */
providers.addListener((SetChangeListener<TimeGraphDrawnEventProvider>) change -> {
if (change == null) {
return;
}
TimeGraphDrawnEventProvider addedProvider = change.getElementAdded();
if (addedProvider != null) {
trackEventProvider(addedProvider);
}
TimeGraphDrawnEventProvider removedProvider = change.getElementRemoved();
if (removedProvider != null) {
untrackEventProvider(removedProvider);
}
});
filterListener = new DrawnEventFilterListener(getWidget());
}
示例2: mergeSet
import javafx.collections.ObservableSet; //导入依赖的package包/类
@SafeVarargs
public static <T, E> void mergeSet(Function<? super E, ? extends T> mapper,
ObservableSet<T> into, ObservableSet<E>... sets) {
final ObservableSet<T> set = into;
for (ObservableSet<E> s : sets) {
for (E item : s) {
set.add(mapper.apply(item));
}
s.addListener((SetChangeListener<E>) c -> {
if (c.wasAdded()) {
set.add(mapper.apply(c.getElementAdded()));
}
if (c.wasRemoved()) {
set.remove(mapper.apply(c.getElementRemoved()));
}
});
}
}
示例3: testObservableSet
import javafx.collections.ObservableSet; //导入依赖的package包/类
@Theory
public void testObservableSet(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
ObservableSet<CustomObject> setEmpty = FXCollections.emptyObservableSet();
ObservableSet<CustomObject> setOne = FXCollections.observableSet(one);
ObservableSet<CustomObject> setTwo = FXCollections.observableSet(one, two);
Function<WithObsSet, ObservableSet<CustomObject>> getter = o -> o.set;
BiConsumer<WithObsSet, ObservableSet<CustomObject>> setter = (o, s) -> o.set = s;
testValue(WithObsSet.class, null, "{\"set\":null}", getter, setter, gson);
testValue(WithObsSet.class, setEmpty, "{\"set\":[]}", getter, setter, gson);
testValue(WithObsSet.class, setOne, "{\"set\":[{\"name\":\"myObj1\"}]}", getter, setter, gson);
// do not check a particular JSON because the order is non-deterministic
testValue(WithObsSet.class, setTwo, null, getter, setter, gson);
}
示例4: SankeyChart
import javafx.collections.ObservableSet; //导入依赖的package包/类
public SankeyChart(ObservableSet<SankeyNode> nodes,
ObservableSet<SankeyLink> links) {
this.nodes = nodes;
this.nodes.addListener(nodesChangeListener);
this.newNodes.addAll(nodes);
this.nodes.stream()
.forEach(node -> node.setChart(this));
this.links = links;
this.links.addListener(linksChangeListener);
this.links.stream()
.forEach(link -> link.setChart(this));
getChartChildren().addAll(links);
getChartChildren().addAll(nodes);
}
示例5: resolveTags
import javafx.collections.ObservableSet; //导入依赖的package包/类
@Override
public ObservableSet<VersionTag> resolveTags(Version version) {
return new SetBinding<VersionTag>() {
{
bind(solutions.getServiceList());
}
@Override
protected ObservableSet<VersionTag> computeValue() {
Set<VersionTag> result = new TreeSet<>();
solutions.getServiceList().forEach(solution -> solution.resolve(version, result));
return FXCollections.unmodifiableObservableSet(FXCollections.observableSet(result));
}
};
}
示例6: unbind
import javafx.collections.ObservableSet; //导入依赖的package包/类
public static void unbind(Object obj1, Object obj2)
{
checkParameters(obj1, obj2);
if ((obj1 instanceof List) && (obj2 instanceof ObservableList))
{
((ObservableList) obj2).removeListener(new ListContentBinding((List) obj1, null));
}
else if ((obj1 instanceof Set) && (obj2 instanceof ObservableSet))
{
((ObservableSet) obj2).removeListener(new SetContentBinding((Set) obj1, null));
}
/*
else if ((obj1 instanceof Map) && (obj2 instanceof ObservableMap))
{
((ObservableMap) obj2).removeListener(new MapContentBinding((Map) obj1, null));
}*/
}
示例7: getSelectedFileTreeCollisionPrivateDtos
import javafx.collections.ObservableSet; //导入依赖的package包/类
private Collection<CollisionPrivateDto> getSelectedFileTreeCollisionPrivateDtos() {
final ObservableSet<File> selectedFiles = fileTreePane.getSelectedFiles();
final List<CollisionPrivateDto> collisionPrivateDtos = new ArrayList<>();
final Set<Uid> collisionIds = new HashSet<>();
for (final File file : selectedFiles) {
final FileTreeItem<?> treeItem = fileTreePane.getRootFileTreeItem().findFirst(file);
if (treeItem != null) {
final CollisionPrivateDtoSet collisionPrivateDtoSet = fileTreePane.getCollisionDtoSet(treeItem);
if (collisionPrivateDtoSet != null) {
for (CollisionPrivateDto collisionPrivateDto : collisionPrivateDtoSet.getAllCollisionPrivateDtos()) {
if (collisionIds.add(collisionPrivateDto.getCollisionId()))
collisionPrivateDtos.add(collisionPrivateDto);
}
}
}
}
return collisionPrivateDtos;
}
示例8: bufferingSet
import javafx.collections.ObservableSet; //导入依赖的package包/类
/**
* @param bean
* bean instance
* @param propertyName
* bean set property name
* @return {@link ObservableSetBuffering} for the property
* @param <T>
* set element type
*/
public <T> ObservableSetBuffering<T> bufferingSet(final Object bean, final String propertyName)
{
ObservableSetBuffering<T> lb = null;
@SuppressWarnings("unchecked")
final Set<T> value = getPropertyValue(bean, propertyName, Set.class);
if (value instanceof ObservableSet<?>)
{
lb = new ObservableSetBuffering<>(bean.getClass(), propertyName, (ObservableSet<T>) value);
}
else
{
lb = new ObservableSetBuffering<>(bean.getClass(), propertyName, FXCollections.observableSet(value));
}
add(lb);
return lb;
}
示例9: dynamic
import javafx.collections.ObservableSet; //导入依赖的package包/类
/**
* Dynamically subscribes to all elements of the given observable set.
* When an element is added to the set, it is automatically subscribed to.
* When an element is removed from the set, it is automatically unsubscribed
* from.
* @param elems observable set of elements that will be subscribed to
* @param f function to subscribe to an element of the set.
* @return An aggregate subscription that tracks elementary subscriptions.
* When the returned subscription is unsubscribed, all elementary
* subscriptions are unsubscribed as well, and no new elementary
* subscriptions will be created.
*/
static <T> Subscription dynamic(
ObservableSet<T> elems,
Function<? super T, ? extends Subscription> f) {
Map<T, Subscription> elemSubs = new HashMap<>();
elems.forEach(t -> elemSubs.put(t, f.apply(t)));
Subscription setSub = EventStreams.changesOf(elems).subscribe(ch -> {
if(ch.wasRemoved()) {
Subscription sub = elemSubs.remove(ch.getElementRemoved());
assert sub != null;
sub.unsubscribe();
}
if(ch.wasAdded()) {
T elem = ch.getElementAdded();
assert !elemSubs.containsKey(elem);
elemSubs.put(elem, f.apply(elem));
}
});
return () -> {
setSub.unsubscribe();
elemSubs.forEach((t, sub) -> sub.unsubscribe());
};
}
示例10: getLoadedPlugins
import javafx.collections.ObservableSet; //导入依赖的package包/类
public ObservableSet<Plugin> getLoadedPlugins() {
return FXCollections.unmodifiableObservableSet(loadedPlugins);
}
示例11: performOperation
import javafx.collections.ObservableSet; //导入依赖的package包/类
/**
* @see BeanPathAdapter.FieldBean#performOperation(String, String,
* Class, String, Observable, Class, SelectionModel, FieldProperty,
* FieldBeanOperation)
*/
public <T> FieldProperty<?, ?, ?> performOperation(
final String fieldPath, final ObservableSet<T> observableSet,
final Class<T> setValueClass, final String collectionItemPath,
final Class<?> collectionItemPathType,
final SelectionModel<T> selectionModel,
final FieldProperty<?, ?, ?> itemMaster,
final FieldBeanOperation operation) {
return performOperation(fieldPath, fieldPath, setValueClass,
collectionItemPath, (Observable) observableSet,
collectionItemPathType, selectionModel, itemMaster,
operation);
}
示例12: builder
import javafx.collections.ObservableSet; //导入依赖的package包/类
/**
* Creates a {@link GsonBuilder} instance pre-configured based on the current configuration. This method is NOT free
* of side-effects to this {@code FxGsonBuilder} instance and hence should not be called multiple times.
*
* @return an instance of GsonBuilder configured with the options currently set in this builder
*/
public GsonBuilder builder() {
// serialization of nulls is necessary to have properties with null values deserialized properly
builder.serializeNulls()
.registerTypeAdapter(ObservableList.class, new ObservableListCreator())
.registerTypeAdapter(ObservableSet.class, new ObservableSetCreator())
.registerTypeAdapter(ObservableMap.class, new ObservableMapCreator())
.registerTypeAdapterFactory(new JavaFxPropertyTypeAdapterFactory(strictProperties, strictPrimitives));
if (includeExtras) {
builder.registerTypeAdapterFactory(new JavaFxExtraTypeAdapterFactory());
}
return builder;
}
示例13: testSetProperty
import javafx.collections.ObservableSet; //导入依赖的package包/类
@Theory
public void testSetProperty(@FromDataPoints("all") Gson gson) {
CustomObject one = new CustomObject("myObj1");
CustomObject two = new CustomObject("myObj2");
ObservableSet<CustomObject> setEmpty = FXCollections.emptyObservableSet();
ObservableSet<CustomObject> setOne = FXCollections.observableSet(one);
ObservableSet<CustomObject> setTwo = FXCollections.observableSet(one, two);
testProperty(WithSetProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
testProperty(WithSetProp.class, setEmpty, "{\"prop\":[]}", o -> o.prop, gson);
testProperty(WithSetProp.class, setOne, "{\"prop\":[{\"name\":\"myObj1\"}]}", o -> o.prop, gson);
// do not check a particular JSON because the order is non-deterministic
testProperty(WithSetProp.class, setTwo, null, o -> o.prop, gson);
}
示例14: changePseudoClass
import javafx.collections.ObservableSet; //导入依赖的package包/类
private void changePseudoClass(ObservableSet<PseudoClass> pseudoClassStates) {
pseudoClassStateChanged(oldPseudoClass, false);
if (pseudoClassStates != null) {
for (PseudoClass pseudoClass : pseudoClassStates) {
if (!COMMON_CELL_PSEUDO_CLASSES.contains(pseudoClass.getPseudoClassName())) {
pseudoClassStateChanged(pseudoClass, true);
oldPseudoClass = pseudoClass;
break;
}
}
}
}
示例15: ValueSetAttribute
import javafx.collections.ObservableSet; //导入依赖的package包/类
public ValueSetAttribute(Class<T> itemType) {
super(null);
this.itemType = itemType;
final ObservableSet<T> observableSet = FXCollections.observableSet(new HashSet<>());
value= observableSet;
observableSet.addListener((SetChangeListener<T>) change -> {
updateListeners(get());
});
}