Class IrisGuiUtil

java.lang.Object
com.illumon.iris.gui.util.IrisGuiUtil

public class IrisGuiUtil
extends Object
Contains some static helper methods to create and manipulate GUI objects.
  • Field Details

  • Constructor Details

  • Method Details

    • getDefaultDialogIcon

      public static Image getDefaultDialogIcon()
    • refreshAllWindows

      public static void refreshAllWindows()
    • showInputAreaDialog

      public static String showInputAreaDialog​(Component parentComponent, String message, String initialSelectionValue)
    • setViewTabTempColor

      public static void setViewTabTempColor​(Component com, Color color, boolean tempColorPropagates)
      Sets the temp color of this view. colors "trickle up" so all ancestor windows will also get this color
      Parameters:
      com - the component that is the child of a colorable tab
      color - the color to set
    • setViewTabAlertColor

      public static void setViewTabAlertColor​(Component com, Color color, boolean alertColorPropagates)
      Sets the alert color of this view. Alerts will "trickle up" so any ancestor will also get the alert color applied
      Parameters:
      com - the component causing the alert
      color - the color of the alert
    • clearAlertTabColor

      public static void clearAlertTabColor​(Component com)
      Clears the alert color with colored child checking
      Parameters:
      com - the component whose ancestor will be colored
    • setTabColor

      public static void setTabColor​(com.illumon.infonode.docking.DockingWindow dw, Color normalColor, Color highlightColor)
      Sets the raw value of the color without checking for any previous color
      Parameters:
      dw - the docking window to be colored
      normalColor - the normal color to be set
      highlightColor - the highlight color to be set
    • getViewTitle

      public static String getViewTitle​(Component com)
    • makeUniqueItem

      public static <V extends com.fishlib.base.stats.Value> com.fishlib.base.stats.Item<V> makeUniqueItem​(String groupName, String itemName, com.fishlib.base.Function.Unary<V,​Long> valueFactory, String description)
    • isNumber

      public static boolean isNumber​(Class type)
    • centerOnScreen

      public static void centerOnScreen​(Window win)
    • getView

      public static com.illumon.infonode.docking.View getView​(Component com)
    • wrap

      public static JPanel wrap​(Object... obj)
    • wrap

      public static JPanel wrap​(Object obj)
    • wrapBorder

      public static JPanel wrapBorder​(@Nullable Object north, @Nullable Object south, @Nullable Object west, @Nullable Object east, @Nullable Object center)
    • wrapBox

      public static JPanel wrapBox​(int axis, Object... obj)
    • centerWrap

      public static JPanel centerWrap​(JComponent com)
    • getTabWindow

      public static com.illumon.infonode.docking.TabWindow getTabWindow​(com.illumon.infonode.docking.DockingWindow window)
    • restoreAllViews

      public static void restoreAllViews​(com.illumon.infonode.docking.RootWindow rootWindow, com.illumon.infonode.docking.util.StringViewMap viewMap, List excludeList)
    • restore

      public static void restore​(com.illumon.infonode.docking.RootWindow rootWindow, com.illumon.infonode.docking.View view)
    • restore

      public static void restore​(com.illumon.infonode.docking.RootWindow rootWindow, com.illumon.infonode.docking.util.StringViewMap viewMap, String viewName)
    • findView

      public static com.illumon.infonode.docking.DockingWindow findView​(com.illumon.infonode.docking.DockingWindow window, String name)
    • countViews

      public static int countViews​(com.illumon.infonode.docking.DockingWindow window)
    • initPropsAndLogs

      public static void initPropsAndLogs​(String appName)
    • makeScrollableTextArea

      public static JScrollPane makeScrollableTextArea​(String message, @Nullable Dimension dim)
      Create a scrollable, non-editable text area with the given message.
      Parameters:
      message - message to display in the text box
      dim - optional preferred size for the text area
      Returns:
      JScrollPane containing a text area
    • showTextAreaDialog

      public static void showTextAreaDialog​(Component parent, String title, String value)
      Create a scrollable, non-editable text area within dialog.
      Parameters:
      parent - parent component for the dialog
      title - title of the dialog
      value - message to display in the text box
    • editableTextAreaDialog

      public static void editableTextAreaDialog​(Component parent, String title, String value, Consumer<String> onOk)
      Create an editable text area within dialog, returning the text on OK.
      Parameters:
      parent - parent component for the dialog
      title - title of the dialog
      value - message to display in the text box
    • editableTextAreaDialog

      public static void editableTextAreaDialog​(Component parent, String title, String value, Consumer<String> onOk, Dialog.ModalityType modalityType)
      Create an editable text area within dialog, returning the text on OK.
      Parameters:
      parent - parent component for the dialog
      title - title of the dialog
      value - message to display in the text box
    • textAreaDialog

      public static void textAreaDialog​(boolean editable, Component parent, String title, String value, @NotNull Consumer<String> onOk, Dialog.ModalityType modalityType)
      Create an editable text area within dialog, returning the text on OK.
      Parameters:
      parent - parent component for the dialog
      title - title of the dialog
      value - message to display in the text box
      modalityType - the modality type for the dialog
    • getScrollableTextArea

      @NotNull public static JScrollPane getScrollableTextArea​(String value)
    • getScrollableTextArea

      @NotNull public static com.fishlib.base.Pair<JScrollPane,​JTextArea> getScrollableTextArea​(String value, boolean editable)
    • addCopyPasteMenu

      public static void addCopyPasteMenu​(JPopupMenu menu, JTextArea textArea)
      Given a textarea, add a Copy/Cut/Paste menu to the passed in menu.
      Parameters:
      menu - the popup menu that we'll add our components to
      textArea - the textArea that we'll be modifying
    • createEmptyDialog

      public static com.fishlib.base.Pair<JFrame,​JPanel> createEmptyDialog​(Component parent, String title)
      Create an empty dialog, with a JPanel that we can put stuff in.
      Parameters:
      parent - parent component for the dialog
      title - title of the dialog
    • addDocumentChangeCallback

      public static void addDocumentChangeCallback​(JTextComponent textComponent, Runnable runnable)
    • addDocumentChangeCallback

      public static void addDocumentChangeCallback​(Document document, Runnable runnable)
    • lookupColorString

      public static Color lookupColorString​(String colorString)
    • lookupColorString

      public static Color lookupColorString​(String colorString, UIDefaults uiDefaults)
    • scale

      public static Color scale​(float v, Color c)
    • adjustAlpha

      public static Color adjustAlpha​(int a, Color c)
    • bindCheckboxToTextComponent

      public static void bindCheckboxToTextComponent​(JTextComponent textComponent, JCheckBox checkBox)
    • setSplitLocation

      public static void setSplitLocation​(JSplitPane pane, double percentPosition)

      Set the location of a JSplitPane divider.

      This method handles the fact that JSplitPane.setDividerLocation(double) is a lie if the view has not been completely drawn yet. We need to wait for the window to be resized to _both_ it's internal sizes before we call setDividerLocation, otherwise the divider will not move to where it's supposed to.

      Parameters:
      pane - The pane to set the divider for
      percentPosition - The position of the divider
    • getDockingWindow

      public static com.illumon.infonode.docking.DockingWindow getDockingWindow​(Component startComponent)
    • addMutualExclusionRadioButton

      public static void addMutualExclusionRadioButton​(JRadioButton radioButton, List<JComponent> enableComponents, List<JComponent> disableComponents)
    • getErrorReporter

      public static ErrorReporter getErrorReporter()
      Get the global ErrorReporter for reporting unexpected errors to the user.
      Returns:
      the error reporter.
    • setErrorReporter

      public static void setErrorReporter​(@NotNull ErrorReporter reporter)
      Set the global ErrorReporter for reporting unexpected errors to the user.
      Parameters:
      reporter - the reporter to use