https://github.com/ben12/infxnity
JavaFX "to infinity and beyond"
https://github.com/ben12/infxnity
binding java java-8 java8 javafx javafx-8 javafx-library mask maskededittext maskedinput maskedtextfield textfield-mask
Last synced: 4 months ago
JSON representation
JavaFX "to infinity and beyond"
- Host: GitHub
- URL: https://github.com/ben12/infxnity
- Owner: ben12
- License: mit
- Created: 2017-10-21T18:02:23.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-09-30T19:09:38.000Z (over 2 years ago)
- Last Synced: 2025-01-21T00:50:12.663Z (over 1 year ago)
- Topics: binding, java, java-8, java8, javafx, javafx-8, javafx-library, mask, maskededittext, maskedinput, maskedtextfield, textfield-mask
- Language: Java
- Homepage: https://infxnity.ben12.eu
- Size: 578 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# infxnity
JavaFX "to infinity and beyond"
[](https://github.com/ben12/infxnity/blob/master/LICENSE)
[](https://travis-ci.org/ben12/infxnity)
[](https://sonarcloud.io/dashboard?id=ben12_infxnity)
[](https://sonarcloud.io/dashboard?id=ben12_infxnity)
[](https://sonarcloud.io/dashboard?id=ben12_infxnity)
[](https://sonarcloud.io/dashboard?id=ben12_infxnity)
## Features
### [MaskTextFilter](http://infxnity.ben12.eu/apidocs/com/ben12/infxnity/control/text/MaskTextFilter.html)
Example to create a [`TextField`](https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TextField.html) allowing only french phone numbers:
```java
final TextField textField = new TextField();
final MaskCharacter[] mask = MaskBuilder.newBuilder()
.appendLiteral("+33 ")
.appendDigit('6')
.appendLiteral(" ")
.appendDigit(2)
.appendLiteral(" ")
.appendDigit(2)
.appendLiteral(" ")
.appendDigit(2)
.appendLiteral(" ")
.appendDigit(2)
.build();
textField.setTextFormatter(new TextFormatter<>(new MaskTextFilter(textField, false, mask)));
```
Default text will be "+33 6 00 00 00 00".
Caret will be placed in 4th position : "+33 |6 00 00 00 00".
Navigate to the right will do that:
"+33 6 |00 00 00 00"
"+33 6 0|0 00 00 00"
"+33 6 00 |00 00 00"
"+33 6 00 0|0 00 00"
"+33 6 00 00 |00 00"
"+33 6 00 00 0|0 00"
"+33 6 00 00 00 |00"
"+33 6 00 00 00 0|0"
"+33 6 00 00 00 00|"
### [ObservableListAggregation](http://infxnity.ben12.eu/apidocs/com/ben12/infxnity/collections/ObservableListAggregation.html)
An [`ObservableList`](https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableList.html)(s) aggregation.
All events of aggregated [`ObservableList`](https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableList.html)(s) are forwarded.
The list of aggregated [`ObservableList`](https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableList.html)(s) can be modified to add, remove or replace one or more of the aggregated [`ObservableList`](https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableList.html)(s). An appropriate event will be fired.
An instance of [`ObservableListAggregation`](http://infxnity.ben12.eu/apidocs/com/ben12/infxnity/collections/ObservableListAggregation.html) is a read only list. Any attempt to modify the list will throw an [`UnsupportedOperationException`](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html).
Example:
```java
final ObservableList list1 = FXCollections.observableArrayList(0, 1, 2);
final ObservableList list2 = FXCollections.observableArrayList(3, 4);
final ObservableList list3 = FXCollections.observableArrayList(5, 6);
final ObservableListAggregation aggregation = new ObservableListAggregation<>(list1, list2);
System.out.println(aggregation); // [0, 1, 2, 3, 4]
aggregation.getLists().add(list3);
System.out.println(aggregation); // [0, 1, 2, 3, 4, 5, 6]
list1.add(0, -1);
System.out.println(aggregation); // [-1, 0, 1, 2, 3, 4, 5, 6]
list3.remove(Integer.valueOf(6));
System.out.println(aggregation); // [-1, 0, 1, 2, 3, 4, 5]
aggregation.getLists().remove(list1);
System.out.println(aggregation); // [3, 4, 5]
```
### [IFXContentBinding](http://infxnity.ben12.eu/apidocs/com/ben12/infxnity/binding/IFXContentBinding.html)
Used to bind a list to an [`ObservableList`](https://docs.oracle.com/javase/8/javafx/api/javafx/collections/ObservableList.html) with a type conversion.
Example:
```java
ObservableList personList = FXCollections.observableArrayList(person -> new Observable[] { person.nameProperty() });
ObservableList personNameList = FXCollections.observableArrayList();
IFXContentBinding.bind(personNameList, personList, Person::getName);
System.out.println(personNameList); // []
personList.add(new Person("Bob"));
System.out.println(personNameList); // [Bob]
personList.addAll(new Person("Fred"), new Person("John"));
System.out.println(personNameList); // [Bob, Fred, John]
personList.get(0).setName("George");
System.out.println(personNameList); // [George, Fred, John]
```