Class KTooltip

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class KTooltip
    extends java.lang.Object
    implements java.lang.Cloneable
    KTooltip is the invariant data holder for a TooltipProp.
    Author:
    Christopher Mindus
    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      static intABOVE
      The location: ABOVE (=8).
      static intAFTER
      The location: AFTER (=6).
      static intBEFORE
      The location: BEFORE (=4).
      static intBELOW
      The location: ABOVE (=2).
      intcategory
      The message category if this applies, -1 for none, 0=informational, 1=warning, 2=error.
      static int[]EMPTY
      The "none" locations.
      intlocations
      The locations as an integer that needs packing up using getLocations(), zero for none.
      intshowDelay
      The show delay in milliseconds, 400 as default, values 0-9999 are allowed.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      KTooltip​(KString text)
      Creates a tooltip with a default location, category "none" and showDelay 400 ms.
      KTooltip​(KString text, int category)
      Creates a tooltip for a message with a default location and showDelay 400 ms.
      KTooltip​(KString text, int showDelay, int... locations)
      Creates a tooltip with category "none".
      KTooltip​(KString text, int showDelay, int category, int... locations)
      Creates a tooltip for a message.
      KTooltip​(KString text, KTooltip prev)
      Creates a tooltip with specified text and settings from another tooltip instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      KTooltipclone()
      Clones the tooltip.
      voiddispose()
      Disposes of the tooltip when no longer needed.
      booleanequals​(java.lang.Object o)
      Checks if two tooltips are equal.
      booleanequalsOmitReferenceRefreshCheck​(KTooltip tooltip)
      Checks for pure equality between two KTooltip's, excluding KString reference refresh counter checking but including potential original source string.
      protected voidfinalize()
      Called when the tooltip is being garbage collected.
      int[]getLocations()
      Gets the locations.
      KStringgetText()
      Gets the text.
      java.lang.StringtoString()
      Creates a string representation for textual output.
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • EMPTY

        public static final int[] EMPTY
        The "none" locations.
      • category

        public final int category
        The message category if this applies, -1 for none, 0=informational, 1=warning, 2=error.
      • showDelay

        public final int showDelay
        The show delay in milliseconds, 400 as default, values 0-9999 are allowed.
      • locations

        public final int locations
        The locations as an integer that needs packing up using getLocations(), zero for none.
    • Constructor Detail

      • KTooltip

        public KTooltip​(KString text)
        Creates a tooltip with a default location, category "none" and showDelay 400 ms.
        Parameters:
        text - The KString text for the tooltip.
        Throws:
        java.lang.NullPointerException - if text is null.
      • KTooltip

        public KTooltip​(KString text,
                        KTooltip prev)
        Creates a tooltip with specified text and settings from another tooltip instance.
        Parameters:
        text - The KString text for the tooltip.
        prev - The previous instance for settings.
        Throws:
        java.lang.NullPointerException - if text is null.
      • KTooltip

        public KTooltip​(KString text,
                        int showDelay,
                        int... locations)
        Creates a tooltip with category "none".
        Parameters:
        text - The KString text for the tooltip.
        showDelay - The show delay in milliseconds (0-9999, -1 for default 400 ms).
        locations - List of locations in priority order, max 4.
        Throws:
        java.lang.NullPointerException - if text is null.
      • KTooltip

        public KTooltip​(KString text,
                        int category)
        Creates a tooltip for a message with a default location and showDelay 400 ms.
        Parameters:
        text - The KString text for the tooltip.
        category - The message category if this applies, -1 for none, 0=informational, 1=warning, 2=error.
        Throws:
        java.lang.NullPointerException - if text is null.
      • KTooltip

        public KTooltip​(KString text,
                        int showDelay,
                        int category,
                        int... locations)
        Creates a tooltip for a message.
        Parameters:
        text - The KString text for the tooltip.
        showDelay - The show delay in milliseconds (0-9999).
        category - The message category if this applies, -1 for none, 0=informational, 1=warning, 2=error.
        locations - List of locations in priority order, max 4.
        Throws:
        java.lang.NullPointerException - if text is null.
    • Method Detail

      • getText

        public KString getText()
        Gets the text.
        Returns:
        The KString text.
      • clone

        public KTooltip clone()
        Clones the tooltip.
        Overrides:
        clone in class java.lang.Object
        Returns:
        A cloned tooltip.
      • dispose

        public void dispose()
        Disposes of the tooltip when no longer needed. This method is required for KString text.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Called when the tooltip is being garbage collected.

        The KString will be disposed if not previously disposed of.

        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • getLocations

        public int[] getLocations()
        Gets the locations.
        Returns:
        A location list of integers, maximum 4 with values 2, 4, 6 or 8 in order of importance.
      • equals

        public boolean equals​(java.lang.Object o)
        Checks if two tooltips are equal.
        Overrides:
        equals in class java.lang.Object
      • equalsOmitReferenceRefreshCheck

        public boolean equalsOmitReferenceRefreshCheck​(KTooltip tooltip)
        Checks for pure equality between two KTooltip's, excluding KString reference refresh counter checking but including potential original source string.

        This method is used when comparing values for e.g. save file.

        Parameters:
        tooltip - Another KTooltip, perhaps null.
        Returns:
        true if equal, false otherwise.
      • toString

        public java.lang.String toString()
        Creates a string representation for textual output.
        Overrides:
        toString in class java.lang.Object
        Returns:
        A string formatted for debug output or logging.