mirror of https://github.com/rusefi/RomRaider.git
Added table precision
git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@591 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
parent
e3c5422c4d
commit
c4c4ecaf3b
|
@ -1,5 +1,7 @@
|
|||
package enginuity.NewGUI.data;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import enginuity.NewGUI.interfaces.TuningEntity;
|
||||
|
||||
public class TableMetaData {
|
||||
|
@ -23,7 +25,7 @@ public class TableMetaData {
|
|||
private String tableGroup;
|
||||
private int dimensions;
|
||||
private TuningEntity parentTuningEntity;
|
||||
|
||||
private DecimalFormat formatter = new DecimalFormat( "#.0" );
|
||||
|
||||
public TableMetaData(int dimensions, double minValue, double maxValue, Object[] ignoredValues, String[] columnLabels, String[] rowLabels, boolean isInvertedColoring, String tableName, String tableIdentifier, String tableGroup, TuningEntity parentTuningEntity) {
|
||||
this.dimensions = dimensions;
|
||||
|
@ -84,4 +86,15 @@ public class TableMetaData {
|
|||
public String getTableGroup() {
|
||||
return tableGroup;
|
||||
}
|
||||
|
||||
|
||||
// Getters and setters for not so commonly used items, not included in constructor
|
||||
|
||||
public DecimalFormat getFormatter() {
|
||||
return formatter;
|
||||
}
|
||||
|
||||
public void setFormatter(DecimalFormat formatter) {
|
||||
this.formatter = formatter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,11 +50,6 @@ public class ETable extends JTable{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void smoothEntireTableData(){
|
||||
Double[][] newData = FitData.getFullSmooth(this.getTheModel().getData());
|
||||
this.getTheModel().replaceData(newData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a cell as being selected.
|
||||
|
|
|
@ -2,6 +2,7 @@ package enginuity.NewGUI.etable;
|
|||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
@ -15,6 +16,7 @@ public class ETableCellRenderer extends DefaultTableCellRenderer{
|
|||
private Object[] ignoredValues;
|
||||
private boolean isInvertedColoring;
|
||||
|
||||
|
||||
public ETableCellRenderer(double min, double max, Object[] ignoredValues, boolean isInvertedColoring){
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package enginuity.NewGUI.etable;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
import enginuity.NewGUI.data.TableMetaData;
|
||||
|
@ -9,6 +11,7 @@ public class ETableModel extends AbstractTableModel {
|
|||
private String[] columnNames = new String[11];
|
||||
private Double[][] data = new Double[11][40];
|
||||
private TableMetaData tableMetaData;
|
||||
private DecimalFormat formatter = new DecimalFormat( "#.0" );
|
||||
|
||||
public ETableModel(TableMetaData metaData, Double[][] initialData) {
|
||||
this.tableMetaData = metaData;
|
||||
|
@ -51,24 +54,28 @@ public class ETableModel extends AbstractTableModel {
|
|||
|
||||
if(value instanceof String){
|
||||
try{
|
||||
temp = Double.parseDouble((String)value);
|
||||
String tempString = formatter.format(value);
|
||||
temp = Double.parseDouble(tempString);
|
||||
}catch (NumberFormatException e) {
|
||||
System.out.println("Not a valid number entered.");
|
||||
}
|
||||
data[col][row] = temp;
|
||||
}else if(value instanceof Double){
|
||||
data[col][row] = (Double)value;
|
||||
String tempString = formatter.format(value);
|
||||
data[col][row] = Double.parseDouble(tempString);
|
||||
}
|
||||
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
public void setDoubleData(int row, int col, double value){
|
||||
this.data[col][row] = value;
|
||||
String tempString = formatter.format(value);
|
||||
this.data[col][row] = Double.parseDouble(tempString);
|
||||
}
|
||||
|
||||
|
||||
public void replaceData(Double[][] newData){
|
||||
|
||||
this.copyData(newData);
|
||||
|
||||
this.fireTableDataChanged();
|
||||
|
@ -87,7 +94,8 @@ public class ETableModel extends AbstractTableModel {
|
|||
for(int i = 0; i < width; i ++){
|
||||
for(int j=0; j < height; j++){
|
||||
double tempData = data[i][j];
|
||||
this.data[i][j] = tempData;
|
||||
String tempString = formatter.format(tempData);
|
||||
this.data[i][j] = Double.parseDouble(tempString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue