net.sourceforge.jsh3modtool.gui.imagetable
Class ImageTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by net.sourceforge.jsh3modtool.gui.imagetable.ImageTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel, ImageLoadingListener

public class ImageTableModel
extends javax.swing.table.AbstractTableModel
implements ImageLoadingListener

A model for a JTable oontaining images

Author:
erma
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ImageTableModel(int cols)
          Creates a new instance of BrowseTableModel
 
Method Summary
 void addFilter(CellFilter filter)
          Adds the filter to the filters list, the filter is used until it is removed from this list.
 void addImageModel(ImageModel imageModel)
           
 void addImageModels(java.util.List filesList)
          Adds the specified images to the model
 void clear()
          Removes all items from the model
 boolean contains(BaseCell cell)
          Returns if the model contains the specified cell
 void fireTableCellUpdate(BaseCell cell)
          Fires a cell update.
 int getColumnCount()
          Returns the number of columns in the model.
 int getRowCount()
          Returns the number of rows in the model.
 int getSize()
          Returns the number of images in the model
 JTableUtil.Cell getTableCell(BaseCell cell)
          Returns a JTableUtil.Cell from the specified list index
 java.lang.Object getValueAt(int row, int col)
          Returns the value for the cell at columnIndex and rowIndex.
 java.lang.Object getValueAt(JTableUtil.Cell cell)
          Returns the value for the cell at columnIndex and rowIndex.
 void imageIsLoaded(BaseCell cell)
          Invoked when an image has been loaded, specified by the index in the list This method fires a cell update event.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns whetever this cell is editable or not, this implementation returns false always.
 void removeAllFilters()
          Removes all filters from the list
 void removeFilter(CellFilter filter)
          Removes the filter from the filters list
 void setCellComparator(java.util.Comparator comparator)
          Sets the new cell comparator.
 void setColumnCount(int cols)
          Changes the number of columns
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageTableModel

public ImageTableModel(int cols)
Creates a new instance of BrowseTableModel

Parameters:
cols - number of columns
Method Detail

getColumnCount

public int getColumnCount()
Returns the number of columns in the model. A JTable uses this method to determine how many columns it should create and display by default.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
the number of columns in the model
See Also:
getRowCount()

getRowCount

public int getRowCount()
Returns the number of rows in the model. A JTable uses this method to determine how many rows it should display. This method should be quick, as it is called frequently during rendering.

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
the number of rows in the model
See Also:
getColumnCount()

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Returns the value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
row - the row whose value is to be queried
col - the column whose value is to be queried
Returns:
the value Object at the specified cell

getValueAt

public java.lang.Object getValueAt(JTableUtil.Cell cell)
Returns the value for the cell at columnIndex and rowIndex.

Parameters:
cell - the cell
Returns:
the value Object at the specified cell

setColumnCount

public void setColumnCount(int cols)
Changes the number of columns

Parameters:
cols - the desired number of columns

addImageModel

public void addImageModel(ImageModel imageModel)

addImageModels

public void addImageModels(java.util.List filesList)
Adds the specified images to the model

Parameters:
filesList - a list of Files

contains

public boolean contains(BaseCell cell)
Returns if the model contains the specified cell

Parameters:
cell - the cell to find in the model
Returns:
true if the cell is in the model; false otherwise

clear

public void clear()
Removes all items from the model


imageIsLoaded

public void imageIsLoaded(BaseCell cell)
Invoked when an image has been loaded, specified by the index in the list This method fires a cell update event.

Specified by:
imageIsLoaded in interface ImageLoadingListener
Parameters:
cell - the cell that was updated.

getSize

public int getSize()
Returns the number of images in the model

Returns:
number of items in table

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Returns whetever this cell is editable or not, this implementation returns false always.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
rowIndex - the row
columnIndex - the column
Returns:
false.

fireTableCellUpdate

public void fireTableCellUpdate(BaseCell cell)
Fires a cell update. The method checks if the cell is acceptable by the filters, if not it is removed from the filteredList.

Parameters:
cell - the cell to update.

getTableCell

public JTableUtil.Cell getTableCell(BaseCell cell)
Returns a JTableUtil.Cell from the specified list index

Parameters:
cell - the cell to find in the table
Returns:
a Cell containing the row and column of the cell

addFilter

public void addFilter(CellFilter filter)
Adds the filter to the filters list, the filter is used until it is removed from this list.

Parameters:
filter - the filter to add

removeFilter

public void removeFilter(CellFilter filter)
Removes the filter from the filters list

Parameters:
filter - the filter to remove

removeAllFilters

public void removeAllFilters()
Removes all filters from the list


setCellComparator

public void setCellComparator(java.util.Comparator comparator)
Sets the new cell comparator. The comparator will be activated with Cells that extends the AbstractCell class. All comparators sent to this method must be able to sort the different cells.

Parameters:
comparator -
See Also:
AbstractCellSorter


Copyright © 2005 sourceforge.net. All Rights Reserved.