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

IDP Update

parent 92fedcf1
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>ADVENTURE</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<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" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.14.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-api:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-key:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-api:1.3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:examination-string:1.3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:22.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-gson:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-legacy:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.kyori:adventure-text-serializer-plain:4.9.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:3.18.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:9.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:9.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:9.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:9.1" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.7.0" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.0.3" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-compiler-javac:2.8.4" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-utils:3.0.22" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-compiler-api:2.8.4" level="project" />
<orderEntry type="library" name="Java EE 6-Java EE 6" level="project" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.82grfl1bif</groupId>
<artifactId>BlockPlacer</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BlockPlacer</name>
<description>Testing automated construcion of Buildings.</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>20030211.134440</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-javac</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
</project>
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.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{
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
Server server = sender.getServer();
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() {
DataHolder.foundation.setLocation(location);
DataHolder.generateSimpleData(Integer.parseInt(args[0]));
fillPlane(server, location, DataHolder.foundation.getWidth(), DataHolder.foundation.getWidth(), 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
}
}
};
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);
}
}
}
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));
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 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.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
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");
Server server = sender.getServer();
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);
}
}
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 {
buildBuilding(server, s.getLocation().clone().add(1, s.getDepth(), 1), s.getWidth() - 2, ((Building) s).getHeight(), s.getMaterial());
}
}
}
}
package de._82grfl1bif.KPI_Visualizer.data;
import de._82grfl1bif.KPI_Visualizer.structures.Building;
import de._82grfl1bif.KPI_Visualizer.structures.Foundation;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom;
public class DataHolder {
public static Foundation foundation = new Foundation(0, Material.COBBLESTONE);
public static void generateSimpleData(int buildingCount){
foundation.removeChildren();
ArrayList<Structure> buildings = new ArrayList<>();
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<>();
for (int i = 0; i < 5; i++) {
buildins3.add(generateBuilding());
}
foundation3.addChildren(buildins3);
ArrayList<Structure> buildins2_1 = new ArrayList<>();
Foundation foundation2_1 = new Foundation(2,Material.BROWN_CONCRETE);
for (int i = 0; i < 5; i++) {
buildins2_1.add(generateBuilding());
}
buildins2_1.add(foundation3);
foundation2_1.addChildren(buildins2_1);
ArrayList<Structure> buildins2_2 = new ArrayList<>();
Foundation foundation2_2 = new Foundation(2,Material.LIGHT_GRAY_CONCRETE);
for (int i = 0; i < 5; i++) {
buildins2_2.add(generateBuilding());
}
foundation2_2.addChildren(buildins2_2);
ArrayList<Structure> buildins1 = new ArrayList<>();
Foundation foundation1 = new Foundation(1,Material.GRAY_CONCRETE);
for (int i = 0; i < 5; i++) {
buildins1.add(generateBuilding());
}
buildins1.add(foundation2_1);
buildins1.add(foundation2_2);
foundation1.addChildren(buildins1);
ArrayList<Structure> buildins0 = new ArrayList<>();
for (int i = 0; i < 5; i++) {
buildins1.add(generateBuilding());
}
buildins0.add(foundation1);
foundation = new Foundation(0,Material.COBBLESTONE);
foundation.addChildren(buildins0);
foundation.setDepth(0);
}
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());
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.structures.Structure;
import javax.management.AttributeNotFoundException;
import java.awt.*;
import java.util.ArrayList;
import java.util.Comparator;
@SuppressWarnings("ALL")
public class Layout {
private final ArrayList<Structure> structures;
private final ArrayList<Quadrat> layout = new ArrayList<>();
public int getSize() {
return size;
}
private int size = 0;
public Layout(ArrayList<Structure> structures){
this.structures = structures;//ordered biggest first.
}
private static class WidthComparator implements Comparator<Quadrat> {
@Override
public int compare(Quadrat o1, Quadrat o2) {
return Integer.compare(o1.getWidth(), o2.getWidth());
}
}
private static class CoordinateXComparator implements Comparator<Quadrat>{
@Override
public int compare(Quadrat o1, Quadrat o2) {
return Integer.compare(o1.bottomLeftCorner.x, o2.bottomLeftCorner.x);
}
}
private static class CoordinateYComparator implements Comparator<Quadrat>{
@Override
public int compare(Quadrat o1, Quadrat o2) {
return Integer.compare(o1.bottomLeftCorner.y, o2.bottomLeftCorner.y);
}
}
public void createLayout(){
boolean first = true;
for (Structure s:structures) {
if(first){
first = false;
this.size = s.getWidth();
layout.add(new Quadrat(new Point(0,0),s.getWidth()));
layout.addAll(layout.get(0).setBelegt(s));
}else{
layout.sort(new CoordinateYComparator());
layout.sort(new CoordinateXComparator());
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)){
noneFoundFlag = false;
layout.addAll(layout.get(i).setBelegt(s));
}
}
if (noneFoundFlag){
appendQuad(s);
}
}
}
}
private void appendQuad(Structure structure){
Quadrat q = new Quadrat(new Point(this.size,0),structure.getWidth());
q.setBelegt(structure);
this.size += structure.getWidth();
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));
}
}
public Point getCoordinateOf(Structure structure) throws AttributeNotFoundException {
for (Quadrat q:this.layout) {
if(q.getBelegt()){
if(q.getStructure().equals(structure)){
return q.bottomLeftCorner;
}
}
}
throw new AttributeNotFoundException("Diese Structure ist nicht in der Ebene.");
}
}
package de._82grfl1bif.KPI_Visualizer.helpers;
import de._82grfl1bif.KPI_Visualizer.structures.Structure;
import java.awt.*;
import java.util.ArrayList;
public class Quadrat extends Shape{
private Boolean belegt;
public Structure getStructure() {
return structure;
}
private Structure structure;
public Quadrat(Point bottomLeftCorner, Point topRightCorner){
this.bottomLeftCorner = bottomLeftCorner;
this.topRightCorner = topRightCorner;
this.xEdgeLength = topRightCorner.x-bottomLeftCorner.x;
this.belegt=false;
if(topRightCorner.y-bottomLeftCorner.y < 3 || topRightCorner.x-bottomLeftCorner.x <3){
throw new IllegalArgumentException("keine Quadrate < 3 erlaubt");
}
}
public Quadrat(Point bottomLeftCorner, int xEdgeLength){
this.xEdgeLength = xEdgeLength;
this.bottomLeftCorner = bottomLeftCorner;
this.topRightCorner = new Point(bottomLeftCorner.x+xEdgeLength,bottomLeftCorner.y+xEdgeLength);
this.belegt = false;
if(xEdgeLength < 3){
throw new IllegalArgumentException("keine Quadrate < 3 erlaubt " + xEdgeLength);
}
}
public ArrayList<Quadrat> setBelegt(Structure structure) {
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%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));
}
}
return result;
}
public Boolean getBelegt() {
return belegt;
}
public int getWidth(){
return this.xEdgeLength;
}
public void applyCoordinates(){
}
}
package de._82grfl1bif.KPI_Visualizer.helpers;
import java.awt.*;
import java.util.ArrayList;
public class Rectangle extends Shape {
private int zEdgeLength;
public Rectangle(int zEdgeLength, int xEdgeLength, Point bottomLeftCorner) {
this.zEdgeLength = zEdgeLength;
this.xEdgeLength = xEdgeLength;
this.bottomLeftCorner = bottomLeftCorner;
this.topRightCorner = new Point(bottomLeftCorner.x + xEdgeLength, bottomLeftCorner.y + zEdgeLength);
}
public ArrayList<Quadrat> splittToQuads(Rectangle r) {
ArrayList<Quadrat> result = new ArrayList<>();
if (r.xEdgeLength >= 3 && r.zEdgeLength >= 3) {
if ((r.xEdgeLength - r.zEdgeLength) < 0) {//standing Rectangle
if ((r.zEdgeLength % r.xEdgeLength) == 0) {//completely degradable
for (int c = 0; c < r.zEdgeLength / r.xEdgeLength; c++) {
result.add(new Quadrat(new Point(r.bottomLeftCorner.x, r.bottomLeftCorner.y + (r.xEdgeLength * c)), r.xEdgeLength));
}
} else {//left over Rectangle
int scrapLength = r.zEdgeLength;
Point scrapPoint = new Point(0, 0);
for (int c = 0; c < r.zEdgeLength / r.xEdgeLength; c++) {
result.add(new Quadrat(new Point(r.bottomLeftCorner.x, r.bottomLeftCorner.y + (r.xEdgeLength * c)), r.xEdgeLength));
scrapLength -= r.xEdgeLength;
scrapPoint.x = r.bottomLeftCorner.x;
scrapPoint.y = (r.bottomLeftCorner.y + (r.xEdgeLength * (c + 1)));
}
if (scrapLength >= 3 && r.xEdgeLength >= 3) {
result.addAll(splittToQuads(new Rectangle(scrapLength, r.xEdgeLength, scrapPoint)));
}
}
} else {//laying Rectangles
if ((r.xEdgeLength % r.zEdgeLength) == 0) {//completely degradable
for (int c = 0; c < r.xEdgeLength / r.zEdgeLength; c++) {
result.add(new Quadrat(new Point(r.bottomLeftCorner.x + (r.zEdgeLength * c), r.bottomLeftCorner.y), r.zEdgeLength));
}
} else {//left over Rectangle
int scrapLength = r.xEdgeLength;
Point scrapPoint = new Point(0, 0);
for (int c = 0; c < r.xEdgeLength / r.zEdgeLength; c++) {
result.add(new Quadrat(new Point(r.bottomLeftCorner.x + (r.zEdgeLength * c), r.bottomLeftCorner.y), r.zEdgeLength));
scrapLength -= r.zEdgeLength;
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)));
}
}
}
}
return result;
}
}
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