Added smiley head to walking human
This commit is contained in:
parent
1f18d57c6b
commit
d53818010a
@ -3,6 +3,7 @@ package org.nanoboot.utils.timecalc.app;
|
||||
import org.nanoboot.utils.timecalc.entity.Visibility;
|
||||
import org.nanoboot.utils.timecalc.swing.common.MainWindow;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.Time;
|
||||
import org.nanoboot.utils.timecalc.swing.progress.WalkingHumanProgress;
|
||||
import org.nanoboot.utils.timecalc.utils.common.FileConstants;
|
||||
import org.nanoboot.utils.timecalc.utils.common.Jokes;
|
||||
import org.nanoboot.utils.timecalc.utils.common.TTime;
|
||||
|
@ -775,6 +775,9 @@ public class MainWindow extends TWindow {
|
||||
int secondNow = clock.secondProperty.getValue();
|
||||
int millisecondNow = clock.millisecondProperty.getValue();
|
||||
|
||||
if(arrivalTextField.getText().isEmpty() || departureTextField.getText().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
TTime startTime = arrivalTextField.asTTime();
|
||||
TTime endTime = departureTextField.asTTime();
|
||||
TTime nowTime = TTime.of(time.asCalendar());
|
||||
|
@ -35,7 +35,9 @@ public class Widget extends JPanel implements
|
||||
protected static final Color BACKGROUND_COLOR = new Color(238, 238, 238);
|
||||
protected static final Font BIG_FONT = new Font("sans", Font.BOLD, 24);
|
||||
protected static final Font MEDIUM_FONT = new Font("sans", Font.BOLD, 16);
|
||||
|
||||
protected static final String HEAD = " () ";
|
||||
protected static final String BODY = "/||\\";
|
||||
protected static final String LEGS = " /\\ ";
|
||||
public static final Color CLOSE_BUTTON_FOREGROUND_COLOR
|
||||
= new Color(127, 127, 127);
|
||||
public static final Color CLOSE_BUTTON_BACKGROUND_COLOR = Color.LIGHT_GRAY;
|
||||
@ -229,12 +231,13 @@ public class Widget extends JPanel implements
|
||||
public Property getVisibilitySupportedColoredProperty() {
|
||||
return visibilitySupportedColoredProperty;
|
||||
}
|
||||
|
||||
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x,
|
||||
int y) {
|
||||
if (smileysVisibleProperty.isDisabled() || (!mouseOver
|
||||
&& smileysVisibleOnlyIfMouseMovingOverProperty
|
||||
.isEnabled())) {
|
||||
paintSmiley(visibility, brush, x, y, false);
|
||||
}
|
||||
protected void paintSmiley(Visibility visibility, Graphics2D brush, int x,
|
||||
int y, boolean paintBody) {
|
||||
if (!shouldBeSmileyPainted()) {
|
||||
if (this.smileyIcon != null) {
|
||||
this.remove(smileyIcon);
|
||||
this.smileyIcon = null;
|
||||
@ -248,7 +251,9 @@ public class Widget extends JPanel implements
|
||||
colored = false;
|
||||
}
|
||||
|
||||
|
||||
if (!colored) {
|
||||
y = y - 2;
|
||||
if (this.smileyIcon != null) {
|
||||
this.remove(smileyIcon);
|
||||
this.smileyIcon = null;
|
||||
@ -263,6 +268,7 @@ public class Widget extends JPanel implements
|
||||
brush.setColor(Color.BLACK);
|
||||
}
|
||||
Color currentColor = brush.getColor();
|
||||
Font currentFont = brush.getFont();
|
||||
brush.setColor(visibility.isStronglyColored() ? Color.WHITE
|
||||
: BACKGROUND_COLOR);
|
||||
brush.fillRect(
|
||||
@ -274,10 +280,12 @@ public class Widget extends JPanel implements
|
||||
brush.setFont(MEDIUM_FONT);
|
||||
brush.drawString(
|
||||
ProgressSmiley.forProgress(donePercent).getCharacter(),
|
||||
x, y + 16
|
||||
x + 1, y + 16
|
||||
);
|
||||
brush.setFont(currentFont);
|
||||
}
|
||||
if (colored) {
|
||||
x = x + 2;
|
||||
ImageIcon imageIcon = ProgressSmileyIcon
|
||||
.forSmiley(ProgressSmiley.forProgress(donePercent))
|
||||
.getIcon();
|
||||
@ -289,6 +297,20 @@ public class Widget extends JPanel implements
|
||||
smileyIcon.setBounds(x, y, 15, 15);
|
||||
this.add(smileyIcon);
|
||||
}
|
||||
if(colored) {
|
||||
x = x - 2;
|
||||
y = y - 2;
|
||||
}
|
||||
if(paintBody) {
|
||||
brush.drawString(BODY, x - 5, y + 26);
|
||||
brush.drawString(LEGS, x - 5, y + 36);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldBeSmileyPainted() {
|
||||
return smileysVisibleProperty.isEnabled() && (mouseOver
|
||||
|| !smileysVisibleOnlyIfMouseMovingOverProperty
|
||||
.isEnabled());
|
||||
}
|
||||
|
||||
protected boolean changedInTheLastXMilliseconds(int milliseconds) {
|
||||
|
@ -17,6 +17,7 @@ import javax.swing.Timer;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.HashSet;
|
||||
@ -31,6 +32,7 @@ public class WalkingHumanProgress extends Widget implements
|
||||
|
||||
private static final String WALL = "||";
|
||||
private final Set<Integer> alreadyShownPercents = new HashSet<>();
|
||||
private static final int LINE_WHERE_HEAD_IS = 2;
|
||||
|
||||
public WalkingHumanProgress() {
|
||||
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 11));
|
||||
@ -81,8 +83,18 @@ public class WalkingHumanProgress extends Widget implements
|
||||
// }
|
||||
brush.setFont(SwingUtils.MEDIUM_MONOSPACE_FONT);
|
||||
int y = SwingUtils.MARGIN;
|
||||
int lineNumber = 0;
|
||||
for (String line : lines) {
|
||||
++lineNumber;
|
||||
brush.drawString(line, SwingUtils.MARGIN, y);
|
||||
|
||||
if(lineNumber == LINE_WHERE_HEAD_IS) {
|
||||
paintSmiley(visibility,
|
||||
(Graphics2D) brush,
|
||||
//29 309
|
||||
29 + ((int) (280 * donePercent)),
|
||||
y - 4, true);
|
||||
}
|
||||
y = y + SwingUtils.MARGIN;
|
||||
}
|
||||
|
||||
@ -94,6 +106,7 @@ public class WalkingHumanProgress extends Widget implements
|
||||
//nothing to do
|
||||
return "";
|
||||
}
|
||||
boolean bodyEnabled = !shouldBeSmileyPainted();
|
||||
Visibility visibility
|
||||
= Visibility.valueOf(visibilityProperty.getValue());
|
||||
this.setVisible(visibility != Visibility.NONE);
|
||||
@ -146,15 +159,15 @@ public class WalkingHumanProgress extends Widget implements
|
||||
.append(spacesTodo == 0 ? "" : "| |").append("\n");
|
||||
|
||||
sb.append(
|
||||
WALL + createSpaces(spacesDone) + " () " + createSpaces(
|
||||
WALL + createSpaces(spacesDone) + (bodyEnabled ? HEAD : " ") + createSpaces(
|
||||
spacesTodo) + (spacesTodo == 0
|
||||
? " \\☼☼☼☼/ "
|
||||
: "| _ |") + Constants.NEW_LINE
|
||||
+ WALL + createSpaces(spacesDone) + "/||\\" + createSpaces(
|
||||
+ WALL + createSpaces(spacesDone) + (bodyEnabled ? BODY : " ") + createSpaces(
|
||||
spacesTodo) + (spacesTodo == 0
|
||||
? " ☼☼☼☼☼☼ "
|
||||
: "| | |") + Constants.NEW_LINE
|
||||
+ WALL + createSpaces(spacesDone) + " /\\ " + createSpaces(
|
||||
+ WALL + createSpaces(spacesDone) + (bodyEnabled ? LEGS : " ") + createSpaces(
|
||||
spacesTodo) + (spacesTodo == 0
|
||||
? " /☼☼☼☼\\ "
|
||||
: "| |") + Constants.NEW_LINE
|
||||
|
Loading…
x
Reference in New Issue
Block a user