some changes
This commit is contained in:
parent
fdc7d9ab56
commit
bd8607a796
@ -26,9 +26,9 @@ public class ControllerBoat {
|
||||
@FXML
|
||||
private Label labelBodyColorValue;
|
||||
@FXML
|
||||
private ComboBox<String> comboBoxNumOfRollers;
|
||||
private ComboBox<String> comboBoxNumOars;
|
||||
@FXML
|
||||
private ComboBox<String> comboBoxOrnamentType;
|
||||
private ComboBox<String> comboBoxOarsType;
|
||||
@FXML
|
||||
private Button buttonCreate;
|
||||
@FXML
|
||||
@ -124,7 +124,7 @@ public class ControllerBoat {
|
||||
{
|
||||
if (_boat != null)
|
||||
{
|
||||
_boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOfRollers.getValue()));
|
||||
_boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue()));
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
@ -133,18 +133,17 @@ public class ControllerBoat {
|
||||
{
|
||||
if (_boat != null)
|
||||
{
|
||||
IDrawningAdditionalElement newDrawningTrackRollers = switch (comboBoxOrnamentType.getValue())
|
||||
IDrawningAdditionalElement newDrawningOars = switch (comboBoxOarsType.getValue())
|
||||
{
|
||||
case "None" -> new DrawningOars(_boat.GetBoat().GetBodyColor());
|
||||
case "Dots" -> new DrawningDotOrnamentTrackRollers(_boat.GetBoat().GetBodyColor());
|
||||
case "Circles" ->
|
||||
new DrawningCircleOrnamentTrackRollers(_boat.GetBoat().GetBodyColor());
|
||||
case "Short" -> new DrawningShortOars(_boat.GetBoat().GetBodyColor());
|
||||
case "Long" -> new DrawningLongOars(_boat.GetBoat().GetBodyColor());
|
||||
default -> null;
|
||||
};
|
||||
if (newDrawningTrackRollers != null)
|
||||
if (newDrawningOars != null)
|
||||
{
|
||||
_boat.SetDrawningOars(newDrawningTrackRollers);
|
||||
_boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOfRollers.getValue()));
|
||||
_boat.SetDrawningOars(newDrawningOars);
|
||||
_boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,181 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ControllerMap
|
||||
{
|
||||
@FXML
|
||||
private Pane root;
|
||||
@FXML
|
||||
private Canvas canvas;
|
||||
@FXML
|
||||
private FlowPane flowPane;
|
||||
@FXML
|
||||
private Label labelSpeedValue;
|
||||
@FXML
|
||||
private Label labelWeightValue;
|
||||
@FXML
|
||||
private Label labelBodyColorValue;
|
||||
@FXML
|
||||
private ComboBox<String> comboBoxNumOars;
|
||||
@FXML
|
||||
private ComboBox<String> comboBoxOarsType;
|
||||
@FXML
|
||||
private ComboBox<String> comboBoxSelectorMap;
|
||||
@FXML
|
||||
private Button buttonCreate;
|
||||
@FXML
|
||||
private Button buttonCreateModif;
|
||||
@FXML
|
||||
private Button buttonLeft;
|
||||
@FXML
|
||||
private Button buttonRight;
|
||||
@FXML
|
||||
private Button buttonUp;
|
||||
@FXML
|
||||
private Button buttonDown;
|
||||
private final double buttonMargin = 10.0;
|
||||
private AbstractMap _abstractMap;
|
||||
|
||||
@FXML
|
||||
public void initialize()
|
||||
{
|
||||
buttonCreate.setTranslateX(buttonMargin);
|
||||
|
||||
root.widthProperty().addListener((obs, oldVal, newVal) ->
|
||||
{
|
||||
UpdateGUI();
|
||||
if (_abstractMap != null)
|
||||
{
|
||||
_abstractMap.DrawMapWithObject();
|
||||
}
|
||||
});
|
||||
root.heightProperty().addListener((obs, oldVal, newVal) ->
|
||||
{
|
||||
UpdateGUI();
|
||||
if (_abstractMap != null)
|
||||
{
|
||||
_abstractMap.DrawMapWithObject();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@FXML
|
||||
void ButtonCreate_Click()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
DrawningBoat boat = new DrawningBoat(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||
Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
SetData(boat);
|
||||
}
|
||||
|
||||
@FXML
|
||||
void ButtonCreateModif_Click()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
DrawningSpeedboat boat = new DrawningSpeedboat(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||
Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)),
|
||||
Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)),
|
||||
(rnd.nextInt(2) != 0), (rnd.nextInt(2) != 0), (rnd.nextInt(2) != 0));
|
||||
SetData(boat);
|
||||
}
|
||||
|
||||
@FXML
|
||||
void ButtonMove_Click(ActionEvent event)
|
||||
{
|
||||
if (_abstractMap == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String buttonName = ((Button) event.getSource()).getId();
|
||||
switch (buttonName)
|
||||
{
|
||||
case "buttonUp" -> _abstractMap.MoveObject(Direction.Up);
|
||||
case "buttonDown" -> _abstractMap.MoveObject(Direction.Down);
|
||||
case "buttonLeft" -> _abstractMap.MoveObject(Direction.Left);
|
||||
case "buttonRight" -> _abstractMap.MoveObject(Direction.Right);
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void ComboBoxSelectorMap_Changed()
|
||||
{
|
||||
switch (comboBoxSelectorMap.getValue())
|
||||
{
|
||||
case "Simple map" -> _abstractMap = new SimpleMap();
|
||||
case "My second map" -> _abstractMap = new MySecondMap();
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeDrawningOars(DrawningBoat boat)
|
||||
{
|
||||
IDrawningAdditionalElement newDrawningOars = switch (comboBoxOarsType.getValue())
|
||||
{
|
||||
case "None" -> new DrawningOars(boat.GetBoat().GetBodyColor());
|
||||
case "Short" -> new DrawningShortOars(boat.GetBoat().GetBodyColor());
|
||||
case "Long" -> new DrawningLongOars(boat.GetBoat().GetBodyColor());
|
||||
default -> null;
|
||||
};
|
||||
if (newDrawningOars != null)
|
||||
{
|
||||
boat.SetDrawningOars(newDrawningOars);
|
||||
boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateGUI()
|
||||
{
|
||||
double sceneWidth = root.getWidth();
|
||||
double sceneHeight = root.getHeight();
|
||||
|
||||
double flowPaneHeight = flowPane.getHeight();
|
||||
double buttonCreateHeight = buttonCreate.getHeight();
|
||||
|
||||
canvas.setWidth(sceneWidth);
|
||||
flowPane.setPrefWidth(sceneWidth);
|
||||
canvas.setHeight(sceneHeight - flowPaneHeight);
|
||||
flowPane.setTranslateY(sceneHeight - flowPaneHeight);
|
||||
|
||||
buttonCreate.setTranslateY(sceneHeight - flowPaneHeight - buttonCreateHeight - buttonMargin);
|
||||
buttonCreateModif.setTranslateY(sceneHeight - flowPaneHeight - buttonCreateHeight - buttonMargin);
|
||||
|
||||
int buttonMoveHeight = 30;
|
||||
int distanceBetweenMoveButtons = 5;
|
||||
buttonUp.setTranslateY(sceneHeight - flowPaneHeight - buttonMoveHeight * 2.0 - buttonMargin -
|
||||
distanceBetweenMoveButtons);
|
||||
int buttonMoveWidth = 30;
|
||||
buttonUp.setTranslateX(sceneWidth - buttonMargin - buttonMoveWidth * 2.0 - distanceBetweenMoveButtons);
|
||||
|
||||
buttonDown.setTranslateY(sceneHeight - flowPaneHeight - buttonMoveHeight - buttonMargin);
|
||||
buttonDown.setTranslateX(sceneWidth- buttonMargin - buttonMoveWidth * 2.0 - distanceBetweenMoveButtons);
|
||||
|
||||
buttonLeft.setTranslateY(sceneHeight - flowPaneHeight - buttonMoveHeight - buttonMargin);
|
||||
buttonLeft.setTranslateX(sceneWidth - buttonMargin - buttonMoveWidth * 3.0 -
|
||||
distanceBetweenMoveButtons * 2.0);
|
||||
|
||||
buttonRight.setTranslateY(sceneHeight - flowPaneHeight - buttonMoveHeight - buttonMargin);
|
||||
buttonRight.setTranslateX(sceneWidth - buttonMargin - buttonMoveWidth);
|
||||
}
|
||||
|
||||
private void SetData(DrawningBoat boat)
|
||||
{
|
||||
ChangeDrawningOars(boat);
|
||||
labelSpeedValue.setText(Integer.toString(boat.GetBoat().GetSpeed()));
|
||||
labelWeightValue.setText(Double.toString(boat.GetBoat().GetWeight()));
|
||||
labelBodyColorValue.setText(boat.GetBoat().GetBodyColor().toString());
|
||||
GraphicsContext gc = canvas.getGraphicsContext2D();
|
||||
gc.clearRect(0.0, 0.0, canvas.getWidth(), canvas.getHeight());
|
||||
_abstractMap.CreateMap((int)canvas.getWidth(), (int)canvas.getHeight(), new DrawningObjectBoat(boat), gc);
|
||||
}
|
||||
}
|
@ -138,5 +138,13 @@ public class DrawningBoat
|
||||
_startPosY = _pictureHeight - _boatHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public float[] GetCurrentPosition()
|
||||
{
|
||||
float[] position = new float[4];
|
||||
position[0] = _startPosX;
|
||||
position[1] = _startPosY;
|
||||
position[2] = _startPosX + _boatWidth;
|
||||
position[3] = _startPosY + _boatHeight;
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,111 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class DrawningLongOars implements IDrawningAdditionalElement {
|
||||
private Color _oarsColor;
|
||||
private NumberOars _numOars;
|
||||
|
||||
public void SetNumberOars(int numberOars) {
|
||||
_numOars = NumberOars.FromInteger(numberOars);
|
||||
}
|
||||
public DrawningLongOars(Color oarsColor) {
|
||||
_oarsColor = oarsColor;
|
||||
}
|
||||
public void DrawOars(GraphicsContext gc, float startPosX, float startPosY) {
|
||||
if (_oarsColor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
|
||||
gc.strokeOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
|
||||
gc.strokeOval(11.0 + startPosX, 42.0 + startPosY, 6.0, 6.0);
|
||||
|
||||
gc.fillOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
|
||||
gc.strokeOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
|
||||
gc.strokeOval(95.0 + startPosX, 42.0 + startPosY, 6.0, 6.0);
|
||||
|
||||
// Орнамент
|
||||
gc.strokeOval(8.0 + startPosX, 39.0 + startPosY, 12.0, 12.0);
|
||||
gc.strokeOval(92.0 + startPosX, 39.0 + startPosY, 12.0, 12.0);
|
||||
|
||||
switch (_numOars) {
|
||||
case One:
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(40.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(68.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
// Орнамент
|
||||
gc.strokeOval(38.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
gc.strokeOval(66.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
break;
|
||||
|
||||
case Two:
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(34.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(54.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(74.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
// Орнамент
|
||||
gc.strokeOval(32.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
gc.strokeOval(52.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
gc.strokeOval(72.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
break;
|
||||
|
||||
case Three:
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(30.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(46.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(62.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(78.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
// Орнамент
|
||||
gc.strokeOval(28.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
gc.strokeOval(44.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
gc.strokeOval(60.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
gc.strokeOval(76.0 + startPosX, 45.0 + startPosY, 8.0, 8.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
|
||||
public class DrawningObjectBoat implements IDrawningObject {
|
||||
private DrawningBoat _boat = null;
|
||||
|
||||
public DrawningObjectBoat(DrawningBoat boat)
|
||||
{
|
||||
_boat = boat;
|
||||
}
|
||||
|
||||
public float GetStep()
|
||||
{
|
||||
if (_boat != null && _boat.GetBoat() != null)
|
||||
{
|
||||
return _boat.GetBoat().GetStep();
|
||||
}
|
||||
return 0F;
|
||||
}
|
||||
|
||||
public float[] GetCurrentPosition()
|
||||
{
|
||||
if (_boat != null)
|
||||
{
|
||||
return _boat.GetCurrentPosition();
|
||||
}
|
||||
return new float[4];
|
||||
}
|
||||
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_boat.MoveTransport(direction);
|
||||
}
|
||||
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
_boat.SetPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
public void DrawningObject(GraphicsContext gc)
|
||||
{
|
||||
if (_boat != null)
|
||||
{
|
||||
_boat.DrawTransport(gc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class DrawningShortOars implements IDrawningAdditionalElement {
|
||||
private Color _oarsColor;
|
||||
private NumberOars _numOars;
|
||||
|
||||
public void SetNumberOars(int numberOars) {
|
||||
_numOars = NumberOars.FromInteger(numberOars);
|
||||
}
|
||||
public DrawningShortOars(Color oarsColor) {
|
||||
_oarsColor = oarsColor;
|
||||
}
|
||||
|
||||
public void DrawOars(GraphicsContext gc, float startPosX, float startPosY) {
|
||||
if (_oarsColor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
|
||||
gc.strokeOval(5.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
|
||||
gc.strokeOval(11.0 + startPosX, 42.0 + startPosY, 6.0, 6.0);
|
||||
|
||||
gc.fillOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
|
||||
gc.strokeOval(89.0 + startPosX, 36.0 + startPosY, 18.0, 18.0);
|
||||
gc.strokeOval(95.0 + startPosX, 42.0 + startPosY, 6.0, 6.0);
|
||||
|
||||
// Орнамент
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(13.0 + startPosX, 38.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(13.0 + startPosX, 50.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(7.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(19.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(9.0 + startPosX, 40.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(9.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(17.0 + startPosX, 40.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(17.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(97.0 + startPosX, 38.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(97.0 + startPosX, 50.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(91.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(103.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(93.0 + startPosX, 40.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(93.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(101.0 + startPosX, 40.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(101.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
switch (_numOars) {
|
||||
case One:
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(35.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(40.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(63.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(68.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
// Орнамент
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(37.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(45.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(41.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(41.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(65.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(73.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(69.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(69.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
break;
|
||||
|
||||
case Two:
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(29.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(34.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(49.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(54.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(69.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(74.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
// Орнамент
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(31.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(39.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(35.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(35.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(51.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(59.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(55.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(55.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(71.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(79.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(75.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(75.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
break;
|
||||
|
||||
case Three:
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(25.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(30.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(41.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(46.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(57.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(62.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
gc.setFill(_oarsColor);
|
||||
gc.fillOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.strokeOval(73.0 + startPosX, 42.0 + startPosY, 14.0, 14.0);
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(78.0 + startPosX, 47.0 + startPosY, 4.0, 4.0);
|
||||
|
||||
// Орнамент
|
||||
gc.setFill(Color.BLACK);
|
||||
gc.fillOval(27.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(35.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(31.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(31.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(43.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(51.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(47.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(47.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(59.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(67.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(63.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(63.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
|
||||
gc.fillOval(75.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(83.0 + startPosX, 48.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(79.0 + startPosX, 44.0 + startPosY, 2.0, 2.0);
|
||||
gc.fillOval(79.0 + startPosX, 52.0 + startPosY, 2.0, 2.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,6 +5,6 @@ import javafx.scene.canvas.GraphicsContext;
|
||||
public interface IDrawningAdditionalElement
|
||||
{
|
||||
public int deltaYdown = 0;
|
||||
public void SetNumberOars(int numberOfRollers);
|
||||
public void SetNumberOars(int numberOars);
|
||||
public void DrawOars(GraphicsContext gc, float startPosX, float startPosY);
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class MySecondMap extends AbstractMap
|
||||
{
|
||||
protected void DrawBarrierPart(GraphicsContext gc, int i, int j)
|
||||
{
|
||||
gc.setFill(Color.RED);
|
||||
gc.fillRect(i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
}
|
||||
protected void DrawRoadPart(GraphicsContext gc, int i, int j)
|
||||
{
|
||||
gc.setFill(Color.rgb(242, 242, 242));
|
||||
gc.fillRect(i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
}
|
||||
|
||||
protected void GenerateMap() {
|
||||
_map = new int[150][100];
|
||||
_size_x = (float)_width / _map.length;
|
||||
_size_y = (float)_height / _map[0].length;
|
||||
int counter = 0;
|
||||
for (int i = 0; i < _map.length; ++i) {
|
||||
for (int j = 0; j < _map[i].length; ++j) {
|
||||
_map[i][j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
while (counter < 10) {
|
||||
int x = _random.nextInt(0, _map.length);
|
||||
int y = _random.nextInt(0, _map[0].length);
|
||||
if (_map[x][y] == _freeRoad) {
|
||||
_map[x][y] = _barrier;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -37,24 +37,24 @@
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Rollers:
|
||||
</Label>
|
||||
<ComboBox fx:id="comboBoxNumOfRollers" value="5" onAction="#ComboBoxNumOfRollers_Changed">
|
||||
<ComboBox fx:id="comboBoxNumOars" value="5" onAction="#ComboBoxNumOfRollers_Changed">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="4"/>
|
||||
<String fx:value="5"/>
|
||||
<String fx:value="6"/>
|
||||
<String fx:value="1"/>
|
||||
<String fx:value="2"/>
|
||||
<String fx:value="3"/>
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Ornament:
|
||||
</Label>
|
||||
<ComboBox fx:id="comboBoxOrnamentType" value="None" onAction="#ComboBoxOrnamentType_Changed">
|
||||
<ComboBox fx:id="comboBoxOarsType" value="None" onAction="#ComboBoxOrnamentType_Changed">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="None"/>
|
||||
<String fx:value="Dots"/>
|
||||
<String fx:value="Circles"/>
|
||||
<String fx:value="Short"/>
|
||||
<String fx:value="Long"/>
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
@ -93,100 +93,4 @@
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</Pane>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
|
||||
<?import javafx.scene.canvas.Canvas?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ComboBox?>
|
||||
<?import javafx.collections.FXCollections?>
|
||||
<?import java.lang.String?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<Pane xmlns:fx="http://javafx.com/fxml" fx:id="root" fx:controller="com.example.pibd22_kalyshev_y_v_motorboat_hard.ControllerBoat"
|
||||
style="-fx-background-color: #31374c;">
|
||||
<Canvas fx:id="canvas">
|
||||
</Canvas>
|
||||
<FlowPane fx:id="flowPane">
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Speed:
|
||||
</Label>
|
||||
<Label fx:id="labelSpeedValue" style="-fx-text-fill: #ffffff; -fx-padding: 5 5 5 0; -fx-font-weight: bold;">
|
||||
-
|
||||
</Label>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Weight:
|
||||
</Label>
|
||||
<Label fx:id="labelWeightValue" style="-fx-text-fill: #ffffff; -fx-padding: 5 5 5 0; -fx-font-weight: bold;">
|
||||
-
|
||||
</Label>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Color:
|
||||
</Label>
|
||||
<Label fx:id="labelBodyColorValue" style="-fx-text-fill: #ffffff; -fx-padding: 5 5 5 0; -fx-font-weight: bold;">
|
||||
-
|
||||
</Label>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Rollers:
|
||||
</Label>
|
||||
<ComboBox fx:id="comboBoxNumOfRollers" value="5" onAction="#ComboBoxNumOfRollers_Changed">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="4"/>
|
||||
<String fx:value="5"/>
|
||||
<String fx:value="6"/>
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Ornament:
|
||||
</Label>
|
||||
<ComboBox fx:id="comboBoxOrnamentType" value="None" onAction="#ComboBoxOrnamentType_Changed">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="None"/>
|
||||
<String fx:value="Dots"/>
|
||||
<String fx:value="Circles"/>
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
</FlowPane>
|
||||
<Button fx:id="buttonCreate" onAction="#ButtonCreate_Click">
|
||||
Create
|
||||
</Button>
|
||||
<Button fx:id="buttonCreateModif" onAction="#ButtonCreateModif_Click">
|
||||
Modification
|
||||
</Button>
|
||||
<Button fx:id="buttonLeft" minWidth="30" minHeight="30" onAction="#ButtonMove_Click">
|
||||
<graphic>
|
||||
<ImageView fitHeight="14.0" fitWidth="14.0" pickOnBounds="true" preserveRatio="true">
|
||||
<Image url="@/arrowLeft.png"/>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="buttonRight" minWidth="30" minHeight="30" onAction="#ButtonMove_Click">
|
||||
<graphic>
|
||||
<ImageView fitHeight="14.0" fitWidth="14.0" pickOnBounds="true" preserveRatio="true">
|
||||
<Image url="@/arrowRight.png"/>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="buttonUp" minWidth="30" minHeight="30" onAction="#ButtonMove_Click">
|
||||
<graphic>
|
||||
<ImageView fitHeight="14.0" fitWidth="14.0" pickOnBounds="true" preserveRatio="true">
|
||||
<Image url="@/arrowUp.png"/>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="buttonDown" minWidth="30" minHeight="30" onAction="#ButtonMove_Click">
|
||||
<graphic>
|
||||
<ImageView fitHeight="14.0" fitWidth="14.0" pickOnBounds="true" preserveRatio="true">
|
||||
<Image url="@/arrowDown.png"/>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</Pane>
|
||||
</Pane>
|
@ -34,26 +34,26 @@
|
||||
-
|
||||
</Label>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Rollers:
|
||||
Oars:
|
||||
</Label>
|
||||
<ComboBox fx:id="comboBoxNumOfRollers" value="5">
|
||||
<ComboBox fx:id="comboBoxNumOars" value="1">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="4"/>
|
||||
<String fx:value="5"/>
|
||||
<String fx:value="6"/>
|
||||
<String fx:value="1"/>
|
||||
<String fx:value="2"/>
|
||||
<String fx:value="3"/>
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Ornament:
|
||||
Type:
|
||||
</Label>
|
||||
<ComboBox fx:id="comboBoxOrnamentType" value="None">
|
||||
<ComboBox fx:id="comboBoxOarsType" value="None">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="None"/>
|
||||
<String fx:value="Dots"/>
|
||||
<String fx:value="Circles"/>
|
||||
<String fx:value="Short"/>
|
||||
<String fx:value="Long"/>
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
@ -62,8 +62,7 @@
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="Simple map"/>
|
||||
<String fx:value="Green map"/>
|
||||
<String fx:value="Cross map"/>
|
||||
<String fx:value="My second map"/>
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
|
Loading…
Reference in New Issue
Block a user