Format table column data per the format property. Ref #496

This commit is contained in:
John M. Penn 2017-10-25 18:17:02 -05:00
parent 6271283c31
commit 41558d7188
2 changed files with 18 additions and 3 deletions

View File

@ -112,6 +112,7 @@ public class PlotUtils {
} catch (IOException e) {
e.printStackTrace();
}
theColumn.dataReader = eachReader;
varDataReaderList.add(eachReader);
}
eachRow.append("\n");
@ -143,14 +144,21 @@ public class PlotUtils {
while (true) {
eachRow.append(lineIndex + "\t");
// get one value for each variable at a time
for (DataReader eachReader : varDataReaderList) {
for (ProductColumn theColumn : theTable.getColumnList()) {
try {
eachVarValue = eachReader.getVarValue();
eachVarValue = theColumn.dataReader.getVarValue();
if (Double.isNaN(eachVarValue)) {
break;
}
eachRow.append(eachVarValue + "\t");
String fmt = theColumn.getFormat();
if (fmt != null && fmt != "") {
eachRow.append( String.format(fmt, eachVarValue) + "\t");
} else {
eachRow.append(eachVarValue + "\t");
}
} catch (FileNotFoundException e) {
System.err.println(e);
} catch (IOException e) {
@ -179,6 +187,9 @@ public class PlotUtils {
for (DataReader eachReader : varDataReaderList) {
eachReader.endRead();
}
for (ProductColumn theColumn : theTable.getColumnList()) {
theColumn.dataReader = null;
}
}
}

View File

@ -7,6 +7,7 @@ package trick.dataproducts.trickqp.utils;
//========================================
// Imports
//========================================
import trick.common.utils.DataReader;
/**
* Defines column data for Trick QP GUI.
@ -20,6 +21,7 @@ public class ProductColumn {
// Public data
//========================================
public static String[] GUI_FIELD_LABELS = new String[] {"Format"};
public DataReader dataReader;
//========================================
// Protected data
@ -45,6 +47,7 @@ public class ProductColumn {
public ProductColumn() {
this.setLabel( "Column" );
this.setUnits( "--" );
this.dataReader = null;
}
/**
@ -57,6 +60,7 @@ public class ProductColumn {
this.setLabel( "Column" );
this.setUnits( "--" );
this.setVar( var );
this.dataReader = null;
}
//========================================