本文整理汇总了Java中javafx.collections.MapChangeListener类的典型用法代码示例。如果您正苦于以下问题:Java MapChangeListener类的具体用法?Java MapChangeListener怎么用?Java MapChangeListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapChangeListener类属于javafx.collections包,在下文中一共展示了MapChangeListener类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: registerListeners
import javafx.collections.MapChangeListener; //导入依赖的package包/类
private void registerListeners() {
widthProperty().addListener(o -> resize());
heightProperty().addListener(o -> resize());
sceneProperty().addListener(o -> {
if (!locations.isEmpty()) { addShapesToScene(locations.values()); }
if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); }
locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> {
if (CHANGE.wasAdded()) {
addShapesToScene(CHANGE.getValueAdded());
} else if(CHANGE.wasRemoved()) {
Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved()));
}
});
});
}
开发者ID:HanSolo,项目名称:worldheatmap,代码行数:17,代码来源:World.java
示例2: LeakDetector
import javafx.collections.MapChangeListener; //导入依赖的package包/类
public LeakDetector(Scene... scenes) {
registerListenerOnSceneRoot(scenes[0]);
map.addListener(((MapChangeListener<WeakRef<Node>, TreeItem<WeakRef<Node>>>) c -> {
if (c.wasAdded()) {
// add TreeItem to root if the node has no parent (else append to TreeItem of parent)
if(getParent(c.getKey()) == null) {
appendTreeItemToRoot(c.getValueAdded());
} else {
addParentOfNode(c.getKey(), c.getValueAdded());
}
}
if(c.wasRemoved()) {
// remove also TreeItem if node was removed from map
Platform.runLater(() -> {
rootItem.getChildren().remove(c.getValueRemoved());
});
}
}));
}
开发者ID:sialcasa,项目名称:leakdetectorFX,代码行数:22,代码来源:LeakDetector.java
示例3: initialiseSystemUnderTest
import javafx.collections.MapChangeListener; //导入依赖的package包/类
@Before public void initialiseSystemUnderTest(){
addedResultsList = new ArrayList<>();
removedResultsList = new ArrayList<>();
observableMap = FXCollections.observableHashMap();
systemUnderTest = new MapChangeListenerRegistrationImpl<>(
observableMap,
( MapChangeListener.Change< ? extends String, ? extends Object > change ) -> {
if ( !observableMap.containsKey( change.getKey() ) ) {
removedResultsList.add( new Pair<>( change.getKey(), change.getValueRemoved() ) );
} else {
addedResultsList.add( new Pair<>( change.getKey(), change.getValueAdded() ) );
}
}
);
}
开发者ID:DanGrew,项目名称:JttDesktop,代码行数:17,代码来源:MapChangeListenerRegistrationImplTest.java
示例4: ValidationSupport
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* Creates validation support instance
*/
public ValidationSupport() {
this.validationResultProperty()
.addListener((o, oldValue, validationResult) -> {
this.invalidProperty.set(!validationResult.getErrors()
.isEmpty());
this.redecorate();
});
// notify validation result observers
this.validationResults.addListener(
(final MapChangeListener.Change<? extends Control, ? extends
ValidationResult> change) -> this
.validationResultProperty.set(
ValidationResult.fromResults(
this.validationResults.values())));
}
开发者ID:aftenkap,项目名称:jutility-javafx,代码行数:23,代码来源:ValidationSupport.java
示例5: onChanged
import javafx.collections.MapChangeListener; //导入依赖的package包/类
@Override
public void onChanged(final MapChangeListener.Change<? extends Object, ? extends Object> change) {
final ObservableMap<?, ?> map = change.getMap();
if (disabledFor.containsKey(map)) {
return;
}
try {
final UUID mapId = objectRegistry.getIdOrFail(map);
final Object key = change.getKey();
if (change.wasAdded()) {
final Object value = change.getValueAdded();
final List<Command> commands = creator.putToMap(mapId, key, value);
registerListenersOnEverything(key);
if (value != null) {
registerListenersOnEverything(value);
}
distributeCommands(commands);
} else {
distributeCommands(creator.removeFromMap(mapId, key));
}
} catch (final SynchronizeFXException e) {
topology.onError(e);
}
}
开发者ID:saxsys,项目名称:SynchronizeFX,代码行数:25,代码来源:Listeners.java
示例6: GraphVisualizer
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* Create a new {@link GraphVisualizer} instance.
* <p>
* The passed {@link GraphStore} is observed by this class. If the {@link GraphStore}
* {@link org.dnacronym.hygene.parser.GfaFile} is updated, it will prompt a redraw. Changing the properties of this
* class will also prompt a redraw if the {@link org.dnacronym.hygene.parser.GfaFile} in {@link GraphStore} is not
* {@code null}.
*
* @param graphDimensionsCalculator {@link GraphDimensionsCalculator} used to calculate node positions
* @param query the {@link Query} used to get the currently queried nodes
* @param bookmarkStore the {@link BookmarkStore} used to draw bookmark indications
* @param graphAnnotation the {@link GraphAnnotation} used to draw annotations
*/
@Inject
public GraphVisualizer(final GraphDimensionsCalculator graphDimensionsCalculator, final Query query,
final BookmarkStore bookmarkStore, final GraphAnnotation graphAnnotation,
final GraphStore graphStore) {
HygeneEventBus.getInstance().register(this);
this.graphDimensionsCalculator = graphDimensionsCalculator;
this.query = query;
this.bookmarkStore = bookmarkStore;
this.colorRoulette = new ColorRoulette();
this.graphAnnotation = graphAnnotation;
this.graphStore = graphStore;
selectedSegmentProperty = new SimpleObjectProperty<>();
selectedSegmentProperty.addListener((observable, oldValue, newValue) -> draw());
hoveredSegmentProperty = new SimpleObjectProperty<>();
hoveredSegmentProperty.addListener((observable, oldValue, newValue) -> draw());
genomePaths = FXCollections.observableArrayList(new HashSet<>());
selectedGenomePaths = FXCollections.observableHashMap();
selectedGenomePaths.addListener((MapChangeListener<String, Color>) change -> draw());
edgeColorProperty = new SimpleObjectProperty<>(DEFAULT_EDGE_COLOR);
nodeHeightProperty = new SimpleDoubleProperty(DEFAULT_NODE_HEIGHT);
graphDimensionsCalculator.getNodeHeightProperty().bind(nodeHeightProperty);
edgeColorProperty.addListener((observable, oldValue, newValue) -> draw());
nodeHeightProperty.addListener((observable, oldValue, newValue) -> draw());
Node.setColorScheme(BasicSettingsViewController.NODE_COLOR_SCHEMES.get(0).getValue());
displayLaneBordersProperty = new SimpleBooleanProperty();
displayLaneBordersProperty.addListener((observable, oldValue, newValue) -> draw());
graphDimensionsCalculator.getGraphProperty()
.addListener((observable, oldValue, newValue) -> setGraph(newValue));
graphDimensionsCalculator.getObservableQueryNodes()
.addListener((ListChangeListener<Node>) change -> draw());
query.getQueriedNodes().addListener((ListChangeListener<Integer>) observable -> draw());
segmentDrawingToolkit = new SegmentDrawingToolkit();
snpDrawingToolkit = new SnpDrawingToolkit();
edgeDrawingToolkit = new EdgeDrawingToolkit();
graphAnnotationVisualizer = new GraphAnnotationVisualizer(graphDimensionsCalculator);
graphAnnotation.indexBuiltProperty().addListener((observable, oldValue, newValue) -> draw());
nodeHeightProperty.addListener((observable, oldValue, newValue) -> {
segmentDrawingToolkit.setNodeHeight(nodeHeightProperty.get());
snpDrawingToolkit.setNodeHeight(nodeHeightProperty.get());
draw();
});
segmentDrawingToolkit.setNodeHeight(nodeHeightProperty.get());
snpDrawingToolkit.setNodeHeight(nodeHeightProperty.get());
}
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:70,代码来源:GraphVisualizer.java
示例7: start
import javafx.collections.MapChangeListener; //导入依赖的package包/类
public void start() {
if (!started.compareAndSet(false, true)) {
throw new DefectException("Can only be started once!");
}
brokersById.addListener((MapChangeListener<String, KafkaBroker>) change -> version.incrementAndGet());
zkClient.waitUntilExists("/brokers", TimeUnit.SECONDS, 10);
executor.submit(() -> {
zkClient.subscribeChildChanges("/brokers/ids", (parentPath, currentChilds) ->
updateBrokers(ImmutableSet.copyOf(currentChilds)));
updateBrokers(ImmutableSet.copyOf(zkClient.getChildren("/brokers/ids")));
});
}
开发者ID:enthusiast94,项目名称:kafka-visualizer,代码行数:15,代码来源:KafkaBrokersTracker.java
示例8: start
import javafx.collections.MapChangeListener; //导入依赖的package包/类
public void start() {
if (!started.compareAndSet(false, true)) {
throw new DefectException("Can only be started once!");
}
topicsByName.addListener((MapChangeListener<String, KafkaTopic>) change -> version.incrementAndGet());
zkClient.waitUntilExists("/brokers", TimeUnit.SECONDS, 10);
executor.submit(() -> {
zkClient.subscribeChildChanges("/brokers/topics", (parentPath, currentChilds) ->
updateTopics(ImmutableSet.copyOf(currentChilds)));
updateTopics(ImmutableSet.copyOf(zkClient.getChildren("/brokers/topics")));
});
}
开发者ID:enthusiast94,项目名称:kafka-visualizer,代码行数:15,代码来源:KafkaTopicsTracker.java
示例9: bindToMapBidirectionally
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* Binds a property to a specific key in a map. If there is no entry for that key, the property's
* value will be set to null.
*
* @param property the property to bind
* @param map the map to bind to
* @param key the key for the entry to bind to
* @param v2t a conversion function for converting objects of type <i>V</i> to type <i>T</i>
* @param <K> the types of the keys in the map
* @param <V> the types of the values in the map
* @param <T> the type of data in the property
*/
public static <K, V, T extends V> void bindToMapBidirectionally(Property<T> property,
ObservableMap<K, V> map,
K key,
Function<V, T> v2t) {
property.addListener((__, oldValue, newValue) -> map.put(key, newValue));
map.addListener((MapChangeListener<K, V>) change -> {
if (change.getKey().equals(key)) {
if (change.wasRemoved() && !map.containsKey(key)) {
property.setValue(null);
} else if (change.wasAdded()) {
property.setValue(v2t.apply(change.getValueAdded()));
}
}
});
}
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:28,代码来源:PropertyUtils.java
示例10: initialize
import javafx.collections.MapChangeListener; //导入依赖的package包/类
@FXML
private void initialize() {
dataOrDefault.addListener((__, prevData, curData) -> {
Map<String, Object> updated = curData.changesFrom(prevData);
if (prevData != null) {
// Remove items for any deleted robot preferences
prevData.asMap().entrySet().stream()
.map(Map.Entry::getKey)
.filter(k -> !curData.containsKey(k))
.forEach(wrapperProperties::remove);
}
updated.forEach((key, value) -> {
if (NetworkTableUtils.isMetadata(key)) {
return;
}
wrapperProperties.computeIfAbsent(key, k -> generateWrapper(k, value)).setValue(value);
});
});
wrapperProperties.addListener((MapChangeListener<String, ObjectProperty<? super Object>>) change -> {
if (change.wasAdded()) {
propertySheet.getItems().add(new ExtendedPropertySheet.PropertyItem<>(change.getValueAdded(), change.getKey()));
} else if (change.wasRemoved()) {
propertySheet.getItems().removeIf(i -> i.getName().equals(change.getKey()));
}
propertySheet.getItems().sort(itemSorter);
});
exportProperties(propertySheet.searchBoxVisibleProperty());
}
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:31,代码来源:RobotPreferencesWidget.java
示例11: WeekTimeScaleView
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* Constructs a new scale view.
*/
public WeekTimeScaleView() {
MapChangeListener<? super Object, ? super Object> propertiesListener = change -> {
if (change.wasAdded()) {
if (change.getKey().equals("week.view")) { //$NON-NLS-1$
detailedWeekView.set((DetailedWeekView) change.getValueAdded());
}
}
};
getProperties().addListener(propertiesListener);
}
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:15,代码来源:WeekTimeScaleView.java
示例12: WeekDayView
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* Constructs a new day view.
*/
public WeekDayView() {
getStyleClass().add(WEEKDAY_VIEW);
MapChangeListener<? super Object, ? super Object> propertiesListener = change -> {
if (change.wasAdded()) {
if (change.getKey().equals("week.view")) { //$NON-NLS-1$
WeekView view = (WeekView) change.getValueAdded();
weekView.set(view);
}
}
};
getProperties().addListener(propertiesListener);
}
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:18,代码来源:WeekDayView.java
示例13: SearchResultView
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* Constructs a new view.
*/
public SearchResultView() {
getStyleClass().add(DEFAULT_STYLE_CLASS);
searchService = new SearchService();
searchService.setOnSucceeded(evt -> updateSearchResults());
searchTextProperty().addListener(it -> {
if (SEARCH.isLoggable(FINE)) {
SEARCH.fine("restarting search service"); //$NON-NLS-1$
}
searchService.restart();
});
/*
* Listens to changes to the properties map. Each control has a
* properties map associated with it. We are using the map to pass
* values from the skin to the control. This allows the skin to update
* read-only properties.
*/
MapChangeListener<? super Object, ? super Object> listener = change -> {
if (change.wasAdded()) {
if (change.getKey().equals(SELECTED_ENTRY)) {
Entry<?> entry = (Entry<?>) change.getValueAdded();
selectedEntry.set(entry);
getProperties().remove(SELECTED_ENTRY);
}
}
};
getProperties().addListener(listener);
}
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:36,代码来源:SearchResultView.java
示例14: getProperties
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* Returns an observable map of properties on this entry for use primarily
* by application developers.
*
* @return an observable map of properties on this entry for use primarily
* by application developers
*/
public final ObservableMap<Object, Object> getProperties() {
if (properties == null) {
properties = FXCollections.observableMap(new HashMap<>());
MapChangeListener<? super Object, ? super Object> changeListener = change -> {
if (change.getKey().equals("com.calendarfx.recurrence.source")) { //$NON-NLS-1$
if (change.getValueAdded() != null) {
@SuppressWarnings("unchecked")
Entry<T> source = (Entry<T>) change.getValueAdded();
// lookup of property first to instantiate
recurrenceSourceProperty();
recurrenceSource.set(source);
}
} else if (change.getKey().equals("com.calendarfx.recurrence.id")) { //$NON-NLS-1$
if (change.getValueAdded() != null) {
setRecurrenceId((String) change.getValueAdded());
}
}
};
properties.addListener(changeListener);
}
return properties;
}
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:34,代码来源:Entry.java
示例15: mergeMap
import javafx.collections.MapChangeListener; //导入依赖的package包/类
@SafeVarargs
public static <K, V> void mergeMap(ObservableMap<K, V> into,
ObservableMap<K, V>... maps) {
final ObservableMap<K, V> map = into;
for (ObservableMap<K, V> m : maps) {
map.putAll(m);
m.addListener((MapChangeListener<K, V>) c -> {
if (c.wasAdded()) {
map.put(c.getKey(), c.getValueAdded());
}
if (c.wasRemoved()) {
map.remove(c.getKey());
}
});
}
}
开发者ID:stechy1,项目名称:drd,代码行数:17,代码来源:ObservableMergers.java
示例16: GeneralGameDataBar
import javafx.collections.MapChangeListener; //导入依赖的package包/类
public GeneralGameDataBar(ObservableMap<String, String> data) {
this.setSpacing(SPACING);
data.addListener(new MapChangeListener<String, String>() {
@Override
public void onChanged(@SuppressWarnings("rawtypes") MapChangeListener.Change change) {
redraw(data);
}
});
redraw(data);
}
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:11,代码来源:GeneralGameDataBar.java
示例17: onSourceCellsChange
import javafx.collections.MapChangeListener; //导入依赖的package包/类
private void onSourceCellsChange(
MapChangeListener.Change<? extends String, ? extends ConstraintCell> change) {
if (change.wasAdded()) {
getCells().put(change.getKey(), new HybridCell<>(change.getValueAdded()));
}
if (change.wasRemoved()) {
getCells().put(change.getKey(), new HybridCell<>(change.getValueRemoved()));
}
}
开发者ID:VerifAPS,项目名称:stvs,代码行数:10,代码来源:HybridRow.java
示例18: cellsMapChanged
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* Called when cells were added or removed to this row.
*
* @param change The change event
*/
private void cellsMapChanged(MapChangeListener.Change<? extends String, ? extends C> change) {
if (change.wasAdded()) {
subscribeToCell(change.getValueAdded());
}
if (change.wasRemoved()) {
unsubscribeFromCell(change.getValueRemoved());
}
}
开发者ID:VerifAPS,项目名称:stvs,代码行数:14,代码来源:SpecificationRow.java
示例19: ActivityDiagramSkin
import javafx.collections.MapChangeListener; //导入依赖的package包/类
/**
* The visual representation of the ActivityDiagram.
*
* @param control The control, must not be null.
*/
public ActivityDiagramSkin(ActivityDiagram control) {
super(control);
getSkinnable().getStyleClass().add("week-activity");
getSkinnable().getActivityMap().addListener((MapChangeListener<LocalDate, Activity>) change -> updateActivities());
getSkinnable().addEventFilter(ANY, mouseEventHandler);
updateActivities();
}
开发者ID:tbressler,项目名称:waterrower-workout,代码行数:15,代码来源:ActivityDiagramSkin.java
示例20: setToKey
import javafx.collections.MapChangeListener; //导入依赖的package包/类
public void setToKey(@Nullable StringTableKey key) {
getChildren().clear();
links.clear();
setDisable(key == null);
//force an update to null so that if the Language is the same as the previous in this observer, the listeners will get notified below at comment marked with: ****
chosenLanguageObserver.updateValue(null);
if (key == null) {
return;
}
key.getLanguageTokenMap().addListener(new MapChangeListener<Language, String>() {
@Override
public void onChanged(Change<? extends Language, ? extends String> change) {
if (change.wasAdded()) {
addLanguage(change.getKey());
if (links.size() == 1) {
chosenLanguageObserver.updateValue(null);
chosenLanguageObserver.updateValue(change.getKey());
}
} else if (change.wasRemoved()) {
removeLanguage(change.getKey());
} else {
throw new IllegalStateException("unexpected change type:" + change);
}
}
});
for (Map.Entry<Language, String> token : key.getLanguageTokenMap().entrySet()) {
addLanguage(token.getKey());
}
chosenLanguageObserver.updateValue(defaultLanguage); //**** (see above comment with valueObserver.updateValue(null))
}
开发者ID:kayler-renslow,项目名称:arma-dialog-creator,代码行数:35,代码来源:LanguageSelectionPane.java
注:本文中的javafx.collections.MapChangeListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论