Skip to content

Commit

Permalink
2021-04-27
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgramTraveler committed Apr 26, 2021
1 parent 15370ac commit 4d9dcbd
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 26 deletions.
Binary file added PenProject.zip
Binary file not shown.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -886,3 +886,18 @@
* 平均值保留两位小数

---

### 2021-04-26

#### 对偏移量精度的修改

* 最初的保留的两位小数,修改为保留三位小数

#### 保存偏移量的数据格式

* 整数的末尾要和小数一样,在末尾补零
* 其实在程序中会是做出显示,例如 **13.000** ,但在文件中确实 **13** 应该是 **CSV** 文件格式问题,所以数字后面的零直接被忽略了
* **解决办法:** 将数字转换成字符,通过判断字符长度来决定是否添加 **后置0**,很妙,这个方法太复杂了,没有实现
* **另一个解决办法:** 直接在后面加制表符 **\t**就行了,直接解决这个问题

---
Binary file modified README.pdf
Binary file not shown.
18 changes: 3 additions & 15 deletions information.csv
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
id,����,ʵ������,ʵ������,ģʽ�л�����,Ŀ����ɫ,Ŀ���ϸ,��ʼʱ��,����ʱ��,��ɫ�л�ʱ��,�����л�ʱ��,ģʽ�л���ʱ��,��������ʱ��,��һ�λ���ʱ��,�ڶ��λ���ʱ��,�����λ���ʱ��,�󴥷�����,��ɫ�л�������,�����л�������,ģʽ�л��ܴ�����,ѹ��1,ѹ��2,ѹ��ƽ��ֵ,��λ��1,��λ��2,��λ��ƽ��ֵ,��б��1,��б��2,��б��ƽ��ֵ,���ƫ����
1,,1,1,��ͳ����ģʽ,��ɫ,2.0,13:24:17:760,13:24:21:756,-1619155459404,-1619155461444,-3238310920848,5757,2428,1252,1487,0,1,1,2,0,0,0,0,0,0,0,0,0,7,
2,,1,2,��ͳ����ģʽ,��ɫ,4.0,13:24:17:760,13:24:21:756,-1619155500150,-1619155502424,-3238311002574,6182,2442,1782,1552,0,1,1,4,0,0,0,0,0,0,0,0,0,10,
3,,1,1,��ͳ����ģʽ,��ɫ,4.0,13:26:20:535,13:26:21:823,-1619155581091,-1619155581718,-3238311162809,1709,706,339,221,0,1,1,2,0,0,0,0,0,0,0,0,0,12,
4,,1,1,��ͳ����ģʽ,��ɫ,4.0,14:32:56:217,14:32:57:206,-1619159576496,-1619159577093,-3238319153589,1509,425,344,295,0,1,1,2,0,0,0,0,0,0,0,0,0,6,
5,,1,1,��ͳ����ģʽ,��ɫ,4.0,14:34:23:396,14:34:24:114,-1619159664161,-1619159664649,-3238319328810,2100,437,645,502,0,1,1,2,0,0,0,0,0,0,0,0,0,20,
6,,1,1,��ͳ����ģʽ,��ɫ,4.0,14:36:01:654,14:36:02:917,-1619159761936,-1619159762719,-3238319524655,3208,531,528,312,0,1,1,2,0,0,0,0,0,0,0,0,0,13,
7,,1,2,��ͳ����ģʽ,��ɫ,2.0,14:36:01:654,14:36:02:917,-1619159775465,-1619159777463,-3238319552928,5493,1723,1831,1534,0,1,1,4,0,0,0,0,0,0,0,0,0,11,
8,,1,1,��ͳ����ģʽ,��ɫ,4.0,14:37:14:895,14:37:19:611,-1619159837182,-1619159839516,-3238319676698,6922,2459,2022,1987,0,1,1,2,0,0,0,0,0,0,0,0,0,14,
9,,1,1,��ͳ����ģʽ,��ɫ,2.0,14:38:02:593,14:38:06:936,-1619159884424,-1619159886748,-3238319771172,6961,2147,1974,2446,0,1,1,2,0,0,0,0,0,0,0,0,0,15,
10,,1,1,��ͳ����ģʽ,��ɫ,4.0,14:38:42:418,14:38:48:89,-1619159925158,-1619159927870,-3238319853028,8411,2865,2570,2456,0,1,1,2,0,0,0,0,0,0,0,0,0,java.text.DecimalFormat@674dc,
11,,1,1,��ͳ����ģʽ,��ɫ,4.0,14:39:44:285,14:39:50:385,-1619159987196,-1619159990089,-3238319977285,8390,3066,2702,1974,0,1,1,2,0,0,0,0,0,0,0,0,0,20.47,
12,,1,2,��ͳ����ģʽ,��ɫ,3.0,14:39:44:285,14:39:50:385,-1619160015618,-1619160018199,-3238320033817,8490,3261,2427,2333,0,1,1,4,0,0,0,0,0,0,0,0,0,16.00,
13,,1,4,��ͳ����ģʽ,��ɫ,4.0,14:39:44:285,14:39:50:385,-1619160052317,-1619160054154,-3238320106471,5369,2087,1377,1303,0,1,1,8,0,0,0,0,0,0,0,0,0,13.17,
14,,1,1,��ͳ����ģʽ,��ɫ,3.0,14:42:15:430,14:42:19:87,-1619160136981,-1619160138645,-3238320275626,5632,2174,1146,1693,0,1,1,2,0,0,0,0,0,0,0,0,0,6.85,
15,,1,2,��ͳ����ģʽ,��ɫ,3.0,14:42:15:430,14:42:19:87,-1619160157324,-1619160159706,-3238320317030,5657,1505,1721,1380,0,1,1,4,0,0,0,0,0,0,0,0,0,2.04,
1,,1,1,��ͳ����ģʽ,��ɫ,2.0,17:34:49:877,17:34:52:993,-1619429691263,-1619429692753,-3238859384016,4474,1648,1254,1111,0,1,1,2,0,0,0,0,0,0,0,0,0,15.765
2,,1,2,��ͳ����ģʽ,��ɫ,3.0,17:34:49:877,17:34:52:993,-1619429700197,-1619429701289,-3238859401486,2893,921,947,626,0,1,1,4,0,0,0,0,0,0,0,0,0,5.000
3,,1,3,��ͳ����ģʽ,��ɫ,3.0,17:34:49:877,17:34:52:993,-1619429709099,-1619429710563,-3238859419662,4636,2013,1297,923,0,1,1,6,0,0,0,0,0,0,0,0,0,21.769
Binary file modified out/production/PenProject/ActualAzimuth.class
Binary file not shown.
Binary file modified out/production/PenProject/ActualPress.class
Binary file not shown.
Binary file modified out/production/PenProject/ActualTilt.class
Binary file not shown.
Binary file modified out/production/PenProject/IncrementAzimuth.class
Binary file not shown.
Binary file modified out/production/PenProject/IncrementPress.class
Binary file not shown.
Binary file modified out/production/PenProject/IncrementTilt.class
Binary file not shown.
Binary file modified out/production/PenProject/PenData.class
Binary file not shown.
Binary file modified out/production/PenProject/ScatteredAzimuth.class
Binary file not shown.
Binary file modified out/production/PenProject/ScatteredPress.class
Binary file not shown.
Binary file modified out/production/PenProject/ScatteredTilt.class
Binary file not shown.
Binary file modified out/production/PenProject/TraditionalFrame.class
Binary file not shown.
52 changes: 41 additions & 11 deletions src/PenData.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class PenData {

private RandomAccessFile csv; // 存实验数据的文件

private ArrayList<Integer> shift; //记录绘制过程中点的偏移量
private ArrayList<Double> shift; //记录绘制过程中点的偏移量

public PenData() {
//对所有数据进行初始化
Expand Down Expand Up @@ -121,7 +121,7 @@ public PenData() {

TimeList = new ArrayList<Long>();
TimeListString = new ArrayList<String>();
shift = new ArrayList<Integer>();
shift = new ArrayList<Double>();

StartColorMode = 0;
EndColorMode = 0;
Expand Down Expand Up @@ -234,7 +234,7 @@ public int GetModeE() {
public void SetStartPixelMode(long l) { StartPixelMode = l; }
public void SetEndPixelMode(long l) { EndPixelMode = l; }
//记录点的偏移量
public void SetShift(int i) { shift.add(i); }
public void SetShift(double i) { shift.add(i); }
//对点的偏移量进行初始化
public void InitShift() { shift.clear(); }
//将时间戳容器的值分配给各个测试变量
Expand Down Expand Up @@ -320,7 +320,7 @@ public void SaveInformation() throws IOException {
+ PaintTime2 + "," + PaintTime3 + "," + TouchError + "," + ColorModeE + "," + PixelModeE +","+ModelError + "," + pressureColor +"," + pressurePixel + "," + pressure / count+ "," + azimuthColor + "," + azimuthPixel+ "," + azimuth / count + "," + tiltColor+ ","+ tiltPixel + "," + tilt / count + ",";

//下面注释的部分是当时为了把所有点的偏移量都记录在文件中,后面对偏移量的记录只需要计算平均值就行了,所以不需要了
int aver = 0;
double aver = 0;
for (int i = 0; i < shift.size(); i ++) {
//下面注释的部分是当时为了把所有点的偏移量都记录在文件中,后面对偏移量的记录只需要计算平均值就行了,所以不需要了
/*String SaveText = index + "," + saveText + shift.get(i) + "," + "\n";
Expand All @@ -331,16 +331,46 @@ public void SaveInformation() throws IOException {
aver += shift.get(i);
}
//System.out.println();
//格式控制,用来输出保留两位小数
DecimalFormat df = new DecimalFormat("#.00");
//System.out.println(df.format(((double)aver / (double)shift.size())));
//System.out.println(aver);
String SaveText = index + "," + saveText + (df.format(((double)aver / (double)shift.size()))) + "," + "\n";
csv.write(SaveText.getBytes("GBK"));
//System.out.println(shift.size());
//格式控制,用来输出保留三位小数
DecimalFormat df = new DecimalFormat("#.000");

System.out.println(df.format((aver / (double)shift.size())));

/*这是一次失败的尝试,为了将整数后的零也显示出来,但是失败了
double tempD = (aver / (double)shift.size());
String str = String.valueOf(tempD);
int len = str.indexOf('.'); //获得小数点开始的位置
//如果是负数,说明是个整数
if (len < 0) {
String SaveText = index + "," + saveText + str + "=\".000 \"" + "\n";
csv.write(SaveText.getBytes("GBK"));
csv.close();
}else if (str.length() - len == 1){
String SaveText = index + "," + saveText + str + "=\".00 \"" + "\n";
csv.write(SaveText.getBytes("GBK"));
csv.close();
}else {
String SaveText = index + "," + saveText + str + "\n";
csv.write(SaveText.getBytes("GBK"));
csv.close();
}*/

/*while (str.length() <= len + 3) {
str += '0';
}*/

//制表符是为了将整数小数点后的0进行显示
String SaveText = index + "," + saveText + df.format((aver / (double)shift.size())) + "\t" + "\n";
//String SaveText = index + "," + saveText + "1" + "\"0.0000000\"" + "\n";
//String SaveText = index + "," + saveText + "1" + "0.0000000\t" + "\n";
csv.write(SaveText.getBytes("GBK"));
csv.close();


}

}
Binary file added 项目编写的其他内容/information7.0.csv
Binary file not shown.

0 comments on commit 4d9dcbd

Please sign in to comment.