-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from m1kc/project-cleanup
Cleanup project
- Loading branch information
Showing
22 changed files
with
824 additions
and
2,608 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,9 @@ | |
# NetBeans folders # | ||
build/ | ||
dist/ | ||
|
||
# IDE files | ||
*.iml | ||
.idea/ | ||
out/ | ||
nbproject/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,59 @@ | ||
/* | ||
* To change this template, choose Tools | Templates | ||
* and open the template in the editor. | ||
*/ | ||
|
||
package ui; | ||
|
||
/** | ||
* | ||
* @author m1kc | ||
*/ | ||
public class Notation | ||
{ | ||
public class Notation { | ||
/** | ||
* Представляет размер в удобном для чтения человеком виде. | ||
* | ||
* @param sizeInBytes размер в байтах | ||
* @return Размер в удобном для чтения человеком виде (например, "20 байт", "260 Гб") | ||
*/ | ||
public static String bestSize(long sizeInBytes) | ||
{ | ||
if (sizeInBytes<1024L*10L) return ""+sizeInBytes+" байт"; | ||
if (sizeInBytes>=1024L*1024L*1024L*10L) return ""+sizeInBytes/(1024L*1024L*1024L)+" Гб"; | ||
if (sizeInBytes>=1024L*1024L*10L) return ""+sizeInBytes/(1024L*1024L)+" Мб"; | ||
return ""+sizeInBytes/1024L+" Кб"; | ||
public static String bestSize(long sizeInBytes) { | ||
if (sizeInBytes < 1024L * 10L) return "" + sizeInBytes + " байт"; | ||
if (sizeInBytes >= 1024L * 1024L * 1024L * 10L) return "" + sizeInBytes / (1024L * 1024L * 1024L) + " Гб"; | ||
if (sizeInBytes >= 1024L * 1024L * 10L) return "" + sizeInBytes / (1024L * 1024L) + " Мб"; | ||
return "" + sizeInBytes / 1024L + " Кб"; | ||
} | ||
|
||
/** | ||
* Представляет скорость в удобном для чтения человеком виде. | ||
* | ||
* @param speedInBytesPerSecond скорость в байт/сек | ||
* @return Скорость в удобном для чтения человеком виде (например, "10 байт/cек", "50 Кб/сек") | ||
*/ | ||
public static String bestSpeed(long speedInBytesPerSecond) | ||
{ | ||
if (speedInBytesPerSecond<1024L*10L) return ""+speedInBytesPerSecond+" байт/сек"; | ||
return ""+speedInBytesPerSecond/1024L+" Кб/сек"; | ||
public static String bestSpeed(long speedInBytesPerSecond) { | ||
if (speedInBytesPerSecond < 1024L * 10L) return "" + speedInBytesPerSecond + " байт/сек"; | ||
return "" + speedInBytesPerSecond / 1024L + " Кб/сек"; | ||
} | ||
|
||
private static String oNumber(long num) | ||
{ | ||
return num<10 ? "0"+num : ""+num; | ||
private static String oNumber(long num) { | ||
return num < 10 ? "0" + num : "" + num; | ||
} | ||
|
||
/** | ||
* Представляет время в удобном для чтения человеком виде. | ||
* | ||
* @param timeInMs время в мс | ||
* @return Время в удобном для чтения человеком виде (например, "10:54") | ||
*/ | ||
public static String bestTime(long timeInMs) | ||
{ | ||
public static String bestTime(long timeInMs) { | ||
//if (timeInMs < 10000L) return ""+timeInMs+" мс"; | ||
return ""+(timeInMs/1000L/60)+":"+oNumber(timeInMs/1000L%60); | ||
return "" + (timeInMs / 1000L / 60) + ":" + oNumber(timeInMs / 1000L % 60); | ||
} | ||
|
||
/** | ||
* Предоставляет данные в виде, угодном XSP. | ||
* | ||
* @param prefix префикс | ||
* @param curr текущее значение размера | ||
* @param size общее значение размера | ||
* @param speed скорость | ||
* @param curr текущее значение размера | ||
* @param size общее значение размера | ||
* @param speed скорость | ||
* @return Строка, содержащая все аргументы в удобном для чтения человеком виде. | ||
*/ | ||
public static String formatAll(String prefix, long curr, long size, long speed, long rest) | ||
{ | ||
return prefix+Notation.bestSize(curr)+"/"+Notation.bestSize(size) | ||
+" ("+Notation.bestSpeed(speed)+"), осталось "+bestTime(rest); | ||
public static String formatAll(String prefix, long curr, long size, long speed, long rest) { | ||
return prefix + Notation.bestSize(curr) + "/" + Notation.bestSize(size) | ||
+ " (" + Notation.bestSpeed(speed) + "), осталось " + bestTime(rest); | ||
} | ||
} |
Oops, something went wrong.