controlP5
Class Tooltip

java.lang.Object
  extended by controlP5.Tooltip

public class Tooltip
extends java.lang.Object

A tooltip can be registered for individual controllers and is activated on rollover.

+Example
  /**
* ControlP5 Tooltip
*
* add a tooltip to a controller.
* hover your mouse on top of a slider in the example and wait 
* for 1 second for the tooltip to appear.
*
* find a list of public methods available for the Tooltip Controller
* at the bottom of this sketch.
*
* by Andreas Schlegel, 2011
* www.sojamo.de/libraries/controlp5
*
*/

import controlP5.*;


ControlP5 cp5;

float s1 = 20, s2 = 100;

void setup() {
  size(700,400);
  smooth();
  noStroke();
  cp5 = new ControlP5(this);
  cp5.begin(100,100);
  cp5.addSlider("s1",10,200).linebreak();
  cp5.addSlider("s2",0,150);
  cp5.end();
  
  cp5.getTooltip().setDelay(500);
  cp5.getTooltip().register("s1","Changes the size of the ellipse.");
  cp5.getTooltip().register("s2","Changes the Background");

}


void keyPressed() {
  println("unregistering the tooltip for s2");
  cp5.getTooltip().unregister("s2");
}
void draw() {
  background(s2);
  fill(255,100);
  ellipse(width/2, height/2, s1,s1);
}



/*
a list of all methods available for the Tooltip Controller
use ControlP5.printPublicMethodsFor(Tooltip.class);
to print the following list into the console.

You can find further details about class Tooltip in the javadoc.

Format:
ClassName : returnType methodName(parameter type)


controlP5.Tooltip : Label getLabel() 
controlP5.Tooltip : Tooltip disable() 
controlP5.Tooltip : Tooltip enable() 
controlP5.Tooltip : Tooltip register(Controller, String) 
controlP5.Tooltip : Tooltip register(String, String) 
controlP5.Tooltip : Tooltip setAlpha(int) 
controlP5.Tooltip : Tooltip setBorder(int) 
controlP5.Tooltip : Tooltip setColorBackground(int) 
controlP5.Tooltip : Tooltip setColorLabel(int) 
controlP5.Tooltip : Tooltip setDelay(long) 
controlP5.Tooltip : Tooltip setDisplay(ControllerDisplay) 
controlP5.Tooltip : Tooltip setHeight(int) 
controlP5.Tooltip : Tooltip setLabel(Label) 
controlP5.Tooltip : Tooltip setPositionOffset(float, float) 
controlP5.Tooltip : Tooltip setWidth(int) 
controlP5.Tooltip : Tooltip unregister(Controller) 
controlP5.Tooltip : Tooltip unregister(String) 
controlP5.Tooltip : boolean isEnabled() 
controlP5.Tooltip : int getBorder() 
java.lang.Object : String toString() 
java.lang.Object : boolean equals(Object) 

*/




Method Summary
 Tooltip disable()
          disables the Tooltip on a global level, when disabled, tooltip will not respond to any registered controller.
 Tooltip enable()
          in case the tooltip is disabled, use enable() to turn the tooltip back on.
 int getBorder()
          returns the value of the border
 Label getLabel()
          returns the current Label
 int getWidth()
           
 boolean isEnabled()
          check if the tooltip is enabled or disabled
 Tooltip register(Controller theController, java.lang.String theText)
          registers a controller with the Tooltip, when activating the tooltip for a particular controller, the registered text (second parameter) will be displayed.
 Tooltip register(java.lang.String theControllerName, java.lang.String theText)
           
 Tooltip setAlpha(int theValue)
          sets the transparency of the default background, default value is 200
 Tooltip setBorder(int theValue)
          sets the border of the tooltip, the default border is 4px.
 Tooltip setColorBackground(int theColor)
          sets the background color of the tooltip, the default color is a dark grey
 Tooltip setColorLabel(int theColor)
          sets the text color of the tooltip's label, the default color is a white
 Tooltip setDelay(long theMillis)
          A tooltip is activated when entered by the mouse, after a given delay time the Tooltip starts to fade in.
 Tooltip setHeight(int theHeight)
           
 Tooltip setLabel(Label theLabel)
          sets the Label to a custom label and replaces the default label.
 Tooltip setPositionOffset(float theX, float theY)
          adds an offset to the position of the controller relative to the mouse cursor's position.
 Tooltip setView(ControllerView theDisplay)
          A custom view can be set for a Tooltip.
 Tooltip setWidth(int theWidth)
          with the default display, the width of the tooltip is set automatically, therefore setWidth() does not have any effect without changing the default display to a custom ControllerView.
 Tooltip unregister(Controller theController)
          removes a controller from the tooltip
 Tooltip unregister(java.lang.String theControllerName)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

disable

public Tooltip disable()
disables the Tooltip on a global level, when disabled, tooltip will not respond to any registered controller. to disable a tooltip for aparticular controller, used unregister(Controller)

Returns:
Tooltip
See Also:
Tooltip.unregister(Controller)

enable

public Tooltip enable()
in case the tooltip is disabled, use enable() to turn the tooltip back on.

Returns:
Tooltip

getBorder

public int getBorder()
returns the value of the border

Returns:

getLabel

public Label getLabel()
returns the current Label

Returns:
Label

getWidth

public int getWidth()

isEnabled

public boolean isEnabled()
check if the tooltip is enabled or disabled

Returns:
boolean

register

public Tooltip register(Controller theController,
                        java.lang.String theText)
registers a controller with the Tooltip, when activating the tooltip for a particular controller, the registered text (second parameter) will be displayed.

Parameters:
theController -
theText -
Returns:
Tooltip

register

public Tooltip register(java.lang.String theControllerName,
                        java.lang.String theText)

setAlpha

public Tooltip setAlpha(int theValue)
sets the transparency of the default background, default value is 200

Parameters:
theValue -
Returns:
Tooltip

setBorder

public Tooltip setBorder(int theValue)
sets the border of the tooltip, the default border is 4px.

Parameters:
theValue -
Returns:
Tooltip

setColorBackground

public Tooltip setColorBackground(int theColor)
sets the background color of the tooltip, the default color is a dark grey

Parameters:
theColor -
Returns:
Tooltip

setColorLabel

public Tooltip setColorLabel(int theColor)
sets the text color of the tooltip's label, the default color is a white

Parameters:
theColor -
Returns:
Tooltip

setDelay

public Tooltip setDelay(long theMillis)
A tooltip is activated when entered by the mouse, after a given delay time the Tooltip starts to fade in. Use setDelay(long) to adjust the default delay time of 1000 millis.

Parameters:
theMillis -
Returns:
Tooltip

setHeight

public Tooltip setHeight(int theHeight)
Parameters:
theHeight -
Returns:
Tooltip
See Also:
Tooltip.setWidth(int)

setLabel

public Tooltip setLabel(Label theLabel)
sets the Label to a custom label and replaces the default label.

Parameters:
theLabel -
Returns:
Tooltip

setPositionOffset

public Tooltip setPositionOffset(float theX,
                                 float theY)
adds an offset to the position of the controller relative to the mouse cursor's position. default offset is (10,20)

Parameters:
theX -
theY -
Returns:
Tooltip

setView

public Tooltip setView(ControllerView theDisplay)
A custom view can be set for a Tooltip. The default view class can be found at the bottom of the Tooltip source.

Parameters:
theDisplay -
Returns:
Tooltip
See Also:
ControllerView

setWidth

public Tooltip setWidth(int theWidth)
with the default display, the width of the tooltip is set automatically, therefore setWidth() does not have any effect without changing the default display to a custom ControllerView.

Returns:
Tooltip
See Also:
ControllerView, controlP5.Tooltip#setDisplay(ControllerView)

unregister

public Tooltip unregister(Controller theController)
removes a controller from the tooltip

Parameters:
theController -
Returns:
Tooltip

unregister

public Tooltip unregister(java.lang.String theControllerName)


processing library controlP5 by Andreas Schlegel. (c) 2006-2012