org.geotoolkit.gui.swing.image
Class MosaicTableModel

Object
  extended by AbstractTableModel
      extended by ListTableModel<Tile>
          extended by MosaicTableModel
All Implemented Interfaces:
Serializable, TableModel

public class MosaicTableModel
extends ListTableModel<Tile>

A table model for a list of tiles. The default implementation provides one row for each tile added to this model and one column for each tile property listed below. This table model does not allows cell edition but allows row insertion and removal, assuming that the list of tiles is modifiable. The default columns are:


External list of tiles
A list of tiles is given to the constructor and retained by direct reference - the list is not cloned, because it may contains millions of tiles, sometime through a custom List implementation fetching the information on-the-fly from a database. Consequently if the content of the list is modified externally, then a fireXXX method (inherited from AbstractTableModel must be invoked explicitly. Note that the fireXXX methods don't need to be invoked if the list is modified through the methods provided in this class.


Multi-threading
Unless otherwise specified, every methods in this class must be invoked from the Swing thread. The main exceptions are the methods listed below, which should actually be invoked from a background thread rather than the Swing thread:


Serialization
This model is serialiable if the underlying list of tiles is serializable.

Since:
3.00
Version:
3.00
Author:
Martin Desruisseaux (Geomatys)
See Also:
MosaicChooser, Serialized Form
Module:
display/geotk-widgets-swing (download)    View source code for this class

Field Summary
 
Fields inherited from class ListTableModel
elements
 
Fields inherited from class AbstractTableModel
listenerList
 
Constructor Summary
MosaicTableModel()
          Creates a new table model backed by an ArrayList of tiles.
MosaicTableModel(List<Tile> tiles)
          Creates a new table model for the given list of tiles.
 
Method Summary
 TableModel add(ImageReaderSpi provider, File[] files, ProgressController progress)
          Adds tiles to be constructed from the given array of files.
 Class<?> getColumnClass(int column)
          Returns the class of values at the given column.
 int getColumnCount()
          Returns the number of columns in the table.
 String getColumnName(int column)
          Returns the name of the given column.
 TileManager[] getTileManager()
          Returns a tile manager for the current list of tiles.
 Object getValueAt(int row, int column)
          Returns the value at the given index.
 
Methods inherited from class ListTableModel
add, getElements, getElements, getElements, getRowCount, insert, remove, remove, removeDuplicates, setElements, sort
 
Methods inherited from class AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MosaicTableModel

public MosaicTableModel()
Creates a new table model backed by an ArrayList of tiles.


MosaicTableModel

public MosaicTableModel(List<Tile> tiles)
Creates a new table model for the given list of tiles. The given list is retained by direct reference - it is not cloned. Consequently if the content of this list is modified externaly, then one of the fireXXX method inherited from AbstractTableModel must be invoked explicitly.

Parameters:
tiles - The list of tiles to display in a table.
Method Detail

getColumnCount

public int getColumnCount()
Returns the number of columns in the table.

Returns:
The number of columns.

getColumnName

public String getColumnName(int column)
Returns the name of the given column.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
column - The column.
Returns:
The column name.

getColumnClass

public Class<?> getColumnClass(int column)
Returns the class of values at the given column.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
column - The column.
Returns:
The classes of values.

getValueAt

public Object getValueAt(int row,
                         int column)
Returns the value at the given index. This method may return null if the value at the given cell can not be obtained, for example because of an I/O error.

Parameters:
row - The row, which is also the index of the tile.
column - The column.
Returns:
The value at the given row and column, or null.

add

public TableModel add(ImageReaderSpi provider,
                      File[] files,
                      ProgressController progress)
               throws UnsupportedOperationException
Adds tiles to be constructed from the given array of files. Every file in the given array must exist, be a valid image and have a valid World File, i.e. a file of the same name in the same directory with ".tfw" extension (for TIFF images) or ".jgw" extension (for JPEG images).

This method loads the World Files and fetches the image sizes immediately. The world file applies to the first image in the file. If the file contains more than one image, then each additional image is assumed to represent the same data than the first image at a different resolution.

This method may be slow and should be invoked in a background thread. After having built the collection of tiles, this method invokes ListTableModel.add(Collection) in the Swing thread, removes duplicates and sorts the result.

On success, this method returns null. If this method failed to constructs some tiles, then the successful tiles are added as explained above and the unused files are returned in a new table model.

Parameters:
provider - The image reader provider to use for reading image data, or null for attempting an automatic detection.
files - The files from which to creates tiles.
progress - An optional controller for reporting progresses, or null if none.
Returns:
null on success, or a list of files that failed otherwise.
Throws:
UnsupportedOperationException - if the underlying list of tiles is not modifiable.

getTileManager

public TileManager[] getTileManager()
                             throws IOException
Returns a tile manager for the current list of tiles. This method should return an array of length 1, but a different length may be obtained if it was not possible to create a single tile manager.

Consider invoking ListTableModel.removeDuplicates() before this method, since duplicated tiles are likely to produce erroneous tile manager. Consider also invoking this getTileManager() method from a background thread, since it may be slow (it is safe to invoke this particular method from non-Swing thread).

Returns:
The tile managers for the current list of tiles.
Throws:
IOException - if an error occurred while reading a tile.


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.