aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java
diff options
context:
space:
mode:
authorSven Göthel <sgothel@jausoft.com>2024-01-07 21:27:18 +0100
committerSven Göthel <sgothel@jausoft.com>2024-01-07 21:27:18 +0100
commit6dbd73108ec0b2f829674c07771c232395034157 (patch)
treef6d8083e5384f4b80785a03f6d30d9e061a2af76 /src/graphui/classes/com/jogamp/graph/ui/Tooltip.java
parentc2452b211dc3f347dbffaac4e6c35b3c3e8c6d65 (diff)
GraphUI Tooltip: Simplify integration w/ Scene + Shape; Use Shape.setToolTip(Tooltip) for generic usage; Add TooltipText colors.
Shape also takes care of setting Tooltip's tool-Shape (itself), simplifying Tooltip ctor and having it more independent from Scene/Shape. Tooltip also drop Scene reference, as it shall be passed from Scene caller at Tooltip.createTip(..)
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/Tooltip.java')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Tooltip.java36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java b/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java
index 88cfeac99..b8e2467fe 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Tooltip.java
@@ -30,30 +30,37 @@ package com.jogamp.graph.ui;
import com.jogamp.common.os.Clock;
import com.jogamp.math.util.PMVMatrix4f;
-/** A HUD tooltip for {@link Shape}, see {@link Shape#setToolTip(CharSequence, com.jogamp.graph.font.Font, float, Scene)}. */
+/** A HUD tooltip for {@link Shape}, see {@link Shape#setToolTip(Tooltip)}. */
public abstract class Tooltip {
- /** Shape belonging to this tooltip's tool. */
- protected final Shape tool;
- protected final long delayMS;
- protected final Scene scene;
+ /** Default tooltip delay is {@value}ms */
+ public static final long DEFAULT_DELAY = 1000;
+
+ private final long delayMS;
/** Delay t1, time to show tooltip, i.e. t0 + delayMS */
- protected volatile long delayT1;
+ private volatile long delayT1;
+ /** Shape 'tool' owning this tooltip. */
+ private Shape tool;
- protected Tooltip(final Shape tool, final long delayMS, final Scene scene) {
- this.tool = tool;
+ protected Tooltip(final long delayMS) {
this.delayMS = delayMS;
- this.scene = scene;
this.delayT1 = 0;
+ this.tool = null;
+ }
+ /* pp */ final void setToolOwner(final Shape owner) { tool = owner; }
+
+ /** Returns {@link Shape} 'tool' owning this tooltip, set after {@link Shape#setToolTip(Tooltip)}. */
+ public final Shape getTool() {
+ return tool;
}
/** Stops the timer. */
- public void stop() {
+ public final void stop() {
this.delayT1 = 0;
}
/** Starts the timer. */
- public void start() {
+ public final void start() {
this.delayT1 = Clock.currentMillis() + delayMS;
}
@@ -61,7 +68,7 @@ public abstract class Tooltip {
* Send tick to this tooltip
* @return true if timer has been reached to {@link #createTip(PMVMatrix4f)}, otherwise false
*/
- public boolean tick() {
+ public final boolean tick() {
if( 0 == delayT1 ) {
return false;
}
@@ -73,10 +80,11 @@ public abstract class Tooltip {
}
/**
- * Create a new HUD tip shape
+ * Create a new HUD tip shape, usually called by {@link Scene}
+ * @param scene the {@link Scene} caller for which this HUD tip shape is created
* @param pmv {@link PMVMatrix4f}, which shall be properly initialized, e.g. via {@link Scene#setupMatrix(PMVMatrix4f)}
* @return newly created HUD tip shape
*/
- public abstract GraphShape createTip(final PMVMatrix4f pmv);
+ public abstract Shape createTip(final Scene scene, final PMVMatrix4f pmv);
} \ No newline at end of file