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


Java ObservableMap類代碼示例

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


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

示例1: testMapStrProperty

import javafx.collections.ObservableMap; //導入依賴的package包/類
@Theory
public void testMapStrProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableMap<String, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
    ObservableMap<String, CustomObject> mapOne = FXCollections.observableHashMap();
    mapOne.put("key1", one);
    ObservableMap<String, CustomObject> mapTwo = FXCollections.observableHashMap();
    mapTwo.put("key1", one);
    mapTwo.put("key2", two);

    testProperty(WithMapStrProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapEmpty, "{\"prop\":{}}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapOne, "{\"prop\":{\"key1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapTwo,
            "{\"prop\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
 
開發者ID:joffrey-bion,項目名稱:fx-gson,代碼行數:19,代碼來源:FxGsonTest.java

示例2: testObservableMapStr

import javafx.collections.ObservableMap; //導入依賴的package包/類
@Theory
public void testObservableMapStr(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableMap<String, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
    ObservableMap<String, CustomObject> mapOne = FXCollections.observableHashMap();
    mapOne.put("key1", one);
    ObservableMap<String, CustomObject> mapTwo = FXCollections.observableHashMap();
    mapTwo.put("key1", one);
    mapTwo.put("key2", two);

    Function<WithObsMapStr, ObservableMap<String, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapStr, ObservableMap<String, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapStr.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapEmpty, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapOne, "{\"map\":{\"key1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapTwo,
            "{\"map\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", getter, setter, gson);
}
 
開發者ID:joffrey-bion,項目名稱:fx-gson,代碼行數:22,代碼來源:FxGsonTest.java

示例3: testMapIntProperty

import javafx.collections.ObservableMap; //導入依賴的package包/類
@Theory
public void testMapIntProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableMap<Integer, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
    ObservableMap<Integer, CustomObject> mapOne = FXCollections.observableHashMap();
    mapOne.put(1, one);
    ObservableMap<Integer, CustomObject> mapTwo = FXCollections.observableHashMap();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    testProperty(WithMapIntProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapEmpty, "{\"prop\":{}}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapOne, "{\"prop\":{\"1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapTwo,
            "{\"prop\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
 
開發者ID:joffrey-bion,項目名稱:fx-gson,代碼行數:19,代碼來源:FxGsonTest.java

示例4: testObservableMapInt

import javafx.collections.ObservableMap; //導入依賴的package包/類
@Theory
public void testObservableMapInt(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    ObservableMap<Integer, CustomObject> mapEmpty = FXCollections.emptyObservableMap();
    ObservableMap<Integer, CustomObject> mapOne = FXCollections.observableHashMap();
    mapOne.put(1, one);
    ObservableMap<Integer, CustomObject> mapTwo = FXCollections.observableHashMap();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    Function<WithObsMapInt, ObservableMap<Integer, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapInt, ObservableMap<Integer, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapInt.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapEmpty, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapOne, "{\"map\":{\"1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapTwo, "{\"map\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}",
            getter, setter, gson);
}
 
開發者ID:joffrey-bion,項目名稱:fx-gson,代碼行數:22,代碼來源:FxGsonTest.java

示例5: testCustomTreeMapStrProperty

import javafx.collections.ObservableMap; //導入依賴的package包/類
@Theory
public void testCustomTreeMapStrProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<String, CustomObject> mapEmpty = new TreeMap<>();
    Map<String, CustomObject> mapOne = new TreeMap<>();
    mapOne.put("key1", one);
    Map<String, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put("key1", one);
    mapTwo.put("key2", two);

    ObservableMap<String, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<String, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<String, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    testProperty(WithMapStrProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapEmptyObs, "{\"prop\":{}}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapOneObs, "{\"prop\":{\"key1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
    testProperty(WithMapStrProp.class, mapTwoObs,
            "{\"prop\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
 
開發者ID:joffrey-bion,項目名稱:fx-gson,代碼行數:23,代碼來源:FxGsonTest.java

示例6: testCustomObservableTreeMapStr

import javafx.collections.ObservableMap; //導入依賴的package包/類
@Theory
public void testCustomObservableTreeMapStr(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<String, CustomObject> mapEmpty = new TreeMap<>();
    Map<String, CustomObject> mapOne = new TreeMap<>();
    mapOne.put("key1", one);
    Map<String, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put("key1", one);
    mapTwo.put("key2", two);

    ObservableMap<String, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<String, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<String, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    Function<WithObsMapStr, ObservableMap<String, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapStr, ObservableMap<String, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapStr.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapEmptyObs, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapOneObs, "{\"map\":{\"key1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapStr.class, mapTwoObs,
            "{\"map\":{\"key1\":{\"name\":\"myObj1\"},\"key2\":{\"name\":\"myObj2\"}}}", getter, setter, gson);
}
 
開發者ID:joffrey-bion,項目名稱:fx-gson,代碼行數:26,代碼來源:FxGsonTest.java

示例7: testCustomTreeMapIntProperty

import javafx.collections.ObservableMap; //導入依賴的package包/類
@Theory
public void testCustomTreeMapIntProperty(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<Integer, CustomObject> mapEmpty = new TreeMap<>();
    Map<Integer, CustomObject> mapOne = new TreeMap<>();
    mapOne.put(1, one);
    Map<Integer, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    ObservableMap<Integer, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<Integer, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<Integer, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    testProperty(WithMapIntProp.class, null, "{\"prop\":null}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapEmptyObs, "{\"prop\":{}}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapOneObs, "{\"prop\":{\"1\":{\"name\":\"myObj1\"}}}", o -> o.prop, gson);
    testProperty(WithMapIntProp.class, mapTwoObs,
            "{\"prop\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}", o -> o.prop, gson);
}
 
開發者ID:joffrey-bion,項目名稱:fx-gson,代碼行數:23,代碼來源:FxGsonTest.java

示例8: testCustomObservableTreeMapInt

import javafx.collections.ObservableMap; //導入依賴的package包/類
@Theory
public void testCustomObservableTreeMapInt(@FromDataPoints("all") Gson gson) {
    CustomObject one = new CustomObject("myObj1");
    CustomObject two = new CustomObject("myObj2");

    Map<Integer, CustomObject> mapEmpty = new TreeMap<>();
    Map<Integer, CustomObject> mapOne = new TreeMap<>();
    mapOne.put(1, one);
    Map<Integer, CustomObject> mapTwo = new TreeMap<>();
    mapTwo.put(1, one);
    mapTwo.put(2, two);

    ObservableMap<Integer, CustomObject> mapEmptyObs = FXCollections.observableMap(mapEmpty);
    ObservableMap<Integer, CustomObject> mapOneObs = FXCollections.observableMap(mapOne);
    ObservableMap<Integer, CustomObject> mapTwoObs = FXCollections.observableMap(mapTwo);

    Function<WithObsMapInt, ObservableMap<Integer, CustomObject>> getter = o -> o.map;
    BiConsumer<WithObsMapInt, ObservableMap<Integer, CustomObject>> setter = (o, m) -> o.map = m;

    testValue(WithObsMapInt.class, null, "{\"map\":null}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapEmptyObs, "{\"map\":{}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapOneObs, "{\"map\":{\"1\":{\"name\":\"myObj1\"}}}", getter, setter, gson);
    testValue(WithObsMapInt.class, mapTwoObs, "{\"map\":{\"1\":{\"name\":\"myObj1\"},\"2\":{\"name\":\"myObj2\"}}}",
            getter, setter, gson);
}
 
開發者ID:joffrey-bion,項目名稱:fx-gson,代碼行數:26,代碼來源:FxGsonTest.java

示例9: fetchKeys

import javafx.collections.ObservableMap; //導入依賴的package包/類
private void fetchKeys(Element element, StringTableKeyPath path, List<StringTableKey> tableKeys) {
	List<Element> keyElements = XmlUtil.getChildElementsWithTagName(element, StringTableXmlConstants.KEY);

	for (Element keyElement : keyElements) {
		String id = keyElement.getAttribute(StringTableXmlConstants.ID).trim();

		if (id.length() > 0) {
			List<Element> valueElements = XmlUtil.getChildElementsWithTagName(keyElement, null);
			ObservableMap<Language, String> map = FXCollections.observableMap(new HashMap<>(valueElements.size()));
			for (Element valueElement : valueElements) {
				Language language;
				String langName = valueElement.getTagName();
				try {
					language = KnownLanguage.valueOf(langName);
				} catch (IllegalArgumentException e) {
					language = new CustomLanguage(langName);
				}
				map.put(language, XmlUtil.getImmediateTextContent(valueElement));
			}
			tableKeys.add(new StringTableKeyImpl(id, path.deepCopy(), map));
		}
	}
}
 
開發者ID:kayler-renslow,項目名稱:arma-dialog-creator,代碼行數:24,代碼來源:DefaultStringTableXmlParser.java

示例10: StatusFilterPropertyUpdater

import javafx.collections.ObservableMap; //導入依賴的package包/類
/**
 * Constructs a new {@link StatusFilterPropertyUpdater}.
 * @param map the map notifying.
 * @param status the {@link BuildResultStatus} to filter for.
 * @param property the {@link ObjectProperty} to update.
 */
public StatusFilterPropertyUpdater( 
         ObservableMap< BuildResultStatus, Color > map,
         BuildResultStatus status, 
         ObjectProperty< Color > property
) {
   super( 
            map, 
            ( k, v ) -> {
               if ( k == status ) {
                  property.set( v );
               }
            }, 
            ( k, v ) -> { /* do nothing if removed, leave previous value */ } 
   );
}
 
開發者ID:DanGrew,項目名稱:JttDesktop,代碼行數:22,代碼來源:StatusFilterPropertyUpdater.java

示例11: addItemConfiguration

import javafx.collections.ObservableMap; //導入依賴的package包/類
/**
 * General mechanism for adding {@link ColorPicker}s.
 * @param row the row to add the items on.
 * @param label the {@link Label} describing the {@link ColorPicker}.
 * @param picker the {@link ColorPicker}.
 * @param shortcut the {@link Button} providing the shortcut.
 * @param map the {@link ObservableMap} providing the {@link Color}.
 */
private void addItemConfiguration( int row, Label label, ColorPicker picker, Button shortcut, ObservableMap< BuildResultStatus, Color > map ) {
   add( label, 0, row );
   
   styling.configureColorPicker( picker, map.get( status ) );
   
   map.addListener( 
            new StatusFilterPropertyUpdater( map, status, picker.valueProperty() )
   );
   picker.valueProperty().addListener( ( s, o, n ) -> map.put( status, n ) );
   add( picker, 1, row );
   
   shortcut.setMaxWidth( Double.MAX_VALUE );
   shortcut.setOnAction( e -> picker.setValue( shortcuts.shortcutColorProperty().get() ) );
   add( shortcut, 2, row );
}
 
開發者ID:DanGrew,項目名稱:JttDesktop,代碼行數:24,代碼來源:StatusConfigurationPane.java

示例12: assertThatElementsAreProvided

import javafx.collections.ObservableMap; //導入依賴的package包/類
private void assertThatElementsAreProvided( 
         Label label, String labelText, 
         ColorPicker picker,
         Button button,
         ObservableMap< BuildResultStatus, Color > map 
){
   assertThat( systemUnderTest.getChildren().contains( label ), is( true ) );
   assertThat( label.getText(), is( labelText ) );
   verify( styling ).createBoldLabel( labelText );
   
   assertThat( systemUnderTest.getChildren().contains( picker ), is( true ) );
   verify( styling ).configureColorPicker( picker, map.get( status ) );
   
   assertThat( systemUnderTest.getChildren().contains( button ), is( true ) );
   assertThat( button.getText(), is( StatusConfigurationPane.SHORTCUT_BUTTON_TEXT ) );
   assertThat( button.getMaxWidth(), is( Double.MAX_VALUE ) );
}
 
開發者ID:DanGrew,項目名稱:JttDesktop,代碼行數:18,代碼來源:StatusConfigurationPaneTest.java

示例13: newModel

import javafx.collections.ObservableMap; //導入依賴的package包/類
protected void newModel(Supplier<ObservableMap<Integer, Supplier<ModelPageEditor>>> initialModelPagesSupplier) {
	undoManagersForgetHistory();
	callUndoManagers(um -> um.undoAvailableProperty().removeListener(this::checkGlobalUndoState));
	
	modelPageEditors.set(initialModelPagesSupplier.get());
	
	// Unbind and create a new page change undo manager for the new model
	canUndoPageChange.unbind();
	canRedoPageChange.unbind();
	pageChangeUndoManager.close();
	
	pageChangeUndoManager = newPageChangeUndoManager();
	canUndoPageChange.bind(pageChangeUndoManager.undoAvailableProperty());
	canRedoPageChange.bind(pageChangeUndoManager.redoAvailableProperty());
	
	bindModelPageEditorUndoManager(0);
	currentModelPageIndexProperty.set(0);
	
	callUndoManagers(um -> um.undoAvailableProperty().addListener(this::checkGlobalUndoState));
}
 
開發者ID:aic-sri-international,項目名稱:aic-praise,代碼行數:21,代碼來源:AbstractPerspective.java

示例14: bufferingMap

import javafx.collections.ObservableMap; //導入依賴的package包/類
/**
 * @param bean
 *            bean instance
 * @param propertyName
 *            bean set property name
 * @return {@link ObservableMapBuffering} for the property
 * @param <K>
 *            map key type
 * @param <E>
 *            map value type
 */
public <K, E> ObservableMapBuffering<K, E> bufferingMap(final Object bean, final String propertyName)
{
	ObservableMapBuffering<K, E> lb = null;
	@SuppressWarnings("unchecked")
	final Map<K, E> value = getPropertyValue(bean, propertyName, Map.class);
	if (value instanceof ObservableMap<?, ?>)
	{
		lb = new ObservableMapBuffering<>(bean.getClass(), propertyName, (ObservableMap<K, E>) value);
	}
	else
	{
		lb = new ObservableMapBuffering<>(bean.getClass(), propertyName, FXCollections.observableMap(value));
	}
	add(lb);
	return lb;
}
 
開發者ID:ben12,項目名稱:reta,代碼行數:28,代碼來源:BufferingManager.java

示例15: setIfUpdate

import javafx.collections.ObservableMap; //導入依賴的package包/類
private static <T> T setIfUpdate(ObservableMap<? extends String, ? extends Object> map,
        String key, WritableValue<T>... props) {
    T newValue = (T) map.get(key);
    if (newValue != null) {
        boolean stringEmpty = false;
        if (newValue instanceof String) {
            String newStr = (String) newValue;
            stringEmpty = newStr.isEmpty();
        }
        for (WritableValue<T> prop : props) {
            if (stringEmpty) {
                if (prop.getValue() == null) {
                    prop.setValue(newValue);
                }
            } else {
                prop.setValue(newValue);
            }
        }
    }
    return newValue;
}
 
開發者ID:brightgenerous,項目名稱:fx-player,代碼行數:22,代碼來源:MediaInfo.java


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