Copyright © 2005 Scientific Applications. All Rights Reserved.

com.sciapp.table.span
Class SpanDrawer

java.lang.Object
  extended by com.sciapp.table.span.SpanDrawer

public class SpanDrawer
extends Object

SpanDrawer is used to enable cell spanning for a JTable.


Field Summary
protected  boolean borderPainted
          flag indicating whether SpanDrawer is responsible for drawing the grid border around the cells
protected  boolean fixedRowHeight
          flag that indicates whether the drawer will assume that the table has a fixed row height
protected  SpanModel spanModel
          the span model.
protected  boolean updateSelections
          boolean flag to indicate that the drawer should update the cell selections evenly after a cell selection.
 
Constructor Summary
SpanDrawer()
          Constructs a default SpanDrawer.
SpanDrawer(JTable table)
          Constructs a default SpanDrawer.
SpanDrawer(JTable table, SpanModel spanModel)
          Constructs a default SpanDrawer.
 
Method Summary
 Rectangle getCellRect(int row, int column, boolean includeSpacing)
          Returns a rectangle for the cell that lies at the intersection of row and column, as it has been modified with the use of the span model.
 boolean getFixedRowHeight()
          Determines whether the drawer will assume that the table has a fixed row height.
 SpanModel getSpanModel()
          Returns the span model that this SpanDrawer queries to lookup the merged cells.
 JTable getTable()
          Returns the associated table.
 boolean getUpdateSelections()
          Determines whether the drawer will update the cell selection evenly after a cell selection.
 boolean getUseSpan()
          Determines the spanning behaviour of the span model.
 boolean isBorderPainted()
          Determines whether SpanDrawer is responsible for drawing the grid border around the cells.
 boolean isCellMerged(int row, int column)
          Determines whether the cell at row, column is merged with another cell.
 boolean isCellNormal(int row, int column)
          Determines whether the cell at row, column is neither merged nor spanned (as it normally is when no spanning at all is used).
 boolean isCellSpanned(int row, int column)
          Determines whether the cell at row, column spans to another cell.
 Component prepare(Component spannedComponent, int row, int column)
          Prepares the component at (row, column) to be used by the span model.
 void setBorderPainted(boolean borderPainted)
          Determines whether SpanDrawer is responsible for drawing the grid border around the cells.
 void setFixedRowHeight(boolean fixedRowHeight)
          Tells the drawer whether the table has a fixed row height.
 void setSpanModel(SpanModel newSpanModel)
          Sets the span model that this SpanDrawer queries to lookup the merged cells.
 void setTable(JTable newTable)
          Assigns the associated table.
 void setUpdateSelections(boolean updateSelections)
          Tells the drawer to update the cell selection evenly after a cell selection.
 void setUseSpan(boolean useSpan)
          Sets the spanning behaviour of the span model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

updateSelections

protected boolean updateSelections
boolean flag to indicate that the drawer should update the cell selections evenly after a cell selection.


fixedRowHeight

protected boolean fixedRowHeight
flag that indicates whether the drawer will assume that the table has a fixed row height


borderPainted

protected boolean borderPainted
flag indicating whether SpanDrawer is responsible for drawing the grid border around the cells


spanModel

protected SpanModel spanModel
the span model.

Constructor Detail

SpanDrawer

public SpanDrawer()
Constructs a default SpanDrawer.


SpanDrawer

public SpanDrawer(JTable table)
Constructs a default SpanDrawer.


SpanDrawer

public SpanDrawer(JTable table,
                  SpanModel spanModel)
Constructs a default SpanDrawer.

Method Detail

getCellRect

public Rectangle getCellRect(int row,
                             int column,
                             boolean includeSpacing)
Returns a rectangle for the cell that lies at the intersection of row and column, as it has been modified with the use of the span model.

Parameters:
row - the row index of the cell
column - the column index of the cell
includeSpacing - if false, return the true cell bounds

getFixedRowHeight

public boolean getFixedRowHeight()
Determines whether the drawer will assume that the table has a fixed row height. If so, span cell drawing is faster. Warning: If the table does not use the same height for all its rows, vertically-spanned cells will not appear correctly.

Returns:
true if the table has a fixed row height, false otherwise

getSpanModel

public SpanModel getSpanModel()
Returns the span model that this SpanDrawer queries to lookup the merged cells.

Returns:
the span model

getTable

public JTable getTable()
Returns the associated table.

Returns:
the JTable object associated with this span drawer.

getUpdateSelections

public boolean getUpdateSelections()
Determines whether the drawer will update the cell selection evenly after a cell selection. Default is false.

Returns:
updateSelections flag

getUseSpan

public boolean getUseSpan()
Determines the spanning behaviour of the span model.

Returns:
true if spanning is used, false otherwise.

isBorderPainted

public boolean isBorderPainted()
Determines whether SpanDrawer is responsible for drawing the grid border around the cells.

Returns:
true, if SpanDrawer will draw the grid border, false if the table will

isCellMerged

public boolean isCellMerged(int row,
                            int column)
Determines whether the cell at row, column is merged with another cell. The merged cell is not visible in the table.

Parameters:
row - the row index of the cell
column - the column index of the cell
Returns:
true if the cell is merged, false otherwise

isCellNormal

public boolean isCellNormal(int row,
                            int column)
Determines whether the cell at row, column is neither merged nor spanned (as it normally is when no spanning at all is used).

Parameters:
row - the row index of the cell
column - the column index of the cell
Returns:
true if the cell is normal, false otherwise

isCellSpanned

public boolean isCellSpanned(int row,
                             int column)
Determines whether the cell at row, column spans to another cell.

Parameters:
row - the row index of the cell
column - the column index of the cell
Returns:
true if the cell is spanned, false otherwise

prepare

public Component prepare(Component spannedComponent,
                         int row,
                         int column)
Prepares the component at (row, column) to be used by the span model. This method should be called from the prepareRenderer method of the JTable.

Parameters:
spannedComponent - the component that we wish to span or merge
row - the row index of the cell
column - the column index of the cell
Returns:
true if the merging was successful, false otherwise.

setBorderPainted

public void setBorderPainted(boolean borderPainted)
Determines whether SpanDrawer is responsible for drawing the grid border around the cells. If borderPainted is true, then the table's showGrid property is switched off.

Parameters:
borderPainted - true, if SpanDrawer will draw the grid border, false if the table will

setFixedRowHeight

public void setFixedRowHeight(boolean fixedRowHeight)
Tells the drawer whether the table has a fixed row height. If so, span cell drawing is faster.
Warning: If the table does not use the same height for all its rows, vertically-spanned cells will not appear correctly. The default value is false.

Parameters:
fixedRowHeight - true if the table has a fixed row height, false otherwise

setSpanModel

public void setSpanModel(SpanModel newSpanModel)
Sets the span model that this SpanDrawer queries to lookup the merged cells.

Parameters:
newSpanModel - the span model to assign

setTable

public void setTable(JTable newTable)
Assigns the associated table.

Parameters:
newTable - the JTable object to associate with this span drawer.

setUpdateSelections

public void setUpdateSelections(boolean updateSelections)
Tells the drawer to update the cell selection evenly after a cell selection. Default is false.

Parameters:
updateSelections - flag

setUseSpan

public void setUseSpan(boolean useSpan)
Sets the spanning behaviour of the span model.

Parameters:
useSpan - true if spanning is used, false otherwise.

Copyright © 2005 Scientific Applications. All Rights Reserved.