71bb329857
Additionally added Tooltips to all current items in the SettingsScene, added ReflectionUtil, changed the cursor on listcells and merged develop into this branch
37 lines
1.1 KiB
Java
37 lines
1.1 KiB
Java
package envoy.client.ui.listcell;
|
|
|
|
import java.util.function.Function;
|
|
|
|
import javafx.scene.Node;
|
|
import javafx.scene.control.ListView;
|
|
|
|
/**
|
|
* A generic list cell rendering an item using a provided render function.
|
|
* <p>
|
|
* Project: <strong>envoy-client</strong><br>
|
|
* File: <strong>GenericListCell.java</strong><br>
|
|
* Created: <strong>18.07.2020</strong><br>
|
|
*
|
|
* @author Kai S. K. Engelbart
|
|
* @param <T> the type of element displayed by the list cell
|
|
* @param <U> the type of node as which the list element will be displayed
|
|
* @since Envoy Client v0.2-beta
|
|
*/
|
|
public final class GenericListCell<T, U extends Node> extends AbstractListCell<T, U> {
|
|
|
|
private final Function<? super T, U> renderer;
|
|
|
|
/**
|
|
* @param listView the list view inside of which the cell will be displayed
|
|
* @param renderer a function converting a list item to a node
|
|
* @since Envoy Client v0.1-beta
|
|
*/
|
|
public GenericListCell(ListView<? extends T> listView, Function<? super T, U> renderer) {
|
|
super(listView);
|
|
this.renderer = renderer;
|
|
}
|
|
|
|
@Override
|
|
protected U renderItem(T item) { return renderer.apply(item); }
|
|
}
|