public class GTableModel extends AbstractTableModel
Modifier and Type | Class and Description |
---|---|
static class |
GTableModel.Format
Format for the entry field.
|
listenerList
Constructor and Description |
---|
GTableModel(boolean isDataEditable,
int rowsNumber,
int columnsNumber,
GUnit headerUnit,
GUnit dataUnit,
double headerDefaultValue,
double dataDefaultValue)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(int columnModelIndex,
double headerValue)
Adds a new blank column (with the default value) to the table model.
|
void |
addColumn(int columnModelIndex,
double[] newColumnValues,
double headerValue)
Adds a new column with values to the table model.
|
void |
addRow(int rowModelIndex)
Adds a new blank row (with the default value) to the table model.
|
void |
addRow(int rowModelIndex,
ArrayList<Double> newRowValuesList)
Adds a new row with values to the table model.
|
void |
deleteColumn(int columnModelIndex)
Deletes a column from the table model.
|
void |
deleteRow(int rowModelIndex)
Deletes a row from the table model.
|
String |
formatValue(int fracDigits,
GTableModel.Format format,
double value)
Format the value to display according to the formatting options of the field.
|
int |
getColumnCount() |
String |
getColumnName(int columnModelIndex) |
GUnit |
getDataCurrentUnit()
Return the header current unit.
|
int |
getDataFracDigits()
Get the number of digits of the data values.
|
GUnit |
getDataUnitInConfigFile()
Get the unit of the data in the configuration file.
|
GUnit |
getHeaderCurrentUnit()
Return the header current unit.
|
int |
getHeaderFracDigits()
Get the number of digits of the header values.
|
GUnit |
getHeaderUnitInConfigFile()
Get the unit of the header in the configuration file.
|
ArrayList<Double> |
getHeaderValues()
Get the arrayList of header values.
|
int |
getRowCount() |
Object |
getValueAt(int rowModelIndex,
int columnModelIndex) |
ArrayList<ArrayList<Double>> |
getValues()
Get the arayList of data values.
|
boolean |
isCellEditable(int rowModelIndex,
int columnModelIndex) |
void |
setColumnName(int columnModelIndex,
Double newValue,
String newUnitString)
Sets the names of the column headers into the list of header names.
|
void |
setDataDefaultValue(double defaultValue)
Set the default value for the data cells.
|
void |
setDataFormat(GTableModel.Format newFormat)
Sets the format allowed for the field.
|
void |
setDataFracDigits(int fracDigits)
Set the number of digits of the data values.
|
void |
setDataUnit(GUnit newUnit)
Set the data unit.
|
void |
setDataUnitInConfigFile(GUnit newUnit)
Set the unit in the configuration file for the data.
|
void |
setDataValue(int rowModelIndex,
int columnModelIndex,
Double newValue,
String newUnitString)
Set the value of the data for the cell identified by rowModelIndex and columnModelIndex.
|
void |
setHeaderDefaultValue(double defaultValue)
Set the default value for the header cells.
|
void |
setHeaderFormat(GTableModel.Format newFormat)
Sets the format allowed for the field.
|
void |
setHeaderFracDigits(int fracDigits)
Set the number of digits of the header values.
|
void |
setHeaderUnit(GUnit newUnit)
Set the header unit.
|
void |
setHeaderUnitInConfigFile(GUnit newUnit)
Set the unit in the configuration file for the header.
|
void |
setValueAt(Object cellContents,
int rowModelIndex,
int columnModelIndex) |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
public GTableModel(boolean isDataEditable, int rowsNumber, int columnsNumber, GUnit headerUnit, GUnit dataUnit, double headerDefaultValue, double dataDefaultValue)
isDataEditable
- boolean flag that originally sets the table to editable if true or false, otherwise.rowsNumber
- the number of rows of the table model.columnsNumber
- the number of columns of the table model.headerUnit
- unit of the header.dataUnit
- unit of the data.headerDefaultValue
- default value for the header cells.dataDefaultValue
- default value for the data cells.public String formatValue(int fracDigits, GTableModel.Format format, double value)
fracDigits
- number of fractional digits to format.format
- used to format the value, either NORMAL or SCIENTIFIC.value
- value to format.public int getRowCount()
public int getColumnCount()
public Object getValueAt(int rowModelIndex, int columnModelIndex)
public String getColumnName(int columnModelIndex)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
public boolean isCellEditable(int rowModelIndex, int columnModelIndex)
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
public void setValueAt(Object cellContents, int rowModelIndex, int columnModelIndex)
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
public void setDataValue(int rowModelIndex, int columnModelIndex, Double newValue, String newUnitString) throws GArithmeticException
rowModelIndex
- index of the row in the model.columnModelIndex
- index of the column in the model.newValue
- new value.newUnitString
- unit of the new value, if null then use the current unit, if any.GArithmeticException
- if newValue is NaNpublic void setColumnName(int columnModelIndex, Double newValue, String newUnitString) throws GArithmeticException
columnModelIndex
- the index in the table model of the header to be named.newValue
- the value of the header.newUnitString
- unit of the newVale, if null the value is considered to be in the current units.GArithmeticException
- if newValue is NaNpublic void addRow(int rowModelIndex)
rowModelIndex
- the index in the table model where to add the new row.public void addRow(int rowModelIndex, ArrayList<Double> newRowValuesList)
rowModelIndex
- the index in the table model where to add the new row.newRowValuesList
- the arrayList containing the values of the new row.public void addColumn(int columnModelIndex, double headerValue)
columnModelIndex
- the index in the table model where to add the new column.headerValue
- the value of the header for the new column.public void addColumn(int columnModelIndex, double[] newColumnValues, double headerValue)
columnModelIndex
- the index in the table model where to add the new column.newColumnValues
- the array containing the values of the new column.headerValue
- the value of the header for the new column.public void deleteRow(int rowModelIndex)
rowModelIndex
- the index in the table model of the row to be deleted.public void deleteColumn(int columnModelIndex)
columnModelIndex
- the index in the table model of the column to be deleted.public void setHeaderUnit(GUnit newUnit)
newUnit
- the new header unit.public void setDataUnit(GUnit newUnit)
newUnit
- the new data unit.public void setHeaderFormat(GTableModel.Format newFormat)
newFormat
- allowed for the field.public void setDataFormat(GTableModel.Format newFormat)
newFormat
- allowed for the field.public void setHeaderFracDigits(int fracDigits)
fracDigits
- the number of digits of the header values.public int getHeaderFracDigits()
public void setDataFracDigits(int fracDigits)
fracDigits
- the number of digits of the data values.public int getDataFracDigits()
public void setHeaderUnitInConfigFile(GUnit newUnit)
newUnit
- the unit in the configuration file for the header.public GUnit getHeaderUnitInConfigFile()
public GUnit getHeaderCurrentUnit()
public void setDataUnitInConfigFile(GUnit newUnit)
newUnit
- the unit in the configuration file for the data.public GUnit getDataUnitInConfigFile()
public GUnit getDataCurrentUnit()
public ArrayList<Double> getHeaderValues()
public ArrayList<ArrayList<Double>> getValues()
public void setDataDefaultValue(double defaultValue) throws GArithmeticException
defaultValue
- the default value for the data cells.GArithmeticException
- if defaultValue is NaNpublic void setHeaderDefaultValue(double defaultValue) throws GArithmeticException
defaultValue
- the default value for the header cells.GArithmeticException
- if defaultValue is NaNCopyright © 2024. All rights reserved.