Started working on a layout for the app

This commit is contained in:
Gregory Ballantine 2023-01-16 14:37:07 -05:00
parent 2613f8a529
commit 8507221f44
4 changed files with 75 additions and 11 deletions

View File

@ -4,6 +4,10 @@ public class SysInfo {
public static String osString = "N/a"; public static String osString = "N/a";
public static double cpuTemp = 0.0;
public static long cpuFreq = 0;
public static long cpuMaxFreq = 0;
public static String javaVersion() { public static String javaVersion() {
return System.getProperty("java.version"); return System.getProperty("java.version");
} }

View File

@ -12,6 +12,14 @@ public class HomeController {
@FXML @FXML
private Label osInfo; private Label osInfo;
@FXML
private Label overCpuTemp;
@FXML
private Label cpuCpuTemp;
@FXML
private Label cpuCpuFreq;
@FXML
private Label cpuCpuMaxFreq;
@FXML @FXML
public void initialize() { public void initialize() {
@ -25,6 +33,10 @@ public class HomeController {
private void updateLabels() { private void updateLabels() {
osInfo.setText(SysInfo.osString); osInfo.setText(SysInfo.osString);
overCpuTemp.setText(String.valueOf(SysInfo.cpuTemp));
cpuCpuTemp.setText(String.valueOf(SysInfo.cpuTemp));
cpuCpuFreq.setText(String.valueOf(SysInfo.cpuFreq));
cpuCpuMaxFreq.setText(String.valueOf(SysInfo.cpuMaxFreq));
} }
} }

View File

@ -1,8 +1,12 @@
package net.metaunix.services; package net.metaunix.services;
import java.util.Arrays;
import javafx.concurrent.ScheduledService; import javafx.concurrent.ScheduledService;
import javafx.concurrent.Task; import javafx.concurrent.Task;
import oshi.SystemInfo; import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.hardware.Sensors;
import oshi.software.os.OperatingSystem; import oshi.software.os.OperatingSystem;
import net.metaunix.SysInfo; import net.metaunix.SysInfo;
@ -18,9 +22,21 @@ public class UpdateSystemInfoService extends ScheduledService<Void> {
@Override @Override
protected Void call() throws Exception { protected Void call() throws Exception {
UpdateSystemInfoService.counter++; UpdateSystemInfoService.counter++;
SystemInfo si = new SystemInfo(); SystemInfo si = new SystemInfo();
OperatingSystem os = si.getOperatingSystem(); OperatingSystem os = si.getOperatingSystem();
SysInfo.osString = String.valueOf(UpdateSystemInfoService.counter) + " " + String.valueOf(os); SysInfo.osString = String.valueOf(UpdateSystemInfoService.counter) + " " + String.valueOf(os);
HardwareAbstractionLayer hal = si.getHardware();
Sensors sensors = hal.getSensors();
SysInfo.cpuTemp = sensors.getCpuTemperature();
CentralProcessor cpu = hal.getProcessor();
SysInfo.cpuMaxFreq = cpu.getMaxFreq();
long[] freqs = cpu.getCurrentFreq();
Arrays.sort(freqs);
SysInfo.cpuFreq = freqs[freqs.length - 1];
return null; return null;
} }

View File

@ -37,9 +37,10 @@
<?import javafx.scene.control.MenuBar?> <?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?> <?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SeparatorMenuItem?> <?import javafx.scene.control.SeparatorMenuItem?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="net.metaunix.controllers.HomeController"> <VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="net.metaunix.controllers.HomeController">
<children> <children>
@ -82,15 +83,46 @@
</Menu> </Menu>
</menus> </menus>
</MenuBar> </MenuBar>
<AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS"> <AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS" />
<children> <TabPane prefHeight="376.0" prefWidth="640.0" tabClosingPolicy="UNAVAILABLE">
<Label alignment="CENTER" layoutX="155.0" layoutY="177.0" style="&#10;" text="Drag components from Library here…" textAlignment="CENTER" textFill="#9f9f9f" wrapText="false"> <tabs>
<font> <Tab text="Overview">
<Font size="18.0" /> <content>
</font> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
</Label> <children>
<Label fx:id="osInfo" layoutX="226.0" layoutY="152.0" text="N/a" /> <Label fx:id="osInfo" layoutX="14.0" layoutY="43.0" text="OS Info" />
</children> <Label fx:id="overCpuTemp" layoutX="14.0" layoutY="82.0" text="Cpu Temp" />
</AnchorPane> </children>
</AnchorPane>
</content>
</Tab>
<Tab text="CPU">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label fx:id="cpuCpuTemp" layoutX="14.0" layoutY="6.0" text="Label" />
<Label fx:id="cpuCpuFreq" layoutX="14.0" layoutY="33.0" text="Label" />
<Label fx:id="cpuCpuMaxFreq" layoutX="14.0" layoutY="61.0" text="Label" />
</children>
</AnchorPane>
</content>
</Tab>
<Tab text="Memory">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<Tab text="GPU">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
<Tab text="OS">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
</content>
</Tab>
</tabs>
</TabPane>
</children> </children>
</VBox> </VBox>