Package jmri.jmrit.beantable.sensor
Class SensorTableDataModel.ImageIconRenderer
java.lang.Object
javax.swing.AbstractCellEditor
jmri.jmrit.beantable.sensor.SensorTableDataModel.ImageIconRenderer
- All Implemented Interfaces:
Serializable,CellEditor,TableCellEditor,TableCellRenderer
- Enclosing class:
- SensorTableDataModel
static class SensorTableDataModel.ImageIconRenderer
extends AbstractCellEditor
implements TableCellEditor, TableCellRenderer
Visualize state in table as a graphic, customized for Sensors (2 states).
Renderer and Editor are identical, as the cell contents are not actually
edited, only used to toggle state using
SensorTableDataModel.clickOn(jmri.Sensor).
A single label is reused for every cell and the icons are loaded once
per JVM, so rendering a cell allocates nothing. The label ignores
revalidate/repaint requests and the row height is set once in
SensorTableDataModel.configureTable(javax.swing.JTable): painting a cell must never schedule more
painting, or the table repaints itself forever.
-
Field Summary
Fields inherited from class javax.swing.AbstractCellEditor
changeEvent, listenerList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static intGet the row height needed to fit the state icons, loading them if required.getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) protected JLabelupdateLabel(String value, int row) Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditingMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.swing.CellEditor
addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
-
Constructor Details
-
ImageIconRenderer
-
-
Method Details
-
getTableCellRendererComponent
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) - Specified by:
getTableCellRendererComponentin interfaceTableCellRenderer
-
getTableCellEditorComponent
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) - Specified by:
getTableCellEditorComponentin interfaceTableCellEditor
-
updateLabel
-
getCellEditorValue
- Specified by:
getCellEditorValuein interfaceCellEditor
-
getIconRowHeight
Get the row height needed to fit the state icons, loading them if required. Used bySensorTableDataModel.configureTable(javax.swing.JTable)to size the rows once, outside of the render path.- Returns:
- required row height in pixels, 0 if the icons could not be read
-