-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base Package :sparkles: Defined public API for virtualized containers (wip) and paginated variants List Package :boom: Implemented paginated variant of VFXList :recycle: Make VFXList implement VFXContainer :recycle: VFXList: move default helper factory to separate method, so that subclasses can easily change it :recycle: VFXListHelper: do not compute the range if the width/height is 0. Also, for some reason, the binding was not invalidating when the estimatedLength was invalid, as a workaround replace it with all its dependencies :recycle: VFXListManager: do not compute a new state for a position change if the old and new ranges aren't of the same size. If that is the case, then probably another type of change has occurred and this was triggered as the result of an invalidation :recycle: VFXListManager: when the orientation changes, now the default behavior is to reset both positions :recycle: VFXListManager: rename the moveOrCreate algorithm to moveReuseCreate, it has been reworked to reuse as much as possible before creating new cells. If the old state is not empty, then those cells will be used :recycle: VFXListSkin: invoke onOrientationChanged() from the orientation listener instead Utils Package :sparkles: StateMap: add poll method Tests :recycle: Minor refactors/changes to ListTests :white_check_mark: Add tests for VFXPaginatedList :truck: Rename JMH tests class, and exclude them from the test task Signed-off-by: palexdev <alessandro.parisi406@gmail.com>
- Loading branch information
Showing
20 changed files
with
1,976 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,9 @@ java { | |
|
||
test { | ||
useJUnitPlatform() | ||
filter { | ||
excludeTestsMatching "JMH*" | ||
} | ||
} | ||
|
||
javafx { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
src/main/java/io/github/palexdev/virtualizedfx/base/Paginated.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package io.github.palexdev.virtualizedfx.base; | ||
|
||
import javafx.beans.property.IntegerProperty; | ||
import javafx.beans.property.ReadOnlyIntegerProperty; | ||
|
||
/** | ||
* Defines the common API for every paginated virtualized container offered by VirtualizedFX. Extends {@link VFXContainer}. | ||
*/ | ||
public interface Paginated extends VFXContainer { | ||
int getPage(); | ||
|
||
/** | ||
* Specifies the page at which the container is. | ||
*/ | ||
IntegerProperty pageProperty(); | ||
|
||
void setPage(int page); | ||
|
||
int getMaxPage(); | ||
|
||
/** | ||
* Specifies the maximum page index at which the container can go. | ||
*/ | ||
ReadOnlyIntegerProperty maxPageProperty(); | ||
|
||
int getCellsPerPage(); | ||
|
||
/** | ||
* Specifies the number of cells/items to show per each page. | ||
*/ | ||
IntegerProperty cellsPerPageProperty(); | ||
|
||
void setCellsPerPage(int cellsPerPage); | ||
|
||
/** | ||
* Goes to the next page if possible. | ||
*/ | ||
default void next() { | ||
setPage(getPage() + 1); | ||
} | ||
|
||
/** | ||
* Goes to the previous page if possible. | ||
*/ | ||
default void previous() { | ||
setPage(getPage() - 1); | ||
} | ||
|
||
/** | ||
* Changes the page by the given delta. | ||
*/ | ||
default void moveBy(int delta) { | ||
setPage(getPage() + delta); | ||
} | ||
|
||
/** | ||
* Given an index, returns the page at which it would be displayed by the container. | ||
* <p></p> | ||
* Note that this will never generate an exception, rather acts as follows for edge cases: | ||
* <p> - empty list or max page is 0 or index < 0: returns 0 | ||
* <p> - index > size: returns max page | ||
*/ | ||
default int findPageByIndex(int index) { | ||
if (isEmpty() || getMaxPage() == 0 || index < 0) return 0; | ||
if (index > size() - 1) return getMaxPage(); | ||
return index / getCellsPerPage(); | ||
} | ||
|
||
/** | ||
* Computes the maximum page index reachable by the container. This depends on the number of items and the number | ||
* of cells/items per page. | ||
* <p> | ||
* The exact formula is as follows: {@code Math.max(0, ((int) Math.ceil(items / (double) cpp)) - 1)} | ||
*/ | ||
default int computeMaxPage() { | ||
int items = size(); | ||
int cpp = getCellsPerPage(); | ||
return Math.max(0, ((int) Math.ceil(items / (double) cpp)) - 1); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/io/github/palexdev/virtualizedfx/base/VFXContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.github.palexdev.virtualizedfx.base; | ||
|
||
import javafx.beans.property.ReadOnlyBooleanProperty; | ||
import javafx.beans.property.ReadOnlyIntegerProperty; | ||
|
||
/** | ||
* Defines the common API for every virtualized container offered by VirtualizedFX. | ||
*/ | ||
public interface VFXContainer { | ||
// TODO maybe more methods can be added here, do it once all containers are implemented | ||
int size(); | ||
|
||
/** | ||
* Specifies the number of items in the data structure. | ||
*/ | ||
ReadOnlyIntegerProperty sizeProperty(); | ||
|
||
boolean isEmpty(); | ||
|
||
/** | ||
* Specifies whether the data set is empty. | ||
*/ | ||
ReadOnlyBooleanProperty emptyProperty(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.