com.guigarage.jgrid.ui
Class BasicGridUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by com.guigarage.jgrid.ui.GridUI
          extended by com.guigarage.jgrid.ui.BasicGridUI
Direct Known Subclasses:
MacOsGridUI

public class BasicGridUI
extends GridUI

A basic L&F implementation of GridUI. This implementation is not static, i.e. there's one UIView implementation for every JGrid objects.

Author:
hendrikebbers

Field Summary
protected  JGrid grid
           
 
Constructor Summary
BasicGridUI()
           
 
Method Summary
 int getCellAt(Point point)
          Returns the index of the cell that point lies in or -1 if point is not in a cell
 Rectangle getCellBounds(int index)
          Returns the Bounds of the cell with index
 int[] getCellsIntersectedBy(Rectangle rect)
          Returns the indexes of cells that intersect with rect, or an empty array if none do
 int getColumnCount()
          Returns the current count of columns in the grid
 int getColumnForIndex(int selectedIndex)
          Returns the index of the column where modelIndex is in
 int getIndexAt(int row, int column)
          Returns the model-index of the cell at row / column
protected  int getPreferredHeightForWidth(int width)
          Returns the preferred height of the JGrid for the specified width
 Dimension getPreferredSize(JComponent c)
           
 int getRowCount()
          Returns the current count of rows in the grid
 int getRowForIndex(int selectedIndex)
          Returns the index of the row where modelIndex is in
 void installUI(JComponent c)
           
protected  boolean isDebugMode()
          Helper for debbuging.
 void markCellBoundsAsDirty()
          Marks the bounds of all rendered cells as dirty.
 void paint(Graphics g, JComponent c)
           
protected  void paintCell(Graphics g, JComponent c, int index, Rectangle bounds, int leadIndex)
          Paints the specified cell.
protected  void paintCellBorder(Graphics g, JComponent c, int index, Rectangle bounds, int leadIndex)
          Paints the Border for the specified cell.
 void uninstallUI(JComponent c)
           
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grid

protected JGrid grid
Constructor Detail

BasicGridUI

public BasicGridUI()
Method Detail

installUI

public void installUI(JComponent c)
Overrides:
installUI in class ComponentUI

uninstallUI

public void uninstallUI(JComponent c)
Overrides:
uninstallUI in class ComponentUI

getCellAt

public int getCellAt(Point point)
Description copied from class: GridUI
Returns the index of the cell that point lies in or -1 if point is not in a cell

Specified by:
getCellAt in class GridUI
Parameters:
point - the location of interest
Returns:
cellindex at the point

isDebugMode

protected boolean isDebugMode()
Helper for debbuging. Returns true if systemproperty "jgrid.debug" is set to "true"

Returns:
true if debugMode is active

getPreferredHeightForWidth

protected int getPreferredHeightForWidth(int width)
Returns the preferred height of the JGrid for the specified width

Parameters:
width - the given width
Returns:
the preferred height

getPreferredSize

public Dimension getPreferredSize(JComponent c)
Overrides:
getPreferredSize in class ComponentUI

paint

public void paint(Graphics g,
                  JComponent c)
Overrides:
paint in class ComponentUI

paintCellBorder

protected void paintCellBorder(Graphics g,
                               JComponent c,
                               int index,
                               Rectangle bounds,
                               int leadIndex)
Paints the Border for the specified cell. Subclasses should override this method and use the specified Graphics object to render the Border of the cell.

Parameters:
g - the Graphics context in which to paint
c - the JGrid being painted
index - the cellindex
bounds - the bounds of the cell

paintCell

protected void paintCell(Graphics g,
                         JComponent c,
                         int index,
                         Rectangle bounds,
                         int leadIndex)
Paints the specified cell. Subclasses should override this method and use the specified Graphics object to render the cell.

Parameters:
g - the Graphics context in which to paint
c - the JGrid being painted
index - the cellindex
bounds - the bounds of the cell

getCellBounds

public Rectangle getCellBounds(int index)
Description copied from class: GridUI
Returns the Bounds of the cell with index

Specified by:
getCellBounds in class GridUI
Parameters:
index - the model-index
Returns:
Bounds of the cell at the given index

getColumnCount

public int getColumnCount()
Description copied from class: GridUI
Returns the current count of columns in the grid

Specified by:
getColumnCount in class GridUI
Returns:
count of columns in the grid

getIndexAt

public int getIndexAt(int row,
                      int column)
Description copied from class: GridUI
Returns the model-index of the cell at row / column

Specified by:
getIndexAt in class GridUI
Parameters:
row - the row of the cell
column - the column of the cell
Returns:
model-index of the cell

getRowCount

public int getRowCount()
Description copied from class: GridUI
Returns the current count of rows in the grid

Specified by:
getRowCount in class GridUI
Returns:
count of rows in the grid

getRowForIndex

public int getRowForIndex(int selectedIndex)
Description copied from class: GridUI
Returns the index of the row where modelIndex is in

Specified by:
getRowForIndex in class GridUI
Returns:
index of the row

getColumnForIndex

public int getColumnForIndex(int selectedIndex)
Description copied from class: GridUI
Returns the index of the column where modelIndex is in

Specified by:
getColumnForIndex in class GridUI
Returns:
index of the column

markCellBoundsAsDirty

public void markCellBoundsAsDirty()
Description copied from class: GridUI
Marks the bounds of all rendered cells as dirty. Next time the bounds are needed or the grid is rendered all bounds will refreshed

Specified by:
markCellBoundsAsDirty in class GridUI

getCellsIntersectedBy

public int[] getCellsIntersectedBy(Rectangle rect)
Description copied from class: GridUI
Returns the indexes of cells that intersect with rect, or an empty array if none do

Specified by:
getCellsIntersectedBy in class GridUI
Parameters:
rect - the area of interest
Returns:
array of cell indexes intersected by rect, in ascending order


Copyright © 2012. All Rights Reserved.