GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — JavaLinuxUndervolt/src/Profile.java at master · zmalrobot/JavaLinuxUndervolt

Expand file tree

/

Profile.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
135 lines (110 loc) · 4.35 KB
/

Profile.java

Copy path

File metadata and controls

135 lines (110 loc) · 4.35 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.util.Date;
import java.util.HashMap;
public class Profile {
private final JFrame frame;
private Config configs = new Config();
private HashMap<String, Double> returnValue;
//Constructor
public Profile(JFrame frame){
this.frame = frame;
}
//Save data to file
public void save(int coreSliderValue, int gpuSliderValue, int cacheSliderValue, int uncoreSliderValue, int analogioSliderValue){
JFileChooser fileChooser = new JFileChooser(new File(configs.getSave_path())){
@Override
protected JDialog createDialog( Component parent ) throws HeadlessException {
JDialog dialog = super.createDialog( parent );
try {
dialog.setIconImage(ImageIO.read(new File(configs.getImage_path()+"icosave.png")));
} catch (IOException e) {
System.out.println("No icon found");
}
return dialog;
}
};
fileChooser.setDialogTitle("Save profile");
int userSelection = fileChooser.showSaveDialog(frame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
try {
Date today = new Date();
FileWriter fw = new FileWriter(fileChooser.getSelectedFile()+".txt");
fw.write("#Setting profile data: " + today);
fw.write("\n");
fw.write("core: " + coreSliderValue+".0 mV");
fw.write("\n");
fw.write("gpu: " + gpuSliderValue+".0 mV");
fw.write("\n");
fw.write("cache: " + cacheSliderValue+".0 mV");
fw.write("\n");
fw.write("uncore: " + uncoreSliderValue+".0 mV");
fw.write("\n");
fw.write("analogio: " + analogioSliderValue+".0 mV");
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//Read data from file
public HashMap<String, Double> read(){
returnValue = new HashMap<String, Double>();
JFileChooser fileChooser = new JFileChooser(new File(configs.getSave_path())){
@Override
protected JDialog createDialog( Component parent ) throws HeadlessException {
JDialog dialog = super.createDialog( parent );
try {
dialog.setIconImage(ImageIO.read(new File(configs.getImage_path()+"icoload.png")));
} catch (IOException e) {
System.out.println("No icon found");
}
return dialog;
}
};
fileChooser.setApproveButtonText("Load");
int userSelection = fileChooser.showOpenDialog(frame);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
readfile(file);
return returnValue;
} else{
returnValue.put("errors", 0.0);
return returnValue;
}
}
//Read the selected file
private void readfile(File file) {
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(file));
//Ignore the first row (date) or it make KABOOOM!!!
String line = reader.readLine();
System.out.println(line);
//Now let's learn how to read ;-)
line = reader.readLine();
while (line != null) {
System.out.println(line);
addToHasmap(line);
line = reader.readLine();
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//Create the hashmap (i's a duplicate forn now form undervolt class, i'll remove soon or later)
private void addToHasmap(String scrptString){
//String preparation
scrptString = scrptString.replace("mV", "");
scrptString = scrptString.replace(" ", "");
String[] parts = scrptString.split(":");
String name = parts[0]; // Core
String value = parts[1]; // 0.0
//Add to hashmap
System.out.println("Adding: " + name + " Value: " + value );
returnValue.put(name, Double.parseDouble(value));
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.