Started working on a layout for the app
This commit is contained in:
		| @@ -4,6 +4,10 @@ public class SysInfo { | ||||
|  | ||||
|     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() { | ||||
|         return System.getProperty("java.version"); | ||||
|     } | ||||
|   | ||||
| @@ -12,6 +12,14 @@ public class HomeController { | ||||
|  | ||||
|   @FXML | ||||
|   private Label osInfo; | ||||
|   @FXML | ||||
|   private Label overCpuTemp; | ||||
|   @FXML | ||||
|   private Label cpuCpuTemp; | ||||
|   @FXML | ||||
|   private Label cpuCpuFreq; | ||||
|   @FXML | ||||
|   private Label cpuCpuMaxFreq; | ||||
|  | ||||
|   @FXML | ||||
|   public void initialize() { | ||||
| @@ -25,6 +33,10 @@ public class HomeController { | ||||
|  | ||||
|   private void updateLabels() { | ||||
|     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)); | ||||
|   } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,12 @@ | ||||
| package net.metaunix.services; | ||||
|  | ||||
| import java.util.Arrays; | ||||
| import javafx.concurrent.ScheduledService; | ||||
| import javafx.concurrent.Task; | ||||
| import oshi.SystemInfo; | ||||
| import oshi.hardware.CentralProcessor; | ||||
| import oshi.hardware.HardwareAbstractionLayer; | ||||
| import oshi.hardware.Sensors; | ||||
| import oshi.software.os.OperatingSystem; | ||||
|  | ||||
| import net.metaunix.SysInfo; | ||||
| @@ -18,9 +22,21 @@ public class UpdateSystemInfoService extends ScheduledService<Void> { | ||||
|       @Override | ||||
|       protected Void call() throws Exception { | ||||
|         UpdateSystemInfoService.counter++; | ||||
|  | ||||
|         SystemInfo si = new SystemInfo(); | ||||
|         OperatingSystem os = si.getOperatingSystem(); | ||||
|         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; | ||||
|       } | ||||
|  | ||||
|   | ||||
| @@ -37,9 +37,10 @@ | ||||
| <?import javafx.scene.control.MenuBar?> | ||||
| <?import javafx.scene.control.MenuItem?> | ||||
| <?import javafx.scene.control.SeparatorMenuItem?> | ||||
| <?import javafx.scene.control.Tab?> | ||||
| <?import javafx.scene.control.TabPane?> | ||||
| <?import javafx.scene.layout.AnchorPane?> | ||||
| <?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"> | ||||
|   <children> | ||||
| @@ -82,15 +83,46 @@ | ||||
|         </Menu> | ||||
|       </menus> | ||||
|     </MenuBar> | ||||
|     <AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS"> | ||||
|       <children> | ||||
|         <Label alignment="CENTER" layoutX="155.0" layoutY="177.0" style="
" text="Drag components from Library here…" textAlignment="CENTER" textFill="#9f9f9f" wrapText="false"> | ||||
|           <font> | ||||
|             <Font size="18.0" /> | ||||
|           </font> | ||||
|         </Label> | ||||
|             <Label fx:id="osInfo" layoutX="226.0" layoutY="152.0" text="N/a" /> | ||||
|       </children> | ||||
|     </AnchorPane> | ||||
|     <AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS" /> | ||||
|       <TabPane prefHeight="376.0" prefWidth="640.0" tabClosingPolicy="UNAVAILABLE"> | ||||
|         <tabs> | ||||
|           <Tab text="Overview"> | ||||
|             <content> | ||||
|               <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"> | ||||
|                      <children> | ||||
|                         <Label fx:id="osInfo" layoutX="14.0" layoutY="43.0" text="OS Info" /> | ||||
|                         <Label fx:id="overCpuTemp" layoutX="14.0" layoutY="82.0" text="Cpu Temp" /> | ||||
|                      </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> | ||||
| </VBox> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user