mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 05:07:54 +00:00
Format table column data per the format property. Ref #496
This commit is contained in:
parent
6271283c31
commit
41558d7188
@ -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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
//========================================
|
||||
|
Loading…
Reference in New Issue
Block a user