.
This commit is contained in:
parent
23803144be
commit
5fa0fdd1a8
4 changed files with 8 additions and 240 deletions
|
|
@ -10,8 +10,14 @@
|
|||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: net.dv8tion:JDA:3.7.1_386" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.rethinkdb:rethinkdb-driver:2.3.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.dv8tion:JDA:3.7.1_391" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.json:json:20160810" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class Main {
|
|||
for (String Token : botTokens) {
|
||||
bots.add(new JDABuilder(AccountType.BOT).setAutoReconnect(true).setToken(Token).buildAsync());
|
||||
}
|
||||
test2.main();
|
||||
Stats.start();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,95 +0,0 @@
|
|||
package discord.data.mining;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.LineMetrics;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Line2D;
|
||||
|
||||
/**
|
||||
* @author Hax
|
||||
* @time 12:46 30.06.2018
|
||||
* @project Cryptix-Data-Mining
|
||||
* @package discord.data.mining
|
||||
* @class test
|
||||
**/
|
||||
|
||||
public class test extends JPanel {
|
||||
|
||||
int[] data = {
|
||||
21, 14, 18, 03, 86, 88, 74, 87, 54, 77,
|
||||
61, 55, 48, 60, 49, 36, 38, 27, 20, 18
|
||||
};
|
||||
final int PAD = 20;
|
||||
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
// Draw ordinate.
|
||||
g2.draw(new Line2D.Double(PAD, PAD, PAD, h-PAD));
|
||||
// Draw abcissa.
|
||||
g2.draw(new Line2D.Double(PAD, h-PAD, w-PAD, h-PAD));
|
||||
// Draw labels.
|
||||
Font font = g2.getFont();
|
||||
FontRenderContext frc = g2.getFontRenderContext();
|
||||
LineMetrics lm = font.getLineMetrics("0", frc);
|
||||
float sh = lm.getAscent() + lm.getDescent();
|
||||
// Ordinate label.
|
||||
String s = "data";
|
||||
float sy = PAD + ((h - 2*PAD) - s.length()*sh)/2 + lm.getAscent();
|
||||
for(int i = 0; i < s.length(); i++) {
|
||||
String letter = String.valueOf(s.charAt(i));
|
||||
float sw = (float)font.getStringBounds(letter, frc).getWidth();
|
||||
float sx = (PAD - sw)/2;
|
||||
g2.drawString(letter, sx, sy);
|
||||
sy += sh;
|
||||
}
|
||||
// Abcissa label.
|
||||
s = "x axis";
|
||||
sy = h - PAD + (PAD - sh)/2 + lm.getAscent();
|
||||
float sw = (float)font.getStringBounds(s, frc).getWidth();
|
||||
float sx = (w - sw)/2;
|
||||
g2.drawString(s, sx, sy);
|
||||
// Draw lines.
|
||||
double xInc = (double)(w - 2*PAD)/(data.length-1);
|
||||
double scale = (double)(h - 2*PAD)/getMax();
|
||||
g2.setPaint(Color.green.darker());
|
||||
for(int i = 0; i < data.length-1; i++) {
|
||||
double x1 = PAD + i*xInc;
|
||||
double y1 = h - PAD - scale*data[i];
|
||||
double x2 = PAD + (i+1)*xInc;
|
||||
double y2 = h - PAD - scale*data[i+1];
|
||||
g2.draw(new Line2D.Double(x1, y1, x2, y2));
|
||||
}
|
||||
// Mark data points.
|
||||
g2.setPaint(Color.red);
|
||||
for(int i = 0; i < data.length; i++) {
|
||||
double x = PAD + i*xInc;
|
||||
double y = h - PAD - scale*data[i];
|
||||
g2.fill(new Ellipse2D.Double(x-2, y-2, 4, 4));
|
||||
}
|
||||
}
|
||||
|
||||
private int getMax() {
|
||||
int max = -Integer.MAX_VALUE;
|
||||
for(int i = 0; i < data.length; i++) {
|
||||
if(data[i] > max)
|
||||
max = data[i];
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JFrame f = new JFrame();
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.add(new test());
|
||||
f.setSize(400,400);
|
||||
f.setLocation(200,200);
|
||||
f.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
package discord.data.mining;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.font.FontRenderContext;
|
||||
import java.awt.font.LineMetrics;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.awt.geom.Line2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Hax
|
||||
* @time 12:52 30.06.2018
|
||||
* @project Cryptix-Data-Mining
|
||||
* @package discord.data.mining
|
||||
* @class test2
|
||||
**/
|
||||
|
||||
public class test2 {
|
||||
|
||||
public static void main() {
|
||||
|
||||
Thread diagramm = new Thread(() -> {
|
||||
TimerTask timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
Date date = new Date();
|
||||
Calendar calendar = GregorianCalendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
if (calendar.get(Calendar.MINUTE)==0) {
|
||||
try {
|
||||
FileReader fr = new FileReader("stats.txt");
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
|
||||
String zeile = "";
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
while ((zeile = br.readLine()) != null) {
|
||||
stringBuilder.append(zeile);
|
||||
}
|
||||
br.close();
|
||||
|
||||
String[] stats = stringBuilder.toString().split(" ");
|
||||
String statsstring = stringBuilder.toString();
|
||||
statsstring = statsstring.replaceFirst(stats[0]+" ", "");
|
||||
statsstring = statsstring+" "+Main.Actionperh;
|
||||
FileWriter fw = new FileWriter("stats.txt");
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write(statsstring);
|
||||
bw.close();
|
||||
Main.Actionperh =0;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (calendar.get(Calendar.HOUR_OF_DAY)==0&&calendar.get(Calendar.MINUTE)==0) {
|
||||
try {
|
||||
FileReader fr = new FileReader("stats.txt");
|
||||
BufferedReader br = new BufferedReader(fr);
|
||||
|
||||
String zeile = "";
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
while ((zeile = br.readLine()) != null) {
|
||||
stringBuilder.append(zeile);
|
||||
}
|
||||
br.close();
|
||||
String[] datas = stringBuilder.toString().split(" ");
|
||||
ArrayList<Integer> data = new ArrayList<>();
|
||||
for (String dataa:datas) {
|
||||
data.add(Integer.parseInt(dataa));
|
||||
}
|
||||
int max = -Integer.MAX_VALUE;
|
||||
for(int i = 0; i < data.size(); i++) {
|
||||
if(data.get(i) > max)
|
||||
max = data.get(i);
|
||||
}
|
||||
BufferedImage bufferedImage = ImageIO.read(new File("Diagramm.jpg"));
|
||||
Graphics2D g2 = bufferedImage.createGraphics();
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
int w = bufferedImage.getWidth();
|
||||
int h = bufferedImage.getHeight();
|
||||
// Draw ordinate.
|
||||
g2.draw(new Line2D.Double(24, 24, 24, h - 24));
|
||||
// Draw abcissa.
|
||||
g2.draw(new Line2D.Double(24, h - 24, w - 24, h - 24));
|
||||
// Draw labels.
|
||||
Font font = g2.getFont();
|
||||
FontRenderContext frc = g2.getFontRenderContext();
|
||||
LineMetrics lm = font.getLineMetrics("0", frc);
|
||||
float sh = lm.getAscent() + lm.getDescent();
|
||||
// Ordinate label.
|
||||
String s = "data";
|
||||
float sy = 24 + ((h - 2 * 24) - s.length() * sh) / 2 + lm.getAscent();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
String letter = String.valueOf(s.charAt(i));
|
||||
float sw = (float) font.getStringBounds(letter, frc).getWidth();
|
||||
float sx = (24 - sw) / 2;
|
||||
g2.drawString(letter, sx, sy);
|
||||
sy += sh;
|
||||
}
|
||||
// Abcissa label.
|
||||
s = "x axis";
|
||||
sy = h - 24 + (24 - sh) / 2 + lm.getAscent();
|
||||
float sw = (float) font.getStringBounds(s, frc).getWidth();
|
||||
float sx = (w - sw) / 2;
|
||||
g2.drawString(s, sx, sy);
|
||||
// Draw lines.
|
||||
double xInc = (double) (w - 2 * 24) / (data.size() - 1);
|
||||
double scale = (double) (h - 2 * 24) / max;
|
||||
g2.setPaint(Color.green.darker());
|
||||
for (int i = 0; i < data.size() - 1; i++) {
|
||||
double x1 = 24 + i * xInc;
|
||||
double y1 = h - 24 - scale * data.get(i);
|
||||
double x2 = 24 + (i + 1) * xInc;
|
||||
double y2 = h - 24 - scale * data.get(i + 1);
|
||||
g2.draw(new Line2D.Double(x1, y1, x2, y2));
|
||||
}
|
||||
// Mark data points.
|
||||
g2.setPaint(Color.red);
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
double x = 24 + i * xInc;
|
||||
double y = h - 24 - scale * data.get(i);
|
||||
g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4));
|
||||
}
|
||||
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
ImageIO.write(bufferedImage, "jpg", os);
|
||||
Main.manager.get(0).getTextChannelById("462534066869370882").sendFile(new ByteArrayInputStream(os.toByteArray()), "test.jpg").queue();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
new Timer().schedule(timerTask, 30000, 60000);
|
||||
});
|
||||
diagramm.start();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue