some better variable naming so i can understand this better at a glance

This commit is contained in:
Gered 2016-03-21 12:29:51 -04:00
parent b02d9d7132
commit ce89b7a14a

View file

@ -227,65 +227,58 @@ class Core extends JPanel implements ActionListener {
FontMetrics coreSegmentTimerFontMetric = graphics.getFontMetrics(Settings.coreSegmentTimerFont.get()); FontMetrics coreSegmentTimerFontMetric = graphics.getFontMetrics(Settings.coreSegmentTimerFont.get());
// Segment Name // Segment Name
int wName = 0; int segmentNameWidth = 0;
int hName = 0; int segmentNameHeight = 0;
if (Settings.coreShowSegmentName.get()) { if (Settings.coreShowSegmentName.get()) {
for (int i = 0; i < run.getRowCount(); i++) { for (int i = 0; i < run.getRowCount(); i++) {
String sName = run.getSegment(i).getName(); String sName = run.getSegment(i).getName();
wName = Math.max(wName, coreFontMetric.stringWidth(sName)); segmentNameWidth = Math.max(segmentNameWidth, coreFontMetric.stringWidth(sName));
} }
hName = coreFontMetric.getHeight(); segmentNameHeight = coreFontMetric.getHeight();
} }
// Segment Times // Segment Times
int wTime = 0; int timeWidth = 0;
int hTime = 0; int timeHeight = 0;
int hBuff = coreOtherTimeFontMetric.getHeight(); int otherTimerFontHeight = coreOtherTimeFontMetric.getHeight();
int wBuff = coreOtherTimeFontMetric.stringWidth( int otherTimerWidth = coreOtherTimeFontMetric.stringWidth("" + (tmRun == null ? tmFake : tmRun));
"" + (tmRun == null ? tmFake : tmRun) otherTimerWidth += coreOtherTimeFontMetric.stringWidth("XX:");
);
wBuff += coreOtherTimeFontMetric.stringWidth("XX:");
if (Settings.coreShowBestTime.get()) { if (Settings.coreShowBestTime.get()) {
hTime = hTime + hBuff; timeHeight += otherTimerFontHeight;
wTime = wBuff; timeWidth = otherTimerWidth;
} }
if (Settings.coreShowSegmentTime.get()) { if (Settings.coreShowSegmentTime.get()) {
hTime = hTime + hBuff; timeHeight += otherTimerFontHeight;
wTime = wBuff; timeWidth = otherTimerWidth;
} }
if (Settings.coreShowSplitTime.get()) { if (Settings.coreShowSplitTime.get()) {
hTime = hTime + hBuff; timeHeight += otherTimerFontHeight;
wTime = wBuff; timeWidth = otherTimerWidth;
} }
// Segment Icon // Segment Icon
int hIcon = 0; int iconHeight = 0;
int wIcon = 0; int iconWidth = 0;
// TODO hasIcon ? // TODO hasIcon ?
if (Settings.coreShowIcons.get() || run.getMaxIconHeight() != 0) { if (Settings.coreShowIcons.get() || run.getMaxIconHeight() != 0) {
hIcon = Settings.coreIconSize.get(); iconHeight = Settings.coreIconSize.get();
wIcon = hIcon; iconWidth = iconHeight; // always assume square icon size (will be scaled as such)
} }
// Run Timer // Run Timer
int wSpTimer = coreTimerFontMetric.stringWidth( int splitTimerWidth = coreTimerFontMetric.stringWidth("" + (tmRun == null ? tmFake : tmRun));
"" + (tmRun == null ? tmFake : tmRun) int splitTimerHeight = coreTimerFontMetric.getHeight();
);
int hSpTimer = coreTimerFontMetric.getHeight();
// Segment Timer // Segment Timer
int wSeTimer = 0; int segmentTimerWidth = 0;
int hSeTimer = 0; int segmentTimerHeight = 0;
if (Settings.coreShowSegmentTimer.get()) { if (Settings.coreShowSegmentTimer.get()) {
wSeTimer = coreSegmentTimerFontMetric.stringWidth( segmentTimerWidth = coreSegmentTimerFontMetric.stringWidth("" + (tmRun == null ? tmFake : tmRun));
"" + (tmRun == null ? tmFake : tmRun) segmentTimerHeight = coreSegmentTimerFontMetric.getHeight();
);
hSeTimer = coreSegmentTimerFontMetric.getHeight();
} }
int maxHeight = Math.max(hIcon, hSpTimer + hSeTimer); int maxHeight = Math.max(iconHeight, splitTimerHeight + segmentTimerHeight);
maxHeight = Math.max(maxHeight, hTime + hName); maxHeight = Math.max(maxHeight, timeHeight + segmentNameHeight);
int maxWidth = wIcon + Math.max(wName, wTime) int maxWidth = iconWidth + Math.max(segmentNameWidth, timeWidth) + Math.max(splitTimerWidth, segmentTimerWidth) + 5;
+ Math.max(wSpTimer, wSeTimer) + 5;
preferredSize = new Dimension(maxWidth, maxHeight); preferredSize = new Dimension(maxWidth, maxHeight);
setMinimumSize(new Dimension(MIN_WIDTH, maxHeight)); setMinimumSize(new Dimension(MIN_WIDTH, maxHeight));