1. Introduction

Fontelico is a font-based icon set, started by the Fontello project.

Griffon version: 2.3.0

2. Usage

2.1. Swing

The griffon-fontelico-swing:1.1.0 JAR provides a new Icon class: griffon.swing.support.fontelico.FontelicoIcon. You may use this class with any Swing component that supports an Icon property.

2.2. JavaFX

The griffon-fontelico-javafx:1.1.0 JAR provides a new Node class: griffon.javafx.support.fontelico.FontelicoIcon. You may use this class with any JavaFX control that accepts a graphic property. You may also use the icon directly as it is a subclass of javafx.scene.control.Label. The icon class can be used inside an FXML file too.

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.GridPane?>
<?import griffon.javafx.support.fontelico.FontelicoIcon?>

<GridPane prefHeight="60.0" prefWidth="200.0"
          xmlns:fx="http://javafx.com/fxml"
          fx:controller="org.example.AppController">
    <children>
        <Button fx:id="preferencesActionTarget"
                GridPane.columnIndex="0" GridPane.rowIndex="0"
                mnemonicParsing="false"
                prefWidth="200.0">
            <graphic>
                <FontelicoIcon fontelico="EMO_HAPPY"/>
            </graphic>
        </Button>
    </children>
</GridPane>

The JavaFX icon requires the usage of the Fontelico enum value.

2.3. Action Resources

Action icons can be set using resources files if the following format is used:

iconClassName|name:size:color

size and color are optional.

Here’s an example using the Swing icon

griffon-app/i18n/messages.properties
org.example.AppController.action.Preferences.small_icon=griffon.swing.support.fontelico.FontelicoIcon|emo-happy

The JavaFX version for the same icon value is

griffon-app/i18n/messages.properties
org.example.AppController.action.Preferences.icon=griffon.javafx.support.fontelico.FontelicoIcon|emo-happy

3. Configuration

The plugin delivers artifacts for both Swing and JavaFX. It also contains Groovy enhancements that can be used in combination with the respective UI toolkit DSL (SwingBuilder and GroovyFX).

3.1. Gradle

You have two options for configuring this plugin: automatic and manual.

3.1.1. Automatic

As long as the project has the org.codehaus.griffon.griffon plugin applied to it you may include the following snippet in build.gradle

dependencies {
    griffon 'org.codehaus.griffon.plugins:griffon-fontelico-plugin:1.1.0'
}

The griffon plugin will take care of the rest given its configuration.

3.1.2. Manual

You will need to configure any of the following blocks depending on your setup

Java + Swing
dependencies {
    compile 'org.codehaus.griffon.plugins:griffon-fontelico-swing:1.1.0'
}
Java + JavaFX
dependencies {
    compile 'org.codehaus.griffon.plugins:griffon-fontelico-javafx:1.1.0'
}
Groovy + Swing
dependencies {
    compile 'org.codehaus.griffon.plugins:griffon-fontelico-swing-groovy:1.1.0'
}
Groovy + JavaFX
dependencies {
    compile 'org.codehaus.griffon.plugins:griffon-fontelico-javafx-groovy:1.1.0'
}

3.2. Maven

First configure the griffon-fontelico-plugin BOM in your POM file, by placing the following snippet before the <build> element

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.codehaus.griffon.plugins</groupId>
            <artifactId>griffon-fontelico-plugin</artifactId>
            <version>1.1.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

Next configure dependencies as required by your particular setup

Java + Swing
<dependency>
    <groupId>org.codehaus.griffon.plugins</groupId>
    <artifactId>griffon-fontelico-swing</artifactId>
</dependency>
Java + JavaFX
<dependency>
    <groupId>org.codehaus.griffon.plugins</groupId>
    <artifactId>griffon-fontelico-javafx</artifactId>
</dependency>
Groovy + Swing
<dependency>
    <groupId>org.codehaus.griffon.plugins</groupId>
    <artifactId>griffon-fontelico-swing-groovy</artifactId>
</dependency>
Groovy + JavaFX
<dependency>
    <groupId>org.codehaus.griffon.plugins</groupId>
    <artifactId>griffon-fontelico-javafx-groovy</artifactId>
</dependency>

4. Modules

The following sections display all bindings per module. Use this information to successfully override a binding on your own modules or to troubleshoot a module binding if the wrong type has been applied by the Griffon runtime.

4.1. JavaFX

Module name: fontelico-javafx-groovy

Depends on: javafx-groovy

bind(BuilderCustomizer.class)
    .to(FontelicoJavaFXBuilderCustomizer.class)
    .asSingleton();

The following nodes will become available on a Groovy View

Node Type

fontelicoIcon

griffon.javafx.support.fontelico.FontelicoIcon

4.2. Swing

Module name: fontelico-swing-groovy

Depends on: swing-groovy

bind(BuilderCustomizer.class)
    .to(FontelicoSwingBuilderCustomizer.class)
    .asSingleton();

The following nodes will become available on a Groovy View

Node Type

fontelicoIcon

griffon.swing.support.fontelico.FontelicoIcon

6. Icon Cheat Sheet

The following tables show all available icons.

Enum Name Icon

EMO_HAPPY

emo-happy

EMO_WINK

emo-wink

EMO_WINK2

emo-wink2

EMO_UNHAPPY

emo-unhappy

EMO_SLEEP

emo-sleep

EMO_THUMBSUP

emo-thumbsup

EMO_DEVIL

emo-devil

EMO_SURPRISED

emo-surprised

EMO_TONGUE

emo-tongue

EMO_COFFEE

emo-coffee

EMO_SUNGLASSES

emo-sunglasses

EMO_DISPLEASED

emo-displeased

EMO_BEER

emo-beer

EMO_GRIN

emo-grin

EMO_ANGRY

emo-angry

EMO_SAINT

emo-saint

EMO_CRY

emo-cry

EMO_SHOOT

emo-shoot

EMO_SQUINT

emo-squint

EMO_LAUGH

emo-laugh

SPIN1

spin1

SPIN2

spin2

SPIN3

spin3

SPIN4

spin4

SPIN5

spin5

SPIN6

spin6

FIREFOX

firefox

CHROME

chrome

OPERA

opera

IE

ie

CROWN

crown

CROWN_PLUS

crown-plus

CROWN_MINUS

crown-minus

MARQUEE

marquee