Add Fontawesome Icon support

This commit is contained in:
Christoph Atteneder 2018-03-27 17:28:46 +02:00
parent ee7c79fe6a
commit 50239b69bc
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
2 changed files with 17 additions and 0 deletions

View file

@ -43,6 +43,7 @@ dependencies {
compile 'de.jensd:fontawesomefx:8.0.0'
compile 'de.jensd:fontawesomefx-commons:8.15'
compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4'
compile 'de.jensd:fontawesomefx-fontawesome:4.7.0-5'
compile 'com.googlecode.jcsv:jcsv:1.4.0'
compileOnly 'org.projectlombok:lombok:1.16.16'
annotationProcessor 'org.projectlombok:lombok:1.16.16'

View file

@ -78,11 +78,13 @@ import org.slf4j.LoggerFactory;
import de.jensd.fx.glyphs.GlyphIcons;
import de.jensd.fx.glyphs.fontawesome.utils.FontAwesomeIconFactory;
import de.jensd.fx.glyphs.materialdesignicons.utils.MaterialDesignIconFactory;
public class FormBuilder {
private static final Logger log = LoggerFactory.getLogger(FormBuilder.class);
public static final String MATERIAL_DESIGN_ICONS = "'Material Design Icons'";
public static final String FONTAWESOME_ICONS = "FontAwesome";
///////////////////////////////////////////////////////////////////////////////////////////
@ -1209,6 +1211,20 @@ public class FormBuilder {
return getIconForLabel(icon, "0.769em", label);
}
public static Text getIcon(GlyphIcons icon) {
Text textIcon;
if (icon.fontFamily().equals(MATERIAL_DESIGN_ICONS)) {
textIcon = MaterialDesignIconFactory.get().createIcon(icon);
} else if (icon.fontFamily().equals(FONTAWESOME_ICONS)) {
textIcon = FontAwesomeIconFactory.get().createIcon(icon);
} else {
throw new IllegalArgumentException("Not supported icon type");
}
return textIcon;
}
public static Button getIconButton(GlyphIcons icon) {
if (icon.fontFamily().equals(MATERIAL_DESIGN_ICONS)) {
final Button textIcon = MaterialDesignIconFactory.get().createIconButton(icon, "","2em", null, ContentDisplay.CENTER);