-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetting.java
More file actions
119 lines (99 loc) · 2.83 KB
/
Copy pathSetting.java
File metadata and controls
119 lines (99 loc) · 2.83 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package parameter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import javafx.scene.paint.Color;
/**
*
* @author Neil Farmer
*
*/
public class Setting{
private Color ColorVertexDefault;
private Color ColorWrittenVertexName;
private Color ColorEdge;
/**
* Constructor
*/
public Setting() {
Properties properties = new Properties();
try {
properties.loadFromXML(new FileInputStream("config.xml"));
} catch (IOException e) {
e.printStackTrace();
}
ColorVertexDefault = Color.valueOf(properties.getProperty("ColorVertexDefault", "Orange"));
ColorWrittenVertexName = Color.valueOf(properties.getProperty("ColorWrittenVertexName", "Black"));
ColorEdge = Color.valueOf(properties.getProperty("ColorEdge", "Gray"));
}
/**
* Function to save a parameter
* @param reference (String) : Reference to the parameter
* @param value (String) : The value of this parameter
*/
private void saveSetting(String reference, String value) {
Properties props = new Properties();
try {
props.loadFromXML(new FileInputStream("config.xml"));
} catch (IOException e) {
e.printStackTrace();
}
Properties propClone = new Properties();
propClone = (Properties) props.clone();
propClone.setProperty(reference, value);
try {
File configFile = new File("config.xml");
FileOutputStream out = new FileOutputStream(configFile);
propClone.storeToXML(out, "Configuration");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Function to set the color of the text of a vertex
* @param value (Color)
*/
public void setColorWrittenVertexName(Color value) {
this.ColorWrittenVertexName = value;
saveSetting("ColorWrittenVertexName", value.toString());
}
/**
*
* @return The default color of vertex
*/
public Color getColorWrittenVertexName() {
return this.ColorWrittenVertexName;
}
/**
* Function to set the color of the text of a vertex
* @param value (Color)
*/
public void setColorVertexDefault(Color value) {
this.ColorVertexDefault = value;
saveSetting("ColorVertexDefault", value.toString());
}
/**
*
* @return The default color of vertex
*/
public Color getColorVertexDefault() {
return this.ColorVertexDefault;
}
/**
* Function to set the color of the text of a vertex
* @param value (Color)
*/
public void setColorEdge(Color value) {
this.ColorEdge = value;
saveSetting("ColorEdge", value.toString());
}
/**
*
* @return The default color of vertex
*/
public Color getColorEdge() {
return this.ColorEdge;
}
}