org.geotoolkit.gui.swing.image
Class ImageTableModel

Object
  extended by AbstractTableModel
      extended by ImageTableModel
All Implemented Interfaces:
Serializable, TableModel

public class ImageTableModel
extends AbstractTableModel

A table model for image sample values (or pixels). This model is serializable if the underlying RenderedImage is serializable.

Since:
2.3
Version:
3.00
Author:
Martin Desruisseaux (IRD)
See Also:
ImageSampleValues, Serialized Form
Module:
display/geotk-widgets-swing (download)    View source code for this class
TODO:
Should supports deferred execution: request for a new tile should wait some maximal amount of time (e.g. 0.1 seconds). If the tile is not yet available after that time, the model should returns null at this time and send a "data changed" event later when the tile is finally available.

Field Summary
 
Fields inherited from class AbstractTableModel
listenerList
 
Constructor Summary
ImageTableModel()
          Creates a new table model with no image.
ImageTableModel(RenderedImage image)
          Creates a new table model for the specified image.
 
Method Summary
 int findColumn(String name)
          Returns a column index given its name.
 int getBand()
          Returns the band to display.
 Color getColorAt(int y, int x)
          Returns the color at the specified row and column.
 Class<? extends Number> getColumnClass(int column)
          Returns the type of sample values regardless of column index.
 int getColumnCount()
          Returns the number of columns in the model, which is the image width.
 String getColumnName(int column)
          Returns the column name.
 NumberFormat getNumberFormat()
          Returns the format to use for formatting sample values.
 RenderedImage getRenderedImage()
          Returns the image to display, or null if none.
 int getRowCount()
          Returns the number of rows in the model, which is the image height.
 String getRowName(int row)
          Returns the row name.
 Number getValueAt(int y, int x)
          Returns the sample value at the specified row and column.
 void setBand(int band)
          Sets the band to display.
 void setNumberFormat(NumberFormat format)
          Sets the format to use for formatting sample values.
 void setRenderedImage(RenderedImage image)
          Sets the image to display.
 
Methods inherited from class AbstractTableModel
addTableModelListener, 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

ImageTableModel

public ImageTableModel()
Creates a new table model with no image.


ImageTableModel

public ImageTableModel(RenderedImage image)
Creates a new table model for the specified image.

Parameters:
image - The image for which to create a table model, or null if none.
Method Detail

setRenderedImage

public void setRenderedImage(RenderedImage image)
Sets the image to display.

Parameters:
image - The new image for this table model, or null if none.

getRenderedImage

public RenderedImage getRenderedImage()
Returns the image to display, or null if none.

Returns:
The image which is backing this table model, or null if none.

getBand

public int getBand()
Returns the band to display.

Returns:
The band where this table model takes its values.

setBand

public void setBand(int band)
Sets the band to display.

Parameters:
band - The band where this table model should take its values.

getNumberFormat

public NumberFormat getNumberFormat()
Returns the format to use for formatting sample values.

Returns:
The format used for formatting cell values.

setNumberFormat

public void setNumberFormat(NumberFormat format)
Sets the format to use for formatting sample values.

Parameters:
format - The new format for formatting cell values.

getRowCount

public int getRowCount()
Returns the number of rows in the model, which is the image height.

Returns:
The image height, or 0 if there is no image.

getColumnCount

public int getColumnCount()
Returns the number of columns in the model, which is the image width.

Returns:
The image width, or 0 if there is no image.

getRowName

public String getRowName(int row)
                  throws IndexOutOfBoundsException
Returns the row name. The names are the pixel row number, starting at the min y value.

Parameters:
row - The row for which to get the name.
Returns:
The name for the requested row.
Throws:
IndexOutOfBoundsException - If the given index is not a positive number smaller than getRowCount().

getColumnName

public String getColumnName(int column)
                     throws IndexOutOfBoundsException
Returns the column name. The names are the pixel column number, starting at the min x value.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
column - The column for which to get the name.
Returns:
The name for the requested column.
Throws:
IndexOutOfBoundsException - If the given index is not a positive number smaller than getColumnCount().

findColumn

public int findColumn(String name)
Returns a column index given its name. If no column having this name is found, returns -1.

Overrides:
findColumn in class AbstractTableModel
Parameters:
name - The column name.
Returns:
The index of the colum of the given name, or -1 if none.

getColumnClass

public Class<? extends Number> getColumnClass(int column)
Returns the type of sample values regardless of column index.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
column - The index for which to get the sample value type.
Returns:
The type of sample values at the given index.

getValueAt

public Number getValueAt(int y,
                         int x)
Returns the sample value at the specified row and column.

Parameters:
y - The row index.
x - The column index.
Returns:
The sample value at the requested cell.

getColorAt

public Color getColorAt(int y,
                        int x)
Returns the color at the specified row and column.

Parameters:
y - The row index.
x - The column index.
Returns:
The color for the requested cell.


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