sigIRCv2/src/sig/TextRow.java

55 lines
1.2 KiB
Java
Raw Normal View History

2017-03-26 02:34:22 -05:00
package sig;
import java.util.Random;
public class TextRow {
private int maxX = 0; //Defines the greatest X position of all the messages in this row.
private int ypos = 0;
final int MESSAGE_SEPARATION=200;
private int scrollSpd = sigIRC.BASESCROLLSPD;
2017-03-26 02:34:22 -05:00
public TextRow(int ypos) {
this.ypos=ypos;
}
public int getY() {
return ypos;
}
public void setY(int ypos) {
this.ypos = ypos;
}
public int getMaxX() {
return maxX;
}
public int getScrollSpd() {
return scrollSpd;
}
2017-03-26 02:34:22 -05:00
public void updateRow(ScrollingText text) {
text.setX(maxX+sigIRC.panel.getWidth()+MESSAGE_SEPARATION);
text.setY(ypos);
text.setTextRow(this);
2017-03-26 02:34:22 -05:00
maxX+=text.getStringWidth()+MESSAGE_SEPARATION;
}
public void update() {
scrollSpd = DetermineScrollSpd();
2017-03-26 02:34:22 -05:00
if (maxX>0) {
maxX-=scrollSpd;
2017-03-26 02:34:22 -05:00
}
}
private int DetermineScrollSpd() {
return maxX/Math.max(1000,sigIRC.windowWidth)+sigIRC.chatScrollSpd;
}
2017-03-26 02:34:22 -05:00
public static TextRow PickRandomTextRow(String username) {
Random r = new Random();
r.setSeed(username.hashCode());
int randomnumb = r.nextInt(sigIRC.rowobj.size());
return sigIRC.rowobj.get(randomnumb);
}
}