Class Icons

java.lang.Object
ch.autumo.ui.fx.control.Icons

public final class Icons extends Object
Icon nodes from the bundled Phosphor icon font (MIT, see fonts/Phosphor-LICENSE.txt).

Phosphor ships 1530 icons; each one is addressed by its name ("warning", "trash", "gear-six", "folder-open", …). The name/codepoint table fonts/phosphor-codepoints.properties is shipped with the font and is generated from the upstream web package, because JavaFX does not apply the font's ligatures reliably — the character code is therefore set explicitly.

Usage:

final Text icon = Icons.create("warning", 24);
if (icon != null) {
    icon.getStyleClass().add("ph-icon-warning");
    button.setGraphic(icon);
}

Missing names and any font loading failure yield null, so a missing icon never breaks a dialog or a toolbar. The base style sheet paints a plain .ph-icon in the standard text colour; the semantic classes ph-icon-info, ph-icon-warning and ph-icon-error carry the colours used by the dialog types.

  • Method Details

    • create

      public static Text create(String name)
      Create an icon node at the default size (16px).
      Parameters:
      name - icon name
      Returns:
      the icon node, or null if the name is unknown or the font cannot be loaded
    • create

      public static Text create(String name, double size)
      Create an icon node at the given size.
      Parameters:
      name - icon name
      size - font size in pixels
      Returns:
      the icon node, or null if the name is unknown or the font cannot be loaded
    • isAvailable

      public static boolean isAvailable(String name)
      Whether the given icon name is known to the bundled font.
      Parameters:
      name - icon name
      Returns:
      true if the icon can be created