public class ToolTipContext extends Object
Constructor and Description |
---|
ToolTipContext()
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target)
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target,
com.github.weisj.darklaf.util.Alignment alignment)
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target,
com.github.weisj.darklaf.util.Alignment alignment,
com.github.weisj.darklaf.util.Alignment centerAlignment)
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target,
com.github.weisj.darklaf.util.Alignment alignment,
com.github.weisj.darklaf.util.Alignment centerAlignment,
AlignmentStrategy alignmentStrategy)
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target,
com.github.weisj.darklaf.util.Alignment alignment,
com.github.weisj.darklaf.util.Alignment centerAlignment,
AlignmentStrategy alignmentStrategy,
boolean alignInside,
Function<MouseEvent,Rectangle> toolTipRectSupplier)
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target,
com.github.weisj.darklaf.util.Alignment alignment,
com.github.weisj.darklaf.util.Alignment centerAlignment,
boolean alignInside)
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target,
com.github.weisj.darklaf.util.Alignment alignment,
AlignmentStrategy alignmentStrategy)
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target,
com.github.weisj.darklaf.util.Alignment alignment,
AlignmentStrategy alignmentStrategy,
boolean alignInside)
Create a new tooltip context to ease the creation of custom tooltips.
|
ToolTipContext(JComponent target,
com.github.weisj.darklaf.util.Alignment alignment,
boolean alignInside)
Create a new tooltip context to ease the creation of custom tooltips.
|
Modifier and Type | Method and Description |
---|---|
com.github.weisj.darklaf.util.Alignment |
getAlignment() |
AlignmentStrategy |
getAlignmentStrategy() |
com.github.weisj.darklaf.util.Alignment |
getCenterAlignment() |
static ToolTipContext |
getDefaultContext() |
Point |
getFallBackPosition() |
JComponent |
getTarget() |
JToolTip |
getToolTip()
Get the tooltip.
|
Point |
getToolTipLocation(MouseEvent event) |
Point |
getToolTipLocation(Point mp,
MouseEvent mouseEvent)
Calculates the tooltip location.
|
boolean |
isAlignInside() |
boolean |
isBestFit() |
boolean |
isIgnoreBorder() |
void |
removeToolTip() |
ToolTipContext |
setAlignInside(boolean alignInside)
Sets whether the component should be aligned inside or outside the supplied rectangle if the current alignment is
not
Alignment.CENTER . |
ToolTipContext |
setAlignment(com.github.weisj.darklaf.util.Alignment alignment)
Sets the alignment with respect to the supplied alignment rectangle.
|
ToolTipContext |
setAlignmentStrategy(AlignmentStrategy alignmentStrategy)
Set the alignment strategy which determines how the current mouse position is considered when calculating the
tooltip location.
|
ToolTipContext |
setApplyComponentInsetsToRect(boolean applyInsetsToRect)
Sets whether the insets of the component insets should be subtracted from the area returned by
setToolTipRectSupplier(Function) . |
ToolTipContext |
setCenterAlignment(com.github.weisj.darklaf.util.Alignment centerAlignment)
When
setAlignment(Alignment) is Alignment.CENTER this property will define on what side relative
to the center point the tooltip will appear. |
static void |
setDefaultContext(ToolTipContext defaultContext) |
ToolTipContext |
setFallBackPositionProvider(Function<ToolTipContext,Point> fallBackPositionProvider) |
ToolTipContext |
setHideOnExit(boolean hideOnExit)
Sets whether the tooltip should be closed if the mouse has left the area set by
setInsideArea(Area) . |
ToolTipContext |
setIgnoreBorder(boolean ignoreBorder)
Sets whether the border should be ignored when aligning outside.
|
ToolTipContext |
setInsideArea(Area insideRect)
Set the area to check if the tooltip should hide.
|
ToolTipContext |
setInsideArea(Rectangle insideRect) |
void |
setTarget(JComponent target) |
void |
setToolTip(JToolTip toolTip) |
ToolTipContext |
setToolTipInsets(Insets insets)
Sets insets for the tooltip.
|
ToolTipContext |
setToolTipRectSupplier(Function<MouseEvent,Rectangle> toolTipRectSupplier)
Set the supplier for the rectangle which is used to calculate the location of the tooltip.
|
ToolTipContext |
setToolTipStyle(ToolTipStyle style)
Set the style of the tooltip.
|
ToolTipContext |
setUpdatePosition(boolean updatePosition)
Sets whether the position should be recalculated each time after the popup has been shown.
|
ToolTipContext |
setUseBestFit(boolean bestFit)
Sets whether the tooltip should try its best to fit inside the window/screen.
|
void |
updateToolTip() |
void |
updateToolTipUI() |
public ToolTipContext()
public ToolTipContext(JComponent target)
target
- the component which the tooltip belongs to.public ToolTipContext(JComponent target, com.github.weisj.darklaf.util.Alignment alignment, com.github.weisj.darklaf.util.Alignment centerAlignment, AlignmentStrategy alignmentStrategy, boolean alignInside, Function<MouseEvent,Rectangle> toolTipRectSupplier)
target
- the component which the tooltip belongs to.alignment
- setAlignment(Alignment)
centerAlignment
- setCenterAlignment(Alignment)
alignmentStrategy
- setAlignmentStrategy(AlignmentStrategy)
alignInside
- setAlignInside(boolean)
toolTipRectSupplier
- setToolTipRectSupplier(Function)
public ToolTipContext(JComponent target, com.github.weisj.darklaf.util.Alignment alignment)
target
- the component which the tooltip belongs to.alignment
- setAlignment(Alignment)
public ToolTipContext(JComponent target, com.github.weisj.darklaf.util.Alignment alignment, com.github.weisj.darklaf.util.Alignment centerAlignment)
target
- the component which the tooltip belongs to.alignment
- setAlignment(Alignment)
centerAlignment
- setCenterAlignment(Alignment)
public ToolTipContext(JComponent target, com.github.weisj.darklaf.util.Alignment alignment, boolean alignInside)
target
- the component which the tooltip belongs to.alignment
- setAlignment(Alignment)
alignInside
- setAlignInside(boolean)
public ToolTipContext(JComponent target, com.github.weisj.darklaf.util.Alignment alignment, com.github.weisj.darklaf.util.Alignment centerAlignment, boolean alignInside)
target
- the component which the tooltip belongs to.alignment
- setAlignment(Alignment)
centerAlignment
- setCenterAlignment(Alignment)
alignInside
- setAlignInside(boolean)
public ToolTipContext(JComponent target, com.github.weisj.darklaf.util.Alignment alignment, AlignmentStrategy alignmentStrategy)
target
- the component which the tooltip belongs to.alignment
- setAlignment(Alignment)
alignmentStrategy
- setAlignmentStrategy(AlignmentStrategy)
public ToolTipContext(JComponent target, com.github.weisj.darklaf.util.Alignment alignment, com.github.weisj.darklaf.util.Alignment centerAlignment, AlignmentStrategy alignmentStrategy)
target
- the component which the tooltip belongs to.alignment
- setAlignment(Alignment)
centerAlignment
- setCenterAlignment(Alignment)
alignmentStrategy
- setAlignmentStrategy(AlignmentStrategy)
public ToolTipContext(JComponent target, com.github.weisj.darklaf.util.Alignment alignment, AlignmentStrategy alignmentStrategy, boolean alignInside)
target
- the component which the tooltip belongs to.alignment
- setAlignment(Alignment)
alignmentStrategy
- setAlignmentStrategy(AlignmentStrategy)
alignInside
- setAlignInside(boolean)
public static ToolTipContext getDefaultContext()
public static void setDefaultContext(ToolTipContext defaultContext)
public ToolTipContext setToolTipStyle(ToolTipStyle style)
style
- the tooltip style.ToolTipStyle
public ToolTipContext setUpdatePosition(boolean updatePosition)
Default is false.
updatePosition
- true if it should be recalculated.public ToolTipContext setAlignInside(boolean alignInside)
Alignment.CENTER
. Default is true
alignInside
- true if the tooltip should be aligned inside.setAlignment(Alignment)
,
setToolTipRectSupplier(Function)
public boolean isIgnoreBorder()
public boolean isBestFit()
public ToolTipContext setAlignment(com.github.weisj.darklaf.util.Alignment alignment)
Alignment.CENTER
one can
additionally supply an alignment using setCenterAlignment(Alignment)
. The tooltip will either be aligned
outside of the rectangle or inside depending on setAlignInside(boolean)
.alignment
- the alignment.setToolTipRectSupplier(Function)
public ToolTipContext setCenterAlignment(com.github.weisj.darklaf.util.Alignment centerAlignment)
setAlignment(Alignment)
is Alignment.CENTER
this property will define on what side relative
to the center point the tooltip will appear.
Default is Alignment.NORTH
.
centerAlignment
- the center alignment.public ToolTipContext setAlignmentStrategy(AlignmentStrategy alignmentStrategy)
Default will be AlignmentStrategy.COMPONENT_BOTH
.
alignmentStrategy
- the alignment strategy.AlignmentStrategy
public ToolTipContext setHideOnExit(boolean hideOnExit)
setInsideArea(Area)
.
Default is false.
hideOnExit
- true if tooltip should hide.public ToolTipContext setToolTipRectSupplier(Function<MouseEvent,Rectangle> toolTipRectSupplier)
Default will be the component bounding rectangle.
toolTipRectSupplier
- rectangle supplier method.public void updateToolTip()
public ToolTipContext setInsideArea(Area insideRect)
setHideOnExit(boolean)
is true.
Defaults to
insideRect
- the area to check.public ToolTipContext setApplyComponentInsetsToRect(boolean applyInsetsToRect)
setToolTipRectSupplier(Function)
.
Default is false.
applyInsetsToRect
- true if they should be applied.public ToolTipContext setInsideArea(Rectangle insideRect)
insideRect
- the rectangle to check.setInsideArea(Area)
public ToolTipContext setToolTipInsets(Insets insets)
insets
- the insets to set.public Point getToolTipLocation(MouseEvent event)
public ToolTipContext setIgnoreBorder(boolean ignoreBorder)
ignoreBorder
- true if border insets should be ignored.public ToolTipContext setUseBestFit(boolean bestFit)
bestFit
- true if best fit adjustments should be made.public Point getToolTipLocation(Point mp, MouseEvent mouseEvent)
mp
- the mouse position in the target component coordinate space.mouseEvent
- the mouse event.JComponent.getToolTipLocation(MouseEvent)
public JComponent getTarget()
public void setTarget(JComponent target)
public JToolTip getToolTip()
JComponent.createToolTip()
public void updateToolTipUI()
public void removeToolTip()
public com.github.weisj.darklaf.util.Alignment getAlignment()
public com.github.weisj.darklaf.util.Alignment getCenterAlignment()
public AlignmentStrategy getAlignmentStrategy()
public boolean isAlignInside()
public void setToolTip(JToolTip toolTip)
public Point getFallBackPosition()
public ToolTipContext setFallBackPositionProvider(Function<ToolTipContext,Point> fallBackPositionProvider)