FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/3D_Visualization_Solar_System.java at main · sksalahuddin2828/Java · GitHub
sksalahuddin2828
/
Java
Public
Notifications
You must be signed in to change notification settings
Fork
59
Star
178
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
Java
/
3D_Visualization_Solar_System.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
55 lines (47 loc) · 1.85 KB
Breadcrumbs
Java
/
3D_Visualization_Solar_System.java
Copy path
File metadata and controls
55 lines (47 loc) · 1.85 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
import
javafx
.
application
.
Application
;
import
javafx
.
scene
.
Group
;
import
javafx
.
scene
.
Scene
;
import
javafx
.
scene
.
paint
.
Color
;
import
javafx
.
scene
.
shape
.
Sphere
;
import
javafx
.
scene
.
text
.
Font
;
import
javafx
.
scene
.
text
.
Text
;
import
javafx
.
stage
.
Stage
;
public
class
CelestialBodies
extends
Application
{
private
static
final
int
WIDTH
=
800
;
private
static
final
int
HEIGHT
=
600
;
private
Group
root
;
@
Override
public
void
start
(
Stage
primaryStage
) {
root
=
new
Group
();
Scene
scene
=
new
Scene
(
root
,
WIDTH
,
HEIGHT
,
Color
.
BLACK
);
primaryStage
.
setScene
(
scene
);
primaryStage
.
setTitle
(
"Celestial Bodies"
);
primaryStage
.
show
();
createBodies
();
}
private
void
createBodies
() {
String
[]
bodyNames
= {
"Sun"
,
"Mercury"
,
"Venus"
,
"Earth"
,
"Mars"
,
"Jupiter"
,
"Saturn"
,
"Uranus"
,
"Neptune"
};
double
[]
xCoordinates
= {
0
,
50
,
70
,
100
,
150
,
220
,
280
,
350
,
400
};
double
[]
yCoordinates
= {
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
double
[]
zCoordinates
= {
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
double
[]
sizes
= {
20
,
5
,
7
,
7
,
6
,
18
,
15
,
12
,
12
};
for
(
int
i
=
0
;
i
<
bodyNames
.
length
;
i
++) {
double
radius
=
sizes
[
i
];
Sphere
body
=
new
Sphere
(
radius
);
body
.
setTranslateX
(
xCoordinates
[
i
]);
body
.
setTranslateY
(
yCoordinates
[
i
]);
body
.
setTranslateZ
(
zCoordinates
[
i
]);
body
.
setMaterial
(
new
PhongMaterial
(
Color
.
WHITE
));
root
.
getChildren
().
add
(
body
);
Text
label
=
new
Text
(
bodyNames
[
i
]);
label
.
setTranslateX
(
xCoordinates
[
i
] -
radius
);
label
.
setTranslateY
(
HEIGHT
-
20
);
label
.
setFill
(
Color
.
WHITE
);
label
.
setFont
(
Font
.
font
(
"Arial"
,
12
));
root
.
getChildren
().
add
(
label
);
}
}
public
static
void
main
(
String
[]
args
) {
launch
(
args
);
}
}
Back
|
FazBrowse Home
|
New Git URL