Skip to content
GitLab
Menu
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
3d499290
Commit
3d499290
authored
Jan 19, 2022
by
Florian Grabowski
Browse files
Refined Builder
parent
fd441de2
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/_82grfl1bif/KPI_Visualizer/data/JsonParser.java
View file @
3d499290
...
...
@@ -7,9 +7,10 @@ import org.json.simple.JSONObject;
import
org.json.simple.parser.JSONParser
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.time.LocalDateTime
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.logging.Level
;
public
class
JsonParser
{
...
...
@@ -35,8 +36,16 @@ public class JsonParser {
}
JSONArray
entities
=
(
JSONArray
)
jsonObject
.
get
(
"entities"
);
ArrayList
<
Klasse
>
entitiesList
=
new
ArrayList
<>();
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd kk:mm:ss Z"
);
for
(
int
i
=
0
;
i
<
entities
.
size
();
i
++)
{
JSONObject
object
=
(
JSONObject
)
entities
.
get
(
i
);
JSONArray
commits
=
(
JSONArray
)
((
JSONObject
)
entities
.
get
(
i
)).
get
(
"commits"
);
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
(),
...
...
@@ -45,8 +54,10 @@ public class JsonParser {
Integer
.
parseInt
(
object
.
get
(
"loc"
).
toString
()),
((
JSONArray
)
object
.
get
(
"commits"
)).
size
(),
((
JSONArray
)
object
.
get
(
"functions"
)).
size
(),
((
JSONArray
)
object
.
get
(
"variables"
)).
size
());
entitiesList
.
add
(
currentKlasse
);
((
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
);
...
...
src/main/java/de/_82grfl1bif/KPI_Visualizer/data/Klasse.java
View file @
3d499290
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
){
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
){
...
...
src/main/java/de/_82grfl1bif/KPI_Visualizer/structures/Builder.java
View file @
3d499290
package
de._82grfl1bif.KPI_Visualizer.structures
;
import
de._82grfl1bif.KPI_Visualizer.data.Klasse
;
import
org.bukkit.Bukkit
;
import
org.bukkit.Location
;
import
org.bukkit.Material
;
import
org.bukkit.Server
;
import
org.bukkit.block.Block
;
import
org.bukkit.block.BlockFace
;
import
org.bukkit.block.Sign
;
import
java.util.Random
;
import
java.util.logging.Level
;
public
class
Builder
{
...
...
@@ -29,14 +36,14 @@ public class Builder {
}
private
void
setWalls
(
Location
startLocation
,
int
x
,
int
y
,
int
z
,
Material
innerMaterial
,
Material
glassMaterial
)
{
Location
temp
=
startLocation
.
clone
().
add
(
0
,
0
,
1
);
Location
temp
=
startLocation
.
clone
().
add
(
0
,
0
,
1
);
for
(
int
cz
=
0
;
cz
<
z
-
2
;
cz
++)
{
//00-0Z
for
(
int
cy
=
0
;
cy
<
y
;
cy
++)
{
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
temp
.
clone
().
add
(
1
,
cy
,
cz
)).
setType
(
innerMaterial
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
temp
.
clone
().
add
(
0
,
cy
,
cz
)).
setType
(
glassMaterial
);
}
}
temp
=
startLocation
.
clone
().
add
(
1
,
0
,
0
);
temp
=
startLocation
.
clone
().
add
(
1
,
0
,
0
);
for
(
int
cx
=
0
;
cx
<
x
-
2
;
cx
++)
{
//00-0X
for
(
int
cy
=
0
;
cy
<
y
;
cy
++)
{
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
temp
.
clone
().
add
(
cx
,
cy
,
1
)).
setType
(
innerMaterial
);
...
...
@@ -80,20 +87,271 @@ public class Builder {
}
}
public
void
buildBuilding
(
Location
startLocation
,
int
x
,
int
y
,
int
z
,
Material
material
)
{
setWalls
(
startLocation
,
x
,
y
,
z
,
material
,
Material
.
GLASS
);
setCorners
(
startLocation
,
x
,
y
,
z
,
Material
.
BLACKSTONE
);
setFoundation
(
startLocation
.
clone
().
add
(
0
,
y
,
0
),
x
,
z
,
Material
.
BLACKSTONE
);
//roof
public
void
buildBuilding
(
Location
startLocation
,
int
x
,
int
y
,
int
craneHeight
,
int
antennaHeight
,
int
z
,
Material
facadeMaterial
,
Material
glassMaterial
,
Material
innerMaterial
)
{
setWalls
(
startLocation
,
x
,
y
,
z
,
innerMaterial
,
glassMaterial
);
setCorners
(
startLocation
,
x
,
y
,
z
,
facadeMaterial
);
setFoundation
(
startLocation
.
clone
().
add
(
0
,
y
,
0
),
x
,
z
,
facadeMaterial
);
//roof
fillQube
(
startLocation
.
clone
().
add
(
Math
.
round
(
x
/
2
),
y
+
1
,
Math
.
round
(
x
/
2
)),
1
,
antennaHeight
,
1
,
Material
.
COBBLESTONE_WALL
);
Random
rm
=
new
Random
();
switch
(
rm
.
nextInt
(
3
)+
1
){
case
1
:
setCrane
(
startLocation
,
x
,
y
,
z
,
craneHeight
,
BlockFace
.
NORTH
);
break
;
case
2
:
setCrane
(
startLocation
,
x
,
y
,
z
,
craneHeight
,
BlockFace
.
WEST
);
break
;
case
3
:
setCrane
(
startLocation
,
x
,
y
,
z
,
craneHeight
,
BlockFace
.
EAST
);
break
;
case
4
:
setCrane
(
startLocation
,
x
,
y
,
z
,
craneHeight
,
BlockFace
.
SOUTH
);
break
;
}
}
public
void
setAllChildren
(
Foundation
foundation
)
{
for
(
Structure
s
:
foundation
.
getChildren
())
{
if
(
s
.
getClass
()
==
Foundation
.
class
)
{
//TODO must be revisited to draw rectangular Foundations
this
.
setFoundation
(
s
.
getLocation
().
clone
().
add
(
0
,
s
.
getDepth
(),
0
),
s
.
getWidth
().
x
,
s
.
getWidth
().
x
,
s
.
getMaterial
());
addDescription
(
s
.
getLocation
().
clone
().
add
(
0
,
s
.
getDepth
(),
0
),
s
);
setAllChildren
((
Foundation
)
s
);
}
else
{
//TODO must be revisited to draw rectangular Buildings
this
.
buildBuilding
(
s
.
getLocation
().
clone
().
add
(
1
,
s
.
getDepth
(),
1
),
s
.
getWidth
().
x
-
2
,
((
Building
)
s
).
getHeight
(),
s
.
getWidth
().
x
-
2
,
s
.
getMaterial
());
this
.
buildBuilding
(
s
.
getLocation
().
clone
().
add
(
1
,
s
.
getDepth
()
+
1
,
1
),
s
.
getWidth
().
x
-
2
,
((
Building
)
s
).
getHeight
(),
((
Building
)
s
).
klasse
.
commits
,
Math
.
round
(((
Building
)
s
).
klasse
.
complexity
/
10000
),
s
.
getWidth
().
x
-
2
,
((((((
Building
)
s
).
klasse
.
zeitSeitErstemCommit
.
toDays
()
-
Klasse
.
zeitSeitErstemCommitMin
.
toDays
())
/
(
Klasse
.
zeitSeitErstemCommitMax
.
toDays
()
-
Klasse
.
zeitSeitErstemCommitMin
.
toDays
()))
>
0.25
)?
Material
.
WAXED_OXIDIZED_COPPER
:
((((
Building
)
s
).
klasse
.
zeitSeitErstemCommit
.
toDays
()
-
Klasse
.
zeitSeitErstemCommitMin
.
toDays
())
/
(
Klasse
.
zeitSeitErstemCommitMax
.
toDays
()
-
Klasse
.
zeitSeitErstemCommitMin
.
toDays
())
>
0.50
)?
Material
.
WAXED_WEATHERED_COPPER
:
((((
Building
)
s
).
klasse
.
zeitSeitErstemCommit
.
toDays
()
-
Klasse
.
zeitSeitErstemCommitMin
.
toDays
())
/
(
Klasse
.
zeitSeitErstemCommitMax
.
toDays
()
-
Klasse
.
zeitSeitErstemCommitMin
.
toDays
())
>
0.75
)?
Material
.
WAXED_EXPOSED_COPPER
:
Material
.
WAXED_COPPER_BLOCK
),
(((((
Building
)
s
).
klasse
.
zeitSeitLetzterBearbeitung
.
toDays
()
-
Klasse
.
zeitSeitLetzterBearbeitungMin
.
toDays
())
/
(
Klasse
.
zeitSeitLetzterBearbeitungMax
.
toDays
()
-
Klasse
.
zeitSeitLetzterBearbeitungMin
.
toDays
())
>
0.25
)?
Material
.
IRON_BARS
:
((((
Building
)
s
).
klasse
.
zeitSeitLetzterBearbeitung
.
toDays
()
-
Klasse
.
zeitSeitLetzterBearbeitungMin
.
toDays
())
/
(
Klasse
.
zeitSeitLetzterBearbeitungMax
.
toDays
()
-
Klasse
.
zeitSeitLetzterBearbeitungMin
.
toDays
())
>
0.50
)?
Material
.
BLUE_STAINED_GLASS
:
((((
Building
)
s
).
klasse
.
zeitSeitLetzterBearbeitung
.
toDays
()
-
Klasse
.
zeitSeitLetzterBearbeitungMin
.
toDays
())
/
(
Klasse
.
zeitSeitLetzterBearbeitungMax
.
toDays
()
-
Klasse
.
zeitSeitLetzterBearbeitungMin
.
toDays
())
>
0.75
)?
Material
.
GLASS
:
Material
.
WHITE_STAINED_GLASS
)
,
s
.
getMaterial
());
addDescription
(
s
.
getLocation
().
clone
().
add
(
1
,
s
.
getDepth
()
+
1
,
1
),
s
);
}
}
}
public
void
setCrane
(
Location
startLocation
,
int
x
,
int
y
,
int
z
,
int
height
,
BlockFace
orientation
){
switch
(
orientation
)
{
case
NORTH:
for
(
int
cy
=
y
+
1
;
cy
<
(
height
+
y
+
2
);
cy
++){
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
cy
,
z
-
2
)).
setType
(
Material
.
YELLOW_CONCRETE
);
}
for
(
int
cz
=
0
;
cz
<
z
;
cz
++){
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
y
+
height
,
cz
)).
setType
(
Material
.
YELLOW_CONCRETE
);
}
break
;
case
WEST:
for
(
int
cy
=
y
+
1
;
cy
<
(
height
+
y
+
2
);
cy
++){
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
x
-
2
,
cy
,
0
)).
setType
(
Material
.
YELLOW_CONCRETE
);
}
for
(
int
cx
=
0
;
cx
<
z
;
cx
++){
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
cx
,
y
+
height
,
0
)).
setType
(
Material
.
YELLOW_CONCRETE
);
}
break
;
case
EAST:
for
(
int
cy
=
y
+
1
;
cy
<
(
height
+
y
+
2
);
cy
++){
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
2
,
cy
,
z
-
1
)).
setType
(
Material
.
YELLOW_CONCRETE
);
}
for
(
int
cx
=
0
;
cx
<
z
;
cx
++){
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
cx
,
y
+
height
,
z
-
1
)).
setType
(
Material
.
YELLOW_CONCRETE
);
}
break
;
case
SOUTH:
for
(
int
cy
=
y
+
1
;
cy
<
(
height
+
y
+
2
);
cy
++){
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
x
-
1
,
cy
,
2
)).
setType
(
Material
.
YELLOW_CONCRETE
);
}
for
(
int
cz
=
0
;
cz
<
z
;
cz
++){
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
x
-
1
,
y
+
height
,
cz
)).
setType
(
Material
.
YELLOW_CONCRETE
);
}
break
;
default
:
Bukkit
.
getLogger
().
log
(
Level
.
SEVERE
,
"fehlerhafte Orientierung"
);
break
;
}
}
private
void
addDescription
(
Location
startLocation
,
Structure
structure
)
{
if
(
structure
.
getClass
()
==
Foundation
.
class
)
{
//if (!((Foundation) structure).getChildren().stream().anyMatch(s -> s.getClass() == Foundation.class)) {//no foundation in Children
setFoundationSing
(
startLocation
,(
Foundation
)
structure
);
//}
}
else
{
setWallSing
(
startLocation
,
(
Building
)
structure
,
BlockFace
.
NORTH
);
setWallSing
(
startLocation
,
(
Building
)
structure
,
BlockFace
.
EAST
);
setWallSing
(
startLocation
,
(
Building
)
structure
,
BlockFace
.
WEST
);
setWallSing
(
startLocation
,
(
Building
)
structure
,
BlockFace
.
SOUTH
);
}
}
private
void
setWallSing
(
Location
startLocation
,
Building
building
,
BlockFace
orientation
)
{
org
.
bukkit
.
block
.
Sign
sign1
=
null
;
org
.
bukkit
.
block
.
Sign
sign2
=
null
;
org
.
bukkit
.
block
.
Sign
sign1o
=
null
;
org
.
bukkit
.
block
.
Sign
sign2o
=
null
;
org
.
bukkit
.
material
.
Sign
matSign
=
new
org
.
bukkit
.
material
.
Sign
(
Material
.
OAK_WALL_SIGN
);
switch
(
orientation
)
{
case
NORTH:
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
1
,
-
1
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign1
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
1
,
-
1
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
3
,
1
,
-
1
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign2
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
3
,
1
,
-
1
)).
getState
();
matSign
.
setFacingDirection
(
BlockFace
.
NORTH
);
if
(
building
.
name
.
length
()
>
60
)
{
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
2
,
-
1
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign1o
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
2
,
-
1
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
3
,
2
,
-
1
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign2o
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
3
,
2
,
-
1
)).
getState
();
}
break
;
case
EAST:
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
2
,
1
,
0
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign1
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
2
,
1
,
0
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
2
,
1
,
building
.
width
.
y
-
3
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign2
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
2
,
1
,
building
.
width
.
y
-
3
)).
getState
();
matSign
.
setFacingDirection
(
BlockFace
.
WEST_NORTH_WEST
);
//Don't have a clue why this works but getting it made me go mad
if
(
building
.
name
.
length
()
>
60
)
{
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
2
,
2
,
0
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign1o
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
2
,
2
,
0
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
2
,
2
,
building
.
width
.
y
-
3
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign2o
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
2
,
2
,
building
.
width
.
y
-
3
)).
getState
();
}
break
;
case
SOUTH:
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
1
,
building
.
width
.
y
-
2
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign1
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
1
,
building
.
width
.
y
-
2
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
3
,
1
,
building
.
width
.
y
-
2
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign2
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
3
,
1
,
building
.
width
.
y
-
2
)).
getState
();
matSign
.
setFacingDirection
(
BlockFace
.
WEST_SOUTH_WEST
);
//Same here ;(
if
(
building
.
name
.
length
()
>
60
)
{
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
2
,
building
.
width
.
y
-
2
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign1o
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
2
,
building
.
width
.
y
-
2
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
3
,
2
,
building
.
width
.
y
-
2
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign2o
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
building
.
width
.
x
-
3
,
2
,
building
.
width
.
y
-
2
)).
getState
();
}
break
;
case
WEST:
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(-
1
,
1
,
0
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign1
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(-
1
,
1
,
0
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(-
1
,
1
,
building
.
width
.
y
-
3
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign2
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(-
1
,
1
,
building
.
width
.
y
-
3
)).
getState
();
matSign
.
setFacingDirection
(
BlockFace
.
WEST
);
if
(
building
.
name
.
length
()
>
60
)
{
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(-
1
,
2
,
0
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign1o
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(-
1
,
2
,
0
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(-
1
,
2
,
building
.
width
.
y
-
3
)).
setType
(
Material
.
OAK_WALL_SIGN
);
sign2o
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(-
1
,
2
,
building
.
width
.
y
-
3
)).
getState
();
}
break
;
default
:
Bukkit
.
getLogger
().
log
(
Level
.
SEVERE
,
"falsche Orientierung übergeben!"
);
}
sign1
.
setData
(
matSign
);
sign2
.
setData
(
matSign
);
sign1o
.
setData
(
matSign
);
sign2o
.
setData
(
matSign
);
sign1
.
setGlowingText
(
true
);
sign2
.
setGlowingText
(
true
);
sign1o
.
setGlowingText
(
true
);
sign2o
.
setGlowingText
(
true
);
if
(
building
.
name
.
length
()
>
60
)
{
setTextToSign
(
sign1
,
sign1o
,
building
.
name
);
setTextToSign
(
sign2
,
sign2o
,
building
.
name
);
}
else
{
setTextToSign
(
sign1
,
building
.
name
);
setTextToSign
(
sign2
,
building
.
name
);
}
}
private
void
setTextToSign
(
Sign
sign
,
String
text
)
{
int
i
=
(
text
.
length
()
>
15
)
?
text
.
length
()
-
15
:
0
;
sign
.
setLine
(
3
,
text
.
substring
(
i
));
int
i1
=
(
text
.
length
()
>
30
)
?
text
.
length
()
-
30
:
0
;
sign
.
setLine
(
2
,
text
.
substring
(
i1
,
i
));
int
i2
=
(
text
.
length
()
>
45
)
?
text
.
length
()
-
45
:
0
;
sign
.
setLine
(
1
,
text
.
substring
(
i2
,
i1
));
sign
.
setLine
(
0
,
text
.
substring
(
Math
.
max
(
text
.
length
()
-
60
,
0
),
i2
));
sign
.
update
();
}
private
void
setTextToSign
(
Sign
sign
,
Sign
oSign
,
String
text
)
{
setTextToSign
(
sign
,
text
);
int
i
=
Math
.
max
(
text
.
length
()
-
75
,
0
);
oSign
.
setLine
(
3
,
text
.
substring
(
i
,
Math
.
max
(
text
.
length
()
-
60
,
0
)));
int
i1
=
Math
.
max
(
text
.
length
()
-
90
,
0
);
oSign
.
setLine
(
2
,
text
.
substring
(
i1
,
i
));
int
i2
=
Math
.
max
(
text
.
length
()
-
105
,
0
);
oSign
.
setLine
(
1
,
text
.
substring
(
i2
,
i1
));
oSign
.
setLine
(
0
,
text
.
substring
(
Math
.
max
(
text
.
length
()
-
120
,
0
),
i2
));
oSign
.
update
();
}
private
void
setFoundationSing
(
Location
startLocation
,
Foundation
foundation
)
{
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
0
,
0
)).
setType
(
Material
.
OAK_SIGN
);
org
.
bukkit
.
block
.
Sign
sign
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
0
,
0
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
foundation
.
width
.
x
-
1
,
0
,
0
)).
setType
(
Material
.
OAK_SIGN
);
org
.
bukkit
.
block
.
Sign
sign1
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
foundation
.
width
.
x
-
1
,
0
,
0
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
0
,
(
foundation
.
getWidth
().
y
==
0
)?
foundation
.
getWidth
().
x
-
1
:
foundation
.
getWidth
().
y
-
1
)).
setType
(
Material
.
OAK_SIGN
);
org
.
bukkit
.
block
.
Sign
sign2
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
0
,
(
foundation
.
getWidth
().
y
==
0
)?
foundation
.
getWidth
().
x
-
1
:
foundation
.
getWidth
().
y
-
1
)).
getState
();
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
foundation
.
getWidth
().
x
-
1
,
0
,
(
foundation
.
getWidth
().
y
==
0
)?
foundation
.
getWidth
().
x
-
1
:
foundation
.
getWidth
().
y
-
1
)).
setType
(
Material
.
OAK_SIGN
);
org
.
bukkit
.
block
.
Sign
sign3
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
foundation
.
getWidth
().
x
-
1
,
0
,
(
foundation
.
getWidth
().
y
==
0
)?
foundation
.
getWidth
().
x
-
1
:
foundation
.
getWidth
().
y
-
1
)).
getState
();
org
.
bukkit
.
material
.
Sign
matSign
=
new
org
.
bukkit
.
material
.
Sign
(
Material
.
OAK_SIGN
);
matSign
.
setFacingDirection
(
BlockFace
.
NORTH_WEST
);
sign
.
setData
(
matSign
);
matSign
.
setFacingDirection
(
BlockFace
.
NORTH_EAST
);
sign1
.
setData
(
matSign
);
matSign
.
setFacingDirection
(
BlockFace
.
SOUTH_WEST
);
sign2
.
setData
(
matSign
);
matSign
.
setFacingDirection
(
BlockFace
.
SOUTH_EAST
);
sign3
.
setData
(
matSign
);
sign
.
setGlowingText
(
true
);
sign1
.
setGlowingText
(
true
);
sign2
.
setGlowingText
(
true
);
sign3
.
setGlowingText
(
true
);
setTextToSign
(
sign
,
foundation
.
name
.
split
(
"/"
)[
foundation
.
name
.
split
(
"/"
).
length
-
1
]);
setTextToSign
(
sign1
,
foundation
.
name
.
split
(
"/"
)[
foundation
.
name
.
split
(
"/"
).
length
-
1
]);
setTextToSign
(
sign2
,
foundation
.
name
.
split
(
"/"
)[
foundation
.
name
.
split
(
"/"
).
length
-
1
]);
setTextToSign
(
sign3
,
foundation
.
name
.
split
(
"/"
)[
foundation
.
name
.
split
(
"/"
).
length
-
1
]);
}
public
void
setLegend
(
Location
startLocation
){
org
.
bukkit
.
material
.
Sign
matSign
=
new
org
.
bukkit
.
material
.
Sign
(
Material
.
OAK_WALL_SIGN
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
0
,-
6
)).
setType
(
Material
.
WAXED_COPPER_BLOCK
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
1
,-
6
)).
setType
(
Material
.
WAXED_EXPOSED_COPPER
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
2
,-
6
)).
setType
(
Material
.
WAXED_WEATHERED_COPPER
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
3
,-
6
)).
setType
(
Material
.
WAXED_OXIDIZED_COPPER
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
0
,-
6
),
"1. Quartal"
,
"Zeit seit dem"
,
"Erstem Commit"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
1
,-
6
),
"2. Quartal"
,
"Zeit seit dem"
,
"Erstem Commit"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
2
,-
6
),
"3. Quartal"
,
"Zeit seit dem"
,
"Erstem Commit"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
3
,-
6
),
"4. Quartal"
,
"Zeit seit dem"
,
"Erstem Commit"
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
0
,-
5
)).
setType
(
Material
.
WHITE_STAINED_GLASS
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
1
,-
5
)).
setType
(
Material
.
GLASS
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
2
,-
5
)).
setType
(
Material
.
BLUE_STAINED_GLASS
);
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
.
clone
().
add
(
0
,
3
,-
5
)).
setType
(
Material
.
IRON_BARS
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
0
,-
5
),
"1. Quartal"
,
"Zeit seit dem"
,
"Letzten Commit"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
1
,-
5
),
"2. Quartal"
,
"Zeit seit dem"
,
"Letzten Commit"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
2
,-
5
),
"3. Quartal"
,
"Zeit seit dem"
,
"Letzten Commit"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
3
,-
5
),
"4. Quartal"
,
"Zeit seit dem"
,
"Letzten Commit"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
0
,-
4
),
"Breite der"
,
"Gebäude = "
,
"#Variablen-3"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
1
,-
4
),
"Höhe der "
,
"Gebäude ="
,
"#Methoden"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
2
,-
4
),
"Höhe der "
,
"Antenne ≈"
,
"Komplexität"
);
setLegendBlock
(
startLocation
.
clone
().
add
(-
1
,
3
,-
4
),
"Höhe der "
,
"Kräne ="
,
"#Commits"
);
}
private
void
setLegendBlock
(
Location
startLocation
,
String
s1
,
String
s2
,
String
s3
){
org
.
bukkit
.
material
.
Sign
matSign
=
new
org
.
bukkit
.
material
.
Sign
(
Material
.
OAK_WALL_SIGN
);
org
.
bukkit
.
block
.
Sign
sign
=
null
;
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
).
setType
(
Material
.
OAK_WALL_SIGN
);
sign
=
(
org
.
bukkit
.
block
.
Sign
)
server
.
getWorlds
().
get
(
0
).
getBlockAt
(
startLocation
).
getState
();
sign
.
setGlowingText
(
true
);
sign
.
setGlowingText
(
true
);
sign
.
setLine
(
1
,
s1
);
sign
.
setLine
(
2
,
s2
);
sign
.
setLine
(
3
,
s3
);
matSign
.
setFacingDirection
(
BlockFace
.
WEST
);
sign
.
setData
(
matSign
);
sign
.
update
();
}
}
src/main/java/de/_82grfl1bif/KPI_Visualizer/structures/Building.java
View file @
3d499290
...
...
@@ -7,34 +7,37 @@ import java.awt.Point;
public
class
Building
extends
Structure
{
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
3
wegen 2 Gehweg"
);
throw
new
IllegalArgumentException
(
"keine Gebäude kleiner
5
wegen 2 Gehweg"
);
}
}
public
Building
(
Point
width
,
int
height
,
Material
material
){
//Buildings are Square -> no depth
public
Building
(
Point
width
/*and depth for complex algorithms*/
,
int
height
,
Material
material
){
this
.
width
=
width
;
this
.
height
=
height
;
this
.
material
=
material
;
if
(
this
.
width
.
x
<
5
||
this
.
width
.
y
<
5
){
throw
new
IllegalArgumentException
(
"keine Gebäude kleiner
3
wegen 2 Gehweg"
);
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
(
5
,
5
);
//TODO: make this work with treemap and square
this
.
area
=
klasse
.
qloc
;
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
.
commits
;
// con be changed to likings TODO: find out which fits best.
this
.
height
=
klasse
.
functions
;
if
(
this
.
width
.
x
<
5
||
this
.
width
.
y
<
5
){
throw
new
IllegalArgumentException
(
"keine Gebäude kleiner
3
wegen 2 Gehweg"
);
throw
new
IllegalArgumentException
(
"keine Gebäude kleiner
5
wegen 2 Gehweg"
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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