cpu form opt
This commit is contained in:
parent
7b8e75da14
commit
e88d1e6211
|
@ -131,7 +131,7 @@
|
||||||
</scrollpane>
|
</scrollpane>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<grid id="b95f4" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="b95f4" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="10" left="0" bottom="10" right="10"/>
|
<margin top="10" left="0" bottom="10" right="10"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<splitpane position="right"/>
|
<splitpane position="right"/>
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
<grid id="f729b" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="f729b" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="10" left="10" bottom="10" right="10"/>
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
|
@ -159,9 +159,83 @@
|
||||||
</grid>
|
</grid>
|
||||||
<vspacer id="303d7">
|
<vspacer id="303d7">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</vspacer>
|
</vspacer>
|
||||||
|
<grid id="cbaf8" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="d4158" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" 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="Usage"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="182a0" class="javax.swing.JLabel">
|
||||||
|
<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"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Freq"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="eca4d" class="javax.swing.JLabel" binding="usageLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" 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="Label"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="3bdf2" class="javax.swing.JLabel" binding="freqLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" 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="Label"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="e4a2d" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="2" 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="Interrupts"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="f5427" class="javax.swing.JLabel" binding="InterruptsLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="2" 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="Label"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="2971c" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="3" 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="Context Switches"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="637b1" class="javax.swing.JLabel" binding="contextSwitchesLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="3" 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="Label"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -41,6 +41,10 @@ public class CpuForm {
|
||||||
private JPanel panel1;
|
private JPanel panel1;
|
||||||
private JPanel pcfPanel;
|
private JPanel pcfPanel;
|
||||||
private JLabel pcfLabel;
|
private JLabel pcfLabel;
|
||||||
|
private JLabel usageLabel;
|
||||||
|
private JLabel freqLabel;
|
||||||
|
private JLabel InterruptsLabel;
|
||||||
|
private JLabel contextSwitchesLabel;
|
||||||
|
|
||||||
private static final Log logger = LogFactory.get();
|
private static final Log logger = LogFactory.get();
|
||||||
|
|
||||||
|
@ -70,6 +74,7 @@ public class CpuForm {
|
||||||
serviceStartPerSecond.scheduleAtFixedRate(() -> {
|
serviceStartPerSecond.scheduleAtFixedRate(() -> {
|
||||||
initPcuInfo();
|
initPcuInfo();
|
||||||
initPcfInfo();
|
initPcfInfo();
|
||||||
|
initIndicatorInfo();
|
||||||
}, 0, 1, TimeUnit.SECONDS);
|
}, 0, 1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -81,6 +86,11 @@ public class CpuForm {
|
||||||
Style.emphaticTitleFont(cpuForm.getPcuTitleLabel());
|
Style.emphaticTitleFont(cpuForm.getPcuTitleLabel());
|
||||||
Style.emphaticTitleFont(cpuForm.getPcfLabel());
|
Style.emphaticTitleFont(cpuForm.getPcfLabel());
|
||||||
|
|
||||||
|
Style.emphaticIndicatorFont(cpuForm.getUsageLabel());
|
||||||
|
Style.emphaticIndicatorFont(cpuForm.getFreqLabel());
|
||||||
|
Style.emphaticIndicatorFont(cpuForm.getInterruptsLabel());
|
||||||
|
Style.emphaticIndicatorFont(cpuForm.getContextSwitchesLabel());
|
||||||
|
|
||||||
Dimension d = new Dimension(-1, 100);
|
Dimension d = new Dimension(-1, 100);
|
||||||
cpuForm.getScuProgressBar().setMinimumSize(d);
|
cpuForm.getScuProgressBar().setMinimumSize(d);
|
||||||
|
|
||||||
|
@ -111,6 +121,7 @@ public class CpuForm {
|
||||||
|
|
||||||
JTextField textField = new JTextField();
|
JTextField textField = new JTextField();
|
||||||
textField.setEditable(false);
|
textField.setEditable(false);
|
||||||
|
textField.setForeground(progressBar.getForeground());
|
||||||
pcfPanel.add(textField, new GridConstraints(i, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
pcfPanel.add(textField, new GridConstraints(i, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
|
||||||
processorTextFields.add(textField);
|
processorTextFields.add(textField);
|
||||||
|
@ -145,8 +156,6 @@ public class CpuForm {
|
||||||
builder.append("<br/><b>Physical Processor Count: </b>").append(processor.getPhysicalProcessorCount());
|
builder.append("<br/><b>Physical Processor Count: </b>").append(processor.getPhysicalProcessorCount());
|
||||||
builder.append("<br/><b>Logical Processor Count: </b>").append(processor.getLogicalProcessorCount());
|
builder.append("<br/><b>Logical Processor Count: </b>").append(processor.getLogicalProcessorCount());
|
||||||
builder.append("<br/><b>Max Freq: </b>").append(new BigDecimal(processor.getMaxFreq()).divide(new BigDecimal(1000000000), 2, RoundingMode.HALF_UP)).append(" GHz");
|
builder.append("<br/><b>Max Freq: </b>").append(new BigDecimal(processor.getMaxFreq()).divide(new BigDecimal(1000000000), 2, RoundingMode.HALF_UP)).append(" GHz");
|
||||||
builder.append("<br/><b>Interrupts: </b>").append(processor.getInterrupts());
|
|
||||||
builder.append("<br/><b>Context Switches: </b>").append(processor.getContextSwitches());
|
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|
||||||
|
@ -183,7 +192,9 @@ public class CpuForm {
|
||||||
int cpuUsagePercent = (int) cpuUsage;
|
int cpuUsagePercent = (int) cpuUsage;
|
||||||
scuProgressBar.setValue(cpuUsagePercent);
|
scuProgressBar.setValue(cpuUsagePercent);
|
||||||
scuProgressBar.setStringPainted(true);
|
scuProgressBar.setStringPainted(true);
|
||||||
scuProgressBar.setString(cpuUsage + "%");
|
String cpuUsageStr = cpuUsage + "%";
|
||||||
|
scuProgressBar.setString(cpuUsageStr);
|
||||||
|
cpuForm.getUsageLabel().setText(cpuUsageStr);
|
||||||
|
|
||||||
long[][] processorTicks = processor.getProcessorCpuLoadTicks();
|
long[][] processorTicks = processor.getProcessorCpuLoadTicks();
|
||||||
if (preProcessorTicks == null) {
|
if (preProcessorTicks == null) {
|
||||||
|
@ -223,6 +234,7 @@ public class CpuForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initPcfInfo() {
|
private static void initPcfInfo() {
|
||||||
|
CpuForm cpuForm = getInstance();
|
||||||
CentralProcessor processor = App.si.getHardware().getProcessor();
|
CentralProcessor processor = App.si.getHardware().getProcessor();
|
||||||
|
|
||||||
long[] currentFreq = processor.getCurrentFreq();
|
long[] currentFreq = processor.getCurrentFreq();
|
||||||
|
@ -231,12 +243,20 @@ public class CpuForm {
|
||||||
|
|
||||||
JTextField textField = processorTextFields.get(i);
|
JTextField textField = processorTextFields.get(i);
|
||||||
BigDecimal divide = new BigDecimal(currentFreq[i]).divide(new BigDecimal(1000000000), 2, RoundingMode.HALF_UP);
|
BigDecimal divide = new BigDecimal(currentFreq[i]).divide(new BigDecimal(1000000000), 2, RoundingMode.HALF_UP);
|
||||||
textField.setText(divide + " GHz");
|
String freqStr = divide + " GHz";
|
||||||
|
textField.setText(freqStr);
|
||||||
|
cpuForm.getFreqLabel().setText(freqStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void initIndicatorInfo() {
|
||||||
|
CpuForm cpuForm = getInstance();
|
||||||
|
CentralProcessor processor = App.si.getHardware().getProcessor();
|
||||||
|
cpuForm.getInterruptsLabel().setText(String.valueOf(processor.getInterrupts()));
|
||||||
|
cpuForm.getContextSwitchesLabel().setText(String.valueOf(processor.getContextSwitches()));
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
// GUI initializer generated by IntelliJ IDEA GUI Designer
|
||||||
// >>> IMPORTANT!! <<<
|
// >>> IMPORTANT!! <<<
|
||||||
|
@ -297,16 +317,43 @@ public class CpuForm {
|
||||||
final Spacer spacer1 = new Spacer();
|
final Spacer spacer1 = new Spacer();
|
||||||
panel3.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
panel3.add(spacer1, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||||
final JPanel panel4 = new JPanel();
|
final JPanel panel4 = new JPanel();
|
||||||
panel4.setLayout(new GridLayoutManager(2, 1, new Insets(10, 0, 10, 10), -1, -1));
|
panel4.setLayout(new GridLayoutManager(3, 1, new Insets(10, 0, 10, 10), -1, -1));
|
||||||
splitPane1.setRightComponent(panel4);
|
splitPane1.setRightComponent(panel4);
|
||||||
final JPanel panel5 = new JPanel();
|
final JPanel panel5 = new JPanel();
|
||||||
panel5.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
|
panel5.setLayout(new GridLayoutManager(1, 1, new Insets(10, 10, 10, 10), -1, -1));
|
||||||
panel4.add(panel5, new GridConstraints(0, 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));
|
panel4.add(panel5, 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));
|
||||||
cpuInfoTextPane = new JTextPane();
|
cpuInfoTextPane = new JTextPane();
|
||||||
cpuInfoTextPane.setEditable(true);
|
cpuInfoTextPane.setEditable(true);
|
||||||
panel5.add(cpuInfoTextPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
panel5.add(cpuInfoTextPane, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||||
final Spacer spacer2 = new Spacer();
|
final Spacer spacer2 = new Spacer();
|
||||||
panel4.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
panel4.add(spacer2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
|
||||||
|
final JPanel panel6 = new JPanel();
|
||||||
|
panel6.setLayout(new GridLayoutManager(2, 4, new Insets(10, 10, 10, 10), -1, -1));
|
||||||
|
panel4.add(panel6, new GridConstraints(0, 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 JLabel label1 = new JLabel();
|
||||||
|
label1.setText("Usage");
|
||||||
|
panel6.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
final JLabel label2 = new JLabel();
|
||||||
|
label2.setText("Freq");
|
||||||
|
panel6.add(label2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
usageLabel = new JLabel();
|
||||||
|
usageLabel.setText("Label");
|
||||||
|
panel6.add(usageLabel, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
freqLabel = new JLabel();
|
||||||
|
freqLabel.setText("Label");
|
||||||
|
panel6.add(freqLabel, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
final JLabel label3 = new JLabel();
|
||||||
|
label3.setText("Interrupts");
|
||||||
|
panel6.add(label3, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
InterruptsLabel = new JLabel();
|
||||||
|
InterruptsLabel.setText("Label");
|
||||||
|
panel6.add(InterruptsLabel, new GridConstraints(1, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
final JLabel label4 = new JLabel();
|
||||||
|
label4.setText("Context Switches");
|
||||||
|
panel6.add(label4, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
|
contextSwitchesLabel = new JLabel();
|
||||||
|
contextSwitchesLabel.setText("Label");
|
||||||
|
panel6.add(contextSwitchesLabel, new GridConstraints(1, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue