org.assertj.swing.driver
Class BasicJTableCellReader

java.lang.Object
  extended by org.assertj.swing.driver.BasicJTableCellReader
All Implemented Interfaces:
JTableCellReader

public class BasicJTableCellReader
extends Object
implements JTableCellReader

Default implementation of JTableCellReader.

Author:
Yvonne Wang, Alex Ruiz

Constructor Summary
BasicJTableCellReader()
          Creates a new BasicJTableCellReader that uses a BasicCellRendererReader to read the value from the cell renderer component in a JTable.
BasicJTableCellReader(CellRendererReader reader)
          Creates a new BasicJTableCellReader.
 
Method Summary
 Color backgroundAt(JTable table, int row, int column)
           Returns the background color of the cell renderer for the given JTable cell.
 Font fontAt(JTable table, int row, int column)
           Returns the font of the cell renderer for the given JTable cell.
 Color foregroundAt(JTable table, int row, int column)
           Returns the foreground color of the cell renderer for the given JTable cell.
 String valueAt(JTable table, int row, int column)
           Returns the internal value of a cell in a JTable as expected in a test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicJTableCellReader

public BasicJTableCellReader()
Creates a new BasicJTableCellReader that uses a BasicCellRendererReader to read the value from the cell renderer component in a JTable.


BasicJTableCellReader

public BasicJTableCellReader(@Nonnull
                             CellRendererReader reader)
Creates a new BasicJTableCellReader.

Parameters:
reader - knows how to read values from the cell renderer component in a JTable.
Throws:
NullPointerException - if reader is null.
Method Detail

valueAt

@RunsInCurrentThread
@Nullable
public String valueAt(@Nonnull
                                                   JTable table,
                                                   int row,
                                                   int column)

Returns the internal value of a cell in a JTable as expected in a test. This method first tries to return the value displayed in the JTable's cell renderer.

If it fails reading the cell renderer, this method will get the value from the toString implementation of the object stored in the JTable's model at the specified indices.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

Specified by:
valueAt in interface JTableCellReader
Parameters:
table - the given JTable.
row - the row index of the cell.
column - the column index of the cell.
Returns:
the internal value of a cell in a JTable as expected in a test.

fontAt

@RunsInCurrentThread
@Nullable
public Font fontAt(@Nonnull
                                                JTable table,
                                                int row,
                                                int column)

Returns the font of the cell renderer for the given JTable cell.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

Specified by:
fontAt in interface JTableCellReader
Parameters:
table - the given JTable.
row - the row index of the cell.
column - the column index of the cell.
Returns:
the font of the cell renderer for the given JTable cell.

backgroundAt

@RunsInCurrentThread
@Nullable
public Color backgroundAt(@Nonnull
                                                       JTable table,
                                                       int row,
                                                       int column)

Returns the background color of the cell renderer for the given JTable cell.

Specified by:
backgroundAt in interface JTableCellReader
Parameters:
table - the given JTable.
row - the row index of the cell.
column - the column index of the cell.
Returns:
the background color of the cell renderer for the given JTable cell.

foregroundAt

@RunsInCurrentThread
@Nullable
public Color foregroundAt(@Nonnull
                                                       JTable table,
                                                       int row,
                                                       int column)

Returns the foreground color of the cell renderer for the given JTable cell.

Note: This method is accessed in the current executing thread. Such thread may or may not be the event dispatch thread (EDT.) Client code must call this method from the EDT.

Specified by:
foregroundAt in interface JTableCellReader
Parameters:
table - the given JTable.
row - the row index of the cell.
column - the column index of the cell.
Returns:
the foreground color of the cell renderer for the given JTable cell.


Copyright © 2014–2015 AssertJ. All rights reserved.