JIDE 3.5.15

com.jidesoft.swing
Class NavigationComponentHelper

java.lang.Object
  extended by com.jidesoft.swing.NavigationComponentHelper
Direct Known Subclasses:
NavigationHierarchicalTable.NavigationHierarchicalTableHelper, NavigationList.NavigationListHelper, NavigationSortableTable.NavigationSortableTableHelper, NavigationTable.NavigationTableHelper, NavigationTree.NavigationTreeHelper, NavigationTreeTable.NavigationTreeTableHelper

public abstract class NavigationComponentHelper
extends Object

NavigationComponentHelper is a helper class to implement on JTree, JList and JTable (or JIDE table subclasses) so they can be used for the navigation purpose. In order to make the component suitable for the navigation, we want the selection effect to be easily noticeable and covers the row (instead of just one cell or one node in the case of JTable and JTree respectively). We also want to have rollover effect the mouse is over a row. Further more, the selection should have different color when the component is focused so that when multiple navigation components are used, we can tell which one is active. Some L&Fs already do it by default but the most L&Fs don't do it. This class provides some common code to make the implementation easy.


Constructor Summary
NavigationComponentHelper()
           
 
Method Summary
 void focusGained(FocusEvent e)
           
 void focusLost(FocusEvent e)
           
 Point getMousePosition()
           
 int getRolloverRow()
          Gets the rollover row that currently has rollover effect.
protected abstract  Rectangle getRowBounds(int row)
           
protected abstract  int[] getSelectedRows()
           
protected  Color getSelectionColor(JComponent c)
          Gets the color to paint the selected rows.
 void mouseClicked(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void paint(Graphics g, JComponent c)
          Paints the rollover row and selection rows.
protected  void paintRolloverRow(Graphics g, JComponent c, int row)
          Paints the rollover row.
protected  void paintSelectedRow(Graphics g, JComponent c, int row)
          Paints the selected row.
 void repaintSelections(JComponent c)
           
protected abstract  int rowAtPoint(Point p)
           
 void setRolloverRow(int rolloverRow)
          Sets the rollover row.
 void setup(JComponent c)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NavigationComponentHelper

public NavigationComponentHelper()
Method Detail

getRowBounds

protected abstract Rectangle getRowBounds(int row)

rowAtPoint

protected abstract int rowAtPoint(Point p)

getSelectedRows

protected abstract int[] getSelectedRows()

mouseMoved

public void mouseMoved(MouseEvent e)

mouseExited

public void mouseExited(MouseEvent e)

mousePressed

public void mousePressed(MouseEvent e)

mouseReleased

public void mouseReleased(MouseEvent e)

mouseClicked

public void mouseClicked(MouseEvent e)

mouseEntered

public void mouseEntered(MouseEvent e)

focusGained

public void focusGained(FocusEvent e)

focusLost

public void focusLost(FocusEvent e)

paint

public void paint(Graphics g,
                  JComponent c)
Paints the rollover row and selection rows.

Parameters:
g - the Graphics
c - the component

paintSelectedRow

protected void paintSelectedRow(Graphics g,
                                JComponent c,
                                int row)
Paints the selected row. This method is called after the tree is painted. It will paint over the content of the tree. In order to not cover the content, the painting code must be semi-transparent. By default, we paint it using the selection color which can be retrieved from UIDefault "Tree.selectionBackground" but with an alpha between 70 to 100 to create a gradient effect.

Parameters:
g - the Graphics
c - the component
row - the row index

getSelectionColor

protected Color getSelectionColor(JComponent c)
Gets the color to paint the selected rows.

Parameters:
c - the component
Returns:
the selection color.
Since:
3.4.6

paintRolloverRow

protected void paintRolloverRow(Graphics g,
                                JComponent c,
                                int row)
Paints the rollover row. This method is called after the tree is painted. It will paint over the content of the tree. In order to not cover the content, the painting code must be semi-transparent. By default, we paint it using the selection color which can be retrieved from UIDefault "Tree.selectionBackground" but with an alpha between 10 to 40 to create a gradient effect.

Parameters:
g - the Graphics
c - the component
row - the row index

setup

public void setup(JComponent c)

repaintSelections

public void repaintSelections(JComponent c)

getRolloverRow

public int getRolloverRow()
Gets the rollover row that currently has rollover effect.

Returns:
the row that has the rollover effect.

setRolloverRow

public void setRolloverRow(int rolloverRow)
Sets the rollover row.

Parameters:
rolloverRow - the row to show the rollover effect.

getMousePosition

public Point getMousePosition()

JIDE 3.5.15