Last commit today

This commit is contained in:
Greg TK 2018-07-10 21:26:17 +02:00
parent 234b01ad4d
commit 21b451a6f3
2 changed files with 5 additions and 10 deletions

View file

@ -41,7 +41,7 @@ public class Main {
for (String Token : botTokens) { for (String Token : botTokens) {
bots.add(new JDABuilder(AccountType.BOT).setAutoReconnect(true).setToken(Token).buildAsync()); bots.add(new JDABuilder(AccountType.BOT).setAutoReconnect(true).setToken(Token).buildAsync());
} }
Stats.main(); Stats.start();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -20,7 +20,7 @@ import java.util.*;
public class Stats { public class Stats {
public static void main() { public static void start() {
Thread diagramm = new Thread(() -> { Thread diagramm = new Thread(() -> {
TimerTask timerTask = new TimerTask() { TimerTask timerTask = new TimerTask() {
@ -72,9 +72,9 @@ public class Stats {
data.add(Integer.parseInt(dataa)); data.add(Integer.parseInt(dataa));
} }
int max = -Integer.MAX_VALUE; int max = -Integer.MAX_VALUE;
for(int i = 0; i < data.size(); i++) { for (Integer aData : data) {
if(data.get(i) > max) if (aData > max)
max = data.get(i); max = aData;
} }
BufferedImage bufferedImage = ImageIO.read(new File("Diagramm.jpg")); BufferedImage bufferedImage = ImageIO.read(new File("Diagramm.jpg"));
Graphics2D g2 = bufferedImage.createGraphics(); Graphics2D g2 = bufferedImage.createGraphics();
@ -82,16 +82,12 @@ public class Stats {
RenderingHints.VALUE_ANTIALIAS_ON); RenderingHints.VALUE_ANTIALIAS_ON);
int w = bufferedImage.getWidth(); int w = bufferedImage.getWidth();
int h = bufferedImage.getHeight(); int h = bufferedImage.getHeight();
// Draw ordinate.
g2.draw(new Line2D.Double(24, 24, 24, h - 24)); g2.draw(new Line2D.Double(24, 24, 24, h - 24));
// Draw abcissa.
g2.draw(new Line2D.Double(24, h - 24, w - 24, h - 24)); g2.draw(new Line2D.Double(24, h - 24, w - 24, h - 24));
// Draw labels.
Font font = g2.getFont(); Font font = g2.getFont();
FontRenderContext frc = g2.getFontRenderContext(); FontRenderContext frc = g2.getFontRenderContext();
LineMetrics lm = font.getLineMetrics("0", frc); LineMetrics lm = font.getLineMetrics("0", frc);
float sh = lm.getAscent() + lm.getDescent(); float sh = lm.getAscent() + lm.getDescent();
// Ordinate label.
String s = "data"; String s = "data";
float sy = 24 + ((h - 2 * 24) - s.length() * sh) / 2 + lm.getAscent(); float sy = 24 + ((h - 2 * 24) - s.length() * sh) / 2 + lm.getAscent();
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
@ -101,7 +97,6 @@ public class Stats {
g2.drawString(letter, sx, sy); g2.drawString(letter, sx, sy);
sy += sh; sy += sh;
} }
// Abcissa label.
s = "x axis"; s = "x axis";
sy = h - 24 + (24 - sh) / 2 + lm.getAscent(); sy = h - 24 + (24 - sh) / 2 + lm.getAscent();
float sw = (float) font.getStringBounds(s, frc).getWidth(); float sw = (float) font.getStringBounds(s, frc).getWidth();