public class Tooltip
extends java.lang.Object
Constructor and Description |
---|
Tooltip(processing.core.PApplet parent,
processing.core.PFont font,
float textSize,
float width)
Creates a tool tip with given parent sketch and font for displaying text.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(float ttX,
float ttY)
Draws the tooltip at the given location.
|
float |
getHeight()
Reports the height of the tooltip.
|
float |
getWidth()
Reports the width of the tooltip.
|
boolean |
isActive()
Reports whether or not this tooltip is active.
|
boolean |
isFixedWidth()
Reports whether or not this tooltip has a fixed width.
|
void |
mouseEvent(processing.event.MouseEvent e)
Responds to mouse presses in the corner of the tooltip.
|
void |
setAnchor(Direction anchorPosition)
Sets the anchor position of the tooltip.
|
void |
setBackgroundColour(int backgroundColour)
Changes the colour of background of the tooltip.
|
void |
setBorderColour(int borderColour)
Changes the colour of border drawn around the tooltip.
|
void |
setBorderWidth(float borderWidth)
Changes the width of border drawn around the tooltip.
|
void |
setIsActive(boolean isActive)
Determines whether or not this tooltip should be active or not.
|
void |
setIsCurved(boolean curve)
Determines if tip is drawn with slightly curved boundaries.
|
void |
setIsFixedWidth(boolean isFixedWidth)
Determines whether or not this tooltip should have a fixed width.
|
void |
setPointerSize(float size)
Determines the size of the pointer when the tip is drawn with
showPointer(true) . |
void |
setText(java.lang.String text)
Sets the text to be displayed in the tooltip.
|
void |
setTextColour(int textColour)
Changes the colour of text to be displayed in the tooltip.
|
void |
showCloseIcon(boolean show)
Determines if a 'close' icon should be drawn in the tooltip.
|
void |
showPointer(boolean show)
Determines whether or not a pointer drawn as part of the tip pointing towards the anchor.
|
public Tooltip(processing.core.PApplet parent, processing.core.PFont font, float textSize, float width)
parent
- Sketch in which this tooltip will be displayed.font
- Font used to display text.textSize
- Size of text in pixels.width
- Width of tooltip in pixels. Height is determined by the content of the tip.public void draw(float ttX, float ttY)
ttX
- x coordinate of location to display tooltip.ttY
- y coordinate of location to display tooltip.public void setText(java.lang.String text)
text
- Text to be displayed.public void setBorderColour(int borderColour)
borderColour
- New border colour to be drawn around the tooltip.public void setTextColour(int textColour)
textColour
- New text colour to be used by the tooltip.public void setBackgroundColour(int backgroundColour)
backgroundColour
- New background colour to be used by the tooltip.public void setBorderWidth(float borderWidth)
borderWidth
- Width of the border to be drawn around the tooltip in pixels.
Can be a fraction of a pixel.public void setIsCurved(boolean curve)
curve
- Lines drawn as curves if true.public void setPointerSize(float size)
showPointer(true)
.size
- Size of pointer in pixels.public void setAnchor(Direction anchorPosition)
Direction.WEST
will draw the tip to the right of the (x,y)
coordinates provided to draw()
.anchorPosition
- Position of the tip's anchor.public void showPointer(boolean show)
show
- Pointer is drawn if true.public void showCloseIcon(boolean show)
isActive()
will return false).show
- True if a close icon is to be drawn.public void setIsActive(boolean isActive)
isActive
- True if the tooltip is to be active, false if invisible.public boolean isActive()
setIsActive()
or it can be made inactive by the user
if the close icon is shown and the user has clicked on it. While the tooltip is inactive,
it cannot be drawn.public void setIsFixedWidth(boolean isFixedWidth)
isFixedWidth
- True if the tip width is to be fixed.public boolean isFixedWidth()
public float getWidth()
isFixedWidth()
is true or the tooltip
contains more than one line, this will be the same as the maximum width specified in the
constructor. Otherwise the width will depend on the width of the text displayed in the
tooltip.public float getHeight()
public void mouseEvent(processing.event.MouseEvent e)
e
- Mouse event.