Class GuiUtils.Buttons

java.lang.Object
sc.fiji.snt.gui.GuiUtils.Buttons
Enclosing class:
GuiUtils

public static class GuiUtils.Buttons extends Object
Utility methods for creating and styling JButtons, including SNT's notification and options buttons.
  • Method Details

    • addToGroup

      public static void addToGroup(List<AbstractButton> buttons)
    • noneSelectedButtonGroup

      public static ButtonGroup noneSelectedButtonGroup()
    • ColorTableButton

      public static GuiUtils.Buttons.OptionsButton ColorTableButton(float scalingFactor, Consumer<String> colorTableAction, String selected, JMenuItem... extraItems)
      Convenience variant of ColorTableButton(float, Consumer, String[], String, JMenuItem...) using the DEFAULT_LUTS choices.
    • ColorTableButton

      public static GuiUtils.Buttons.OptionsButton ColorTableButton(float scalingFactor, Consumer<String> colorTableAction, String[] choices, String selected, JMenuItem... extraItems)
      Builds a dropdown button whose popup lists color-table choices as a mutually exclusive group. The supplied action is invoked with the chosen name whenever a selection is made; any extraItems are appended below a separator.
      Parameters:
      scalingFactor - icon scaling factor
      colorTableAction - action applied with the selected choice (may be null)
      choices - the color-table names to offer
      selected - the name to pre-check (may be null for none)
      extraItems - optional app-specific items appended after a separator
    • OptionsButton

      public static GuiUtils.Buttons.OptionsButton OptionsButton(IconFactory.GLYPH glyph, float scalingFactor, JPopupMenu menu)
    • OptionsButton

      public static GuiUtils.Buttons.OptionsButton OptionsButton(IconFactory.GLYPH glyph, Color color, float scalingFactor, JPopupMenu menu, boolean dropdownIndicator)
    • help

      public static JButton help(String url)
    • notificationCenterButton

      public static JButton notificationCenterButton(Color color, float scalingFactor)
      Creates a "notification center" bell button reflecting the (single, process-wide) pending-notices queue (see GuiUtils.Notices.queueNotice(java.lang.String, java.lang.String, java.lang.Runnable)): badged with a small corner dot whenever a notice is queued, and, on click, listing (and letting the user dismiss/act on) whatever is currently pending. Add the returned button to a toolbar/panel; icon state, badge, and popup are all wired automatically
      Returns:
      the fully wired button
    • keyboardCheatSheetButton

      public static JButton keyboardCheatSheetButton(Color color, float scalingFactor)
    • undo

      public static JButton undo()
    • undo

      public static JButton undo(Action action)
    • undo

      public static JButton undo(String tooltip)
      Convenience variant of undo() for the common "reset to default" button: builds the borderless undo-styled button and assigns it the given tooltip in one call, instead of the two-line undo()/setToolTipText(...) pair repeated across several dialogs.
      Parameters:
      tooltip - the tooltip text (may be HTML), or null for none
    • sync

      public static JButton sync(boolean borderless)
    • histogram

      public static JButton histogram()
      Small borderless icon button styled to sit next to a spinner. Used by the Curation Assistant's per-check histogram popups, but generic.
    • show

      public static JButton show(Color color)
    • delete

      public static JButton delete(Color color)
    • edit

      public static JToggleButton edit()
    • options

      public static JButton options()
    • makeBorderless

      public static void makeBorderless(AbstractButton... buttons)
    • smallButton

      public static JButton smallButton(String text)
    • makeRoundRect

      public static void makeRoundRect(AbstractButton button)
    • toolbarButton

      public static JButton toolbarButton(String badgeName)
    • toolbarButton

      public static JButton toolbarButton(Action action, String tooltipText)
    • toolbarToggleButton

      public static JToggleButton toolbarToggleButton(Action action, String tooltipText, IconFactory.GLYPH glyph1, IconFactory.GLYPH glyph2)
    • toolbarToggleButton

      public static JToggleButton toolbarToggleButton(Action action, String tooltipText, IconFactory.GLYPH glyph1, IconFactory.GLYPH glyph2, Color color)
    • toolbarButton

      public static JButton toolbarButton(IconFactory.GLYPH glyph, Color color, float scalingFactor)
    • get

      public static AbstractButton get(Container parent, String label)
    • blink

      public static void blink(AbstractButton button, int animationCycles)
      Briefly "blinks" button's icon a handful of times towards a color-inverted negative of itself/

      The negative is derived from button's own current icon (rasterized once into a BufferedImage, RGB channels inverted pixel-by-pixel, alpha left untouched). Crossfades the two directly (same technique as SplashScreen's icon transitions.

      Stops immediately, rather than running to completion, the moment button is actually clicked, and restores button's original icon either way once done.

      Parameters:
      button - the button to be 'blinked'
      animationCycles - the no. of animation cycles. Setting it to -1 applies a default.