Commit b7e294e8 authored by Florian Grabowski's avatar Florian Grabowski
Browse files

Code Style and Imports

parent b262e83d
/src/server/logs/
/src/server/world/
/src/server/plugins/
/src/server/world_nether/
/src/server/world_the_end/
*.class
/.idea/inspectionProfiles/Project_Default.xml
/.idea/sqldialects.xml
*.mca
.console_history
package de._82grfl1bif.KPI_Visualizer.commands;
package de._82grfl1bif.kpiVisualizer.commands;
import de._82grfl1bif.KPI_Visualizer.data.DataHolder;
import de._82grfl1bif.KPI_Visualizer.data.JsonParser;
import de._82grfl1bif.KPI_Visualizer.layouts.TreeMap.Rectangle;
import de._82grfl1bif.KPI_Visualizer.layouts.TreeMap.Row;
import de._82grfl1bif.KPI_Visualizer.layouts.TreeMap.SquarifiedTreemapLayout;
import de._82grfl1bif.KPI_Visualizer.structures.*;
import de._82grfl1bif.kpiVisualizer.data.DataHolder;
import de._82grfl1bif.kpiVisualizer.data.JsonParser;
import de._82grfl1bif.kpiVisualizer.layouts.treeMap.Rectangle;
import de._82grfl1bif.kpiVisualizer.layouts.treeMap.Row;
import de._82grfl1bif.kpiVisualizer.layouts.treeMap.SquarifiedTreemapLayout;
import de._82grfl1bif.kpiVisualizer.structures.Builder;
import de._82grfl1bif.kpiVisualizer.structures.Building;
import de._82grfl1bif.kpiVisualizer.structures.Foundation;
import de._82grfl1bif.kpiVisualizer.structures.Structure;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
......@@ -21,7 +24,7 @@ import java.awt.*;
import java.util.Map;
import java.util.logging.Level;
public class generateLayout implements CommandExecutor {
public class GenerateLayout implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
......@@ -29,7 +32,6 @@ public class generateLayout implements CommandExecutor {
sender.sendMessage("please type or select the needed Arguments with tab.");
return false;
}
sender.sendMessage("generating SimpleSquareLayout");
Server server = sender.getServer();
Builder builder = new Builder(server);
Player player = server.getPlayer(sender.getName());
......@@ -41,6 +43,7 @@ public class generateLayout implements CommandExecutor {
if (player != null) { //check if Player exists for getting Start coordinates.
Location location = player.getLocation();
if (args[1].equals("SquarifiedTreemap")) { //check 2. Argument whether to use SquarifiedTreemap or SimpleSquare Layout.
sender.sendMessage("generating SquarifiedTreemapLayout");
BukkitRunnable t = new BukkitRunnable() {
@Override
public void run() {
......@@ -56,18 +59,13 @@ public class generateLayout implements CommandExecutor {
}else{
builder.fillQube(location.clone().add(r.getOrigin().x,s.getDepth()+100,r.getOrigin().y),(int)(r.getWidth()),((Building)s).getHeight(),(int)(r.getHeight()),s.getMaterial());
}
if(r.getHeight() >= 5 && r.getWidth() >= 5){
}else{
Bukkit.getLogger().log(Level.SEVERE,"the rectangle is too small");
}
}
}
}
};
t.run();
return true;
} else {
sender.sendMessage("generating SimpleSquareLayout");
BukkitRunnable t = new BukkitRunnable() {
@Override
public void run() {
......@@ -80,8 +78,8 @@ public class generateLayout implements CommandExecutor {
}
};
t.run();
return true;
}
return true;
} else {
Bukkit.getLogger().log(Level.SEVERE, "Kein Spieler gefunden.");
......
package de._82grfl1bif.KPI_Visualizer.commands;
package de._82grfl1bif.kpiVisualizer.commands;
import de._82grfl1bif.KPI_Visualizer.data.DataHolder;
import de._82grfl1bif.KPI_Visualizer.structures.Builder;
import de._82grfl1bif.KPI_Visualizer.structures.Building;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import de._82grfl1bif.kpiVisualizer.data.DataHolder;
import de._82grfl1bif.kpiVisualizer.structures.Builder;
import de._82grfl1bif.kpiVisualizer.structures.Building;
import de._82grfl1bif.kpiVisualizer.structures.Structure;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Server;
......@@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.logging.Level;
@Deprecated
public class SetPreset implements CommandExecutor {
@Override
......
package de._82grfl1bif.KPI_Visualizer.data;
package de._82grfl1bif.kpiVisualizer.data;
import de._82grfl1bif.KPI_Visualizer.structures.Building;
import de._82grfl1bif.KPI_Visualizer.structures.Foundation;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import de._82grfl1bif.kpiVisualizer.structures.Building;
import de._82grfl1bif.kpiVisualizer.structures.Foundation;
import de._82grfl1bif.kpiVisualizer.structures.Structure;
import org.bukkit.Material;
import java.util.ArrayList;
......@@ -70,7 +70,6 @@ public class DataHolder {
public static void generateTreeFromKlassenList(ArrayList<Klasse> klassen) {
foundation = new Foundation(0, Material.YELLOW_CONCRETE);
ArrayList<String> Pakete = new ArrayList<>();
for (Klasse currentKlasse : klassen) {
if (currentKlasse.depth >= 0) {
String[] strings = currentKlasse.path.split("/");
......@@ -98,6 +97,7 @@ public class DataHolder {
}
}
@Deprecated
private static Building generateBuilding() {
Building result = new Building(ThreadLocalRandom.current().nextInt(4, 60 + 1), ThreadLocalRandom.current().nextInt(4, 200 + 1), Material.LIME_CONCRETE);
result.setLocation(foundation.getLocation());
......
package de._82grfl1bif.KPI_Visualizer.data;
package de._82grfl1bif.kpiVisualizer.data;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
......@@ -6,10 +6,16 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Level;
public class JsonParser {
......@@ -36,13 +42,13 @@ public class JsonParser {
JSONArray entities = (JSONArray) jsonObject.get("entities");
ArrayList<Klasse> entitiesList = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd kk:mm:ss Z");
for (int i=0; i < entities.size(); i++) {
JSONObject object = (JSONObject) entities.get(i);
JSONArray commits = (JSONArray) ((JSONObject) entities.get(i)).get("commits");
for (Object entity : entities) {
JSONObject object = (JSONObject) entity;
JSONArray commits = (JSONArray) ((JSONObject) entity).get("commits");
ArrayList<LocalDateTime> dates = new ArrayList<>();
for (Object o: commits){
for (Object o : commits) {
Object date = ((JSONObject) o).get("date");
LocalDateTime time = LocalDateTime.parse(date.toString(),formatter);
LocalDateTime time = LocalDateTime.parse(date.toString(), formatter);
dates.add(time);
}
Klasse currentKlasse = new Klasse(
......@@ -56,7 +62,7 @@ public class JsonParser {
((JSONArray) object.get("variables")).size(),
Math.round(Float.parseFloat(object.get("complexity").toString())),
dates);
if(currentKlasse.depth != -1)entitiesList.add(currentKlasse);
if (currentKlasse.depth != -1) entitiesList.add(currentKlasse);
}
entitiesList.sort(new DepthComparator());
DataHolder.generateTreeFromKlassenList(entitiesList);
......
package de._82grfl1bif.KPI_Visualizer.data;
package de._82grfl1bif.kpiVisualizer.data;
import java.time.Duration;
import java.time.LocalDateTime;
......
package de._82grfl1bif.KPI_Visualizer.helpers;
package de._82grfl1bif.kpiVisualizer.helpers;
import de._82grfl1bif.KPI_Visualizer.data.JsonParser;
import de._82grfl1bif.kpiVisualizer.data.JsonParser;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
......
package de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare;
package de._82grfl1bif.kpiVisualizer.layouts.simpleSquare;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import de._82grfl1bif.kpiVisualizer.structures.Structure;
import java.awt.*;
import java.awt.Point;
import java.util.ArrayList;
public class Quadrat extends Shape {
......@@ -62,6 +62,7 @@ public class Quadrat extends Shape {
return new Point(topRightCorner.x-bottomLeftCorner.x,topRightCorner.y-bottomLeftCorner.y);
}
@Deprecated
public void applyCoordinates(Point coordinates){
this.bottomLeftCorner = coordinates;
}
......
package de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare;
package de._82grfl1bif.kpiVisualizer.layouts.simpleSquare;
import java.awt.*;
import java.awt.Point;
import java.util.ArrayList;
public class Rectangle extends Shape {
......
package de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare;
package de._82grfl1bif.kpiVisualizer.layouts.simpleSquare;
import java.awt.Point;
......
package de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare;
package de._82grfl1bif.kpiVisualizer.layouts.simpleSquare;
import de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare.Quadrat;
import de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare.Rectangle;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import de._82grfl1bif.kpiVisualizer.structures.Structure;
import javax.management.AttributeNotFoundException;
import java.awt.*;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Comparator;
......@@ -78,9 +76,9 @@ public class SimpleSquareLayout {
layout.add(new Quadrat(new Point(q.bottomLeftCorner.y,q.bottomLeftCorner.x),new Point(q.topRightCorner.y,q.topRightCorner.x))); // gespiegeltes Quadrat
layout.add(new Quadrat(new Point(q.bottomLeftCorner.x,q.bottomLeftCorner.x),structure.getWidth().x)); // Oberes rechtes Quadrat
if((this.size-(2*structure.getWidth().x)) > 0){ //falls Abstand zwischen den Quadraten ist.
de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare.Rectangle rTop = new de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare.Rectangle(structure.getWidth().x,(this.size-2*structure.getWidth().x),new Point(q .topRightCorner.y,q.bottomLeftCorner.x));
de._82grfl1bif.kpiVisualizer.layouts.simpleSquare.Rectangle rTop = new de._82grfl1bif.kpiVisualizer.layouts.simpleSquare.Rectangle(structure.getWidth().x,(this.size-2*structure.getWidth().x),new Point(q .topRightCorner.y,q.bottomLeftCorner.x));
layout.addAll(rTop.splitToQuads(rTop));
de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare.Rectangle rRight = new Rectangle((this.size-2*structure.getWidth().x),structure.getWidth().x,new Point(q.bottomLeftCorner.x,q.topRightCorner.y));
de._82grfl1bif.kpiVisualizer.layouts.simpleSquare.Rectangle rRight = new Rectangle((this.size-2*structure.getWidth().x),structure.getWidth().x,new Point(q.bottomLeftCorner.x,q.topRightCorner.y));
layout.addAll(rRight.splitToQuads(rRight));
}
}
......
package de._82grfl1bif.KPI_Visualizer.layouts.TreeMap;
package de._82grfl1bif.kpiVisualizer.layouts.treeMap;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.awt.Point;
public class Rectangle{
......
package de._82grfl1bif.KPI_Visualizer.layouts.TreeMap;
package de._82grfl1bif.kpiVisualizer.layouts.treeMap;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import de._82grfl1bif.kpiVisualizer.structures.Structure;
import java.awt.*;
import java.awt.Point;
import java.util.HashMap;
import java.util.Map;
......
package de._82grfl1bif.KPI_Visualizer.layouts.TreeMap;
package de._82grfl1bif.kpiVisualizer.layouts.treeMap;
import de._82grfl1bif.KPI_Visualizer.structures.Foundation;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import de._82grfl1bif.kpiVisualizer.structures.Foundation;
import de._82grfl1bif.kpiVisualizer.structures.Structure;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class SquarifiedTreemapLayout {
private ArrayList<Row> rows = new ArrayList<>();
private final ArrayList<Row> rows;
public ArrayList<Row> getRows() {
return rows;
......
package de._82grfl1bif.KPI_Visualizer;
package de._82grfl1bif.kpiVisualizer;
import de._82grfl1bif.KPI_Visualizer.commands.SetPreset;
import de._82grfl1bif.KPI_Visualizer.commands.generateLayout;
import de._82grfl1bif.KPI_Visualizer.helpers.FileInputTabCompleter;
import de._82grfl1bif.kpiVisualizer.commands.GenerateLayout;
import de._82grfl1bif.kpiVisualizer.commands.SetPreset;
import de._82grfl1bif.kpiVisualizer.helpers.FileInputTabCompleter;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Objects;
public final class main extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
getCommand("setPreset").setExecutor(new SetPreset());
getCommand("generateLayout").setExecutor(new generateLayout());
getCommand("generateLayout").setTabCompleter(new FileInputTabCompleter());
Objects.requireNonNull(getCommand("setPreset")).setExecutor(new SetPreset());
Objects.requireNonNull(getCommand("generateLayout")).setExecutor(new GenerateLayout());
Objects.requireNonNull(getCommand("generateLayout")).setTabCompleter(new FileInputTabCompleter());
}
@Override
......
package de._82grfl1bif.KPI_Visualizer.structures;
package de._82grfl1bif.kpiVisualizer.structures;
import de._82grfl1bif.KPI_Visualizer.data.Klasse;
import de._82grfl1bif.kpiVisualizer.data.Klasse;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
......@@ -10,11 +10,11 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import java.time.Duration;
import java.util.Objects;
import java.util.Random;
import java.util.logging.Level;
import static de._82grfl1bif.KPI_Visualizer.data.Klasse.zeitSeitLetzterBearbeitungMin;
@SuppressWarnings("ALL")
public class Builder {
Server server;
......@@ -94,7 +94,7 @@ public class Builder {
setWalls(startLocation, x, y, z, innerMaterial, glassMaterial);
setCorners(startLocation, x, y, z, facadeMaterial);
setFoundation(startLocation.clone().add(0, y, 0), x, z, facadeMaterial);//roof
fillQube(startLocation.clone().add(Math.round(x/2),y+1,Math.round(x/2)),1,antennaHeight,1,Material.COBBLESTONE_WALL);
fillQube(startLocation.clone().add(Math.round(x/2f),y+1,Math.round(x/2f)),1,antennaHeight,1,Material.COBBLESTONE_WALL);
Random rm = new Random();
switch (rm.nextInt(3)+1){
case 1: setCrane(startLocation,x,y,z,craneHeight,BlockFace.NORTH);
......@@ -150,13 +150,13 @@ public class Builder {
}else {
facadeInnerMaterial = Material.IRON_BARS;
}
System.out.println(letzterBearbeitung);
System.out.println(scaleLetzterBearbeitung);
//System.out.println(letzterBearbeitung);
//System.out.println(scaleLetzterBearbeitung);
this.buildBuilding(s.getLocation().clone().add(1, s.getDepth() + 1,1),
s.getWidth().x - 2,
((Building) s).getHeight()+1,
((Building)s).klasse.commits,
Math.round(((Building)s).klasse.complexity/100),
Math.round(((Building)s).klasse.complexity/100f),
s.getWidth().x - 2,
facadeMaterial,
facadeInnerMaterial,
......@@ -281,13 +281,13 @@ public class Builder {
default:
Bukkit.getLogger().log(Level.SEVERE, "falsche Orientierung übergeben!");
}
sign1.setData(matSign);
sign2.setData(matSign);
Objects.requireNonNull(sign1).setData(matSign);
Objects.requireNonNull(sign2o).setData(matSign);
sign1.setGlowingText(true);
sign2.setGlowingText(true);
if (building.name.length() > 60) {
sign1o.setData(matSign);
sign2o.setData(matSign);
Objects.requireNonNull(sign1o).setData(matSign);
Objects.requireNonNull(sign2o).setData(matSign);
sign1o.setGlowingText(true);
sign2o.setGlowingText(true);
setTextToSign(sign1, sign1o, building.name);
......@@ -351,7 +351,6 @@ public class Builder {
}
public void setLegend(Location startLocation){
org.bukkit.material.Sign matSign = new org.bukkit.material.Sign(Material.OAK_WALL_SIGN);
server.getWorlds().get(0).getBlockAt(startLocation.clone().add(0,0,-6)).setType(Material.WAXED_COPPER_BLOCK);
server.getWorlds().get(0).getBlockAt(startLocation.clone().add(0,1,-6)).setType(Material.WAXED_EXPOSED_COPPER);
server.getWorlds().get(0).getBlockAt(startLocation.clone().add(0,2,-6)).setType(Material.WAXED_WEATHERED_COPPER);
......@@ -378,7 +377,7 @@ public class Builder {
private void setLegendBlock(Location startLocation,String s1,String s2,String s3){
org.bukkit.material.Sign matSign = new org.bukkit.material.Sign(Material.OAK_WALL_SIGN);
org.bukkit.block.Sign sign = null;
org.bukkit.block.Sign sign;
server.getWorlds().get(0).getBlockAt(startLocation).setType(Material.OAK_WALL_SIGN);
sign = (org.bukkit.block.Sign) server.getWorlds().get(0).getBlockAt(startLocation).getState();
sign.setGlowingText(true);
......
package de._82grfl1bif.KPI_Visualizer.structures;
package de._82grfl1bif.kpiVisualizer.structures;
import de._82grfl1bif.KPI_Visualizer.data.Klasse;
import de._82grfl1bif.kpiVisualizer.data.Klasse;
import org.bukkit.Material;
import java.awt.Point;
......@@ -20,19 +20,10 @@ public class Building extends Structure{
}
}
public Building(Point width/*and depth for complex algorithms*/, int height, Material material){
this.width = width;
this.height = height;
this.material = material;
if(this.width.x < 5 || this.width.y < 5){
throw new IllegalArgumentException("keine Gebäude kleiner 5 wegen 2 Gehweg");
}
}
public Building(Material material, Klasse klasse, String name){ //Buildings are Square -> no depth
this.klasse = klasse;
this.material = material;
this.width = new Point((int)Math.round((klasse.variables+5)),(int)Math.round((klasse.variables+5))); //TODO: make this work with treemap and square
this.width = new Point(Math.round((klasse.variables+5)), Math.round((klasse.variables+5))); //TODO: make this work with treemap and square
this.area = klasse.variables*25;
this.name = name;
this.height = klasse.functions;
......
package de._82grfl1bif.KPI_Visualizer.structures;
package de._82grfl1bif.kpiVisualizer.structures;
import de._82grfl1bif.KPI_Visualizer.data.Klasse;
import de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare.SimpleSquareLayout;
import de._82grfl1bif.kpiVisualizer.data.Klasse;
import de._82grfl1bif.kpiVisualizer.layouts.simpleSquare.SimpleSquareLayout;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import javax.management.AttributeNotFoundException;
import java.awt.*;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
......@@ -214,7 +214,7 @@ public class Foundation extends Structure {
private boolean baseFoundation = true;
public void organizeFoundation() {
if (this.depth == 0 && baseFoundation) { //rootElement prepwork and recursion call
if (this.depth == 0 && baseFoundation) { //rootElement prep-work and recursion call
ArrayList<Foundation> allFoundations = collectAllFoundations();
baseFoundation = false;
allFoundations.sort(new DepthComparator());
......@@ -249,6 +249,7 @@ public class Foundation extends Structure {
return fCollection;
}
@Deprecated
public ArrayList<Building> collectAllBuildings() { //called on the base Foundation
ArrayList<Building> buildings = new ArrayList<>();
for (Structure s: children) {
......
package de._82grfl1bif.KPI_Visualizer.structures;
package de._82grfl1bif.kpiVisualizer.structures;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import javax.persistence.Column;
import javax.persistence.Entity;
import java.awt.*;
import java.awt.Point;
public abstract class Structure{
......@@ -33,6 +31,7 @@ public abstract class Structure{
this.location = location;
}
@Deprecated
public void addVector(Vector vector){
this.location.add(vector);
}
......
name: main
version: '${project.version}'
main: de._82grfl1bif.KPI_Visualizer.main
main: de._82grfl1bif.kpiVisualizer.main
api-version: 1.17
authors: [ FlorianGrabowski ]
description: Testing automated construcion of Buildings.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment