引入统一 Feather 图标系统

This commit is contained in:
张家训
2026-08-01 13:37:16 +08:00
parent 06667475b8
commit e8cf4e42ea
4 changed files with 99 additions and 0 deletions
@@ -0,0 +1,31 @@
package com.example.workutils.system.ui.icon;
import org.kordamp.ikonli.Ikon;
import org.kordamp.ikonli.feather.Feather;
public enum AppIcon {
MENU(Feather.MENU),
SETTINGS(Feather.SETTINGS),
CHEVRON_LEFT(Feather.CHEVRON_LEFT),
CHEVRON_RIGHT(Feather.CHEVRON_RIGHT),
GIT_SYNC(Feather.REFRESH_CW),
GIT_REVIEW(Feather.GIT_BRANCH),
DIFF(Feather.COLUMNS),
SQL_EXPORT(Feather.DATABASE),
MYBATIS_GENERATOR(Feather.CODE),
SCANNER(Feather.SEARCH),
API_DOC(Feather.FILE_TEXT),
EXPORT(Feather.DOWNLOAD),
CANCEL(Feather.X),
APP(Feather.TOOL);
private final Feather glyph;
AppIcon(Feather glyph) {
this.glyph = glyph;
}
public Ikon glyph() {
return glyph;
}
}
@@ -0,0 +1,25 @@
package com.example.workutils.system.ui.icon;
import org.kordamp.ikonli.javafx.FontIcon;
import java.util.Objects;
public final class IconFactory {
private static final int BUTTON_ICON_SIZE = 16;
private static final String ICON_STYLE_CLASS = "app-icon";
private IconFactory() {
}
public static FontIcon create(AppIcon icon, int size) {
FontIcon node = FontIcon.of(Objects.requireNonNull(icon, "icon must not be null").glyph(), size);
node.getStyleClass().add(ICON_STYLE_CLASS);
return node;
}
public static FontIcon createButtonIcon(AppIcon icon, String accessibleText) {
FontIcon node = create(icon, BUTTON_ICON_SIZE);
node.setAccessibleText(Objects.requireNonNull(accessibleText, "accessibleText must not be null"));
return node;
}
}