com.tensegrity.gui.swt
Class SwtToolTipGenerator

java.lang.Object
  extended bycom.tensegrity.gui.swt.SwtToolTipGenerator
All Implemented Interfaces:
ToolTipGenerator
Direct Known Subclasses:
SwtGraphPanelToolTipGenerator, SwtToolBar.SwtToolbarToolTipGenerator

public abstract class SwtToolTipGenerator
extends java.lang.Object
implements ToolTipGenerator

This is the default SWT implementation of ToolTipGenerator.

Note this implementation is largely inspired from a sample provided in http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/platform-swt-home/dev.html#snippets.

Instances of SwtToolTipGenerator are associated with a single Control, the one passed as parameter to the class constructor. See SwtToolTipGenerator(Control).

Subclasses can overwrite createTooltip(Shell, Object, int, int) in order to customize the tooltips. Also, the two methods getOffsetX() and getOffsetY() provide them with the mean of changing the tooltips position. The getTooltipBackGroundColor(Display) and getTooltipForeGroundColor(Display) methods are provided in order to customize the tooltips.

The following properties can also be set:

An instance of SwtToolTipGenerator can be registered on the SwtToolTipManager instance in order to allow a central management of tooltips.

Use the abstract subclass SwtGraphPanelToolTipGenerator in order to provide your SwtGraphPanel with custom tootips.

Use the destroy() method in order to unregister a SwtToolTipGenerator instance.

Version:
$Id: SwtToolTipGenerator.java,v 1.13 2006/03/02 11:42:01 BurkhardWick Exp $
Author:
S�bastien Guyon

Constructor Summary
SwtToolTipGenerator(org.eclipse.swt.widgets.Control control)
          Initialises and activates tooltips on the given Control.
 
Method Summary
protected  void createTooltip(org.eclipse.swt.widgets.Shell shell, java.lang.Object tooltip, int x, int y)
           This methods create a default tooltip.
 void destroy()
           Removes internal listeners and unregisters the SwtToolTipGenerator from the SwtToolTipManager instance.
 org.eclipse.swt.widgets.Control getControl()
          Returns the Control.
protected  int getDismissDelay()
          Returns the dismissDelay.
protected  int getInitialDelay()
          Returns the initialDelay.
protected  int getOffsetX()
          Returns the offset used to display the tooltip on the X axis.
protected  int getOffsetY()
          Returns the offset used to display the tooltip on the Y axis.
protected  int getReshowDelay()
          Returns the reshowDelay.
protected  org.eclipse.swt.graphics.Color getTooltipBackGroundColor(org.eclipse.swt.widgets.Display display)
           Returns the background color used for tooltips.
protected  org.eclipse.swt.graphics.Color getTooltipForeGroundColor(org.eclipse.swt.widgets.Display display)
           Returns the foreground color used for tooltips.
protected  boolean isEnabled()
          Returns true if tooltips are enabled, false otherwise.
protected  void setDismissDelay(int dismissDelay)
          Sets the dismissDelay property.
protected  void setEnabled(boolean enabled)
          Enables or disables the tooltips.
protected  void setInitialDelay(int initialDelay)
          Sets the initialDelay property.
protected  void setReshowDelay(int reshowDelay)
          Sets the reshowDelay property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.tensegrity.gui.graphdocument.ToolTipGenerator
getToolTip, getToolTip
 

Constructor Detail

SwtToolTipGenerator

public SwtToolTipGenerator(org.eclipse.swt.widgets.Control control)
Initialises and activates tooltips on the given Control.

Parameters:
control - the Control for which tooltips are herein generated.
Method Detail

destroy

public void destroy()

Removes internal listeners and unregisters the SwtToolTipGenerator from the SwtToolTipManager instance.


getOffsetX

protected int getOffsetX()
Returns the offset used to display the tooltip on the X axis. Default value is 0.

Returns:
the offset used to display the tooltip on the X axis (0 by default)

getOffsetY

protected int getOffsetY()
Returns the offset used to display the tooltip on the Y axis. Default value is 20.

Returns:
the offset used to display the tooltip on the Y axis (20 by default)

createTooltip

protected void createTooltip(org.eclipse.swt.widgets.Shell shell,
                             java.lang.Object tooltip,
                             int x,
                             int y)

This methods create a default tooltip. Subclasses can override this method in order to provide application specific tooltips.

Parameters:
shell - Shell which displays to tooltip
tooltip - tooltip object
x - mouse position, x direction
y - mouse position, y direction

getTooltipForeGroundColor

protected org.eclipse.swt.graphics.Color getTooltipForeGroundColor(org.eclipse.swt.widgets.Display display)

Returns the foreground color used for tooltips.

Parameters:
display - a Display which can be used to retrieve system colors.
Returns:
the foreground color used for tooltips.

getTooltipBackGroundColor

protected org.eclipse.swt.graphics.Color getTooltipBackGroundColor(org.eclipse.swt.widgets.Display display)

Returns the background color used for tooltips.

Parameters:
display - a Display which can be used to retrieve system colors.
Returns:
the background color used for tooltips.

getDismissDelay

protected int getDismissDelay()
Returns the dismissDelay.

Returns:
the dismissDelay.

setDismissDelay

protected void setDismissDelay(int dismissDelay)
Sets the dismissDelay property.

Parameters:
dismissDelay - The dismissDelay to set.

isEnabled

protected boolean isEnabled()
Returns true if tooltips are enabled, false otherwise.

Returns:
true if tooltips are enabled, false otherwise.

setEnabled

protected void setEnabled(boolean enabled)
Enables or disables the tooltips.

Parameters:
enabled - if false no tooltip is displayed.

getInitialDelay

protected int getInitialDelay()
Returns the initialDelay.

Returns:
the initialDelay.

setInitialDelay

protected void setInitialDelay(int initialDelay)
Sets the initialDelay property.

Parameters:
initialDelay - The initialDelay to set.

getReshowDelay

protected int getReshowDelay()
Returns the reshowDelay.

Returns:
the reshowDelay.

setReshowDelay

protected void setReshowDelay(int reshowDelay)
Sets the reshowDelay property.

Parameters:
reshowDelay - The reshowDelay to set.

getControl

public final org.eclipse.swt.widgets.Control getControl()
Returns the Control.

Returns:
Returns the Control.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.