From 41caca9b9bb7957903b1425577311631508bc968 Mon Sep 17 00:00:00 2001 From: Laurent Clouet Date: Sun, 2 Jul 2017 17:43:17 +0200 Subject: [PATCH] Improvement: better ui, only display 10 labels per slider --- .../standalone/swing/activity/Settings.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/com/sheepit/client/standalone/swing/activity/Settings.java b/src/com/sheepit/client/standalone/swing/activity/Settings.java index 4fd29ff..51b7ff3 100644 --- a/src/com/sheepit/client/standalone/swing/activity/Settings.java +++ b/src/com/sheepit/client/standalone/swing/activity/Settings.java @@ -225,8 +225,15 @@ public class Settings implements Activity { CPU cpu = new CPU(); if (cpu.cores() > 1) { // if only one core is available, no need to show the choice + double step = 1; + double display = (double)cpu.cores() / step; + while (display > 10) { + step += 1.0; + display = (double)cpu.cores() / step; + } + cpuCores = new JSlider(1, cpu.cores()); - cpuCores.setMajorTickSpacing(1); + cpuCores.setMajorTickSpacing((int)(step)); cpuCores.setMinorTickSpacing(1); cpuCores.setPaintTicks(true); cpuCores.setPaintLabels(true); @@ -252,9 +259,14 @@ public class Settings implements Activity { int all_ram = os.getMemory(); ram = new JSlider(0, all_ram); int step = 1000000; + double display = (double)all_ram / (double)step; + while (display > 10) { + step += 1000000; + display = (double)all_ram / (double)step; + } Hashtable labelTable = new Hashtable(); for (int g = 0; g < all_ram; g += step) { - labelTable.put(new Integer(g), new JLabel("" + (g / step))); + labelTable.put(new Integer(g), new JLabel("" + (g / 1000000))); } ram.setMajorTickSpacing(step); ram.setLabelTable(labelTable);