Skip to content

Commit be0365f

Browse files
committed
New API feature: showing progress by double value
1 parent f3cbf20 commit be0365f

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/main/java/com/nativejavafx/taskbar/TaskbarProgressbar.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,19 @@ protected TaskbarProgressbar() {
8282
*/
8383
public abstract void showCustomProgress(long done, long max, @NotNull Type type);
8484

85+
/**
86+
* Shows custom progress on the taskbar
87+
*
88+
* @param progress A positive value between 0 and 1 indicates the percentage of progress where 0 is 0% and 1 is 100%.
89+
* @param type the type of the progress; mustn't be null
90+
* @throws NullPointerException if type is null
91+
* @throws IllegalArgumentException if progress is less than 0
92+
*/
93+
public void showCustomProgress(double progress, @NotNull Type type) {
94+
if (progress < 0) throw new IllegalArgumentException("Progress can't be less than 0!");
95+
showCustomProgress((long) Math.min(progress * 100, 100), 100, type);
96+
}
97+
8598
/**
8699
* Sets the type of the progress
87100
*
@@ -161,6 +174,18 @@ public static void showCustomProgress(@NotNull Stage stage, long done, long max,
161174
getTaskbarProgressbarImpl(stage).showCustomProgress(done, max, type);
162175
}
163176

177+
/**
178+
* Shows a custom progress on the taskbar.
179+
*
180+
* @param stage the javaFX stage to show the progress on; mustn't be null
181+
* @param progress A positive value between 0 and 1 indicates the percentage of progress where 0 is 0% and 1 is 100%.
182+
* @param type the type of the progress; mustn't be null
183+
* @throws NullPointerException if the stage or the type is null
184+
*/
185+
public static void showCustomProgress(@NotNull Stage stage, double progress, @NotNull Type type) {
186+
getTaskbarProgressbarImpl(stage).showCustomProgress(progress, type);
187+
}
188+
164189
/**
165190
* Sets the type of the progress on the given stage.
166191
*

0 commit comments

Comments
 (0)