Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ProjLab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
insert epic projlab name here
ProjLab
Commits
96e8ef33
Verified
Commit
96e8ef33
authored
May 2, 2021
by
Tóth Miklós Tibor
Browse files
Options
Downloads
Patches
Plain Diff
bindings
parent
0cf3dca0
No related branches found
No related tags found
1 merge request
!114
Tomi
Pipeline
#7848
failed
May 2, 2021
Stage: build
Stage: getjar
Stage: docs
Stage: test
Stage: zip
Stage: telegram
Pipeline: tester
#7849
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/.gitignore
+3
-1
3 additions, 1 deletion
docs/.gitignore
src/projlab/MainPanel.java
+47
-32
47 additions, 32 deletions
src/projlab/MainPanel.java
with
50 additions
and
33 deletions
docs/.gitignore
+
3
−
1
View file @
96e8ef33
...
@@ -7,3 +7,5 @@ projlab.fls
...
@@ -7,3 +7,5 @@ projlab.fls
projlab.out
projlab.out
projlab.synctex(busy)
projlab.synctex(busy)
projlab.toc
projlab.toc
tmp
flap.log
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/projlab/MainPanel.java
+
47
−
32
View file @
96e8ef33
package
projlab
;
package
projlab
;
import
javafx.application.Platform
;
import
javafx.application.Platform
;
import
javafx.beans.binding.DoubleBinding
;
import
javafx.beans.property.DoubleProperty
;
import
javafx.beans.property.SimpleDoubleProperty
;
import
javafx.event.EventHandler
;
import
javafx.event.EventHandler
;
import
javafx.scene.Node
;
import
javafx.scene.Node
;
import
javafx.scene.control.Button
;
import
javafx.scene.control.Button
;
...
@@ -20,6 +23,7 @@ import java.util.Map;
...
@@ -20,6 +23,7 @@ import java.util.Map;
*/
*/
@Docs
(
changed
=
true
)
@Docs
(
changed
=
true
)
public
class
MainPanel
extends
AnchorPane
{
public
class
MainPanel
extends
AnchorPane
{
/**
/**
* A meglátogatható objektumok, amelyek gombként jelennek meg.
* A meglátogatható objektumok, amelyek gombként jelennek meg.
*/
*/
...
@@ -64,7 +68,7 @@ public class MainPanel extends AnchorPane {
...
@@ -64,7 +68,7 @@ public class MainPanel extends AnchorPane {
/**
/**
* Legenerált aszteroidák száma.
* Legenerált aszteroidák száma.
*/
*/
private
final
int
astAmount
=
30
;
private
final
int
astAmount
=
25
;
/**
/**
* Telepes, amit irányítani lehet.
* Telepes, amit irányítani lehet.
...
@@ -120,16 +124,20 @@ public class MainPanel extends AnchorPane {
...
@@ -120,16 +124,20 @@ public class MainPanel extends AnchorPane {
var
ast
=
new
Asteroid
(
0
,
10
,
mat
);
var
ast
=
new
Asteroid
(
0
,
10
,
mat
);
Game
.
addAsteroid
(
ast
);
Game
.
addAsteroid
(
ast
);
ast
.
addObserver
(
astObs
);
ast
.
addObserver
(
astObs
);
}
var
asts
=
Game
.
getAsteroids
();
for
(
int
i
=
0
;
i
<
astAmount
;
i
++)
{
if
(
i
!=
0
)
{
var
ast
=
asts
.
get
(
i
);
var
nei
=
Rand
.
newListElement
(
Game
.
getAsteroids
()
);
var
neighbour
=
Rand
.
newListElement
(
asts
);
ast
.
addNeighbour
(
nei
);
ast
.
addNeighbour
(
neighbour
);
nei
.
addNeighbour
(
ast
);
neighbour
.
addNeighbour
(
ast
);
}
}
}
}
private
static
final
int
btWidth
=
150
;
private
static
final
int
btHeight
=
90
;
public
void
arrangeAsteroids
()
{
var
asts
=
Game
.
getAsteroids
();
int
maxIndex
=
0
;
int
maxIndex
=
0
;
for
(
int
i
=
1
;
i
<
astAmount
;
i
++){
for
(
int
i
=
1
;
i
<
astAmount
;
i
++){
var
astMax
=
asts
.
get
(
maxIndex
);
var
astMax
=
asts
.
get
(
maxIndex
);
...
@@ -139,49 +147,55 @@ public class MainPanel extends AnchorPane {
...
@@ -139,49 +147,55 @@ public class MainPanel extends AnchorPane {
}
}
}
}
// create base asteroid
//var mat = Rand.newMaterial();
//var base = new Asteroid(0, 10, mat);
var
base
=
asts
.
get
(
maxIndex
);
var
base
=
asts
.
get
(
maxIndex
);
//Game.addAsteroid(base);
//base.addObserver(astObs);
var
bt
=
new
Button
();
var
bt
=
new
Button
();
var
hand
=
new
VisitableClickedHandler
(
base
);
var
hand
=
new
VisitableClickedHandler
(
base
);
bt
.
setOnMouseClicked
(
hand
);
bt
.
setOnMouseClicked
(
hand
);
//Coordinates location = getLocation(base);
var
middleX
=
widthProperty
().
divide
(
2
);
Coordinates
location
=
new
Coordinates
(
getWidth
()/
2
,
getHeight
()/
2
);
var
btXProp
=
middleX
.
subtract
(
bt
.
widthProperty
().
divide
(
2
));
this
.
add
(
bt
,
location
.
x
,
location
.
y
);
bt
.
layoutXProperty
().
bind
(
btXProp
);
var
middleY
=
heightProperty
().
divide
(
2
);
var
btYProp
=
middleY
.
subtract
(
bt
.
heightProperty
().
divide
(
2
));
bt
.
layoutYProperty
().
bind
(
btYProp
);
bt
.
setManaged
(
false
);
bt
.
resize
(
btWidth
,
btHeight
);
getChildren
().
add
(
bt
);
visitables
.
put
(
base
,
bt
);
visitables
.
put
(
base
,
bt
);
setButtonText
(
base
);
setButtonText
(
base
);
// create asteroids
// create asteroids
double
xdistance
=
700
;
var
xdistance
=
widthProperty
().
subtract
(
bt
.
widthProperty
()).
divide
(
2
)
;
double
ydistance
=
400
;
var
ydistance
=
heightProperty
().
subtract
(
bt
.
heightProperty
()).
divide
(
2
)
;
for
(
int
i
=
0
;
i
<
astAmount
;
i
++)
{
for
(
int
i
=
0
;
i
<
astAmount
;
i
++)
{
if
(
i
!=
maxIndex
)
{
if
(
i
!=
maxIndex
)
{
//mat = Rand.newMaterial();
//var ast = new Asteroid(0, 10, mat);
var
ast
=
asts
.
get
(
i
);
var
ast
=
asts
.
get
(
i
);
//var asts = Game.getAsteroids();
//var neighbour = Rand.newListElement(asts);
//ast.addNeighbour(neighbour);
//neighbour.addNeighbour(ast);
//Game.addAsteroid(ast);
//ast.addObserver(astObs);
bt
=
new
Button
();
bt
=
new
Button
();
hand
=
new
VisitableClickedHandler
(
ast
);
hand
=
new
VisitableClickedHandler
(
ast
);
bt
.
setOnMouseClicked
(
hand
);
bt
.
setOnMouseClicked
(
hand
);
//location = getLocation(ast);
//this.add(bt, location.x, location.y)
;
var
ind
=
i
;
if
(
i
<
maxIndex
){
if
(
i
>
maxIndex
){
this
.
add
(
bt
,
location
.
x
+
xdistance
*
Math
.
cos
(((
360.0
/
(
astAmount
-
1
))
*
i
)
*
Math
.
PI
/
180
),
location
.
y
+
ydistance
*
Math
.
sin
(((
360.0
/
(
astAmount
-
1.0
))
*
i
)
*
Math
.
PI
/
180
))
;
ind
=
i
-
1
;
}
}
else
{
this
.
add
(
bt
,
location
.
x
+
xdistance
*
Math
.
cos
(((
360.0
/
(
astAmount
-
1
))
*
(
i
-
1
))
*
Math
.
PI
/
180
),
location
.
y
+
ydistance
*
Math
.
sin
(((
360.0
/
(
astAmount
-
1.0
))
*
(
i
-
1
))
*
Math
.
PI
/
180
));
DoubleBinding
xOffset
=
xdistance
.
multiply
(
Math
.
cos
(((
360.0
/
(
astAmount
-
1
))
*
ind
)
*
Math
.
PI
/
180
));
DoubleBinding
yOffset
=
ydistance
.
multiply
(
Math
.
sin
(((
360.0
/
(
astAmount
-
1.0
))
*
ind
)
*
Math
.
PI
/
180
));
if
(
ind
%
2
==
0
)
{
xOffset
=
xOffset
.
divide
(
1.4
);
yOffset
=
yOffset
.
divide
(
1.4
);
}
}
bt
.
layoutXProperty
().
bind
(
middleX
.
add
(
xOffset
).
subtract
(
bt
.
widthProperty
().
divide
(
2
)));
bt
.
layoutYProperty
().
bind
(
middleY
.
add
(
yOffset
).
subtract
(
bt
.
heightProperty
().
divide
(
2
)));
bt
.
setManaged
(
false
);
bt
.
resize
(
btWidth
,
btHeight
);
visitables
.
put
(
ast
,
bt
);
visitables
.
put
(
ast
,
bt
);
setButtonText
(
ast
);
setButtonText
(
ast
);
getChildren
().
add
(
bt
);
}
}
}
}
...
@@ -193,6 +207,7 @@ public class MainPanel extends AnchorPane {
...
@@ -193,6 +207,7 @@ public class MainPanel extends AnchorPane {
*/
*/
public
void
init
()
{
public
void
init
()
{
initAsteroids
();
initAsteroids
();
arrangeAsteroids
();
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment