Java Code Examples for javafx.collections.FXCollections#observableArrayList()

The following examples show how to use javafx.collections.FXCollections#observableArrayList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SetSqlController.java    From Vert.X-generator with MIT License 8 votes vote down vote up
@Override
public void initialize(URL location, ResourceBundle resources) {
	tblProperty.setEditable(true);
	tblProperty.setStyle("-fx-font-size:14px");
	StringProperty property = Main.LANGUAGE.get(LanguageKey.SET_TBL_TIPS);
	String title = property == null ? "可以在右边自定义添加属性..." : property.get();
	tblProperty.setPlaceholder(new Label(title));
	tblPropertyValues = FXCollections.observableArrayList();
	// 设置列的大小自适应
	tblProperty.setColumnResizePolicy(resize -> {
		double width = resize.getTable().getWidth();
		tdKey.setPrefWidth(width / 3);
		tdValue.setPrefWidth(width / 3);
		tdDescribe.setPrefWidth(width / 3);
		return true;
	});
	btnConfirm.widthProperty().addListener(w -> {
		double x = btnConfirm.getLayoutX() + btnConfirm.getWidth() + 10;
		btnCancel.setLayoutX(x);
	});
}
 
Example 2
Source File: Text3DMesh.java    From FXyzLib with GNU General Public License v3.0 8 votes vote down vote up
protected final void updateMesh() {
    // 1. Full Text to get position of each letter
    Text3DHelper helper = new Text3DHelper(text3D.get(), font.get(), fontSize.get());
    offset=helper.getOffset();

    // 2. Create mesh for each LineSegment        
    meshes=FXCollections.<TexturedMesh>observableArrayList();
    indLetters=new AtomicInteger();
    indSegments=new AtomicInteger();
    letterPath=new Path();
    
    text3D.get().chars().mapToObj(i->(char)i).filter(c->c!=SPACE)
            .forEach(letter->createLetter(letter.toString()));
    
    getChildren().setAll(meshes);
    updateTransforms();
}
 
Example 3
Source File: DrilldownPieChartSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public DrilldownPieChartSample() {
    String drilldownCss = DrilldownPieChartSample.class.getResource("DrilldownChart.css").toExternalForm();

    PieChart pie = new PieChart(
            FXCollections.observableArrayList(
            A = new PieChart.Data("A", 20),
            B = new PieChart.Data("B", 30),
            C = new PieChart.Data("C", 10),
            D = new PieChart.Data("D", 40)));
    ((Parent) pie).getStylesheets().add(drilldownCss);

    setDrilldownData(pie, A, "a");
    setDrilldownData(pie, B, "b");
    setDrilldownData(pie, C, "c");
    setDrilldownData(pie, D, "d");
    getChildren().add(pie);
}
 
Example 4
Source File: OfferBookViewModelTest.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testMaxCharactersForAmount() {
    OfferBook offerBook = mock(OfferBook.class);
    OpenOfferManager openOfferManager = mock(OpenOfferManager.class);
    final ObservableList<OfferBookListItem> offerBookListItems = FXCollections.observableArrayList();
    offerBookListItems.addAll(make(OfferBookListItemMaker.btcBuyItem));

    when(offerBook.getOfferBookListItems()).thenReturn(offerBookListItems);

    final OfferBookViewModel model = new OfferBookViewModel(null, openOfferManager, offerBook, empty, null, null,
            null, null, null, null, coinFormatter, new BsqFormatter());
    model.activate();

    assertEquals(6, model.maxPlacesForAmount.intValue());
    offerBookListItems.addAll(make(btcBuyItem.but(with(amount, 2000000000L))));
    assertEquals(7, model.maxPlacesForAmount.intValue());
}
 
Example 5
Source File: BidirectionalListBinderTest.java    From dolphin-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReplaceSingleElementInSingleElementDolphinList() {
    // given:
    final javafx.collections.ObservableList<String> javaFXList = FXCollections.observableArrayList();
    final ObservableList<Integer> dolphinList = new ObservableArrayList<>();
    FXBinder.bind(javaFXList).bidirectionalTo(dolphinList, Object::toString, Integer::parseInt);
    dolphinList.add(1);

    // when:
    javaFXList.set(0, "42");

    // then:
    assertThat(dolphinList, contains(42));
}
 
Example 6
Source File: BidirectionalListBinderTest.java    From dolphin-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReplaceSingleElementInMiddleOfDolphinList() {
    // given:
    final ObservableList<Integer> dolphinList = new ObservableArrayList<>();
    final javafx.collections.ObservableList<String> javaFXList = FXCollections.observableArrayList();
    FXBinder.bind(javaFXList).bidirectionalTo(dolphinList, Object::toString, Integer::parseInt);
    dolphinList.addAll(1, 2, 3);

    // when:
    javaFXList.set(1, "42");

    // then:
    assertThat(dolphinList, contains(1, 42, 3));
}
 
Example 7
Source File: BidirectionalListBinderTest.java    From dolphin-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldRemoveSingleElementAtEndOfDolphinList() {
    // given:
    final javafx.collections.ObservableList<String> javaFXList = FXCollections.observableArrayList();
    final ObservableList<Integer> dolphinList = new ObservableArrayList<>();
    FXBinder.bind(javaFXList).bidirectionalTo(dolphinList, Object::toString, Integer::parseInt);
    dolphinList.addAll(1, 2, 3);

    // when:
    javaFXList.remove("3");

    // then:
    assertThat(dolphinList, contains(1, 2));
}
 
Example 8
Source File: ListSelectionDialog.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public ListSelectionDialog(final Node root,
                           final String title,
                           final Supplier<ObservableList<String>>    available,
                           final Supplier<ObservableList<String>>    selected,
                           final Function<String, Boolean> addSelected,
                           final Function<String, Boolean> removeSelected)
{
    this.addSelected    = addSelected;
    this.removeSelected = removeSelected;

    selectedItems  = new ListView<>(selected.get());
    // We want to remove items from the available list as they're selected, and add them back as they are unselected.
    // Due to this we need a copy as available.get() returns an immutable list.
    availableItems = new ListView<>(
            FXCollections.observableArrayList(new ArrayList<>(available.get())));

    // Remove what's already selected from the available items
    for (String item : selectedItems.getItems())
        availableItems.getItems().remove(item);

    setTitle(title);
    
    final ButtonType apply = new ButtonType(Messages.Apply, ButtonBar.ButtonData.OK_DONE);

    getDialogPane().getButtonTypes().addAll(ButtonType.CANCEL, apply);
    getDialogPane().setContent(formatContent());

    setResizable(true);

    DialogHelper.positionAndSize(this, root,
            PhoebusPreferenceService.userNodeForClass(ListSelectionDialog.class),
            500, 600);

    setResultConverter(button ->  button == apply);
}
 
Example 9
Source File: ConcentricRingChart.java    From charts with Apache License 2.0 5 votes vote down vote up
public ConcentricRingChart(final List<ChartItem> ITEMS) {
    items = FXCollections.observableArrayList();
    items.setAll(ITEMS);
    _barBackgroundFill = Color.rgb(230, 230, 230);
    _sorted            = false;
    _order             = Order.ASCENDING;
    _numberFormat      = NumberFormat.NUMBER;
    _itemLabelFill     = Color.BLACK;
    listeners          = new CopyOnWriteArrayList<>();
    popup              = new InfoPopup();
    itemEventListener  = e -> {
        final EventType TYPE = e.getEventType();
        switch(TYPE) {
            case UPDATE  : drawChart(); break;
            case FINISHED: drawChart(); break;
        }
    };
    chartItemListener   = c -> {
        while (c.next()) {
            if (c.wasAdded()) {
                c.getAddedSubList().forEach(addedItem -> addedItem.addItemEventListener(itemEventListener));
            } else if (c.wasRemoved()) {
                c.getRemoved().forEach(removedItem -> removedItem.removeItemEventListener(itemEventListener));
            }
        }
        drawChart();
    };
    mouseHandler        = e -> handleMouseEvents(e);
    initGraphics();
    registerListeners();
}
 
Example 10
Source File: PrintStudents2Controller.java    From School-Management-System with Apache License 2.0 5 votes vote down vote up
@FXML
void loadGrades() {
    ArrayList arrayList = null;
    try {
        arrayList = GradeController.getGrades();
    } catch (ClassNotFoundException | SQLException e) {
        e.printStackTrace();
    }
    ObservableList observableArray = FXCollections.observableArrayList();
    observableArray.addAll(arrayList);

    if (observableArray != null) {
        loadGrades.setItems(observableArray);
    }
}
 
Example 11
Source File: FXBinderTest.java    From dolphin-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void testCorrectUnbind() {
    ObservableList<String> dolphinList = new ObservableArrayList<>();
    ObservableList<String> dolphinList2 = new ObservableArrayList<>();
    javafx.collections.ObservableList<String> javaFXList = FXCollections.observableArrayList();

    Binding binding = FXBinder.bind(javaFXList).to(dolphinList);

    dolphinList.add("Foo");

    assertEquals(dolphinList.size(), 1);
    assertEquals(dolphinList2.size(), 0);
    assertEquals(javaFXList.size(), 1);

    binding.unbind();
    FXBinder.bind(javaFXList).to(dolphinList2);

    assertEquals(dolphinList.size(), 1);
    assertEquals(dolphinList2.size(), 0);
    assertEquals(javaFXList.size(), 0);

    dolphinList2.add("Foo");
    dolphinList2.add("Bar");

    assertEquals(dolphinList.size(), 1);
    assertEquals(dolphinList2.size(), 2);
    assertEquals(javaFXList.size(), 2);
}
 
Example 12
Source File: WebdavLoadTask.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected ObservableList<WebDavResource> call() throws Exception {
  ObservableList<WebDavResource> result = FXCollections.observableArrayList();
  updateMessage("Connecting to the server");
  List<WebDavResource> resources = myWorker.load().second();
  if (isCancelled()) {
    updateMessage("Cancelled");
    return null;
  }
  result.setAll(resources);
  return result;
}
 
Example 13
Source File: LanguagePanel.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Create a new LanguagePanel
 */
public LanguagePanel()
{
	originalLanguage = ConfigurationSettings.getLanguage();

	if ((SettingsHandler.getGameAsProperty().get() != null) && (SettingsHandler.getGameAsProperty().get().getUnitSet() != null))
	{
		originalUnitSet = SettingsHandler.getGameAsProperty().get().getUnitSet().getDisplayName();
	}
	else
	{
		originalUnitSet = "";
	}

	VBox vbox = new VBox();

	for (LanguageChoice languageChoice: LanguageChoice.values())
	{
		ToggleButton languageButton = new RadioButton();
		languageButton.setUserData(languageChoice.getShortName());
		languageButton.setText(languageChoice.getLongName());
		languageButton.setToggleGroup(languageChoiceGroup);
		vbox.getChildren().add(languageButton);
	}

	Collection<UnitSet> unitSets = SettingsHandler.getGameAsProperty().get().getModeContext().getReferenceContext()
	                                              .getConstructedCDOMObjects(UnitSet.class);
	Collection<String> names = unitSets.stream()
	                                   .filter(Objects::nonNull)
	                                   .map(UnitSet::getDisplayName)
	                                   .collect(Collectors.toUnmodifiableList());
	ObservableList<String> unitSetNames = FXCollections.observableArrayList(names);
	unitSetType = new ChoiceBox<>();
	unitSetType.setItems(unitSetNames);
	Label unitSetLabel = new Label(LanguageBundle.getString("in_Prefs_unitSetType"));
	unitSetLabel.setLabelFor(unitSetType);
	vbox.getChildren().add(unitSetLabel);
	vbox.getChildren().add(unitSetType);

	Node restartInfo = new Text(LanguageBundle.getString("in_Prefs_restartInfo"));
	vbox.getChildren().add(restartInfo);

	this.add(GuiUtility.wrapParentAsJFXPanel(vbox));
}
 
Example 14
Source File: TradeChatSession.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public ObservableList<ChatMessage> getObservableChatMessageList() {
    return trade != null ? trade.getChatMessages() : FXCollections.observableArrayList();
}
 
Example 15
Source File: FX.java    From FxDock with Apache License 2.0 4 votes vote down vote up
public static <T> ObservableList<T> observableArrayList()
{
	return FXCollections.observableArrayList();
}
 
Example 16
Source File: ServiceDataFound.java    From Corendon-LostLuggage with MIT License 4 votes vote down vote up
/**  
 * Method where will be looped trough the given resultSet  
 * 
 * @throws SQLException        a resultSet will be read
 * @param resultSet            given resultSet that will be read
 * @param checkIfMatched       if this is true > get only the not matched 
 * @return ObservableList      of the type: found luggage  
 */
public static ObservableList<FoundLuggage> loopTroughResultSet(
                                        ResultSet resultSet, 
                                        boolean checkIfMatched) throws SQLException{
    //create a temporary list
    ObservableList<FoundLuggage> list = FXCollections.observableArrayList(); 
    //loop trough al the results of the resultSet
    while (resultSet.next()) {
        //Set all the columns to the right variables
        String registrationNr =     resultSet.getString("registrationNr");
        String dateFound =          resultSet.getString("dateFound");
        String timeFound =          resultSet.getString("timeFound");

        String luggageTag =         resultSet.getString("luggageTag");
        int luggageType =           resultSet.getInt("luggageType");
        String brand =              resultSet.getString("brand");
        String mainColor =             resultSet.getString("mainColor");
        String secondColor =           resultSet.getString("secondColor");
        String size =               resultSet.getString("size");
        String weight =                resultSet.getString("weight");   
        String otherCharacteristics=resultSet.getString("otherCharacteristics");
        int passengerId =           resultSet.getInt("passengerId");

        String arrivedWithFlight =  resultSet.getString("arrivedWithFlight"); 
        String locationFound =         resultSet.getString("locationFound");
        String employeeId =         resultSet.getString("employeeId");
        int matchedId =             resultSet.getInt("matchedId");
            
        //if check matched is true, filter the result
        if (checkIfMatched == true){
            //if the match id is unasigned put the luggage in the list
            if (matchedId == 0 || "".equals(matchedId)) {
                //add the data in a found luggage objects and put that in the list 
                list.add(
                    new FoundLuggage(
                        registrationNr, 
                        dateFound, 
                        timeFound, 

                        luggageTag, 
                        luggageType, 
                        brand,  
                        mainColor, 
                        secondColor, 
                        size, 
                        weight, 
                        otherCharacteristics, 
                        passengerId, 

                        arrivedWithFlight, 
                        locationFound, 
                        employeeId, 
                        matchedId
                    ));
                } else {
                    //Luggage is already matched
                }
        } else {
            list.add(
                new FoundLuggage(
                    registrationNr, 
                    dateFound, 
                    timeFound, 

                    luggageTag, 
                    luggageType, 
                    brand,  
                    mainColor, 
                    secondColor, 
                    size, 
                    weight, 
                    otherCharacteristics, 
                    passengerId, 

                    arrivedWithFlight, 
                    locationFound, 
                    employeeId, 
                    matchedId
                ));
        }
    }
    return list;
}
 
Example 17
Source File: Notifications.java    From yfiton with Apache License 2.0 4 votes vote down vote up
/**
 * Specify the actions that should be shown in the notification as buttons.
 */
public Notifications action(Action... actions) {
    this.actions = actions == null ? FXCollections.<Action>observableArrayList() : FXCollections
            .observableArrayList(actions);
    return this;
}
 
Example 18
Source File: Datasets.java    From SONDY with GNU General Public License v3.0 4 votes vote down vote up
public Datasets(){
    list = FXCollections.observableArrayList();
}
 
Example 19
Source File: SimpleLineChart.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public SimpleLineChart() {
    sections    = FXCollections.observableArrayList();
    series      = new XYChart.Series();
    getStyleClass().setAll("canvas-chart");
}
 
Example 20
Source File: Field.java    From CPUSim with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Constructor for new Field with specified Name.
 * Other values are set to defaults.
 *
 * @param name - The name of the field.
 */
public Field(String name) {
    this(name, Type.required, 0, Relativity.absolute, FXCollections
            .observableArrayList(new ArrayList<>()), 0, true);
}