Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Florian Grabowski
Informationslandschaften in Minecraft zur Visualisierung von Softwarequalität
Commits
d94398f9
Commit
d94398f9
authored
3 years ago
by
Florian Grabowski
Browse files
Options
Download
Email Patches
Plain Diff
Minor Changes and removal of duplicate Code.
parent
946ede3b
master
1 merge request
!1
Bachelor Project final State
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
src/main/java/de/_82grfl1bif/KPI_Visualizer/commands/SetPreset.java
+16
-52
...ava/de/_82grfl1bif/KPI_Visualizer/commands/SetPreset.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/commands/generateLayout.java
+26
-107
...e/_82grfl1bif/KPI_Visualizer/commands/generateLayout.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/data/JsonParser.java
+29
-0
...n/java/de/_82grfl1bif/KPI_Visualizer/data/JsonParser.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/data/ResultSetMapper.java
+0
-58
...a/de/_82grfl1bif/KPI_Visualizer/data/ResultSetMapper.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/helpers/Layout.java
+2
-2
...in/java/de/_82grfl1bif/KPI_Visualizer/helpers/Layout.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/helpers/Quadrat.java
+5
-5
...n/java/de/_82grfl1bif/KPI_Visualizer/helpers/Quadrat.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/helpers/Rectangle.java
+5
-5
...java/de/_82grfl1bif/KPI_Visualizer/helpers/Rectangle.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/structures/Builder.java
+102
-0
...ava/de/_82grfl1bif/KPI_Visualizer/structures/Builder.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/structures/Building.java
+1
-3
...va/de/_82grfl1bif/KPI_Visualizer/structures/Building.java
src/main/java/de/_82grfl1bif/KPI_Visualizer/structures/Structure.java
+0
-3
...a/de/_82grfl1bif/KPI_Visualizer/structures/Structure.java
with
186 additions
and
235 deletions
+186
-235
src/main/java/de/_82grfl1bif/KPI_Visualizer/commands/SetPreset.java
+
16
-
52
View file @
d94398f9
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
)
{
Builder
builder
=
new
Builder
();
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
()
{
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
().
x
,
DataHolder
.
foundation
.
getWidth
().
y
,
DataHolder
.
foundation
.
getMaterial
());
builder
.
setFoundation
(
server
,
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
().
x
,
building
.
getHeight
(),
building
.
getWidth
().
y
,
building
.
getMaterial
());
//Not yet ready to print foundations
builder
.
fillQube
(
server
,
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
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/commands/generateLayout.java
+
26
-
107
View file @
d94398f9
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.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,123 +12,45 @@ import org.bukkit.entity.Player;
import
org.bukkit.scheduler.BukkitRunnable
;
import
org.jetbrains.annotations.NotNull
;
import
java.util.logging.Level
;
public
class
generateLayout
implements
CommandExecutor
{
Builder
builder
=
new
Builder
();
@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
().
x
,
DataHolder
.
foundation
.
getWidth
().
x
,
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
);
}
if
(
player
!=
null
)
{
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
);
builder
.
setFoundation
(
server
,
DataHolder
.
foundation
.
getLocation
().
clone
().
add
(
0
,
DataHolder
.
foundation
.
getDepth
(),
0
),
DataHolder
.
foundation
.
getWidth
().
x
,
DataHolder
.
foundation
.
getWidth
().
x
,
DataHolder
.
foundation
.
getMaterial
());
setAllChildren
(
server
,
DataHolder
.
foundation
);
}
};
t
.
run
();
return
true
;
}
else
{
Bukkit
.
getLogger
().
log
(
Level
.
SEVERE
,
"Kein Spieler gefunden."
);
return
false
;
}
}
private
void
buildBuilding
(
Server
server
,
Location
startLocation
,
int
x
,
int
y
,
Material
material
)
{
setWalls
(
server
,
startLocation
.
clone
().
add
(
0
,
1
,
0
),
x
,
y
,
material
);
}
private
void
setWalls
(
Server
server
,
Location
startLocation
,
int
x
,
int
y
,
Material
material
)
{
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
);
}
}
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
);
}
}
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
);
}
}
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
);
}
}
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
)
{
//TODO must be revisited to draw rectangular Foundations
setFoundation
(
server
,
s
.
getLocation
().
clone
().
add
(
0
,
s
.
getDepth
(),
0
),
s
.
getWidth
().
x
,
s
.
getWidth
().
x
,
s
.
getMaterial
());
builder
.
setFoundation
(
server
,
s
.
getLocation
().
clone
().
add
(
0
,
s
.
getDepth
(),
0
),
s
.
getWidth
().
x
,
s
.
getWidth
().
x
,
s
.
getMaterial
());
setAllChildren
(
server
,
(
Foundation
)
s
);
}
else
{
//TODO must be revisited to draw rectangular Buildings
buildBuilding
(
server
,
s
.
getLocation
().
clone
().
add
(
1
,
s
.
getDepth
(),
1
),
s
.
getWidth
().
x
-
2
,
((
Building
)
s
).
getHeight
(),
s
.
getMaterial
());
builder
.
buildBuilding
(
server
,
s
.
getLocation
().
clone
().
add
(
1
,
s
.
getDepth
(),
1
),
s
.
getWidth
().
x
-
2
,
((
Building
)
s
).
getHeight
(),
s
.
getMaterial
());
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/data/JsonParser.java
0 → 100644
+
29
-
0
View file @
d94398f9
package
de._82grfl1bif.KPI_Visualizer.data
;
import
com.google.gson.Gson
;
import
com.google.gson.stream.JsonReader
;
import
org.bukkit.Bukkit
;
import
java.io.FileReader
;
import
java.util.logging.Level
;
public
class
JsonParser
{
String
standardPath
=
""
;
private
boolean
evalJson
(
String
fileName
)
{
if
(!
fileName
.
contains
(
".json"
))
{
fileName
=
fileName
+
".json"
;
}
//Add .json in case user forgets
if
(!(
fileName
.
contains
(
"/"
))){
fileName
=
standardPath
+
fileName
;
}
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
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/data/ResultSetMapper.java
deleted
100644 → 0
+
0
-
58
View file @
946ede3b
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
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/helpers/Layout.java
+
2
-
2
View file @
d94398f9
...
...
@@ -78,9 +78,9 @@ public class Layout {
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.
Rectangle
rTop
=
new
Rectangle
(
structure
.
getWidth
().
x
,(
this
.
size
-
2
*
structure
.
getWidth
().
x
),
new
Point
(
q
.
topRightCorner
.
y
,
q
.
bottomLeftCorner
.
x
));
layout
.
addAll
(
rTop
.
split
t
ToQuads
(
rTop
));
layout
.
addAll
(
rTop
.
splitToQuads
(
rTop
));
Rectangle
rRight
=
new
Rectangle
((
this
.
size
-
2
*
structure
.
getWidth
().
x
),
structure
.
getWidth
().
x
,
new
Point
(
q
.
bottomLeftCorner
.
x
,
q
.
topRightCorner
.
y
));
layout
.
addAll
(
rRight
.
split
t
ToQuads
(
rRight
));
layout
.
addAll
(
rRight
.
splitToQuads
(
rRight
));
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/helpers/Quadrat.java
+
5
-
5
View file @
d94398f9
...
...
@@ -41,16 +41,16 @@ public class Quadrat extends Shape{
this
.
belegt
=
true
;
this
.
structure
=
structure
;
ArrayList
<
Quadrat
>
result
=
new
ArrayList
<>();
if
(
this
.
xEdgeLength
>
structure
.
getWidth
().
x
+
3
){
//if you can split
t
rest into more quads
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
().
x
));
result
.
addAll
(
temp
.
split
t
ToQuads
(
temp
));
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
.
split
t
ToQuads
(
temp
));
result
.
addAll
(
temp
.
splitToQuads
(
temp
));
}
}
return
result
;
...
...
@@ -64,7 +64,7 @@ public class Quadrat extends Shape{
return
new
Point
(
topRightCorner
.
x
-
bottomLeftCorner
.
x
,
topRightCorner
.
y
-
bottomLeftCorner
.
y
);
}
public
void
applyCoordinates
(){
public
void
applyCoordinates
(
Point
coordinates
){
this
.
bottomLeftCorner
=
coordinates
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/helpers/Rectangle.java
+
5
-
5
View file @
d94398f9
...
...
@@ -5,7 +5,7 @@ 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
>
split
t
ToQuads
(
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
(
split
t
ToQuads
(
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
(
split
t
ToQuads
(
new
Rectangle
(
r
.
zEdgeLength
,
scrapLength
,
scrapPoint
)));
if
(
scrapLength
>=
3
)
{
result
.
addAll
(
splitToQuads
(
new
Rectangle
(
r
.
zEdgeLength
,
scrapLength
,
scrapPoint
)));
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/structures/Builder.java
0 → 100644
+
102
-
0
View file @
d94398f9
package
de._82grfl1bif.KPI_Visualizer.structures
;
import
org.bukkit.Location
;
import
org.bukkit.Material
;
import
org.bukkit.Server
;
import
org.bukkit.block.Block
;
public
class
Builder
{
public
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
);
}
}
}
public
void
fillQube
(
Server
server
,
Location
startLocation
,
int
x
,
int
y
,
int
z
,
Material
material
)
{
for
(
int
cy
=
0
;
cy
<
y
;
cy
++)
{
setFoundation
(
server
,
startLocation
.
clone
().
add
(
0
,
cy
,
0
),
x
,
z
,
material
);
}
}
private
void
setWalls
(
Server
server
,
Location
startLocation
,
int
x
,
int
y
,
Material
material
)
{
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
);
}
}
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
);
}
}
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
);
}
}
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
);
}
}
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
);
}
public
void
buildBuilding
(
Server
server
,
Location
startLocation
,
int
x
,
int
y
,
Material
material
)
{
setWalls
(
server
,
startLocation
.
clone
().
add
(
0
,
1
,
0
),
x
,
y
,
material
);
}
}
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/structures/Building.java
+
1
-
3
View file @
d94398f9
...
...
@@ -2,11 +2,9 @@ package de._82grfl1bif.KPI_Visualizer.structures;
import
org.bukkit.Material
;
import
javax.persistence.Column
;
import
java.awt.*
;
import
java.awt.Point
;
public
class
Building
extends
Structure
{
@Column
(
name
=
"height"
)
private
final
int
height
;
public
Building
(
int
width
,
int
height
,
Material
material
){
//Buildings are Square -> no depth
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/_82grfl1bif/KPI_Visualizer/structures/Structure.java
+
0
-
3
View file @
d94398f9
...
...
@@ -8,12 +8,9 @@ import javax.persistence.Column;
import
javax.persistence.Entity
;
import
java.awt.*
;
@Entity
public
class
Structure
{
@Column
(
name
=
"width"
)
protected
Point
width
=
new
Point
(
0
,
0
);
@Column
(
name
=
"material"
)
protected
Material
material
;
protected
Location
location
;
protected
int
depth
;
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets