JIDE 3.5.15

com.jidesoft.tooltip
Class ExpandedTip<S extends JComponent>

java.lang.Object
  extended by com.jidesoft.tooltip.ExpandedTip<S>
Type Parameters:
S -
Direct Known Subclasses:
ListExpandedTip, TableHeaderExpandedTip, TableRowExpandedTip, TreeExpandedTip

public abstract class ExpandedTip<S extends JComponent>
extends Object

ExpandedTip makes a component showing an expanded tooltip when the mouse is a node or a cell. It is the base class and has subclasses to implement for different components. It is useful for JList and JTree when they are narrow but the content is wide.

License notice: The file was originally copied from IntelliJ IDEA Community Edition (Apache 2.0 license) but was modified extensively to make the API easier to use.

Since:
3.3.0

Field Summary
protected  S _component
           
static String CLIENT_PROPERTY_EXPANDED_TIP
          The client property for ExpandedTip instance.
 
Constructor Summary
protected ExpandedTip(S component)
           
 
Method Summary
protected  BufferedImage createImage(int width, int height)
          Creates a BufferedImage.
protected  Point createToolTipImage(int index, boolean rightOrLeft)
           
protected  void fillBackground(Graphics2D g, int width, int height)
          Fills the background on the tip component.
 S getComponent()
          Gets the component where the ExpandedTip is installed on.
protected  Component getComponent(int index)
          Gets the target component.
static ExpandedTip getExpandedTip(JComponent component)
          Gets the ExpandedTip installed on the component.
protected abstract  Rectangle getRowBounds(int index)
          Gets the bounds of the image that will be put on the tip.
protected  Rectangle getVisibleRect(int index)
          Gets the visible rect of the component.
protected  void handleSelectionChange(int selected)
           
protected  void handleSelectionChange(int selected, boolean processIfUnfocused)
           
 void hideTip()
           
protected  void paintTipImage(Graphics2D g, Component component, Rectangle bounds, int index)
          Paints the tip image.
protected abstract  int rowAtPoint(Point point)
          Gets the row index or the node index on the location.
protected  void setWindowShape(JWindow window, boolean rightOrLeft)
          Adjusts the window shape in case the tip window is not rectangular.
protected  boolean shouldDrawBorder()
           
 void showTip()
           
 void uninstall()
           
protected  void updateCurrentSelection()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLIENT_PROPERTY_EXPANDED_TIP

public static final String CLIENT_PROPERTY_EXPANDED_TIP
The client property for ExpandedTip instance. When ExpandedTip is installed on a component, this client property has the ExpandedTip.

See Also:
Constant Field Values

_component

protected final S extends JComponent _component
Constructor Detail

ExpandedTip

protected ExpandedTip(S component)
Method Detail

uninstall

public void uninstall()

updateCurrentSelection

protected void updateCurrentSelection()

handleSelectionChange

protected void handleSelectionChange(int selected)

handleSelectionChange

protected void handleSelectionChange(int selected,
                                     boolean processIfUnfocused)

showTip

public void showTip()

hideTip

public void hideTip()

setWindowShape

protected void setWindowShape(JWindow window,
                              boolean rightOrLeft)
Adjusts the window shape in case the tip window is not rectangular. By default, we override it and change the window shape to rounded corner for the navigation component such as NavigationTree and NavigationList.

Parameters:
window - the window.
rightOrLeft - right or left.

createToolTipImage

protected Point createToolTipImage(int index,
                                   boolean rightOrLeft)

shouldDrawBorder

protected boolean shouldDrawBorder()

createImage

protected BufferedImage createImage(int width,
                                    int height)
Creates a BufferedImage.

Parameters:
width - the width of the image
height - the height of the image
Returns:
a new BufferedImage

fillBackground

protected void fillBackground(Graphics2D g,
                              int width,
                              int height)
Fills the background on the tip component.

Parameters:
g - the graphics
width - the width
height - the height

paintTipImage

protected void paintTipImage(Graphics2D g,
                             Component component,
                             Rectangle bounds,
                             int index)
Paints the tip image. It will take a sub-image from the component at the specified bounds and paint it on the provided graphics.

Parameters:
g - the graphics
component - the component where the sub-image is taken from
bounds - the bounds where the sub-image is at
index - the index of the row or the node

getVisibleRect

protected Rectangle getVisibleRect(int index)
Gets the visible rect of the component.

Parameters:
index - the index of the row or node
Returns:
the visible rect of the component.

getComponent

public S getComponent()
Gets the component where the ExpandedTip is installed on.

Returns:
the component where the ExpandedTip is installed on.

getComponent

protected Component getComponent(int index)
Gets the target component. This component contains the image that will be put on the tip. The area of the image is returned in the getRowBounds(int). What we will do is to take a capture of the image at the bounds on the component and copy it to the tip component.

Parameters:
index - the index of the row or node.
Returns:
the component.

getRowBounds

protected abstract Rectangle getRowBounds(int index)
Gets the bounds of the image that will be put on the tip. The position is relative to the component returned from getComponent(int). The bounds should cover the row or the node. We will calculate it so that only the invisible area is shown on the tip component.

Parameters:
index - the index of the row or node.
Returns:
the bounds.

rowAtPoint

protected abstract int rowAtPoint(Point point)
Gets the row index or the node index on the location.

Parameters:
point - the location.
Returns:
the index of the row or node.

getExpandedTip

public static ExpandedTip getExpandedTip(JComponent component)
Gets the ExpandedTip installed on the component. Null is no ExpandedTip was installed.

Parameters:
component - the component
Returns:
the ExpandedTip installed. Null is no ExpandedTip was installed.

JIDE 3.5.15