Skip to content

Commit 44183ad

Browse files
committed
Added a sources.
1 parent f2b2bd3 commit 44183ad

File tree

8 files changed

+1419
-0
lines changed

8 files changed

+1419
-0
lines changed

src/main/java/com/cpm/Main.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.cpm;
2+
3+
import com.cpm.prog.Conformation;
4+
import com.cpm.prog.Program;
5+
import com.cpm.parameters.Constant;
6+
import com.cpm.parameters.ParametersSystem;
7+
import com.cpm.prog.License;
8+
9+
import javax.swing.*;
10+
11+
public class Main {
12+
13+
public static void main(String[] args) {
14+
try {
15+
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
16+
if ("Windows".equals(info.getName())) {
17+
UIManager.setLookAndFeel(info.getClassName());
18+
break;
19+
}
20+
}
21+
} catch (Exception ex) {
22+
ex.printStackTrace();
23+
}
24+
newApplication();
25+
}
26+
27+
private static void newApplication() {
28+
ParametersSystem.setFileName(Constant.FILE_SYSTEM);
29+
final ParametersSystem parameters = ParametersSystem.getInstance();
30+
try {
31+
if (!parameters.isLicense()) {
32+
final Thread thread = new Thread(new License());
33+
thread.start();
34+
thread.join();
35+
}
36+
} catch (InterruptedException ex) {
37+
ex.printStackTrace();
38+
}
39+
final Conformation conformation = new Conformation();
40+
final Program program = new Program(conformation);
41+
final Thread th = new Thread(program);
42+
th.start();
43+
}
44+
}

src/main/java/com/cpm/gui/UserInterface.java

Lines changed: 415 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.cpm.parameters;
2+
3+
public final class Constant {
4+
5+
public static final int NUMBER_DEFOULT = 6;
6+
public static final int ACCURACY_DEFOULT = 3;
7+
8+
public static final String NAME = "CPM";
9+
public static final String VERSION = "v. 1.0";
10+
public static final String FILE_RESULT = NAME + "_Result.txt";
11+
public static final String FILE_MANUAL = "manual.pdf";
12+
public static final String FILE_SYSTEM = "system.cpm";
13+
14+
public static final String FONT_NAME = "Times New Roman";
15+
public static final String MAIN_FRAME_NAME = NAME + ": Cremer-Pople method";
16+
17+
public static final String ERROR = NAME + ": Error!";
18+
public static final String WARNING = NAME + ": Warning!";
19+
public static final String ABOUT = NAME + ": About the program";
20+
public static final String LICENSE = NAME + ": License agreement";
21+
public static final String NUMERICAL_VALUE = "Torsion angles should take numerical values!";
22+
public static final String NUMBERS_DIAPASON = "The number of members in the cycle can be anywhere from 5 to 15!";
23+
public static final String ACCURACY_DIAPASON = "The order of accuracy can be anywhere from 1 to 5!";
24+
public static final String ENTER_ANGLES = "Enter the experimental torsion angles!";
25+
public static final String SAVE_RESULT = "Do you want to save results to file?";
26+
public static final String FILE_ABSENT = "File is absent!";
27+
28+
public static final String PROGRAM_ABOUT = NAME + " " + VERSION + "\n"
29+
+ "\nAuthors: Yu. A. Salimov and Yu. G. Vlasenko\n"
30+
+ "\nE-mail:\n"
31+
+ "yuriy.alex.salimov@gmail.com\n"
32+
+ "jgeorge@ukr.net";
33+
34+
public static final String LICENSE_AGREEMENT = NAME + " " + VERSION + "\n"
35+
+ "Same text\n"
36+
+ "You agree?\n";
37+
38+
private Constant() {
39+
}
40+
}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
package com.cpm.parameters;
2+
3+
import com.cpm.prog.Files;
4+
5+
import java.io.IOException;
6+
import java.io.Serializable;
7+
8+
public final class ParametersSystem implements Serializable {
9+
10+
private static final long serialVersionUID = 1L;
11+
private static transient String fileName;
12+
private int number;
13+
private int accuracy;
14+
private boolean onTop;
15+
private boolean autoSave;
16+
private boolean license;
17+
18+
private transient static ParametersSystem parameters;
19+
20+
private ParametersSystem() {
21+
this.number = Constant.NUMBER_DEFOULT;
22+
this.accuracy = Constant.ACCURACY_DEFOULT;
23+
}
24+
25+
public static ParametersSystem getInstance() {
26+
if (parameters == null) {
27+
try {
28+
parameters = (ParametersSystem) Files.deserialization(fileName);
29+
} catch (IOException | ClassNotFoundException ex) {
30+
parameters = new ParametersSystem();
31+
}
32+
}
33+
return parameters;
34+
}
35+
36+
@Override
37+
public String toString() {
38+
return "number = " + this.number +
39+
"; \r\naccuracy = " + this.accuracy +
40+
"; \r\nonTop = " + this.onTop +
41+
"; \r\navtoSave = " + this.autoSave +
42+
"; \r\nlicense = " + this.license;
43+
}
44+
45+
public static void setFileName(final String fileName) {
46+
ParametersSystem.fileName = fileName;
47+
}
48+
49+
public static String getFileName() {
50+
return fileName;
51+
}
52+
53+
public void setNumber(final int number) {
54+
this.number = number;
55+
}
56+
57+
public int getNumber() {
58+
return this.number;
59+
}
60+
61+
public void setAccuracy(final int accuracy) {
62+
this.accuracy = accuracy;
63+
}
64+
65+
public int getAccuracy() {
66+
return this.accuracy;
67+
}
68+
69+
public void setOnTop(final boolean onTop) {
70+
this.onTop = onTop;
71+
}
72+
73+
public boolean isOnTop() {
74+
return this.onTop;
75+
}
76+
77+
public void setAutoSave(final boolean autoSave) {
78+
this.autoSave = autoSave;
79+
}
80+
81+
public boolean isAutoSave() {
82+
return this.autoSave;
83+
}
84+
85+
public void setLicense(final boolean license) {
86+
this.license = license;
87+
}
88+
89+
public boolean isLicense() {
90+
return this.license;
91+
}
92+
}

0 commit comments

Comments
 (0)