ui: cleanup progress bar
This commit is contained in:
@@ -31,6 +31,7 @@ import java.awt.Dimension;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
@@ -213,9 +214,10 @@ class XpInfoBox extends JPanel
|
|||||||
: "Lvl. " + xpSnapshotSingle.getEndLevel());
|
: "Lvl. " + xpSnapshotSingle.getEndLevel());
|
||||||
|
|
||||||
// Add intermediate level positions to progressBar
|
// Add intermediate level positions to progressBar
|
||||||
final List<Double> positions = new ArrayList<>();
|
|
||||||
if (xpTrackerConfig.showIntermediateLevels() && xpSnapshotSingle.getEndLevel() - xpSnapshotSingle.getStartLevel() > 1)
|
if (xpTrackerConfig.showIntermediateLevels() && xpSnapshotSingle.getEndLevel() - xpSnapshotSingle.getStartLevel() > 1)
|
||||||
{
|
{
|
||||||
|
final List<Double> positions = new ArrayList<>();
|
||||||
|
|
||||||
for (int level = xpSnapshotSingle.getStartLevel() + 1; level < xpSnapshotSingle.getEndLevel(); level++)
|
for (int level = xpSnapshotSingle.getStartLevel() + 1; level < xpSnapshotSingle.getEndLevel(); level++)
|
||||||
{
|
{
|
||||||
double relativeStartExperience = Experience.getXpForLevel(level) - xpSnapshotSingle.getStartGoalXp();
|
double relativeStartExperience = Experience.getXpForLevel(level) - xpSnapshotSingle.getStartGoalXp();
|
||||||
@@ -227,7 +229,7 @@ class XpInfoBox extends JPanel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
progressBar.setPositions(positions);
|
progressBar.setPositions(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
progressBar.setToolTipText(String.format(
|
progressBar.setToolTipText(String.format(
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.awt.BorderLayout;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.SwingConstants;
|
import javax.swing.SwingConstants;
|
||||||
@@ -49,7 +49,7 @@ public class ProgressBar extends DimmableJPanel
|
|||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private List<Double> positions = new ArrayList<>();
|
private List<Double> positions = Collections.emptyList();
|
||||||
|
|
||||||
private final JLabel leftLabel = new JShadowedLabel();
|
private final JLabel leftLabel = new JShadowedLabel();
|
||||||
private final JLabel rightLabel = new JShadowedLabel();
|
private final JLabel rightLabel = new JShadowedLabel();
|
||||||
@@ -88,8 +88,8 @@ public class ProgressBar extends DimmableJPanel
|
|||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g)
|
public void paint(Graphics g)
|
||||||
{
|
{
|
||||||
double percentage = getPercentage();
|
int percentage = getPercentage();
|
||||||
int topWidth = (int) (getSize().width * (percentage / 100));
|
int topWidth = (int) (getSize().width * (percentage / 100f));
|
||||||
|
|
||||||
super.paint(g);
|
super.paint(g);
|
||||||
g.setColor(getForeground());
|
g.setColor(getForeground());
|
||||||
@@ -98,7 +98,7 @@ public class ProgressBar extends DimmableJPanel
|
|||||||
|
|
||||||
for (final Double position : positions)
|
for (final Double position : positions)
|
||||||
{
|
{
|
||||||
final int xCord = (int) (getSize().width * (position));
|
final int xCord = (int) (getSize().width * position);
|
||||||
if (xCord > topWidth)
|
if (xCord > topWidth)
|
||||||
{
|
{
|
||||||
g.fillRect(xCord, 0, 1, 16);
|
g.fillRect(xCord, 0, 1, 16);
|
||||||
@@ -149,7 +149,7 @@ public class ProgressBar extends DimmableJPanel
|
|||||||
centerLabel.setText(isDimmed() ? txt : centerLabelText);
|
centerLabel.setText(isDimmed() ? txt : centerLabelText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPercentage()
|
public int getPercentage()
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user