Open homebeaver opened 1 year ago
nach cimmit 3cb9d20
kann man auf das Überschreiben der Methode getTreeCellRendererComponent
verzichten
TreeCellRenderer renderer = new JXTree.DelegatingRenderer(sv) {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
Component comp = super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
if(comp instanceof WrappingIconPanel wip) {
if(value instanceof String string) {
// default icon for Catagory, Artist/Composer
} else if(value instanceof MusicTreeModel.Song song) {
wip.setIcon(FeatheRmusic.of(SizingConstants.XS, SizingConstants.XS));
} else if(value instanceof MusicTreeModel.Album album) {
wip.setIcon(FeatheRdisc.of(SizingConstants.SMALL_ICON, SizingConstants.SMALL_ICON));
} else {
LOG.warning("value \""+value+"\" is "+value.getClass());
}
}
return comp;
}
Denn jetzt funktionieren die API-Highlighter korrekt und man kann kurz definieren:
Highlighter discIcon = new IconHighlighter(new HighlightPredicate.DepthHighlightPredicate(3),
FeatheRdisc.of(SizingConstants.SMALL_ICON, SizingConstants.SMALL_ICON));
addHighlighter(discIcon);
Highlighter musicIcon = new IconHighlighter(HighlightPredicate.IS_LEAF,
FeatheRmusic.of(SizingConstants.XS, SizingConstants.XS));
addHighlighter(musicIcon);