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) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
theColumn.dataReader = eachReader;
|
||||||
varDataReaderList.add(eachReader);
|
varDataReaderList.add(eachReader);
|
||||||
}
|
}
|
||||||
eachRow.append("\n");
|
eachRow.append("\n");
|
||||||
@ -143,14 +144,21 @@ public class PlotUtils {
|
|||||||
while (true) {
|
while (true) {
|
||||||
eachRow.append(lineIndex + "\t");
|
eachRow.append(lineIndex + "\t");
|
||||||
// get one value for each variable at a time
|
// get one value for each variable at a time
|
||||||
for (DataReader eachReader : varDataReaderList) {
|
for (ProductColumn theColumn : theTable.getColumnList()) {
|
||||||
try {
|
try {
|
||||||
eachVarValue = eachReader.getVarValue();
|
eachVarValue = theColumn.dataReader.getVarValue();
|
||||||
|
|
||||||
if (Double.isNaN(eachVarValue)) {
|
if (Double.isNaN(eachVarValue)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fmt = theColumn.getFormat();
|
||||||
|
if (fmt != null && fmt != "") {
|
||||||
|
eachRow.append( String.format(fmt, eachVarValue) + "\t");
|
||||||
|
} else {
|
||||||
eachRow.append(eachVarValue + "\t");
|
eachRow.append(eachVarValue + "\t");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.err.println(e);
|
System.err.println(e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -179,6 +187,9 @@ public class PlotUtils {
|
|||||||
for (DataReader eachReader : varDataReaderList) {
|
for (DataReader eachReader : varDataReaderList) {
|
||||||
eachReader.endRead();
|
eachReader.endRead();
|
||||||
}
|
}
|
||||||
|
for (ProductColumn theColumn : theTable.getColumnList()) {
|
||||||
|
theColumn.dataReader = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ package trick.dataproducts.trickqp.utils;
|
|||||||
//========================================
|
//========================================
|
||||||
// Imports
|
// Imports
|
||||||
//========================================
|
//========================================
|
||||||
|
import trick.common.utils.DataReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines column data for Trick QP GUI.
|
* Defines column data for Trick QP GUI.
|
||||||
@ -20,6 +21,7 @@ public class ProductColumn {
|
|||||||
// Public data
|
// Public data
|
||||||
//========================================
|
//========================================
|
||||||
public static String[] GUI_FIELD_LABELS = new String[] {"Format"};
|
public static String[] GUI_FIELD_LABELS = new String[] {"Format"};
|
||||||
|
public DataReader dataReader;
|
||||||
|
|
||||||
//========================================
|
//========================================
|
||||||
// Protected data
|
// Protected data
|
||||||
@ -45,6 +47,7 @@ public class ProductColumn {
|
|||||||
public ProductColumn() {
|
public ProductColumn() {
|
||||||
this.setLabel( "Column" );
|
this.setLabel( "Column" );
|
||||||
this.setUnits( "--" );
|
this.setUnits( "--" );
|
||||||
|
this.dataReader = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,6 +60,7 @@ public class ProductColumn {
|
|||||||
this.setLabel( "Column" );
|
this.setLabel( "Column" );
|
||||||
this.setUnits( "--" );
|
this.setUnits( "--" );
|
||||||
this.setVar( var );
|
this.setVar( var );
|
||||||
|
this.dataReader = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================
|
//========================================
|
||||||
|
Loading…
Reference in New Issue
Block a user