Added new improvements

This commit is contained in:
Robert Vokac 2024-02-03 04:31:51 +00:00
parent b8ee1a1a0f
commit 0812555926
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
3 changed files with 99 additions and 41 deletions

View File

@ -0,0 +1,44 @@
package org.nanoboot.utils.timecalc.gui.progress;
import org.nanoboot.utils.timecalc.utils.Utils;
import javax.swing.JTextPane;
import java.awt.Font;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/**
* @author Robert
* @since 21.02.2024
*/
public class WalkingHumanProgressAsciiArt extends JTextPane {
public WalkingHumanProgressAsciiArt() {
setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
Utils.highlighted.flip();
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
putClientProperty("mouseEntered", "true");
}
@Override
public void mouseExited(MouseEvent e) {
putClientProperty("mouseEntered", "false");
}
});
}
}

View File

@ -0,0 +1,31 @@
package org.nanoboot.utils.timecalc.main;
import org.nanoboot.utils.timecalc.gui.common.TimeCalcButton;
import org.nanoboot.utils.timecalc.utils.Utils;
import javax.swing.JOptionPane;
/**
* @author Robert
* @since 21.02.2024
*/
public class AboutButton extends TimeCalcButton {
public AboutButton() {
super("About");
addActionListener(e -> {
String version = Utils.getVersion();
String buildDate = Utils.getBuildDate();
if (version == null) {
version = "unknown";
}
if (buildDate == null) {
buildDate = "unknown";
}
JOptionPane.showMessageDialog(null,
"Version: " + version + "\n" + "Built on (universal time): "
+ buildDate, "About \"Pdf DME Downloader\"",
JOptionPane.INFORMATION_MESSAGE);
});
}
}

View File

@ -9,6 +9,7 @@ import org.nanoboot.utils.timecalc.gui.progress.AnalogClock;
import org.nanoboot.utils.timecalc.gui.progress.Battery; import org.nanoboot.utils.timecalc.gui.progress.Battery;
import org.nanoboot.utils.timecalc.gui.progress.ProgressCircle; import org.nanoboot.utils.timecalc.gui.progress.ProgressCircle;
import org.nanoboot.utils.timecalc.gui.progress.ProgressSquare; import org.nanoboot.utils.timecalc.gui.progress.ProgressSquare;
import org.nanoboot.utils.timecalc.gui.progress.WalkingHumanProgressAsciiArt;
import org.nanoboot.utils.timecalc.utils.Constants; import org.nanoboot.utils.timecalc.utils.Constants;
import org.nanoboot.utils.timecalc.utils.DateFormats; import org.nanoboot.utils.timecalc.utils.DateFormats;
import org.nanoboot.utils.timecalc.utils.Jokes; import org.nanoboot.utils.timecalc.utils.Jokes;
@ -20,7 +21,6 @@ import javax.imageio.ImageIO;
import javax.swing.ImageIcon; import javax.swing.ImageIcon;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JTextPane;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.Rectangle; import java.awt.Rectangle;
@ -85,22 +85,7 @@ public class TimeCalcManager {
TimeCalcButton jokeButton = new TimeCalcButton("Joke"); TimeCalcButton jokeButton = new TimeCalcButton("Joke");
TimeCalcButton restartButton = new TimeCalcButton("Restart"); TimeCalcButton restartButton = new TimeCalcButton("Restart");
TimeCalcButton exitButton = new TimeCalcButton("Exit"); TimeCalcButton exitButton = new TimeCalcButton("Exit");
TimeCalcButton aboutButton = new TimeCalcButton("About"); AboutButton aboutButton = new AboutButton();
aboutButton.addActionListener(e -> {
String version = Utils.getVersion();
String buildDate = Utils.getBuildDate();
if (version == null) {
version = "unknown";
}
if (buildDate == null) {
buildDate = "unknown";
}
JOptionPane.showMessageDialog(null,
"Version: " + version + "\n" + "Built on (universal time): "
+ buildDate, "About \"Pdf DME Downloader\"",
JOptionPane.INFORMATION_MESSAGE);
});
//window.add(weatherButton); //window.add(weatherButton);
window.addAll(commandButton, focusButton, jokeButton, restartButton, window.addAll(commandButton, focusButton, jokeButton, restartButton,
@ -135,15 +120,15 @@ public class TimeCalcManager {
window.repaint(); window.repaint();
} }
}); });
JTextPane text = new JTextPane(); WalkingHumanProgressAsciiArt walkingHumanProgressAsciiArt = new WalkingHumanProgressAsciiArt();
text.setBounds(MARGIN, MARGIN + 210 + MARGIN, 500, 250); walkingHumanProgressAsciiArt.setBounds(MARGIN, MARGIN + 210 + MARGIN, 500, 250);
text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
text.setForeground(Color.GRAY);
text.setBackground(new Color(238, 238, 238));
text.putClientProperty("mouseEntered", "false");
text.setFocusable(false);
text.addMouseListener(new MouseListener() { walkingHumanProgressAsciiArt.setForeground(Color.GRAY);
walkingHumanProgressAsciiArt.setBackground(new Color(238, 238, 238));
walkingHumanProgressAsciiArt.putClientProperty("mouseEntered", "false");
walkingHumanProgressAsciiArt.setFocusable(false);
walkingHumanProgressAsciiArt.addMouseListener(new MouseListener() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
Utils.highlighted.flip(); Utils.highlighted.flip();
@ -161,24 +146,24 @@ public class TimeCalcManager {
@Override @Override
public void mouseEntered(MouseEvent e) { public void mouseEntered(MouseEvent e) {
text.putClientProperty("mouseEntered", "true"); walkingHumanProgressAsciiArt.putClientProperty("mouseEntered", "true");
} }
@Override @Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
text.putClientProperty("mouseEntered", "false"); walkingHumanProgressAsciiArt.putClientProperty("mouseEntered", "false");
} }
}); });
window.add(text); window.add(walkingHumanProgressAsciiArt);
weatherButton weatherButton
.setBounds(20, text.getY() + text.getHeight() + MARGIN); .setBounds(20, walkingHumanProgressAsciiArt.getY() + walkingHumanProgressAsciiArt.getHeight() + MARGIN);
commandButton.setBounds(20, text.getY() + text.getHeight() + MARGIN); commandButton.setBounds(20, walkingHumanProgressAsciiArt.getY() + walkingHumanProgressAsciiArt.getHeight() + MARGIN);
jokeButton.setBounds(140, text.getY() + text.getHeight() + MARGIN); jokeButton.setBounds(140, walkingHumanProgressAsciiArt.getY() + walkingHumanProgressAsciiArt.getHeight() + MARGIN);
restartButton restartButton
.setBounds(280, text.getY() + text.getHeight() + MARGIN); .setBounds(280, walkingHumanProgressAsciiArt.getY() + walkingHumanProgressAsciiArt.getHeight() + MARGIN);
exitButton.setBounds(390, text.getY() + text.getHeight() + MARGIN); exitButton.setBounds(390, walkingHumanProgressAsciiArt.getY() + walkingHumanProgressAsciiArt.getHeight() + MARGIN);
aboutButton.setBounds(exitButton.getX(), aboutButton.setBounds(exitButton.getX(),
exitButton.getY() + exitButton.getHeight() + MARGIN); exitButton.getY() + exitButton.getHeight() + MARGIN);
@ -351,7 +336,7 @@ public class TimeCalcManager {
ComponentRegistry componentRegistry = new ComponentRegistry(); ComponentRegistry componentRegistry = new ComponentRegistry();
componentRegistry.addAll( componentRegistry.addAll(
text, walkingHumanProgressAsciiArt,
progressSquare, progressSquare,
progressCircle, progressCircle,
analogClock, analogClock,
@ -499,7 +484,7 @@ public class TimeCalcManager {
} }
if (hourRemains == 0 && minuteRemains <= 3) { if (hourRemains == 0 && minuteRemains <= 3) {
Utils.highlighted.set(true); Utils.highlighted.set(true);
text.setForeground(Color.BLUE); walkingHumanProgressAsciiArt.setForeground(Color.BLUE);
} }
if (hourRemains <= 0 && minuteRemains <= 0) { if (hourRemains <= 0 && minuteRemains <= 0) {
@ -508,8 +493,7 @@ public class TimeCalcManager {
toasterManager.setDisplayTime(30000); toasterManager.setDisplayTime(30000);
toasterManager.showToaster( toasterManager.showToaster(
"Congratulation :-) It is the time to go home."); "Congratulation :-) It is the time to go home.");
//System.out.println(sb.toString()); walkingHumanProgressAsciiArt.setText(sb.toString());
text.setText(sb.toString());
try { try {
Thread.sleep(10000); Thread.sleep(10000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -523,8 +507,7 @@ public class TimeCalcManager {
} }
} }
} else { } else {
//System.out.println(sb.toString()); walkingHumanProgressAsciiArt.setText(sb.toString());
text.setText(sb.toString());
} }
try { try {
@ -533,8 +516,8 @@ public class TimeCalcManager {
} }
text.setForeground( walkingHumanProgressAsciiArt.setForeground(
Utils.highlighted.get() || text Utils.highlighted.get() || walkingHumanProgressAsciiArt
.getClientProperty("mouseEntered").equals("true") ? .getClientProperty("mouseEntered").equals("true") ?
Color.BLACK : Color.LIGHT_GRAY); Color.BLACK : Color.LIGHT_GRAY);
} }