當前位置: 首頁>>代碼示例>>Java>>正文


Java MapChangeListener類代碼示例

本文整理匯總了Java中javafx.collections.MapChangeListener的典型用法代碼示例。如果您正苦於以下問題:Java MapChangeListener類的具體用法?Java MapChangeListener怎麽用?Java MapChangeListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MapChangeListener類屬於javafx.collections包,在下文中一共展示了MapChangeListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的javafx.collections.MapChangeListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。