com.ephox.editlive.model.table
Interface EphoxTableModel<T>


public interface EphoxTableModel<T>

Allows easy navigation of the complex HTML table model, handling colspan / rowspan details. Hidden elements (eg comments) in the table are not included in the model.

Instance available via TableManager.


Method Summary
 Rectangle find(Element cell)
          Finds the cell in the tale matching the specified element and returns a Rectangle representing the area within the display cell model that it occupies.
 T get(int row, int col)
          Returns the object at the specified display row and column.
 Collection<T> getAllCells()
          Flattens the cells into a single collection, in HTML order (one row at a time).
 int getCellCount()
          Calculates how many cells are in the table.
 int getDisplayColumns()
          Get the number of display columns in the table.
 int getDisplayRows()
          Get the number of display rows in the table.
 Element getElement(int row, int col)
          Returns the element at the specified display row and column.
 boolean isFilled(int row, int col)
          Determine if the specified display cell is filled.
 

Method Detail

get

T get(int row,
      int col)
Returns the object at the specified display row and column. Colspanned and Rowspanned cells will be returned in multiple positions.

Parameters:
row - the display row of the object to return.
col - the display column of the object to return.
Returns:
the object in the specified display cell or null if no object occupies that cell.

getElement

Element getElement(int row,
                   int col)
Returns the element at the specified display row and column. If this model was created using elements, this returns the same as get(int, int).

Parameters:
row - the display row of the element to return.
col - the display column of the element to return.
Returns:
the Element in the specified display cell or null if no element occupies that cell.

isFilled

boolean isFilled(int row,
                 int col)
Determine if the specified display cell is filled.

Parameters:
row - the display row to check.
col - the display column to check.
Returns:
true if the display cell specified is filled.

getCellCount

int getCellCount()
Calculates how many cells are in the table.


getAllCells

Collection<T> getAllCells()
Flattens the cells into a single collection, in HTML order (one row at a time).


getDisplayRows

int getDisplayRows()
Get the number of display rows in the table. If there are hidden elements in the table, not all rows will be filled.

Returns:
the number of display rows in the table.

getDisplayColumns

int getDisplayColumns()
Get the number of display columns in the table. If there are hidden elements in the table, not all columns will be filled.

Returns:
the number of display cols in the table.

find

Rectangle find(Element cell)
Finds the cell in the tale matching the specified element and returns a Rectangle representing the area within the display cell model that it occupies. The (x, y) of the Rectangle is the (row, col) of the display cell occupied by the element as used by get(int, int). The width of the rectangle is the colspan of the element and the height is the rowspan.

The Rectangle class is used as it's operations such as Rectangle.add(Rectangle) can be used to combine cells when generating a range. Note that in this manner the add method of Rectangle does not take into account the colspan and rowspan of any cells between the two cells being added.

Parameters:
cell - the cell to find.
Returns:
the Rectangle representing the element's position in the display cells.
Throws:
IllegalArgumentException

Copyright (c) 2005-2012 Ephox Pty Ltd. All rights reserved.