FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Graph/GraphV.java at master · infSloe/Graph · GitHub
infSloe
/
Graph
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Graph
/
GraphV.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
100 lines (87 loc) · 2.64 KB
Breadcrumbs
Graph
/
GraphV.java
Copy path
File metadata and controls
100 lines (87 loc) · 2.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import
java
.
util
.*;
import
javafx
.
scene
.
layout
.
Pane
;
import
javafx
.
scene
.
paint
.*;
import
javafx
.
scene
.
layout
.*;
public
class
GraphV
extends
Pane
{
Graph
graph
;
ArrayList
<
KnotenV
>
knotenliste
;
ArrayList
<
KanteV
>
kantenliste
;
Controller
controller
;
public
GraphV
(
double
breite
,
double
hoehe
,
Controller
controller_
,
Graph
graph_
){
graph
=
graph_
;
knotenliste
=
new
ArrayList
<
KnotenV
>();
kantenliste
=
new
ArrayList
<
KanteV
>();
setWidth
(
breite
);
setHeight
(
hoehe
);
controller
=
controller_
;
setStyle
(
"-fx-background-color: white"
);
}
public
void
knotenEinfuegen
(
String
a
)
{
graph
.
knotenEinfuegen
(
a
);
Knoten
k
=
graph
.
getKnoten
(
a
);
KnotenV
knotenV
=
new
KnotenV
(
k
,
controller
);
knotenV
.
setTranslateX
(
100
+
Math
.
random
()*
50
);
knotenV
.
setTranslateY
(
100
+
Math
.
random
()*
50
);
knotenliste
.
add
(
knotenV
);
getChildren
().
add
(
knotenV
);
}
public
void
knotenEinfuegen
(
String
a
,
double
x
,
double
y
)
{
graph
.
knotenEinfuegen
(
a
);
Knoten
k
=
graph
.
getKnoten
(
a
);
KnotenV
knotenV
=
new
KnotenV
(
k
,
controller
);
knotenV
.
setTranslateX
(
x
);
knotenV
.
setTranslateY
(
y
);
knotenliste
.
add
(
knotenV
);
getChildren
().
add
(
knotenV
);
}
public
KnotenV
sucheKnoten
(
String
inhalt
)
{
for
(
KnotenV
knotenV
:
knotenliste
)
{
if
(
inhalt
.
equals
(
knotenV
.
getInhalt
()))
{
return
knotenV
;
}
}
return
null
;
}
public
void
kanteEinfuegen
(
String
a
,
String
b
)
{
KnotenV
k1
=
sucheKnoten
(
a
);
KnotenV
k2
=
sucheKnoten
(
b
);
if
(
a
!=
null
&&
b
!=
null
)
{
graph
.
kanteEinfuegen
(
a
,
b
);
graph
.
kanteEinfuegen
(
b
,
a
);
KanteV
kante
=
new
KanteV
(
k1
,
k2
,
this
);
kantenliste
.
add
(
kante
);
getChildren
().
add
(
kante
);
k1
.
toFront
();
k2
.
toFront
();
}
controller
.
optimiere
();
}
public
void
kanteLoeschen
(
KanteV
kante
)
{
graph
.
kanteEntfernen
(
kante
.
getStart
().
getInhalt
(),
kante
.
getZiel
().
getInhalt
());
graph
.
kanteEntfernen
(
kante
.
getZiel
().
getInhalt
(),
kante
.
getStart
().
getInhalt
());
getChildren
().
remove
(
kante
);
kantenliste
.
remove
(
kante
);
controller
.
optimiere
();
}
public
ArrayList
<
KnotenV
>
getKnotenliste
()
{
return
knotenliste
;
}
public
boolean
istKante
(
KnotenV
k1
,
KnotenV
k2
)
{
return
graph
.
istKante
(
k1
.
getInhalt
(),
k2
.
getInhalt
());
}
public
int
knotenAnzahl
()
{
return
knotenliste
.
size
();
}
}
Back
|
FazBrowse Home
|
New Git URL