diff options
author | Simon Rettberg | 2018-05-09 13:53:32 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-05-09 13:53:32 +0200 |
commit | f0c3c1a90c1b93719acaf4730abaab53ec9e0757 (patch) | |
tree | 74b4efafee64226412558e144122b191bc2c1b8e /dozentenmodul/src/main/java/org/openslx/dozmod/gui/control | |
parent | [server] Fix CRC32 generation (diff) | |
download | tutor-module-f0c3c1a90c1b93719acaf4730abaab53ec9e0757.tar.gz tutor-module-f0c3c1a90c1b93719acaf4730abaab53ec9e0757.tar.xz tutor-module-f0c3c1a90c1b93719acaf4730abaab53ec9e0757.zip |
[client] Show server side progress and estimated virtual speed
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/control')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java index a80cf2b9..2b26b397 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/BlockProgressBar.java @@ -17,8 +17,12 @@ import org.openslx.thrifthelper.TransferStatusWrapper; public class BlockProgressBar extends JPanel { private final Color[] blockColors = new Color[6]; + + private static final Color potentialCompleteColor = new Color(200, 220, 255, 255); private final TransferStatusWrapper blocks = new TransferStatusWrapper(null); + + private final TransferStatusWrapper.Progress progress = new TransferStatusWrapper.Progress(); private boolean simpleMode = true; @@ -78,14 +82,18 @@ public class BlockProgressBar extends JPanel { } final int width = getWidth(); final int height = getHeight(); - final float complete = blocks.getComplete(); - final int doneWidth = (int) ((float) width * complete); + blocks.getCompleteEx(progress); + final int doneWidth = (int) ((float) width * progress.done); + final int potentialWidth = (int) ((float) width * progress.potentiallyDone); + final int sumWidth = doneWidth + potentialWidth; g.setColor(Color.BLUE); g.fillRect(0, 0, doneWidth, height); + g.setColor(potentialCompleteColor); + g.fillRect(doneWidth, 0, potentialWidth, height); g.setColor(Color.WHITE); - g.fillRect(doneWidth, 0, width - doneWidth, height); - final String progress = (int) (complete * 100) + "%"; - Rectangle2D textExtent = g.getFontMetrics().getStringBounds(progress, g); + g.fillRect(sumWidth, 0, width - sumWidth, height); + final String percentDisplay = (int) (progress.done * 100) + "%"; + Rectangle2D textExtent = g.getFontMetrics().getStringBounds(percentDisplay, g); final double tw = textExtent.getWidth(); final int textX = (int) ((width - tw) / 2); final int textXEnd = (int) ((width + tw) / 2); @@ -93,12 +101,12 @@ public class BlockProgressBar extends JPanel { if (doneWidth >= textX) { g.setColor(Color.WHITE); g.setClip(0, 0, doneWidth, height); - g.drawString(progress, textX, textY); + g.drawString(percentDisplay, textX, textY); } if (doneWidth <= textXEnd) { g.setColor(Color.BLACK); g.setClip(doneWidth, 0, width - doneWidth, height); - g.drawString(progress, textX, textY); + g.drawString(percentDisplay, textX, textY); } } |