public class TooltipManagerImpl extends java.lang.Object implements TooltipManager
AbstractLabel
is moved/resized to
display a tooltip text for an "active" GUI element.Modifier and Type | Field and Description |
---|---|
private GUIElement |
activeGuiElement
The last known active gui element.
|
private java.lang.Object |
activeGuiElementSync
Synchronizes accesses to
activeGuiElement . |
private java.lang.Runnable |
resetRunnable
The
Runnable that implements the functionality of reset() . |
private AbstractLabel |
tooltip
The tooltip label.
|
private static int |
TOOLTIP_DISTANCE
Distance of tooltip from its associated GUI element.
|
private java.util.Map<GUIElement,TooltipText> |
tooltipTexts
Maps
GUIElement to associated TooltipText . |
private int |
windowHeight
The current window height.
|
private int |
windowWidth
The current window width.
|
Constructor and Description |
---|
TooltipManagerImpl() |
Modifier and Type | Method and Description |
---|---|
private void |
addTooltip()
Adds or updates the tooltip (text and location) for the
activeGuiElement . |
boolean |
hasTooltipText(AbstractGUIElement element)
Returns whether the tooltip is enabled.
|
private void |
removeTooltip()
Removes the tooltip label.
|
void |
reset()
Removes the tooltip.
|
void |
setElement(GUIElement guiElement)
Displays the tooltip for a GUI element.
|
void |
setScreenSize(int windowWidth,
int windowHeight)
Updates the current window size.
|
void |
setTooltip(AbstractLabel tooltip)
Sets the tooltip label.
|
void |
setTooltipText(AbstractGUIElement element,
java.lang.String tooltipText)
Updates the tooltip text of a GUI element.
|
void |
setTooltipText(GUIElement element,
java.lang.String tooltipText,
int x,
int y,
int w,
int h)
Updates the tooltip text of a GUI element.
|
void |
unsetElement(GUIElement guiElement)
Removes the tooltip of a GUI element.
|
@Nullable private GUIElement activeGuiElement
@NotNull private final java.lang.Object activeGuiElementSync
activeGuiElement
.@NotNull private final java.lang.Runnable resetRunnable
Runnable
that implements the functionality of reset()
.@Nullable private AbstractLabel tooltip
null
if the skin does not use
tooltips.private static final int TOOLTIP_DISTANCE
@NotNull private final java.util.Map<GUIElement,TooltipText> tooltipTexts
GUIElement
to associated TooltipText
. The tooltip
text is shown when the mouse is inside this element. May be null
to show no tooltip.private int windowHeight
private int windowWidth
private void addTooltip()
activeGuiElement
.public boolean hasTooltipText(AbstractGUIElement element)
hasTooltipText
in interface TooltipManager
element
- the element to checkprivate void removeTooltip()
public void reset()
public void setElement(@NotNull GUIElement guiElement)
setElement
in interface TooltipManager
guiElement
- the GUI element to show the tooltip ofpublic void setScreenSize(int windowWidth, int windowHeight)
windowWidth
- the window widthwindowHeight
- the window heightpublic void setTooltip(@Nullable AbstractLabel tooltip)
tooltip
- the tooltip label, or null
public void setTooltipText(@NotNull AbstractGUIElement element, @Nullable java.lang.String tooltipText)
setTooltipText
in interface TooltipManager
element
- the GUI elementtooltipText
- the next tooltip textpublic void setTooltipText(@NotNull GUIElement element, @Nullable java.lang.String tooltipText, int x, int y, int w, int h)
setTooltipText
in interface TooltipManager
element
- the GUI element to processtooltipText
- the text to display in the tooltipx
- the x coordinate of the tooltipy
- the y coordinate of the tooltipw
- the width of the tooltiph
- the height of the tooltippublic void unsetElement(@NotNull GUIElement guiElement)
unsetElement
in interface TooltipManager
guiElement
- the gui element to remove the tooltip of