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

Merge branch 'quarified_tree_map_algorithm' into 'master'

Bachelor Project final State

See merge request !1
parents bad6607d 7a34aeb9
/src/server/logs/
*.class
/.idea/inspectionProfiles/Project_Default.xml
/.idea/sqldialects.xml
......@@ -18,6 +18,8 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
<excludeFolder url="file://$MODULE_DIR$/src/server/logs" />
<excludeFolder url="file://$MODULE_DIR$/.idea/dataSources" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="@localhost" uuid="7964bdec-e778-4768-bdf5-f18b5b7f77b6">
<driver-ref>mariadb</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
<jdbc-url>jdbc:mariadb://localhost:3306</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>
\ No newline at end of file
package de._82grfl1bif.KPI_Visualizer.commands;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
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 org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.io.FileReader;
import java.util.logging.Level;
public class SetPreset implements CommandExecutor{
public class SetPreset implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
Server server = sender.getServer();
Builder builder = new Builder(server);
Player player = server.getPlayer(sender.getName());
Location location = player.getLocation();
if(location == null){
Bukkit.getLogger().log(Level.SEVERE,"Keine Location gefunden.");
return false;
} //if no Player is found
if (args.length != 1){
sender.sendMessage("try with one Number behind the command.");
return false;
}else {
Runnable t = new Runnable() {
@Override
public void run() {
if (player != null) {
Location location = player.getLocation();
if (args.length != 1) {
sender.sendMessage("try with one Number behind the command.");
return false;
} else {
Runnable t = () -> {
DataHolder.foundation.setLocation(location);
DataHolder.generateSimpleData(Integer.parseInt(args[0]));
fillPlane(server, location, DataHolder.foundation.getWidth(), DataHolder.foundation.getWidth(), DataHolder.foundation.getMaterial());
builder.setFoundation(location, DataHolder.foundation.getWidth().x, DataHolder.foundation.getWidth().y, DataHolder.foundation.getMaterial());
for (Structure structure : DataHolder.foundation.getChildren()) {
Building building = (Building) structure;
sender.sendMessage("bau" + building.toString());
fillQube(server, building.getLocation(), building.getWidth(), building.getHeight(), building.getWidth(), building.getMaterial());//Not yet ready to print foundations
builder.fillQube(building.getLocation(), building.getWidth().x, building.getHeight(), building.getWidth().y, building.getMaterial());//Not yet ready to print foundations
}
}
};
t.run();
}
return true;
}
private void fillPlane(Server server, Location startLocation, int x, int z, Material material){
for (int cx = 0; cx < x; cx++ ) {
for ( int cz = 0; cz < z; cz++){
Block block = server.getWorlds().get(0).getBlockAt(startLocation.clone().add(cx,0,cz));
block.setType(material);
};
t.run();
}
}
}
private void fillQube(Server server,Location startLocation, int x, int y, int z, Material material){
for(int cy = 0; cy < y; cy++){
fillPlane(server,startLocation.clone().add(0,cy,0),x,z,material);
}
}
private boolean evalJson(String fileName){
if(!fileName.contains(".json")){
fileName = fileName + ".json";
} //Add .json in case user forgets
try(JsonReader reader = new JsonReader(new FileReader("/Users/flgr/Desktop/PaperServer/LayoutJson"+ fileName))){
Gson gson = new Gson();
}catch (Exception ex){
Bukkit.getLogger().log(Level.SEVERE, String.valueOf(ex));
} else {
Bukkit.getLogger().log(Level.SEVERE, "Kein Spieler gefunden.");
return false;
}
return true;
......
package de._82grfl1bif.KPI_Visualizer.commands;
import de._82grfl1bif.KPI_Visualizer.data.DataHolder;
import de._82grfl1bif.KPI_Visualizer.structures.Building;
import de._82grfl1bif.KPI_Visualizer.structures.Foundation;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
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 org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
......@@ -15,124 +17,75 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.Map;
import java.util.logging.Level;
public class generateLayout implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
sender.sendMessage("generating Layout");
if (args.length < 2) {
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());
Location location = player.getLocation();
BukkitRunnable t = new BukkitRunnable() {
@Override
public void run() {
DataHolder.ComplexData();
DataHolder.foundation.setLocation(location);
DataHolder.foundation.organizeFoundation();
DataHolder.foundation.correctAllLocations(location);
setFoundation(server, DataHolder.foundation.getLocation().clone().add(0, DataHolder.foundation.getDepth(), 0), DataHolder.foundation.getWidth(), DataHolder.foundation.getWidth(), DataHolder.foundation.getMaterial());
setAllChildren(server, DataHolder.foundation);
}
};
t.run();
return true;
}
private void setFoundation(Server server, Location startLocation, int x, int z, Material material) {
for (int cx = 0; cx < x; cx++) {
for (int cz = 0; cz < z; cz++) {
Block block = server.getWorlds().get(0).getBlockAt(startLocation.clone().add(cx, 0, cz));
block.setType(material);
}
}
}
private void buildBuilding(Server server, Location startLocation, int x, int y, Material material) {
setWalls(server, startLocation.clone().add(0, 1, 0), x, y);
}
private void setWalls(Server server, Location startLocation, int x, int y) {
Location save = startLocation.clone();
Location temp = startLocation.clone();
for (int cx = 0; cx < x - 1; cx++) {// x+x Wall
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(cx,cy,1)).setType(Material.RED_CONCRETE);
}
}
temp = save.clone();
for (int cz = 0; cz < x - 1; cz++) {// z+x Wall
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(1, cy, cz)).setType(Material.RED_CONCRETE);
}
}
temp = save.clone().add(0, 0, x - 1);
for (int cx = 0; cx < x; cx++) {// x+x z+x Wall from x+x
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(cx, cy, -1)).setType(Material.RED_CONCRETE);
}
}
temp = save.clone().add(x - 1, 0, 0);
for (int cz = 0; cz < x - 1; cz++) {// x+x z+x Wall from x+z
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(-1, cy, cz)).setType(Material.RED_CONCRETE);
}
}
temp = save.clone();
for (int cx = 0; cx < x - 1; cx++) {// x+x Wall
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(cx, cy, 0)).setType(Material.GLASS);
}
}
temp = save.clone();
for (int cz = 0; cz < x - 1; cz++) {// z+x Wall
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, cz)).setType(Material.GLASS);
}
}
temp = save.clone().add(0, 0, x - 1);
for (int cx = 0; cx < x; cx++) {// x+x z+x Wall from x+x
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(cx, cy, 0)).setType(Material.GLASS);
}
}
temp = save.clone().add(x - 1, 0, 0);
for (int cz = 0; cz < x - 1; cz++) {// x+x z+x Wall from x+z
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, cz)).setType(Material.GLASS);
}
JsonParser jsonParser = new JsonParser();
if (!jsonParser.evalJson(args[0])) {
sender.sendMessage("failed to parse Json");
return false;
}
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.
BukkitRunnable t = new BukkitRunnable() {
@Override
public void run() {
SquarifiedTreemapLayout squarifiedTreemapLayout = new SquarifiedTreemapLayout();
squarifiedTreemapLayout.generateLayout(DataHolder.foundation, new Rectangle(DataHolder.foundation.getArea(), Math.sqrt(DataHolder.foundation.getArea()), new Point(0, 0)));
builder.setFoundation(location,(int)Math.round(Math.sqrt(DataHolder.foundation.getArea())),(int)Math.round(Math.sqrt(DataHolder.foundation.getArea())), Material.COBBLESTONE);
for (Row row : squarifiedTreemapLayout.getRows()) {
for (Map.Entry<Rectangle, Structure> entry : row.getRectangles().entrySet()) {
Rectangle r = entry.getKey();
Structure s = entry.getValue();
if(s.getClass() == Foundation.class){
builder.setFoundation(location.clone().add(r.getOrigin().x,s.getDepth(),r.getOrigin().y),(int)(r.getWidth()),(int)(r.getHeight()),s.getMaterial());
}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){
temp = save.clone();
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, 0)).setType(Material.BLACKSTONE);
}
temp = save.clone().add(x - 1, 0, 0);
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, 0)).setType(Material.BLACKSTONE);
}
temp = save.clone().add(0, 0, x - 1);
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, 0)).setType(Material.BLACKSTONE);
}
temp = save.clone().add(x - 1, 0, x - 1);
for (int cy = 0; cy < y; cy++) {
server.getWorlds().get(0).getBlockAt(temp.clone().add(0, cy, 0)).setType(Material.BLACKSTONE);
}
save.add(0,y,0);//roof
setFoundation(server,save,x,x,Material.BLACKSTONE);
}
private void setAllChildren(Server server, Foundation foundation) {
for (Structure s : foundation.getChildren()) {
if (s.getClass() == Foundation.class) {
setFoundation(server, s.getLocation().clone().add(0, s.getDepth(), 0), s.getWidth(), s.getWidth(), s.getMaterial());
setAllChildren(server, (Foundation) s);
}else{
Bukkit.getLogger().log(Level.SEVERE,"the rectangle is too small");
}
}
}
}
};
t.run();
return true;
} else {
buildBuilding(server, s.getLocation().clone().add(1, s.getDepth(), 1), s.getWidth() - 2, ((Building) s).getHeight(), s.getMaterial());
BukkitRunnable t = new BukkitRunnable() {
@Override
public void run() {
DataHolder.foundation.setLocation(location);
DataHolder.foundation.organizeFoundation();
DataHolder.foundation.correctAllLocations(location);
builder.setFoundation(DataHolder.foundation.getLocation().clone().add(0, DataHolder.foundation.getDepth(), 0), DataHolder.foundation.getWidth().x, DataHolder.foundation.getWidth().x, DataHolder.foundation.getMaterial());
builder.setAllChildren(DataHolder.foundation);
builder.setLegend(location);
}
};
t.run();
return true;
}
} else {
Bukkit.getLogger().log(Level.SEVERE, "Kein Spieler gefunden.");
return false;
}
}
......
......@@ -12,63 +12,94 @@ public class DataHolder {
public static Foundation foundation = new Foundation(0, Material.COBBLESTONE);
public static void generateSimpleData(int buildingCount){
@Deprecated
public static void generateSimpleData(int buildingCount) {
foundation.removeChildren();
ArrayList<Structure> buildings = new ArrayList<>();
for(int c = 0; c < buildingCount; c++){
for (int c = 0; c < buildingCount; c++) {
buildings.add(generateBuilding());
}
foundation.addChildren(buildings);
foundation.optimizeLayout();
}
public static void ComplexData(){
Foundation foundation3 = new Foundation(3,Material.BLACK_CONCRETE);
ArrayList<Structure> buildins3 = new ArrayList<>();
@Deprecated
public static void ComplexData() {
Foundation foundation3 = new Foundation(3, Material.BLACK_CONCRETE);
ArrayList<Structure> buildings3 = new ArrayList<>();
for (int i = 0; i < 5; i++) {
buildins3.add(generateBuilding());
buildings3.add(generateBuilding());
}
foundation3.addChildren(buildins3);
foundation3.addChildren(buildings3);
ArrayList<Structure> buildins2_1 = new ArrayList<>();
Foundation foundation2_1 = new Foundation(2,Material.BROWN_CONCRETE);
ArrayList<Structure> buildings2_1 = new ArrayList<>();
Foundation foundation2_1 = new Foundation(2, Material.BROWN_CONCRETE);
for (int i = 0; i < 5; i++) {
buildins2_1.add(generateBuilding());
buildings2_1.add(generateBuilding());
}
buildins2_1.add(foundation3);
foundation2_1.addChildren(buildins2_1);
buildings2_1.add(foundation3);
foundation2_1.addChildren(buildings2_1);
ArrayList<Structure> buildins2_2 = new ArrayList<>();
Foundation foundation2_2 = new Foundation(2,Material.LIGHT_GRAY_CONCRETE);
ArrayList<Structure> buildings2_2 = new ArrayList<>();
Foundation foundation2_2 = new Foundation(2, Material.LIGHT_GRAY_CONCRETE);
for (int i = 0; i < 5; i++) {
buildins2_2.add(generateBuilding());
buildings2_2.add(generateBuilding());
}
foundation2_2.addChildren(buildins2_2);
foundation2_2.addChildren(buildings2_2);
ArrayList<Structure> buildins1 = new ArrayList<>();
Foundation foundation1 = new Foundation(1,Material.GRAY_CONCRETE);
ArrayList<Structure> buildings1 = new ArrayList<>();
Foundation foundation1 = new Foundation(1, Material.GRAY_CONCRETE);
for (int i = 0; i < 5; i++) {
buildins1.add(generateBuilding());
buildings1.add(generateBuilding());
}
buildins1.add(foundation2_1);
buildins1.add(foundation2_2);
foundation1.addChildren(buildins1);
buildings1.add(foundation2_1);
buildings1.add(foundation2_2);
foundation1.addChildren(buildings1);
ArrayList<Structure> buildins0 = new ArrayList<>();
ArrayList<Structure> buildings0 = new ArrayList<>();
for (int i = 0; i < 5; i++) {
buildins1.add(generateBuilding());
buildings1.add(generateBuilding());
}
buildins0.add(foundation1);
foundation = new Foundation(0,Material.COBBLESTONE);
foundation.addChildren(buildins0);
buildings0.add(foundation1);
foundation = new Foundation(0, Material.COBBLESTONE);
foundation.addChildren(buildings0);
foundation.setDepth(0);
}
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("/");
Foundation f = foundation;
StringBuilder sb = new StringBuilder();
for (int i = 2; i < currentKlasse.depth + 2; i++) {
sb.append(strings[i]);
if (!(strings[i].contains(".java"))){//is foundation
sb.append("/");
}
if (foundation.getFromTree(sb.toString()) == null) {// checks Tree for Element doesn't find it
if (strings[i].contains(".java")) {//is not foundation
f.generateChild(false, currentKlasse, sb.toString());
f = foundation;
} else {
f = (Foundation) f.generateChild(true,currentKlasse,sb.toString());
}
}else{//finds Element in tree
if ((foundation.getFromTree(sb.toString()).getClass() == Foundation.class)){
f = (Foundation) foundation.getFromTree(sb.toString());
}
}
}
}
}
}
private static Building generateBuilding() {
Building result = new Building(ThreadLocalRandom.current().nextInt(4, 60 + 1),ThreadLocalRandom.current().nextInt(4, 200 + 1),Material.LIME_CONCRETE);
Building result = new Building(ThreadLocalRandom.current().nextInt(4, 60 + 1), ThreadLocalRandom.current().nextInt(4, 200 + 1), Material.LIME_CONCRETE);
result.setLocation(foundation.getLocation());
return result;
}
......
package de._82grfl1bif.KPI_Visualizer.data;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.logging.Level;
public class JsonParser {
String standardPath = System.getProperty("user.dir");
public boolean evalJson(@NotNull String fileName) {
if (!fileName.contains(".json")) {
fileName = fileName + ".json";
} //Add .json in case user forgets
if (!(fileName.contains("/"))) {
fileName = standardPath + "/" + fileName;
}
try (FileReader jsonFileReader = new FileReader(fileName)) {
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(jsonFileReader);
if (!(getFileHistory().contains(fileName))) { //if file isn't in history add it.
try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(standardPath + "/plugins/JsonFileHistory",true))){
bufferedWriter.newLine();
bufferedWriter.write(fileName);
} catch (Exception e) {
Bukkit.getLogger().log(Level.SEVERE, String.valueOf(e));
}
}
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");
ArrayList<LocalDateTime> dates = new ArrayList<>();
for (Object o: commits){
Object date = ((JSONObject) o).get("date");
LocalDateTime time = LocalDateTime.parse(date.toString(),formatter);
dates.add(time);
}
Klasse currentKlasse = new Klasse(
Integer.parseInt(object.get("entity_id").toString()),
object.get("name").toString(),
object.get("path").toString(),
Integer.parseInt(object.get("qloc").toString()),
Integer.parseInt(object.get("loc").toString()),
((JSONArray) object.get("commits")).size(),
((JSONArray) object.get("functions")).size(),
((JSONArray) object.get("variables")).size(),
Math.round(Float.parseFloat(object.get("complexity").toString())),
dates);
if(currentKlasse.depth != -1)entitiesList.add(currentKlasse);
}
entitiesList.sort(new DepthComparator());
DataHolder.generateTreeFromKlassenList(entitiesList);
} catch (Exception ex) {
Bukkit.getLogger().log(Level.SEVERE, String.valueOf(ex));
return false;
}
return true;
}
private static class DepthComparator implements Comparator<Klasse> {
@Override
public int compare(Klasse o1, Klasse o2) {
return Integer.compare(o1.depth,o2.depth);
}
}
public List<String> getFileHistory() {
String path = System.getProperty("user.dir");
String fileName = "/plugins/JsonFileHistory";
List<String> filesInHistory = new ArrayList<>();
try {
File file = new File(path + fileName);
if (file.createNewFile()) {//Create file
return null;
} //File exists
BufferedReader br = new BufferedReader(new FileReader(path + fileName));
String line;
while ((line = br.readLine()) != null) {
filesInHistory.add(line);
}
br.close();
} catch (Exception e) {
Bukkit.getLogger().log(Level.SEVERE, String.valueOf(e));
return null;
}
return filesInHistory;
}
}
package de._82grfl1bif.KPI_Visualizer.data;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
public class Klasse {
public String name;
public String path;
public int qloc;
public static int qlocMin = Integer.MAX_VALUE;
public static int qlocMax;
public int loc;
public static int locMin= Integer.MAX_VALUE;
public static int locMax;
public int commits;
public static int commitsMin= Integer.MAX_VALUE;
public static int commitsMax;
public int depth;
public static int depthMax;
public int complexity;
public static int complexityMax;
public static int complexityMin= Integer.MAX_VALUE;
public final int id;
public int functions;
public static int functionsMin= Integer.MAX_VALUE;
public static int functionsMax;
public int variables;
public static int variablesMin= Integer.MAX_VALUE;
public static int variablesMax;
public Duration bearbeiteteZeit;
public static Duration bearbeiteteZeitMin;
public static Duration bearbeiteteZeitMax;
public Duration zeitSeitLetzterBearbeitung;
public static Duration zeitSeitLetzterBearbeitungMin;
public static Duration zeitSeitLetzterBearbeitungMax;
public Duration zeitSeitErstemCommit;
public static Duration zeitSeitErstemCommitMin;
public static Duration zeitSeitErstemCommitMax;
ArrayList<LocalDateTime> commitTimes;
public Klasse(int id, String name, String path, int qloc, int loc, int commits, int functions, int variables,int complexity, ArrayList<LocalDateTime> commitTimes){
this.id = id;
this.commits = commits;
commitsMax = Math.max(commitsMax,commits);
commitsMin = Math.min(commitsMin,commits);
this.depth = getDepthOfPath(path);
depthMax = Math.max(depthMax,depth);
this.loc = loc;
locMax = Math.max(locMax,loc);
locMin = Math.min(locMin,loc);
this.qloc = qloc;
qlocMax = Math.max(qlocMax,qloc);
qlocMin = Math.min(qlocMin,qloc);
this.functions = functions;
functionsMax = Math.max(functionsMax,functions);
functionsMin = Math.min(functionsMin,functions);
this.variables = variables;
variablesMax = Math.max(variablesMax,variables);
variablesMin = Math.min(variablesMin,variables);
this.complexity = complexity;
complexityMax = Math.max(complexityMax,complexity);
complexityMin = Math.min(complexityMin,complexity);
this.name = name;
this.path = path;
this.commitTimes = commitTimes;
this.bearbeiteteZeit = (commitTimes.isEmpty()) ? null:Duration.between(commitTimes.get(commitTimes.size()-1), commitTimes.get(0));
if (bearbeiteteZeit != null) {
if(bearbeiteteZeitMax == null)bearbeiteteZeitMax = Duration.ofMillis(Long.MIN_VALUE);
if(bearbeiteteZeitMin == null)bearbeiteteZeitMin = Duration.ofMillis((Long.MAX_VALUE));
bearbeiteteZeitMax = (bearbeiteteZeitMax.toMillis() >= bearbeiteteZeit.toMillis()) ? bearbeiteteZeitMax:bearbeiteteZeit;
bearbeiteteZeitMin = (bearbeiteteZeitMin.toMillis() <= bearbeiteteZeit.toMillis()) ? bearbeiteteZeitMin:bearbeiteteZeit;
}
this.zeitSeitLetzterBearbeitung = (commitTimes.isEmpty()) ? null:Duration.between(commitTimes.get(0),LocalDateTime.now());
if (zeitSeitLetzterBearbeitung != null) {
if(zeitSeitLetzterBearbeitungMax == null)zeitSeitLetzterBearbeitungMax = Duration.ofMillis(Long.MIN_VALUE);
if(zeitSeitLetzterBearbeitungMin == null)zeitSeitLetzterBearbeitungMin = Duration.ofMillis(Long.MAX_VALUE);
zeitSeitLetzterBearbeitungMax = (zeitSeitLetzterBearbeitungMax.toMillis() >= zeitSeitLetzterBearbeitung.toMillis()) ? zeitSeitLetzterBearbeitungMax:zeitSeitLetzterBearbeitung;
zeitSeitLetzterBearbeitungMin = (zeitSeitLetzterBearbeitungMin.toMillis() <= zeitSeitLetzterBearbeitung.toMillis()) ? zeitSeitLetzterBearbeitungMin:zeitSeitLetzterBearbeitung;
}
this.zeitSeitErstemCommit = (commitTimes.isEmpty()) ? null:Duration.between(commitTimes.get(commitTimes.size()-1),LocalDateTime.now());
if (zeitSeitErstemCommit != null) {
if(zeitSeitErstemCommitMax == null)zeitSeitErstemCommitMax = Duration.ofMillis(Long.MIN_VALUE);
if(zeitSeitErstemCommitMin == null)zeitSeitErstemCommitMin = Duration.ofMillis(Long.MAX_VALUE);
zeitSeitErstemCommitMax = (zeitSeitErstemCommitMax.toMillis() >= zeitSeitErstemCommit.toMillis()) ? zeitSeitErstemCommitMax:zeitSeitErstemCommit;
zeitSeitErstemCommitMin = (zeitSeitErstemCommitMin.toMillis() <= zeitSeitErstemCommit.toMillis()) ? zeitSeitErstemCommitMin:zeitSeitErstemCommit;
}
}
private int getDepthOfPath(String path){
int result = -1;
if(path.contains("tmp")){
result = path.split("/").length-2;
}
return result;
}
}
package de._82grfl1bif.KPI_Visualizer.data;
import org.apache.commons.beanutils.BeanUtils;
import javax.persistence.Column;
import javax.swing.text.html.parser.Entity;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.List;
public class ResultSetMapper<T> {
public List<T> mapResultSetToObject(ResultSet rs, Class outputClass) {
List<T> outputList = null;
try {
// make sure resultSet is not null
if (rs != null) {
// check if outputClass has 'Entity' annotation
if (outputClass.isAnnotationPresent(Entity.class)) {
// get the resultSet metadata
ResultSetMetaData rsMetaData = rs.getMetaData();
// get all the attributes of outputClass
Field[] fields = outputClass.getDeclaredFields();
while (rs.next()) {
T bean = (T) outputClass.newInstance();
for (int _iterator = 0; _iterator < rsMetaData.getColumnCount(); _iterator++) {
// getting the SQL column name
String columnName = rsMetaData.getColumnName(_iterator + 1);
// reading the value of the SQL column
Object columnValue = rs.getObject(_iterator + 1);
// iterating over outputClass attributes to check if any attribute has 'Column' annotation with matching 'name' value
for (Field field : fields) {
if (field.isAnnotationPresent(Column.class)) {
Column column = field.getAnnotation(Column.class);
if (column.name().equalsIgnoreCase(columnName) && columnValue != null) {
BeanUtils.setProperty(bean, field.getName(), columnValue);
break;
}
}
}
}
if (outputList == null) {
outputList = new ArrayList<>();
}
outputList.add(bean);
}
}
} else {
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
return outputList;
}
}
\ No newline at end of file
package de._82grfl1bif.KPI_Visualizer.helpers;
import de._82grfl1bif.KPI_Visualizer.data.JsonParser;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class FileInputTabCompleter implements TabCompleter {
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
if (args.length == 1) {
return new JsonParser().getFileHistory();
}
if (args.length == 2) {
List<String> result = new ArrayList<>();
result.add("SquarifiedTreemap");
result.add("SimpleCornerOptimizer");
return result;
}
return null;
}
}
package de._82grfl1bif.KPI_Visualizer.helpers;
package de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import java.awt.*;
import java.util.ArrayList;
public class Quadrat extends Shape{
public class Quadrat extends Shape {
private Boolean belegt;
......@@ -32,7 +30,7 @@ public class Quadrat extends Shape{
this.bottomLeftCorner = bottomLeftCorner;
this.topRightCorner = new Point(bottomLeftCorner.x+xEdgeLength,bottomLeftCorner.y+xEdgeLength);
this.belegt = false;
if(xEdgeLength < 3){
if(xEdgeLength < 3 || topRightCorner.x-bottomLeftCorner.x <3){
throw new IllegalArgumentException("keine Quadrate < 3 erlaubt " + xEdgeLength);
}
}
......@@ -41,16 +39,16 @@ public class Quadrat extends Shape{
this.belegt = true;
this.structure = structure;
ArrayList<Quadrat> result = new ArrayList<>();
if(this.xEdgeLength > structure.getWidth()+3){//if you can splitt rest into more quads
int scrapLength = this.xEdgeLength-structure.getWidth();
result.add(new Quadrat(new Point(this.bottomLeftCorner.x+structure.getWidth(),this.bottomLeftCorner.y),scrapLength));
result.add(new Quadrat(new Point(this.bottomLeftCorner.x,this.bottomLeftCorner.y+structure.getWidth()),scrapLength));
result.add(new Quadrat(new Point(this.bottomLeftCorner.x+structure.getWidth(),this.bottomLeftCorner.y+structure.getWidth()),scrapLength));
if(this.xEdgeLength > structure.getWidth().x+3){//if you can split rest into more quads
int scrapLength = this.xEdgeLength-structure.getWidth().x;
result.add(new Quadrat(new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y),scrapLength));
result.add(new Quadrat(new Point(this.bottomLeftCorner.x,this.bottomLeftCorner.y+structure.getWidth().x),scrapLength));
result.add(new Quadrat(new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y+structure.getWidth().x),scrapLength));
if(this.xEdgeLength%scrapLength != 0){
Rectangle temp = new Rectangle(scrapLength,this.xEdgeLength-2*scrapLength,new Point(this.bottomLeftCorner.x+scrapLength,this.bottomLeftCorner.y+structure.getWidth()));
result.addAll(temp.splittToQuads(temp));
temp = new Rectangle(this.xEdgeLength-2*scrapLength,scrapLength,new Point(this.bottomLeftCorner.x+structure.getWidth(),this.bottomLeftCorner.y+scrapLength));
result.addAll(temp.splittToQuads(temp));
Rectangle temp = new Rectangle(scrapLength,this.xEdgeLength-2*scrapLength,new Point(this.bottomLeftCorner.x+scrapLength,this.bottomLeftCorner.y+structure.getWidth().x));
result.addAll(temp.splitToQuads(temp));
temp = new Rectangle(this.xEdgeLength-2*scrapLength,scrapLength,new Point(this.bottomLeftCorner.x+structure.getWidth().x,this.bottomLeftCorner.y+scrapLength));
result.addAll(temp.splitToQuads(temp));
}
}
return result;
......@@ -60,11 +58,11 @@ public class Quadrat extends Shape{
return belegt;
}
public int getWidth(){
return this.xEdgeLength;
public Point getWidth(){
return new Point(topRightCorner.x-bottomLeftCorner.x,topRightCorner.y-bottomLeftCorner.y);
}
public void applyCoordinates(){
public void applyCoordinates(Point coordinates){
this.bottomLeftCorner = coordinates;
}
}
package de._82grfl1bif.KPI_Visualizer.helpers;
package de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare;
import java.awt.*;
import java.util.ArrayList;
public class Rectangle extends Shape {
private int zEdgeLength;
private final int zEdgeLength;
public Rectangle(int zEdgeLength, int xEdgeLength, Point bottomLeftCorner) {
this.zEdgeLength = zEdgeLength;
......@@ -14,7 +14,7 @@ public class Rectangle extends Shape {
this.topRightCorner = new Point(bottomLeftCorner.x + xEdgeLength, bottomLeftCorner.y + zEdgeLength);
}
public ArrayList<Quadrat> splittToQuads(Rectangle r) {
public ArrayList<Quadrat> splitToQuads(Rectangle r) {
ArrayList<Quadrat> result = new ArrayList<>();
if (r.xEdgeLength >= 3 && r.zEdgeLength >= 3) {
if ((r.xEdgeLength - r.zEdgeLength) < 0) {//standing Rectangle
......@@ -32,7 +32,7 @@ public class Rectangle extends Shape {
scrapPoint.y = (r.bottomLeftCorner.y + (r.xEdgeLength * (c + 1)));
}
if (scrapLength >= 3 && r.xEdgeLength >= 3) {
result.addAll(splittToQuads(new Rectangle(scrapLength, r.xEdgeLength, scrapPoint)));
result.addAll(splitToQuads(new Rectangle(scrapLength, r.xEdgeLength, scrapPoint)));
}
}
} else {//laying Rectangles
......@@ -49,8 +49,8 @@ public class Rectangle extends Shape {
scrapPoint.x = (r.bottomLeftCorner.x + (r.zEdgeLength * (c + 1)));
scrapPoint.y = r.bottomLeftCorner.y;
}
if (r.zEdgeLength >= 3 && scrapLength >= 3) {
result.addAll(splittToQuads(new Rectangle(r.zEdgeLength, scrapLength, scrapPoint)));
if (scrapLength >= 3) {
result.addAll(splitToQuads(new Rectangle(r.zEdgeLength, scrapLength, scrapPoint)));
}
}
}
......
package de._82grfl1bif.KPI_Visualizer.helpers;
package de._82grfl1bif.KPI_Visualizer.layouts.SimpleSquare;
import java.awt.Point;
......
package de._82grfl1bif.KPI_Visualizer.helpers;
package de._82grfl1bif.KPI_Visualizer.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 javax.management.AttributeNotFoundException;
......@@ -7,8 +9,7 @@ import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
@SuppressWarnings("ALL")
public class Layout {
public class SimpleSquareLayout {
private final ArrayList<Structure> structures;
private final ArrayList<Quadrat> layout = new ArrayList<>();
......@@ -19,7 +20,7 @@ public class Layout {
private int size = 0;
public Layout(ArrayList<Structure> structures){
public SimpleSquareLayout(ArrayList<Structure> structures){
this.structures = structures;//ordered biggest first.
}
......@@ -27,7 +28,7 @@ public class Layout {
@Override
public int compare(Quadrat o1, Quadrat o2) {
return Integer.compare(o1.getWidth(), o2.getWidth());
return Integer.compare(o1.getWidth().x, o2.getWidth().x);
}
}
private static class CoordinateXComparator implements Comparator<Quadrat>{
......@@ -48,8 +49,8 @@ public class Layout {
for (Structure s:structures) {
if(first){
first = false;
this.size = s.getWidth();
layout.add(new Quadrat(new Point(0,0),s.getWidth()));
this.size = s.getWidth().x;
layout.add(new Quadrat(new Point(0,0),s.getWidth().x));
layout.addAll(layout.get(0).setBelegt(s));
}else{
layout.sort(new CoordinateYComparator());
......@@ -57,7 +58,7 @@ public class Layout {
layout.sort(new WidthComparator());
boolean noneFoundFlag = true;
for (int i = 0;i < layout.size();i++) {
if((s.getWidth() <= layout.get(i).getWidth())&&(!layout.get(i).getBelegt())&&(noneFoundFlag)){
if((s.getWidth().x <= layout.get(i).getWidth().x)&&(!layout.get(i).getBelegt())&&(noneFoundFlag)){
noneFoundFlag = false;
layout.addAll(layout.get(i).setBelegt(s));
}
......@@ -70,17 +71,17 @@ public class Layout {
}
private void appendQuad(Structure structure){
Quadrat q = new Quadrat(new Point(this.size,0),structure.getWidth());
Quadrat q = new Quadrat(new Point(this.size,0),structure.getWidth().x);
q.setBelegt(structure);
this.size += structure.getWidth();
this.size += structure.getWidth().x;
layout.add(q);
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())); // Oberes rechtes Quadrat
if((this.size-(2*structure.getWidth())) > 0){ //falls Abstand zwischen den Quadraten ist.
Rectangle rTop = new Rectangle(structure.getWidth(),(this.size-2*structure.getWidth()),new Point(q .topRightCorner.y,q.bottomLeftCorner.x));
layout.addAll(rTop.splittToQuads(rTop));
Rectangle rRight = new Rectangle((this.size-2*structure.getWidth()),structure.getWidth(),new Point(q.bottomLeftCorner.x,q.topRightCorner.y));
layout.addAll(rRight.splittToQuads(rRight));
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));
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));
layout.addAll(rRight.splitToQuads(rRight));
}
}
......
package de._82grfl1bif.KPI_Visualizer.layouts.TreeMap;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
public class Rectangle{
private double area;
private double width;
private double height;
private Point origin;
public void setHeight(double height) {
this.height = height;
this.width = area/height;
}
public void setWidth(double width) {
this.width = width;
this.height = area/width;
}
public double getArea() {
return area;
}
public double getWidth() {
return width;
}
public double getHeight() {
return height;
}
public Point getOrigin() {
return origin;
}
public void setOrigin(Point origin) {
this.origin = origin;
}
public Rectangle(double area,double width,Point origin){
this.area = area;
this.origin = origin;
setWidth(width);
}
public double getSideRelation(){
return Math.max(width/height,height/width);
}
public boolean checkSideRelation(double side){
return !(getSideRelation() < Math.max((area/side)/side,side/(area/side)));// false if the Relation gets worse.
}
}
package de._82grfl1bif.KPI_Visualizer.layouts.TreeMap;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
public class Row {
double broad;
boolean horizontal;
public HashMap<Rectangle, Structure> getRectangles() {
return rectangles;
}
HashMap<Rectangle, Structure> rectangles;
Rectangle space;
public Row(Rectangle space) {
this.space = space;
this.rectangles = new HashMap<>();
this.broad = 0;
this.horizontal = (space.getWidth() >= space.getHeight());
}
private double getSideRelation() {
double currentMax = 0;
for (Map.Entry<Rectangle, Structure> entry : rectangles.entrySet()) {
Rectangle r = entry.getKey();
currentMax = Math.max(r.getSideRelation(), currentMax);
}
return currentMax;
}
public void addRectangle(double area, Structure structure) {
double currentArea = getCurrentArea() + area;
if (horizontal) {
this.broad = currentArea / space.getHeight(); //calculating the new broad
int currentHeight = this.space.getOrigin().y; //new temp for height of origins
for (Map.Entry<Rectangle, Structure> entry : rectangles.entrySet()) {
Rectangle r = entry.getKey();
r.setWidth(this.broad);//setting new width&Height for all existing rectangles
r.setOrigin(new Point(this.space.getOrigin().x, currentHeight));//setting new origins for all existing rectangles
currentHeight += (int) Math.round(r.getHeight());//for next origin
}
rectangles.put((new Rectangle(area, this.broad, new Point(this.space.getOrigin().x, currentHeight))), structure);//add new Rectangle
} else {
this.broad = currentArea / space.getWidth(); //calculating the new broad
int currentWidth = this.space.getOrigin().x; //new temp for width of origins
for (Map.Entry<Rectangle, Structure> entry : rectangles.entrySet()) {
Rectangle r = entry.getKey();
r.setHeight(this.broad);//setting new width&Height for all existing rectangles
r.setOrigin(new Point(currentWidth, space.getOrigin().y));//setting new origins for all existing rectangles
currentWidth += (int) Math.round(r.getHeight());//for next origin
}
rectangles.put(new Rectangle(area, area / this.broad, new Point(currentWidth, space.getOrigin().y)), structure);
}
}
private double getCurrentArea() {
double currentArea = 0;
for (Map.Entry<Rectangle, Structure> entry : rectangles.entrySet()) {
Rectangle r = entry.getKey();
currentArea += r.getArea();
}
return currentArea;
}
public boolean checkInsert(double area) {
if (!rectangles.isEmpty()) {
double currentArea = getCurrentArea() + area;
double broadTemp = horizontal ? currentArea / space.getHeight() : currentArea / space.getWidth();
for (Map.Entry<Rectangle, Structure> entry : rectangles.entrySet()) {
Rectangle r = entry.getKey();
if (!r.checkSideRelation(broadTemp))
return false;//returns false if one of the existing rectangles gets worse
}
return !(new Rectangle(area, broad, new Point(0, 0)).getSideRelation() > getSideRelation()); //returns false if the inserted rectangle is worse, than any other before
}else {
return true;
}
}
public Rectangle getLeftover() {
Point origin;
double width;
if (horizontal) {
origin = new Point(space.getOrigin().x + (int)(broad), space.getOrigin().y);
width = space.getWidth() - getWidth();
} else {
origin = new Point(space.getOrigin().x, space.getOrigin().y + (int)(broad));
width = getWidth();
}
return new Rectangle(this.space.getArea() - getCurrentArea(), width, origin);
}
public double getWidth() {
if (horizontal) {
return this.broad;
} else {
return this.space.getWidth();
}
}
public double getHeight() {
if (horizontal) {
return this.space.getHeight();
} else {
return this.broad;
}
}
public boolean isFull(){
return (Math.round(this.space.getArea()) <= Math.round(this.getCurrentArea()));
}
}
package de._82grfl1bif.KPI_Visualizer.layouts.TreeMap;
import de._82grfl1bif.KPI_Visualizer.structures.Foundation;
import de._82grfl1bif.KPI_Visualizer.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<>();
public ArrayList<Row> getRows() {
return rows;
}
public SquarifiedTreemapLayout() {
this.rows = new ArrayList<>();
}
public void generateLayout(Foundation foundation, Rectangle bounds) {
rows.addAll(generateSubLayout(foundation, bounds));
ArrayList<Foundation> foundations = new ArrayList<>();
foundations.add(foundation);
do {
ArrayList<Row> tempRows = new ArrayList<>();
rows.stream().filter(r -> r.rectangles.containsValue(foundations.get(foundations.size()-1))).forEach(row ->
tempRows.addAll(generateSubLayout(foundations.get(foundations.size()-1), new Rectangle(foundations.get(foundations.size()-1).getArea(), row.getWidth(), row.space.getOrigin()))));
rows.addAll(tempRows);//letztes element bearbeitet und ein subLayout dafür angelegt.
ArrayList<Foundation> tempFoundations = new ArrayList<>();
for (Structure s : foundations.get(foundations.size() - 1).getChildren()) {
if (s.getClass() == Foundation.class) {
tempFoundations.add((Foundation) s);
}
}
foundations.remove(foundations.size()-1);
foundations.addAll(tempFoundations);//alle Kinder(nur Foundations) des letzten Elements in die Liste geschrieben und das Element entfernt.
} while (!foundations.isEmpty());
}
private ArrayList<Row> generateSubLayout(Foundation foundation, Rectangle rectangle) {
ArrayList<Row> result = new ArrayList<>();
result.add(new Row(rectangle));
for (Structure s : foundation.getChildren()) {
if (!result.get(result.size() - 1).checkInsert(s.getArea())) {//wenn einfügen in die bestehende Reihe das Seitenverhältnis verschlechtern würde.
Row tempRow = new Row(result.get(result.size() - 1).getLeftover());//erzeige neue Reihe mit dem Rest des alten spaces als space.
result.add(tempRow);//füge die neue Reihe ans Ende der Sammlung ein.
}
result.get(result.size() - 1).addRectangle(s.getArea(), s);//füge das Kind in die letzte Reihe ein, die in der Liste ist.
}
return result;
}
}
......@@ -2,6 +2,7 @@ package de._82grfl1bif.KPI_Visualizer;
import de._82grfl1bif.KPI_Visualizer.commands.SetPreset;
import de._82grfl1bif.KPI_Visualizer.commands.generateLayout;
import de._82grfl1bif.KPI_Visualizer.helpers.FileInputTabCompleter;
import org.bukkit.plugin.java.JavaPlugin;
public final class main extends JavaPlugin {
......@@ -11,6 +12,7 @@ public final class main extends JavaPlugin {
// Plugin startup logic
getCommand("setPreset").setExecutor(new SetPreset());
getCommand("generateLayout").setExecutor(new generateLayout());
getCommand("generateLayout").setTabCompleter(new FileInputTabCompleter());
}
@Override
......
package de._82grfl1bif.KPI_Visualizer.structures;
import de._82grfl1bif.KPI_Visualizer.data.Klasse;
import org.bukkit.Material;
import javax.persistence.Column;
import java.awt.Point;
public class Building extends Structure{
@Column(name = "height")
private final int height;
public Klasse klasse = null;
@Deprecated
public Building(int width, int height, Material material){ //Buildings are Square -> no depth
this.width.x = width;
this.width.y = width;
this.height = height;
this.material = material;
if(this.width.x < 5){
throw new IllegalArgumentException("keine Gebäude kleiner 5 wegen 2 Gehweg");
}
}
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 < 3){
throw new IllegalArgumentException("keine Gebäude kleiner 3 wegen 2 gehweg");
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.area = klasse.variables*25;
this.name = name;
this.height = klasse.functions;
if(this.width.x < 5 || this.width.y < 5){
throw new IllegalArgumentException("keine Gebäude kleiner 5 wegen 2 Gehweg");
}
}
public int getHeight() {
return this.height;
}
@Override
public Structure getFromTree(String checkName) {
if(this.name.equals(checkName))return this;
return null;
}
}
Markdown is supported
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