Add latest revisions after getting it functional
This commit is contained in:
parent
9653e273e4
commit
ffcecb8e8e
1443 changed files with 258988 additions and 6046 deletions
56
src/main/java/com/zontreck/ariaslib/util/Progress.java
Normal file
56
src/main/java/com/zontreck/ariaslib/util/Progress.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package com.zontreck.ariaslib.util;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class Progress
|
||||
{
|
||||
private int maximum;
|
||||
private int current;
|
||||
private AtomicInteger tickNum = new AtomicInteger(0);
|
||||
private static final String TICKS="-\\|/";
|
||||
|
||||
public String getSpinnerTick()
|
||||
{
|
||||
if(tickNum.get()>=TICKS.length()) tickNum.set(0);
|
||||
|
||||
return "[" + TICKS.substring(tickNum.getAndIncrement(), tickNum.get()) + "]";
|
||||
}
|
||||
|
||||
public Progress(int maximum)
|
||||
{
|
||||
current=0;
|
||||
this.maximum=maximum;
|
||||
}
|
||||
|
||||
public int getPercent(){
|
||||
return (current*100/maximum);
|
||||
}
|
||||
|
||||
public String getPercentStr()
|
||||
{
|
||||
return (getPercent()+"%");
|
||||
}
|
||||
|
||||
public static int getPercentOf(int current, int max)
|
||||
{
|
||||
return (current*100/max);
|
||||
}
|
||||
|
||||
public void increment(){
|
||||
current++;
|
||||
sanity();
|
||||
}
|
||||
private void sanity(){
|
||||
if(current > maximum) current = maximum;
|
||||
if(current < 0)current = 0;
|
||||
}
|
||||
public void decrement(){
|
||||
current--;
|
||||
sanity();
|
||||
}
|
||||
|
||||
public void setCurrent(int cur)
|
||||
{
|
||||
current=cur;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue