Added some improvements

This commit is contained in:
Robert Vokac 2024-03-09 15:51:40 +00:00
parent 5291779733
commit db1c0764dd
No known key found for this signature in database
GPG Key ID: 693D30BEE3329055
6 changed files with 32 additions and 8 deletions

View File

@ -56,7 +56,7 @@ Configuration for a profile is stored here.
Current profile is stored here.
### time-calc-profiles.txt
### ./tc/time-calc-profiles.txt
Optional assignments of profiles to numbers is stored here.

View File

@ -25,8 +25,28 @@ public class SwingUtils {
//Not meant to be instantiated.
}
public static void paintCloseIcon(Graphics brush, int width) {
brush.setColor(SwingUtils.CLOSE_BUTTON_BACKGROUND_COLOR);
public static void paintCloseIcon(Graphics brush, int width,
boolean mouseOver, boolean mouseOverCloseButton) {
if(!mouseOver) {
//nothing to do
return;
}
if(!mouseOverCloseButton) {
//nothing to do
return;
}
brush.setColor(SwingUtils.CLOSE_BUTTON_BACKGROUND_COLOR);
// if(!mouseOverCloseButton) {
// brush.drawRect(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE,
// CLOSE_BUTTON_SIDE);
// brush.drawRect(width - CLOSE_BUTTON_SIDE - 1+1, 0 + 1 +1, CLOSE_BUTTON_SIDE - 2,
// CLOSE_BUTTON_SIDE - 2);
// return;
// }
brush.fillOval(width - CLOSE_BUTTON_SIDE - 1, 0 + 1, CLOSE_BUTTON_SIDE,
CLOSE_BUTTON_SIDE);
brush.setColor(Color.LIGHT_GRAY);

View File

@ -9,7 +9,7 @@ import java.time.LocalDate;
import java.util.Calendar;
/**
* @author Robert
* @author Robert Vokac
* @since 06.03.2024
*/
@Getter

View File

@ -19,6 +19,7 @@ public class FileConstants {
new File(TC_DIRECTORY, "time-calc-current-profile.txt");
public static final File FILE_WITHOUT_ANY_PROFILE =
new File(TC_DIRECTORY, "timecalc.conf");
public static final File JOKES_TXT = new File(TC_DIRECTORY, "jokes.txt");
private FileConstants() {
//Not meant to be instantiated.

View File

@ -33,7 +33,8 @@ public class Jokes {
static {
try {
array = JokesTxt.getAsArray();
Set<String> set = new HashSet<>();
if(array.length > 0) {
Set<String> set = new HashSet<>();
for (String vtip : array) {
if (vtip.trim().isEmpty()) {
//nothing to do
@ -43,6 +44,8 @@ public class Jokes {
}
array = new String[set.size()];
array = set.toArray(array);
}
} catch (IOException e) {
System.err.println(e);
}
@ -63,7 +66,7 @@ public class Jokes {
}
public static void showRandom() {
if (!TimeCalcProperties.getInstance().getBooleanProperty(
if (array.length == 0 || !TimeCalcProperties.getInstance().getBooleanProperty(
TimeCalcProperty.JOKES_VISIBLE)) {
//nothing to do
return;

View File

@ -14,10 +14,10 @@ public class JokesTxt {
}
public static String[] getAsArray() throws IOException {
File jokeTxtFile = new File("jokes.txt");
File jokeTxtFile = FileConstants.JOKES_TXT;
if (!jokeTxtFile.exists()) {
//nothing to do
return new String[] {"A", "B", "C"};
return new String[] {};
}
return Utils.readTextFromFile(jokeTxtFile).split("-----SEPARATOR-----");
}