overview form

This commit is contained in:
rememberber 2021-11-21 09:01:03 +08:00
parent be81ce9a42
commit 49de2b3c42
5 changed files with 84 additions and 33 deletions

View File

@ -17,6 +17,9 @@ import java.awt.*;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* CpuForm
@ -58,10 +61,9 @@ public class CpuForm {
initUi();
initCpuInfo();
Timer timer = new Timer(UiConsts.REFRESH_FAST, e -> {
initInfo();
});
timer.start();
ScheduledExecutorService serviceStartPerSecond = Executors.newSingleThreadScheduledExecutor();
serviceStartPerSecond.scheduleAtFixedRate(CpuForm::initInfo, 0, 1, TimeUnit.SECONDS);
}
private static void initUi() {

View File

@ -17,6 +17,9 @@ import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* MemoryForm
@ -61,10 +64,10 @@ public class MemoryForm {
initUi();
initPhysicalMemoryInfo();
Timer timer = new Timer(UiConsts.REFRESH_FAST, e -> {
initMemoryProgressInfo();
});
timer.start();
ScheduledExecutorService serviceStartPerSecond = Executors.newSingleThreadScheduledExecutor();
serviceStartPerSecond.scheduleAtFixedRate(MemoryForm::initMemoryProgressInfo, 0, 1, TimeUnit.SECONDS);
}
private static void initPhysicalMemoryInfo() {

View File

@ -26,6 +26,9 @@ import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.List;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/**
* NetworkForm
@ -79,10 +82,8 @@ public class NetworkForm {
initParameters();
initInterfaces();
Timer timer = new Timer(UiConsts.REFRESH_FAST, e -> {
initNetworkSpeed();
});
timer.start();
ScheduledExecutorService serviceStartPerSecond = Executors.newSingleThreadScheduledExecutor();
serviceStartPerSecond.scheduleAtFixedRate(NetworkForm::initNetworkSpeed, 0, 1, TimeUnit.SECONDS);
}
private static void initInterfaces() {

View File

@ -88,7 +88,7 @@
</constraints>
<properties/>
</component>
<grid id="9c58e" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="9c58e" layout-manager="GridLayoutManager" row-count="6" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@ -136,6 +136,14 @@
<text value="DiskStorage"/>
</properties>
</component>
<component id="8b50" class="javax.swing.JLabel" binding="displayLabel" default-binding="true">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Display"/>
</properties>
</component>
<component id="2892f" class="javax.swing.JLabel" binding="cpuInfo">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@ -176,6 +184,14 @@
<text value="DiskStorage info"/>
</properties>
</component>
<component id="5c598" class="javax.swing.JLabel" binding="displayInfoLabel" default-binding="true">
<constraints>
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Display info"/>
</properties>
</component>
<hspacer id="84083">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>

View File

@ -49,6 +49,8 @@ public class OverviewForm {
private JLabel baseBoardInfoLabel;
private JLabel diskStorageLabel;
private JLabel diskStorageInfoLabel;
private JLabel displayInfoLabel;
private JLabel displayLabel;
public static OverviewForm getInstance() {
if (overviewForm == null) {
@ -75,6 +77,7 @@ public class OverviewForm {
Style.emphaticLabelFont(overviewForm.getGraphicsCardLabel());
Style.emphaticLabelFont(overviewForm.getBaseBoardLabel());
Style.emphaticLabelFont(overviewForm.getDiskStorageLabel());
Style.emphaticLabelFont(overviewForm.getDisplayLabel());
}
private static void initInfo() {
@ -93,27 +96,9 @@ public class OverviewForm {
overviewForm.getGraphicsCardInfo().setText(getGraphicsCardInfo(hardware));
overviewForm.getBaseBoardInfoLabel().setText(getBaseBoardInfo(hardware.getComputerSystem().getBaseboard()));
overviewForm.getDiskStorageInfoLabel().setText(getDiskStorageInfo(hardware));
overviewForm.getDisplayInfoLabel().setText(getDisplayInfo(hardware));
List<Display> displays = hardware.getDisplays();
for (Display display : displays) {
byte[] edid = display.getEdid();
byte[][] desc = EdidUtil.getDescriptors(edid);
Map<String, String> infoMap = Maps.newHashMap();
for (byte[] b : desc) {
int descriptorType = EdidUtil.getDescriptorType(b);
if (descriptorType == 0xff || descriptorType == 0xfe || descriptorType == 0xfd || descriptorType == 0xfb || descriptorType == 0xfa) {
} else if (descriptorType == 0xfc) {
infoMap.put("name", EdidUtil.getDescriptorText(b));
} else {
if (EdidUtil.getDescriptorType(b) > 0x0f || EdidUtil.getDescriptorType(b) < 0x00) {
infoMap.put("size", EdidUtil.getTimingDescriptor(b));
}
}
}
System.err.println(infoMap);
}
}
/**
@ -200,6 +185,44 @@ public class OverviewForm {
return StringUtils.join(detailList, " + ");
}
/**
* Display Info
*
* @param hardware
* @return
*/
private static String getDisplayInfo(HardwareAbstractionLayer hardware) {
List<String> detailList = new ArrayList<>();
StringBuilder detailBuilder;
List<Display> displays = hardware.getDisplays();
for (Display display : displays) {
detailBuilder = new StringBuilder();
byte[] edid = display.getEdid();
byte[][] desc = EdidUtil.getDescriptors(edid);
Map<String, String> infoMap = Maps.newHashMap();
for (byte[] b : desc) {
int descriptorType = EdidUtil.getDescriptorType(b);
if (descriptorType == 0xff || descriptorType == 0xfe || descriptorType == 0xfd || descriptorType == 0xfb || descriptorType == 0xfa) {
} else if (descriptorType == 0xfc) {
infoMap.put("name", EdidUtil.getDescriptorText(b));
} else {
if (EdidUtil.getDescriptorType(b) > 0x0f || EdidUtil.getDescriptorType(b) < 0x00) {
infoMap.put("size", EdidUtil.getTimingDescriptor(b));
}
}
}
detailBuilder.append(infoMap.get("name"));
detailBuilder.append(" ").append(infoMap.get("size"));
detailList.add(detailBuilder.toString());
}
return StringUtils.join(detailList, " + ");
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
@ -247,7 +270,7 @@ public class OverviewForm {
final JSeparator separator1 = new JSeparator();
panel1.add(separator1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
final JPanel panel5 = new JPanel();
panel5.setLayout(new GridLayoutManager(5, 3, new Insets(10, 10, 10, 10), -1, -1));
panel5.setLayout(new GridLayoutManager(6, 3, new Insets(10, 10, 10, 10), -1, -1));
panel1.add(panel5, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
cpuLabel = new JLabel();
cpuLabel.setText("CPU");
@ -264,6 +287,9 @@ public class OverviewForm {
diskStorageLabel = new JLabel();
diskStorageLabel.setText("DiskStorage");
panel5.add(diskStorageLabel, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
displayLabel = new JLabel();
displayLabel.setText("Display");
panel5.add(displayLabel, new GridConstraints(5, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
cpuInfo = new JLabel();
cpuInfo.setText("CPU info");
panel5.add(cpuInfo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
@ -279,6 +305,9 @@ public class OverviewForm {
diskStorageInfoLabel = new JLabel();
diskStorageInfoLabel.setText("DiskStorage info");
panel5.add(diskStorageInfoLabel, new GridConstraints(4, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
displayInfoLabel = new JLabel();
displayInfoLabel.setText("Display info");
panel5.add(displayInfoLabel, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer4 = new Spacer();
panel5.add(spacer4, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
}