at.tuwien.ifs.commons.gui.controls.swing.table
Class ClassColorTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by at.tuwien.ifs.commons.gui.controls.swing.table.ClassColorTableModel
All Implemented Interfaces:
Serializable, TableModel

public class ClassColorTableModel
extends AbstractTableModel

Version:
$Id: ClassColorTableModel.java 3943 2010-11-22 14:22:07Z frank $
Author:
Jakob Frank
See Also:
Serialized Form

Field Summary
private  Color[] classColors
           
private  String[] classNames
           
private  boolean[] classSelected
           
static int COLOR_COLUMN_INDEX
           
private static String[] columnTitles
           
static int NAME_COLUMN_INDEX
           
static int SELECT_COLUMN_INDEX
           
private  boolean selectionAllowed
           
private static long serialVersionUID
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
ClassColorTableModel()
           
ClassColorTableModel(String[] names, Color[] colors)
           
 
Method Summary
static BufferedImage asBufferedImage(ClassColorTableModel theModel)
           
static BufferedImage asBufferedImage(ClassColorTableModel theModel, boolean showAllRows)
           
static JTable createColorLegendTable(ClassColorTableModel theModel)
          Creates a ColorLegendTable to be used with the required default listeners added.
private static void fixColumnWidth(JTable table, int columnIndex, boolean setMin, boolean setMax)
           
 String getClassName(int row)
           
 String[] getClassNames()
           
 Color getColor(int row)
           
 Color[] getColors()
           
 Class<?> getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int columnIndex)
           
 String getLongestName()
           
 int getRowCount()
           
 String[] getSelectedClasses()
           
 int[] getSelectedClassIndices()
           
 Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isAllSelected()
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 boolean isSelectionAllowed()
           
static void main(String[] args)
           
 void setAllSelected(boolean selected)
           
 void setColumnName(int columnIndex, String name)
           
 void setSelected(int[] selectedClassIndices)
           
 void setSelected(int rowIndex, boolean selected)
           
 void setSelectionAllowed(boolean selectionAllowed)
           
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

NAME_COLUMN_INDEX

public static final int NAME_COLUMN_INDEX
See Also:
Constant Field Values

COLOR_COLUMN_INDEX

public static final int COLOR_COLUMN_INDEX
See Also:
Constant Field Values

SELECT_COLUMN_INDEX

public static final int SELECT_COLUMN_INDEX
See Also:
Constant Field Values

columnTitles

private static String[] columnTitles

classColors

private final Color[] classColors

classNames

private final String[] classNames

classSelected

private final boolean[] classSelected

selectionAllowed

private boolean selectionAllowed
Constructor Detail

ClassColorTableModel

public ClassColorTableModel()

ClassColorTableModel

public ClassColorTableModel(String[] names,
                            Color[] colors)
Method Detail

setAllSelected

public void setAllSelected(boolean selected)

setSelected

public void setSelected(int rowIndex,
                        boolean selected)

getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getColumnName

public String getColumnName(int columnIndex)
Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel

setColumnName

public void setColumnName(int columnIndex,
                          String name)

getColumnClass

public Class<?> getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel
Overrides:
setValueAt in class AbstractTableModel

main

public static void main(String[] args)

createColorLegendTable

public static JTable createColorLegendTable(ClassColorTableModel theModel)
Creates a ColorLegendTable to be used with the required default listeners added.

Parameters:
theModel - the ClassColorTableModel
Returns:
a JTable with nice default settings

fixColumnWidth

private static void fixColumnWidth(JTable table,
                                   int columnIndex,
                                   boolean setMin,
                                   boolean setMax)

isAllSelected

public boolean isAllSelected()

getSelectedClasses

public String[] getSelectedClasses()

getSelectedClassIndices

public int[] getSelectedClassIndices()

getColors

public Color[] getColors()

getColor

public Color getColor(int row)

getClassNames

public String[] getClassNames()

getClassName

public String getClassName(int row)

getLongestName

public String getLongestName()
Returns:
the longest ClassName

isSelectionAllowed

public boolean isSelectionAllowed()

setSelectionAllowed

public void setSelectionAllowed(boolean selectionAllowed)

asBufferedImage

public static BufferedImage asBufferedImage(ClassColorTableModel theModel)

asBufferedImage

public static BufferedImage asBufferedImage(ClassColorTableModel theModel,
                                            boolean showAllRows)
Parameters:
theModel - The model to paint
showAllRows - paint all rows or just selected
Returns:
a buffered image.

setSelected

public void setSelected(int[] selectedClassIndices)