Class ToolTipWrapUtil

java.lang.Object
com.illumon.iris.console.events.ToolTipWrapUtil

public class ToolTipWrapUtil extends Object
Utility class to wrap text for multi-line tooltips.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    wrapTip(String value, int actualCellWidth, double preferredTextWidth)
    Returns the appropriate HTML to display a preview of value in a tooltip, if value is multiline text or is too big to display in the cell that contains it.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ToolTipWrapUtil

      public ToolTipWrapUtil()
  • Method Details

    • wrapTip

      public static String wrapTip(String value, int actualCellWidth, double preferredTextWidth)
      Returns the appropriate HTML to display a preview of value in a tooltip, if value is multiline text or is too big to display in the cell that contains it. The tooltip will only display up to MAX_TOOLTIP_LINES of text; if more lines would be required to display the text in its entirety, then the last line will read: "<Truncated N more lines>", where N is the number of lines omitted from the tooltip.

      This function will automatically wrap text by sequentially appending words from value to a StringBuilder, inserting newlines before appending any word that would make the current line contain more than than MAX_TOOLTIP_COLS. However, it will not automatically wrap text when doing so would produce a line containing fewer than 0.10 * MAX_TOOLTIP_COLS.

      If the original text contained newlines, then each automatically-inserted newline will be followed by an arrow character. The arrow character '↳' is unicode U+21b3.

      If an individual word is longer than MAX_TOOLTIP_COLS, it will be placed on its own line. Text will only be wrapped at whitespace; never in the middle of a word.

      If value does not require a tooltip (meaning that it does not contains newlines, or that actualCellWidth >= preferredTextWidth), then this method simply returns null.

      Parameters:
      value - The value or
      actualCellWidth - The current width of the cell value is displayed in.
      preferredTextWidth - The preferred width of the cell value is displayed in. This is how wide the cell would have to be to fit the text of value in its entirety.
      Returns:
      HTML to display the first MAX_TOOLTIP_LINES of value, if it contains newlines or is too big to fit in its cell. Otherwise, null.