Skip to content

Commit

Permalink
--wip--
Browse files Browse the repository at this point in the history
  • Loading branch information
palexdev committed May 8, 2024
1 parent 0160633 commit 08cfdf4
Show file tree
Hide file tree
Showing 43 changed files with 7,166 additions and 116 deletions.
9 changes: 6 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## General

- [ ] Replace `IntegerRage.expandRangeToSet(...)` with a class implementation that keeps track of removed indexes.
This way it is much more efficient.
- [ ] Review APIs (classes, simplify as much as possible/re-organize at least)
- [ ] Rename cells to VFXxxx (?)
- [ ] Implement paginated Grid (?)
- [ ] Implement paginated Table
- [ ] Implement paginated Table
- [ ] Review listeners in skin, in particular, allow constructs to have the same listener to save up memory
- [ ] Make table cells use a Skin (?)
- [ ] Optimize cells to update only if and invalidation occurred (?)
- [ ] Rename special EMPTY state to INVALID
- [ ] Rename absIndex/absIdx to layoutIdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ default int size() {
/**
* Specifies the number of items in the data structure.
*/
ReadOnlyIntegerProperty sizeProperty();
default ReadOnlyIntegerProperty sizeProperty() {
return itemsProperty().sizeProperty();
}

default boolean isEmpty() {
return emptyProperty().get();
Expand All @@ -46,7 +48,9 @@ default boolean isEmpty() {
/**
* Specifies whether the data set is empty.
*/
ReadOnlyBooleanProperty emptyProperty();
default ReadOnlyBooleanProperty emptyProperty() {
return itemsProperty().emptyProperty();
}

/**
* Delegate for {@link VFXListHelper#getVirtualMaxX()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* Defines the common API for every paginated virtualized container offered by VirtualizedFX. Extends {@link VFXContainer}.
*/
public interface Paginated<T> extends VFXContainer<T> {
public interface VFXPaginated<T> extends VFXContainer<T> {

default int getPage() {
return pageProperty().get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public abstract class CellBase<T> extends Control<CellBaseBehavior<T>> implement
//================================================================================
// Properties
//================================================================================
private final IntegerProperty index = new SimpleIntegerProperty();
private final IntegerProperty index = new SimpleIntegerProperty(-1);
private final ObjectProperty<T> item = new SimpleObjectProperty<>();

//================================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.github.palexdev.virtualizedfx.cells;

import io.github.palexdev.mfxcore.utils.converters.FunctionalStringConverter;
import javafx.util.StringConverter;

import java.util.function.Function;

public interface MappingTableCell<T, E> extends TableCell<T> {

Function<T, E> getExtractor();

void setExtractor(Function<T, E> extractor);

StringConverter<E> getConverter();

void setConverter(StringConverter<E> converter);

default void setConverter(Function<E, String> converter) {
setConverter(FunctionalStringConverter.to(converter));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.github.palexdev.virtualizedfx.cells;

import io.github.palexdev.virtualizedfx.table.VFXTableColumn;
import io.github.palexdev.virtualizedfx.table.VFXTableRow;

public interface TableCell<T> extends Cell<T> {

default void updateColumn(VFXTableColumn<T, ? extends TableCell<T>> column) {}

default void updateRow(VFXTableRow<T> row) {}

default void invalidate() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.palexdev.virtualizedfx.enums;

import io.github.palexdev.mfxcore.utils.EnumUtils;
import io.github.palexdev.virtualizedfx.table.VFXTable;

/**
* Enumerator to specify the layout modes for columns in {@link VFXTable}.
*/
public enum ColumnsLayoutMode {

/**
* In this mode, all columns will have the same width specified by {@link VFXTable#columnsSizeProperty()}.
*/
FIXED,

/**
* In this mode, columns are allowed to have different widths. This enables features like:
* columns auto-sizing ({@link VariableTableHelper#autosizeColumn(TableColumn)}), or resizing at runtime
* through gestures (not implemented by the default column type)
*/
VARIABLE,
;

public static ColumnsLayoutMode next(ColumnsLayoutMode mode) {
return EnumUtils.next(ColumnsLayoutMode.class, mode);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.github.palexdev.virtualizedfx.enums;

public enum GeometryChangeType {
WIDTH,
HEIGHT,
OTHER,
;
}
16 changes: 0 additions & 16 deletions src/main/java/io/github/palexdev/virtualizedfx/grid/VFXGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,22 +277,6 @@ public VFXGrid<T, C> populateCache() {
return this;
}

/**
* Delegate for {@link ListProperty#sizeProperty()}.
*/
@Override
public ReadOnlyIntegerProperty sizeProperty() {
return items.sizeProperty();
}

/**
* Delegate for {@link ListProperty#emptyProperty()}
*/
@Override
public ReadOnlyBooleanProperty emptyProperty() {
return items.emptyProperty();
}

/**
* Delegate for {@link VFXGridState#getRowsRange()}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ public int lastColumn() {
*/
@Override
public int visibleColumns() {
return (int) Math.ceil(grid.getWidth() / getTotalCellSize().getWidth());
double width = getTotalCellSize().getWidth();
return width > 0 ?
(int) Math.ceil(grid.getWidth() / width) :
0;
}

/**
Expand Down Expand Up @@ -532,7 +535,10 @@ public int lastRow() {
*/
@Override
public int visibleRows() {
return (int) Math.ceil(grid.getHeight() / getTotalCellSize().getHeight());
double height = getTotalCellSize().getHeight();
return height > 0 ?
(int) Math.ceil(grid.getHeight() / height) :
0;
}

/**
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/io/github/palexdev/virtualizedfx/list/VFXList.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,6 @@ public VFXList<T, C> populateCache() {
return this;
}

/**
* Delegate for {@link ListProperty#sizeProperty()}.
*/
@Override
public ReadOnlyIntegerProperty sizeProperty() {
return items.sizeProperty();
}

/**
* Delegate for {@link ListProperty#emptyProperty()}
*/
@Override
public ReadOnlyBooleanProperty emptyProperty() {
return items.emptyProperty();
}

/**
* Delegate for {@link VFXListState#getRange()}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ public int lastVisible() {
*/
@Override
public int visibleNum() {
return (int) Math.ceil(list.getHeight() / getTotalCellSize());
double size = getTotalCellSize();
return size > 0 ?
(int) Math.ceil(list.getHeight() / size) :
0;
}

/**
Expand Down Expand Up @@ -554,7 +557,10 @@ public int lastVisible() {
*/
@Override
public int visibleNum() {
return (int) Math.ceil(list.getWidth() / getTotalCellSize());
double size = getTotalCellSize();
return size > 0 ?
(int) Math.ceil(list.getWidth() / size) :
0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,14 @@ protected void onSpacingChanged() {
protected void moveReuseCreateAlgorithm(IntegerRange range, VFXListState<T, C> newState) {
VFXList<T, C> list = getNode();
VFXListState<T, C> current = list.getState();
ExcludingRange eRange = new ExcludingRange(range);
for (Integer index : range) {
C c = current.removeCell(index);
if (c == null) continue;
eRange.exclude(index);
newState.addCell(index, c);
ExcludingRange eRange = ExcludingRange.of(range);
if (!current.isEmpty()) {
for (Integer index : range) {
C c = current.removeCell(index);
if (c == null) continue;
eRange.exclude(index);
newState.addCell(index, c);
}
}
remainingAlgorithm(eRange, newState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import io.github.palexdev.mfxcore.controls.SkinBase;
import io.github.palexdev.mfxcore.utils.fx.PropUtils;
import io.github.palexdev.mfxcore.utils.fx.StyleUtils;
import io.github.palexdev.virtualizedfx.base.Paginated;
import io.github.palexdev.virtualizedfx.base.VFXPaginated;
import io.github.palexdev.virtualizedfx.cells.Cell;
import io.github.palexdev.virtualizedfx.list.VFXList;
import io.github.palexdev.virtualizedfx.list.VFXListHelper;
Expand Down Expand Up @@ -37,7 +37,7 @@
* Simple and naive implementation of a paginated variant of {@link VFXList}.
* The default style class is extended to: '.vfx-list.paginated'.
* <p>
* Extends {@link VFXList}, implements {@link Paginated}, has its own skin {@link VFXPaginatedListSkin} and behavior
* Extends {@link VFXList}, implements {@link VFXPaginated}, has its own skin {@link VFXPaginatedListSkin} and behavior
* {@link VFXPaginatedListSkin}.
* <p>
* A: What do you mean by naive? <p>
Expand Down Expand Up @@ -65,7 +65,7 @@
* {@link #helperFactoryProperty()} that produces helpers of type {@link VFXListHelper}, don't do that!
* You may end up with invalid states, thus a broken component.
*/
public class VFXPaginatedList<T, C extends Cell<T>> extends VFXList<T, C> implements Paginated<T> {
public class VFXPaginatedList<T, C extends Cell<T>> extends VFXList<T, C> implements VFXPaginated<T> {
//================================================================================
// Properties
//================================================================================
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.palexdev.virtualizedfx.properties;

import io.github.palexdev.virtualizedfx.table.VFXTableState;
import javafx.beans.property.ReadOnlyObjectWrapper;

/**
* Convenience property that extends {@link ReadOnlyObjectWrapper} for {@link VFXTableState}.
*/
public class VFXTableStateProperty<T> extends ReadOnlyObjectWrapper<VFXTableState<T>> {

//================================================================================
// Constructors
//================================================================================
public VFXTableStateProperty() {}

public VFXTableStateProperty(VFXTableState<T> initialValue) {
super(initialValue);
}

public VFXTableStateProperty(Object bean, String name) {
super(bean, name);
}

public VFXTableStateProperty(Object bean, String name, VFXTableState<T> initialValue) {
super(bean, name, initialValue);
}
}

0 comments on commit 08cfdf4

Please sign in to comment.