fix: gamma LC SCAC Baseline 文件生成
This commit is contained in:
parent
bb2822a25a
commit
0ac2c77e27
|
@ -0,0 +1,90 @@
|
|||
package org.jeecg.common.util;
|
||||
|
||||
import org.jeecg.modules.entity.vo.BaseControls;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
public class GammaReportUtil {
|
||||
public static void writeBaseline(BaseControls baseCtrl, String path){
|
||||
// 创建文件
|
||||
File file = new File(path);
|
||||
try {
|
||||
// 创建PrintWriter对象
|
||||
PrintWriter out = new PrintWriter(file);
|
||||
out.println("#AnalyseRange");
|
||||
String low = String.valueOf(baseCtrl.getRg_low());
|
||||
String high = String.valueOf(baseCtrl.getRg_high());
|
||||
out.printf("%" + (low.length() + 15) + "s", low);
|
||||
out.printf("%" + (high.length() + 15) + "s", high);
|
||||
|
||||
out.println("#XCtrl");
|
||||
format(baseCtrl.getXCtrl(), out);
|
||||
|
||||
out.println("#YCtrl");
|
||||
format(baseCtrl.getYCtrl(), out);
|
||||
|
||||
out.println("#YSlope");
|
||||
format(baseCtrl.getYSlope(), out);
|
||||
|
||||
out.println("#Baseline");
|
||||
format(baseCtrl.getBaseline(), out);
|
||||
|
||||
out.println("#StepCounts");
|
||||
format(baseCtrl.getStepCounts(), out);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void writeSCAC(BaseControls baseCtrl, String path){
|
||||
// 创建文件
|
||||
File file = new File(path);
|
||||
try {
|
||||
// 创建PrintWriter对象
|
||||
PrintWriter out = new PrintWriter(file);
|
||||
out.println("#AnalyseRange");
|
||||
String low = String.valueOf(baseCtrl.getRg_low());
|
||||
String high = String.valueOf(baseCtrl.getRg_high());
|
||||
out.printf("%" + (low.length() + 15) + "s", low);
|
||||
out.printf("%" + (high.length() + 15) + "s", high);
|
||||
|
||||
out.println("#XCtrl");
|
||||
format(baseCtrl.getXCtrl(), out);
|
||||
|
||||
out.println("#YCtrl");
|
||||
format(baseCtrl.getYCtrl(), out);
|
||||
|
||||
out.println("#YSlope");
|
||||
format(baseCtrl.getYSlope(), out);
|
||||
|
||||
out.println("#Baseline");
|
||||
format(baseCtrl.getBaseline(), out);
|
||||
|
||||
out.println("#StepCounts");
|
||||
format(baseCtrl.getStepCounts(), out);
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void format(List<Double> baseline, PrintWriter out) {
|
||||
// 每行的数量
|
||||
int numPerLine = 5;
|
||||
int nBL = baseline.size(), nGroupBL = nBL / numPerLine * numPerLine;
|
||||
// 计算每列数据中最长的字符串长度
|
||||
int[] columnWidths = new int[baseline.size()];
|
||||
for (int i = 0; i < baseline.size(); i++) {
|
||||
columnWidths[i] = Math.max(columnWidths[i], baseline.get(i).toString().length());
|
||||
}
|
||||
|
||||
for(int i = 1; i < nGroupBL; i++)
|
||||
{
|
||||
out.printf("%" + (columnWidths[i] + 15) + "s", baseline.get(i-1));
|
||||
if(i % numPerLine == 0){
|
||||
out.println("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user