DirectoryCellFactory.java
package ui.directory;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.text.Font;
import javafx.util.Callback;
import libsidutils.C64FontUtils;
import java.io.InputStream;
/**
* Classify SidDump table cells for CSS styling.
*
* @author Ken Händel
*
*/
public class DirectoryCellFactory
implements Callback<TableColumn<DirectoryItem, String>, TableCell<DirectoryItem, String>> {
protected static final Font c64Font;
static {
try {
InputStream fontStream = DirectoryCellFactory.class.getResourceAsStream(C64FontUtils.FONT_NAME);
c64Font = Font.loadFont(fontStream, 10);
} catch (Exception e) {
throw new ExceptionInInitializerError(e);
}
}
@Override
public TableCell<DirectoryItem, String> call(final TableColumn<DirectoryItem, String> column) {
return new TableCell<DirectoryItem, String>() {
@Override
public void updateItem(String value, boolean empty) {
super.updateItem(value, empty);
if (!empty) {
setText(value);
} else {
setText("");
}
setFont(c64Font);
}
};
}
}