![JAR search and dependency download from the Maven repository](/logo.png)
de.gsi.chart.utils.GlyphFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chartfx-chart Show documentation
Show all versions of chartfx-chart Show documentation
This charting library ${project.artifactId}- is an extension
in the spirit of Oracle's XYChart and performance/time-proven JDataViewer charting functionalities.
Emphasis was put on plotting performance for both large number of data points and real-time displays,
as well as scientific accuracies leading to error bar/surface plots, and other scientific plotting
features (parameter measurements, fitting, multiple axes, zoom, ...).
/**
* Copyright (c) 2017 European Organisation for Nuclear Research (CERN), All Rights Reserved.
*/
package de.gsi.chart.utils;
import java.io.IOException;
import java.io.InputStream;
import org.controlsfx.glyphfont.FontAwesome;
import org.controlsfx.glyphfont.Glyph;
import org.controlsfx.glyphfont.GlyphFont;
import org.controlsfx.glyphfont.GlyphFontRegistry;
/**
* Factory class for glyphs from Fontawesome library.
* Usage example:
*
*
* Glyph g = GlyphFactory.create(FontAwesome.Glyph.CLOSE);
* g.setTextFill(Color.RED);
* Button button = new Button("", g);
*
*
* @author Luca Molinari
*/
public final class GlyphFactory { // NOPMD nomen est fix
private static GlyphFont fontAwesome;
private GlyphFactory() {
}
static {
try (InputStream is = GlyphFactory.class.getResourceAsStream("FONT_AWESOME-webfont")) {
GlyphFactory.fontAwesome = new FontAwesome(is);
GlyphFontRegistry.register(GlyphFactory.fontAwesome);
} catch (final IOException e) {
e.printStackTrace();
}
}
/**
* Creates a glyph for given identifier
*
* @param icon one of the font code available in {@link FontAwesome} Glyph enum.
* @return created glyph
*/
public static synchronized Glyph create(final FontAwesome.Glyph icon) {
if (GlyphFactory.fontAwesome == null) {
try (InputStream is = GlyphFactory.class.getResourceAsStream("FONT_AWESOME-webfont")) {
GlyphFactory.fontAwesome = new FontAwesome(is);
GlyphFontRegistry.register(GlyphFactory.fontAwesome);
} catch (final IOException e) {
e.printStackTrace();
}
}
return GlyphFactory.fontAwesome.create(icon);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy