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
Radnai László
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
No related merge requests found
Changes
2
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
projlab.out
projlab.synctex(busy)
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
;
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.scene.Node
;
import
javafx.scene.control.Button
;
...
...
@@ -20,6 +23,7 @@ import java.util.Map;
*/
@Docs
(
changed
=
true
)
public
class
MainPanel
extends
AnchorPane
{
/**
* A meglátogatható objektumok, amelyek gombként jelennek meg.
*/
...
...
@@ -64,7 +68,7 @@ public class MainPanel extends AnchorPane {
/**
* Legenerált aszteroidák száma.
*/
private
final
int
astAmount
=
30
;
private
final
int
astAmount
=
25
;
/**
* Telepes, amit irányítani lehet.
...
...
@@ -120,16 +124,20 @@ public class MainPanel extends AnchorPane {
var
ast
=
new
Asteroid
(
0
,
10
,
mat
);
Game
.
addAsteroid
(
ast
);
ast
.
addObserver
(
astObs
);
}
var
asts
=
Game
.
getAsteroids
();
for
(
int
i
=
0
;
i
<
astAmount
;
i
++)
{
var
ast
=
asts
.
get
(
i
);
var
neighbour
=
Rand
.
newListElement
(
asts
);
ast
.
addNeighbour
(
neighbour
);
neighbour
.
addNeighbour
(
ast
);
if
(
i
!=
0
)
{
var
nei
=
Rand
.
newListElement
(
Game
.
getAsteroids
()
);
ast
.
addNeighbour
(
nei
);
nei
.
addNeighbour
(
ast
);
}
}
}
private
static
final
int
btWidth
=
150
;
private
static
final
int
btHeight
=
90
;
public
void
arrangeAsteroids
()
{
var
asts
=
Game
.
getAsteroids
();
int
maxIndex
=
0
;
for
(
int
i
=
1
;
i
<
astAmount
;
i
++){
var
astMax
=
asts
.
get
(
maxIndex
);
...
...
@@ -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
);
//Game.addAsteroid(base);
//base.addObserver(astObs);
var
bt
=
new
Button
();
var
hand
=
new
VisitableClickedHandler
(
base
);
bt
.
setOnMouseClicked
(
hand
);
//Coordinates location = getLocation(base);
Coordinates
location
=
new
Coordinates
(
getWidth
()/
2
,
getHeight
()/
2
);
this
.
add
(
bt
,
location
.
x
,
location
.
y
);
var
middleX
=
widthProperty
().
divide
(
2
);
var
btXProp
=
middleX
.
subtract
(
bt
.
widthProperty
().
divide
(
2
));
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
);
setButtonText
(
base
);
// create asteroids
double
xdistance
=
700
;
double
ydistance
=
400
;
var
xdistance
=
widthProperty
().
subtract
(
bt
.
widthProperty
()).
divide
(
2
)
;
var
ydistance
=
heightProperty
().
subtract
(
bt
.
heightProperty
()).
divide
(
2
)
;
for
(
int
i
=
0
;
i
<
astAmount
;
i
++)
{
if
(
i
!=
maxIndex
)
{
//mat = Rand.newMaterial();
//var ast = new Asteroid(0, 10, mat);
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
();
hand
=
new
VisitableClickedHandler
(
ast
);
bt
.
setOnMouseClicked
(
hand
);
//location = getLocation(ast);
//this.add(bt, location.x, location.y)
;
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
))
;
var
ind
=
i
;
if
(
i
>
maxIndex
){
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
);
setButtonText
(
ast
);
getChildren
().
add
(
bt
);
}
}
...
...
@@ -193,6 +207,7 @@ public class MainPanel extends AnchorPane {
*/
public
void
init
()
{
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