-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplineThread.java
More file actions
73 lines (65 loc) · 2.79 KB
/
Copy pathSplineThread.java
File metadata and controls
73 lines (65 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package heyingzhe;
import java.awt.Color;
import java.io.IOException;
import java.nio.file.Paths;
import java.sql.SQLException;
import static heyingzhe.SplineInterpolation.splineInterpolation;
public class SplineThread extends Thread {
private double[][] data;
private String outputPath;
private Color color1;
private Color color2;
private String outputSplineImage;
private String dbUserName;
private String dbPassword;
public SplineThread(double[][]data, String outputPath, String outputSplineImage, Color color1, Color color2, String dbUserName, String dbPassword) {
this.data = data;
this.outputPath = outputPath;
this.color1 = color1;
this.color2 = color2;
this.outputSplineImage = outputSplineImage;
this.dbUserName = dbUserName;
this.dbPassword = dbPassword;
}
public void run() {
System.out.println("正在进行样条插值……");
double[][] splineInterpolationResult = splineInterpolation(data); //样条插值
System.out.println("样条插值完成");
// 插值结果输出图片
ImageVisualizer imageVision = new ImageVisualizer();
imageVision.colorizeWithLevels(splineInterpolationResult, color1, color2, 20);
try {
imageVision.saveImage(Paths.get(outputPath, outputSplineImage).toString(), "png");
} catch (IOException e) {
throw new RuntimeException(e);
}
//储存数据到数据库
SaveResult saveProcessing = new SaveResult();
// 配置数据库
saveProcessing.setMySQLProperty(dbUserName, dbPassword);
try {
saveProcessing.createDatabase("result");
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
System.out.println("样条插值:数据库连接成功!");
System.out.println("正在将Spline插值结果上传至数据库……");
try {
saveProcessing.createTable("result", "splineInterpolation");
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}try {
saveProcessing.saveArrayToAscFile(splineInterpolationResult, outputPath, "spline.asc"); //保存为二进制文件
//saveProcessing.saveArrayToMySQL(splineInterpolationResult, "splineInterpolation");
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println("spline数据已经添加到数据库里面");
}
}