Compare commits

...

8 Commits

Author SHA1 Message Date
Zyzf
09cac4779e done 2022-12-05 09:57:15 +04:00
root
9bed7a6ad8 blockquptes fix 2022-12-04 17:15:09 +04:00
root
527adad2d5 final with issues 2022-12-04 16:53:31 +04:00
root
ea1dd16b8e some added 2022-12-03 01:36:48 +04:00
Zyzf
bd8607a796 some changes 2022-11-21 11:19:46 +04:00
root
fdc7d9ab56 something 2022-11-20 18:05:13 +04:00
Zyzf
8b9754e0a4 done 2022-11-07 10:51:50 +04:00
root
f3180c1e37 final 2022-10-24 21:59:25 +04:00
35 changed files with 1592 additions and 127 deletions

View File

@ -0,0 +1,3 @@
<component name="ProjectDictionaryState">
<dictionary name="zyzf" />
</component>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>

124
.idea/uiDesigner.xml Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_19">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-controls:19-ea+7" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-controls:linux:19-ea+7" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:19-ea+7" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:linux:19-ea+7" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-base:19-ea+7" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-base:linux:19-ea+7" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:19-ea+7" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-fxml:linux:19-ea+7" level="project" />
<orderEntry type="library" name="Maven: org.controlsfx:controlsfx:11.1.1" level="project" />
<orderEntry type="library" name="Maven: com.dlsc.formsfx:formsfx-core:11.5.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.8.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.8.2" level="project" />
</component>
</module>

View File

@ -4,49 +4,27 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="3d7ff202-9cad-4078-bd8f-498ca8bb863e" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/../.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/../.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../PIbd-22_Kalyshev_Y_V_MotorBoat_Hard.iml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/../pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/Direction.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningOars.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/EntityBoat.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/FormBoat.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/HelloController.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/com/example/pibd22_kalyshev_y_v_motorboat_hard/NumberOars.java" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/java/module-info.java" beforeDir="false" afterPath="$PROJECT_DIR$/../src/main/java/module-info.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/arrowDown.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/arrowLeft.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/arrowRight.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/arrowUp.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../src/main/resources/com/example/pibd22_kalyshev_y_v_motorboat_hard/hello-view.fxml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/arrowDown.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/arrowLeft.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/arrowRight.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/arrowUp.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/Direction.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat$1.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningBoat.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningOars$1.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/DrawningOars.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/EntityBoat.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/FormBoat.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/HelloController.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/NumberOars.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/com/example/pibd22_kalyshev_y_v_motorboat_hard/hello-view.fxml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/../target/classes/module-info.class" beforeDir="false" />
</list>
<list default="true" id="2d1216e0-b7d3-4ac2-84ce-a7bb2dc057ec" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Enum" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectId" id="2GajoRqizwxNpAzsDBkYvL8dopf" />
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2GZGMEhxNuxaGk45kFR2jtFs8iE" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
@ -56,17 +34,18 @@
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true"
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.WIDTH": "590"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="3d7ff202-9cad-4078-bd8f-498ca8bb863e" name="Changes" comment="" />
<created>1666633764627</created>
<changelist id="2d1216e0-b7d3-4ac2-84ce-a7bb2dc057ec" name="Changes" comment="" />
<created>1666588645694</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1666633764627</updated>
<updated>1666588645694</updated>
</task>
<servers />
</component>

View File

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zyzf</groupId>
<groupId>com.example</groupId>
<artifactId>PIbd-22_Kalyshev_Y_V_MotorBoat_Hard</artifactId>
<version>1.0-SNAPSHOT</version>
<name>PIbd-22_Kalyshev_Y_V_MotorBoat_Hard</name>
@ -76,7 +76,7 @@
<id>default-cli</id>
<configuration>
<mainClass>
com.zyzf.pibd22_kalyshev_y_v_motorboat_hard/com.zyzf.pibd22_kalyshev_y_v_motorboat_hard.HelloApplication
com.example.pibd22_kalyshev_y_v_motorboat_hard/com.example.pibd22_kalyshev_y_v_motorboat_hard.HelloApplication
</mainClass>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>

View File

@ -0,0 +1,109 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import java.util.Random;
public abstract class AbstractMap {
private IDrawningObject _drawningObject = null;
private GraphicsContext _graphicsContext = null;
protected int[][] _map = null;
protected int _width;
protected int _height;
protected float _size_x;
protected float _size_y;
protected final Random _random = new Random();
protected final int _freeRoad = 0;
protected final int _barrier = 1;
public void CreateMap(int width, int height, IDrawningObject drawningObject, GraphicsContext gc) {
_width = width;
_height = height;
_drawningObject = drawningObject;
_graphicsContext = gc;
GenerateMap();
while (!SetObjectOnMap()) {
GenerateMap();
}
DrawMapWithObject();
}
public void MoveObject(Direction direction) {
boolean enoughPlace = false;
switch (direction) {
case Up:
enoughPlace = CheckEnoughPlace(0, (_drawningObject.GetStep() + 30) * -1);
break;
case Down:
enoughPlace = CheckEnoughPlace(0, _drawningObject.GetStep());
break;
case Left:
enoughPlace = CheckEnoughPlace(_drawningObject.GetStep() * -1, 0);
break;
case Right:
enoughPlace = CheckEnoughPlace(_drawningObject.GetStep(), 0);
break;
}
if (enoughPlace) {
_drawningObject.MoveObject(direction);
}
DrawMapWithObject();
}
private boolean SetObjectOnMap() {
if (_drawningObject == null || _map == null) {
return false;
}
int x = _random.nextInt(10);
int y = _random.nextInt(50);
_drawningObject.SetObject(x, y, _width, _height);
while (!CheckEnoughPlace(0, -40)) {
x += 10;
if (x >= _width) {
if (y <= _height) {
y += 10;
x = 0;
} else {
return false;
}
}
_drawningObject.SetObject(x, y, _width, _height);
}
return true;
}
private boolean CheckEnoughPlace(float x, float y) {
float[] position = _drawningObject.GetCurrentPosition();
float right = (position[2] + x) / _size_x > 0 ? (position[2] + x) / _size_x : 0;
float left = (position[0] + x) / _size_x > 0 ? (position[0] + x) / _size_x : 0;
float up = (position[1] + y) / _size_y > 0 ? (position[1] + y) / _size_y : 0;
float down = (position[3] + y) / _size_y > 0 ? (position[3] + y) / _size_y : 0;
if (position[3] + y > _height || position[2] + x > _width || position[1] + y < 0 || position[0] + x < 0) return false;
for (float i = left; i <= right; i+=0.5) {
for (float j = up; j <= down; j+=0.5) {
if (_map[Math.round(i)][Math.round(j)] == _barrier) {
return false;
}
}
}
return true;
}
public void DrawMapWithObject() {
if (_drawningObject == null || _map == null) {
return;
}
for (int i = 0; i < _map.length; i++) {
for (int j = 0; j < _map[i].length; j++) {
if (_map[i][j] == _freeRoad) {
DrawRoadPart(_graphicsContext, i, j);
}
else if (_map[i][j] == _barrier) {
DrawBarrierPart(_graphicsContext, i, j);
}
}
}
_drawningObject.DrawningObject(_graphicsContext);
}
protected abstract void GenerateMap();
protected abstract void DrawRoadPart(GraphicsContext gc, int i, int j);
protected abstract void DrawBarrierPart(GraphicsContext gc, int i, int j);
}

View File

@ -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 ControllerBoat {
@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 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 rootPadding = 10.0;
private DrawningBoat _boat;
@FXML
public void initialize() {
buttonCreate.setTranslateX(rootPadding);
root.widthProperty().addListener((obs, oldVal, newVal) -> {
UpdateGUI();
if (_boat != null)
{
_boat.ChangeBorders((int) canvas.getWidth(), (int) canvas.getHeight());
}
Draw();
});
root.heightProperty().addListener((obs, oldVal, newVal) -> {
UpdateGUI();
if (_boat != null) {
_boat.ChangeBorders((int) canvas.getWidth(), (int) canvas.getHeight());
}
Draw();
});
}
@FXML
void ButtonCreate_Click() {
Random rnd = new Random();
_boat = new DrawningBoat(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
SetData();
Draw();
}
@FXML
void ButtonCreateModif_Click() {
Random rnd = new Random();
_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();
Draw();
}
@FXML
void ButtonMove_Click(ActionEvent event) {
if (_boat == null) {
return;
}
String buttonName = ((Button) event.getSource()).getId();
switch (buttonName) {
case "buttonUp" -> _boat.MoveTransport(Direction.Up);
case "buttonDown" -> _boat.MoveTransport(Direction.Down);
case "buttonLeft" -> _boat.MoveTransport(Direction.Left);
case "buttonRight" -> _boat.MoveTransport(Direction.Right);
}
Draw();
}
@FXML
private void ComboBoxOrnamentType_Changed() {
if (_boat != null) {
ChangeDrawningOars();
Draw();
}
}
@FXML
private void ComboBoxNumOfRollers_Changed() {
if (_boat != null) {
_boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue()));
Draw();
}
}
private void ChangeDrawningOars() {
if (_boat != null) {
IDrawningAdditionalElement newDrawningOars = switch (comboBoxOarsType.getValue()) {
case "None" -> new DrawningOars(_boat.GetBoat().GetBodyColor());
case "Slim" -> new DrawningSlimOars(_boat.GetBoat().GetBodyColor());
case "Large" -> new DrawningLargeOars(_boat.GetBoat().GetBodyColor());
default -> null;
};
if (newDrawningOars != null) {
_boat.SetDrawningOars(newDrawningOars);
_boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue()));
}
}
}
private void UpdateGUI() {
double rootWidth = root.getWidth();
double rootHeight = root.getHeight();
double flowPaneHeight = flowPane.getHeight();
double buttonCreateHeight = buttonCreate.getHeight();
canvas.setWidth(rootWidth);
flowPane.setPrefWidth(rootWidth);
canvas.setHeight(rootHeight - flowPaneHeight);
flowPane.setTranslateY(rootHeight - flowPaneHeight);
buttonCreate.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
buttonCreateModif.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
int buttonMoveSize = 30;
int distanceBetweenButtons = 5;
buttonUp.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize * 2.0 - rootPadding -
distanceBetweenButtons);
buttonUp.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 2.0 - distanceBetweenButtons);
buttonDown.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonDown.setTranslateX(rootWidth- rootPadding - buttonMoveSize * 2.0 - distanceBetweenButtons);
buttonLeft.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonLeft.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 3.0 -
distanceBetweenButtons * 2.0);
buttonRight.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonRight.setTranslateX(rootWidth - rootPadding - buttonMoveSize);
}
private void Draw() {
GraphicsContext gc = canvas.getGraphicsContext2D();
gc.clearRect(0.0, 0.0, canvas.getWidth(), canvas.getHeight());
gc.setFill(Color.WHITE);
gc.fillRect(0.0, 0.0, canvas.getWidth(), canvas.getHeight());
gc.setStroke(Color.BLACK);
gc.setLineWidth(4);
gc.strokeRect(0.0, 0.0, canvas.getWidth(), canvas.getHeight());
if (_boat != null) {
_boat.DrawTransport(gc);
}
}
private void SetData() {
ChangeDrawningOars();
Random rnd = new Random();
_boat.SetPosition(rnd.nextInt(90) + 10, rnd.nextInt(90),
(int) canvas.getWidth(), (int) canvas.getHeight());
labelSpeedValue.setText(Integer.toString(_boat.GetBoat().GetSpeed()));
labelWeightValue.setText(Double.toString(_boat.GetBoat().GetWeight()));
labelBodyColorValue.setText(_boat.GetBoat().GetBodyColor().toString());
}
}

View File

@ -0,0 +1,153 @@
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 "Slim" -> new DrawningSlimOars(boat.GetBoat().GetBodyColor());
case "Large" -> new DrawningLargeOars(boat.GetBoat().GetBodyColor());
default -> null;
};
if (newDrawningOars != null) {
newDrawningOars.SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue()));
boat.SetDrawningOars(newDrawningOars);
}
}
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);
}
}

View File

@ -0,0 +1,23 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
public enum Direction {
Up,
Down,
Left,
Right;
public static Direction FromInteger(int intValue) {
switch(intValue) {
case 1:
return Up;
case 2:
return Down;
case 3:
return Left;
case 4:
return Right;
default:
System.out.println("Error: incorrect value for enum");
return Up;
}
}
}

View File

@ -0,0 +1,123 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class DrawningBoat {
private EntityBoat _boat;
private IDrawningAdditionalElement _drawningOars;
protected float _startPosX;
protected float _startPosY;
private Integer _pictureWidth;
private Integer _pictureHeight;
private int _boatWidth = 170;
private int _boatHeight = 60;
public EntityBoat GetBoat()
{
return _boat;
}
protected void SetBoat(EntityBoat boat)
{
_boat = boat;
}
public IDrawningAdditionalElement GetDrawningOars() {
return _drawningOars;
}
public void SetDrawningOars(IDrawningAdditionalElement drawningOars)
{
_drawningOars = drawningOars;
}
public DrawningBoat(int speed, float weight, Color bodyColor) {
_boat = new EntityBoat(speed, weight, bodyColor);
_drawningOars = new DrawningOars(bodyColor);
}
protected DrawningBoat(int speed, float weight, Color bodyColor, int boatWidth, int boatHeight) {
this(speed, weight, bodyColor);
_boatHeight = boatHeight;
_boatWidth = boatWidth;
}
public void SetPosition(int x, int y, int width, int height) {
if (x < 0 || y < 0) {
return;
}
if (x + _boatWidth > width || y + _drawningOars.deltaYdown + _boatHeight > height) {
return;
}
_startPosX = x;
_startPosY = y;
_pictureWidth = width;
_pictureHeight = height;
}
public void MoveTransport(Direction direction) {
if (_pictureWidth == null || _pictureHeight == null) {
return;
}
switch (direction) {
case Up:
if (_startPosY - _boat.GetStep() - _drawningOars.deltaYup > 0) {
_startPosY -= _boat.GetStep();
}
break;
case Down:
if (_startPosY + _boatHeight + _boat.GetStep() + _drawningOars.deltaYdown < _pictureHeight) {
_startPosY += _boat.GetStep();
}
break;
case Left:
if (_startPosX - _boat.GetStep() > 0) {
_startPosX -= _boat.GetStep();
}
break;
case Right:
if (_startPosX + _boatWidth + _boat.GetStep() < _pictureWidth) {
_startPosX += _boat.GetStep();
}
break;
default:
break;
}
}
public void DrawTransport(GraphicsContext gc) {
if (_startPosX < 0 || _startPosY < 0 || _pictureWidth == null || _pictureHeight == null) {
return;
}
_startPosY += 40;
// Корпус
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.setFill(_boat.GetBodyColor());
gc.fillPolygon(new double[] {_startPosX, _startPosX+120, _startPosX+170, _startPosX+120, _startPosX, _startPosX},
new double[] {_startPosY, _startPosY, _startPosY+30, _startPosY+60, _startPosY+60, _startPosY}, 6);
gc.strokePolyline(new double[] {_startPosX, _startPosX+120, _startPosX+170, _startPosX+120, _startPosX, _startPosX},
new double[] {_startPosY, _startPosY, _startPosY+30, _startPosY+60, _startPosY+60, _startPosY}, 6);
// Седло
gc.setFill(Color.BROWN);
gc.fillOval(_startPosX+10, _startPosY+10, 110, 40);
_startPosY -= 40;
_drawningOars.DrawOars(gc, _startPosX, _startPosY);
}
public void ChangeBorders(int width, int height) {
_pictureWidth = width;
_pictureHeight = height;
if (_pictureWidth <= _boatWidth || _pictureHeight <= _boatHeight) {
_pictureWidth = null;
_pictureHeight = null;
return;
}
if (_startPosX + _boatWidth > _pictureWidth) {
_startPosX = _pictureWidth - _boatWidth;
}
if (_startPosY + _boatHeight > _pictureHeight) {
_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;
}
}

View File

@ -0,0 +1,73 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class DrawningLargeOars implements IDrawningAdditionalElement {
private Color _OarsColor;
private NumberOars _numOars;
public void SetNumberOars(int numberOars) {
_numOars = NumberOars.FromInteger(numberOars);
}
public int deltaYdown = 0;
public int deltaYup = 0;
public DrawningLargeOars(Color oarsColor)
{
_OarsColor = oarsColor;
}
public void DrawOars(GraphicsContext gc, float startPosX, float startPosY) {
if (_OarsColor == null) {
return;
}
gc.setFill(_OarsColor);
switch (_numOars) {
case One:
DrawOar1(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
case Two:
DrawOar1(gc, startPosX, startPosY);
DrawOar2(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
case Three:
DrawOar1(gc, startPosX, startPosY);
DrawOar2(gc, startPosX, startPosY);
DrawOar3(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
}
}
void DrawOar1(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX + 50, startPosX + 70, startPosX + 60, startPosX + 60, startPosX + 90, startPosX + 90, startPosX + 80, startPosX + 60, startPosX + 50},
new double[]{startPosY + 60, startPosY + 20, startPosY + 20, startPosY, startPosY, startPosY + 20, startPosY + 20, startPosY + 60, startPosY + 60}, 9);
gc.fillPolygon(new double[]{startPosX + 50, startPosX + 70, startPosX + 60, startPosX + 60, startPosX + 90, startPosX + 90, startPosX + 80, startPosX + 60, startPosX + 50},
new double[]{startPosY + 60, startPosY + 20, startPosY + 20, startPosY, startPosY, startPosY + 20, startPosY + 20, startPosY + 60, startPosY + 60}, 9);
}
void DrawOar2(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX+50, startPosX+30, startPosX+20, startPosX+20, startPosX+50, startPosX+50, startPosX+40, startPosX+60, startPosX+50},
new double[]{startPosY+80, startPosY+120, startPosY+120, startPosY+140, startPosY+140, startPosY+120, startPosY+120, startPosY+80, startPosY+80}, 9);
gc.fillPolygon(new double[]{startPosX+50, startPosX+30, startPosX+20, startPosX+20, startPosX+50, startPosX+50, startPosX+40, startPosX+60, startPosX+50},
new double[]{startPosY+80, startPosY+120, startPosY+120, startPosY+140, startPosY+140, startPosY+120, startPosY+120, startPosY+80, startPosY+80}, 9);
}
void DrawOar3(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX+20, startPosX+20, startPosX+10, startPosX+10, startPosX+40, startPosX+40, startPosX+30, startPosX+30, startPosX+20},
new double[]{startPosY+80, startPosY+30, startPosY+30, startPosY+10, startPosY+10, startPosY+30, startPosY+30, startPosY+80, startPosY+80}, 9);
gc.fillPolygon(new double[]{startPosX+20, startPosX+20, startPosX+10, startPosX+10, startPosX+40, startPosX+40, startPosX+30, startPosX+30, startPosX+20},
new double[]{startPosY+80, startPosY+30, startPosY+30, startPosY+10, startPosY+10, startPosY+30, startPosY+30, startPosY+80, startPosY+80}, 9);
}
}

View File

@ -0,0 +1,75 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class DrawningOars implements IDrawningAdditionalElement{
private Color _OarsColor;
private NumberOars _numOars;
public void SetNumberOars(int numberOars) {
_numOars = NumberOars.FromInteger(numberOars);
}
public int deltaYdown = 0;
public int deltaYup = 0;
public DrawningOars(Color oarsColor)
{
_OarsColor = oarsColor;
}
public void DrawOars(GraphicsContext gc, float startPosX, float startPosY) {
if (_OarsColor == null) {
return;
}
gc.setFill(_OarsColor);
switch (_numOars) {
case One:
DrawOar1(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
case Two:
DrawOar1(gc, startPosX, startPosY);
DrawOar2(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
case Three:
DrawOar1(gc, startPosX, startPosY);
DrawOar2(gc, startPosX, startPosY);
DrawOar3(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
}
}
void DrawOar1(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX + 50, startPosX + 70, startPosX + 70, startPosX + 80, startPosX + 90, startPosX + 80, startPosX + 60, startPosX + 50},
new double[]{startPosY + 60, startPosY + 20, startPosY + 10, startPosY, startPosY + 10, startPosY + 20, startPosY + 60, startPosY + 60}, 8);
gc.fillPolygon(new double[]{startPosX + 50, startPosX + 70, startPosX + 70, startPosX + 80, startPosX + 90, startPosX + 80, startPosX + 60, startPosX + 50},
new double[]{startPosY + 60, startPosY + 20, startPosY + 10, startPosY, startPosY + 10, startPosY + 20, startPosY + 60, startPosY + 60}, 8);
}
void DrawOar2(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX+50, startPosX+30, startPosX+20, startPosX+30, startPosX+40, startPosX+40, startPosX+60, startPosX+50},
new double[]{startPosY+80, startPosY+120, startPosY+130, startPosY+140, startPosY+130, startPosY+120, startPosY+80, startPosY+80}, 8);
gc.fillPolygon(new double[]{startPosX+50, startPosX+30, startPosX+20, startPosX+30, startPosX+40, startPosX+40, startPosX+60, startPosX+50},
new double[]{startPosY+80, startPosY+120, startPosY+130, startPosY+140, startPosY+130, startPosY+120, startPosY+80, startPosY+80}, 8);
}
void DrawOar3(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX+90, startPosX+100, startPosX+100, startPosX+100, startPosX+110, startPosX+100, startPosX+90, startPosX+90},
new double[]{startPosY+90, startPosY+90, startPosY+30, startPosY+40, startPosY+30, startPosY+20, startPosY+30, startPosY+90}, 8);
gc.fillPolygon(new double[]{startPosX+90, startPosX+100, startPosX+100, startPosX+100, startPosX+110, startPosX+100, startPosX+90, startPosX+90},
new double[]{startPosY+90, startPosY+90, startPosY+30, startPosY+40, startPosY+30, startPosY+20, startPosY+30, startPosY+90}, 8);
}
}

View File

@ -0,0 +1,37 @@
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 IDrawningAdditionalElement GetDrawningOars() {return _boat.GetDrawningOars();}
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);
}
}
}

View File

@ -0,0 +1,74 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class DrawningSlimOars implements IDrawningAdditionalElement {
private Color _OarsColor;
private NumberOars _numOars;
public void SetNumberOars(int numberOars)
{
_numOars = NumberOars.FromInteger(numberOars);
}
public int deltaYdown = 0;
public int deltaYup = 0;
public DrawningSlimOars(Color oarsColor)
{
_OarsColor = oarsColor;
}
public void DrawOars(GraphicsContext gc, float startPosX, float startPosY) {
if (_OarsColor == null) {
return;
}
gc.setFill(_OarsColor);
switch (_numOars) {
case One:
DrawOar1(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
case Two:
DrawOar1(gc, startPosX, startPosY);
DrawOar2(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
case Three:
DrawOar1(gc, startPosX, startPosY);
DrawOar2(gc, startPosX, startPosY);
DrawOar3(gc, startPosX, startPosY);
deltaYup = 80;
deltaYdown = 80;
break;
}
}
void DrawOar1(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX + 50, startPosX + 70, startPosX + 70, startPosX + 80, startPosX + 80, startPosX + 60, startPosX + 50},
new double[]{startPosY + 60, startPosY + 20, startPosY, startPosY, startPosY + 20, startPosY + 60, startPosY + 60}, 7);
gc.fillPolygon(new double[]{startPosX + 50, startPosX + 70, startPosX + 70, startPosX + 80, startPosX + 80, startPosX + 60, startPosX + 50},
new double[]{startPosY + 60, startPosY + 20, startPosY, startPosY, startPosY + 20, startPosY + 60, startPosY + 60}, 7);
}
void DrawOar2(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX+50, startPosX+30, startPosX+30, startPosX+40, startPosX+40, startPosX+60, startPosX+50},
new double[]{startPosY+80, startPosY+120, startPosY+140, startPosY+140, startPosY+120, startPosY+80, startPosY+80}, 7);
gc.fillPolygon(new double[]{startPosX+50, startPosX+30, startPosX+30, startPosX+40, startPosX+40, startPosX+60, startPosX+50},
new double[]{startPosY+80, startPosY+120, startPosY+140, startPosY+140, startPosY+120, startPosY+80, startPosY+80}, 7);
}
void DrawOar3(GraphicsContext gc, float startPosX, float startPosY) {
gc.setFill(_OarsColor);
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
gc.strokePolyline(new double[]{startPosX+20, startPosX+20, startPosX+30, startPosX+30, startPosX+20},
new double[]{startPosY+80, startPosY+10, startPosY+10, startPosY+80, startPosY+80}, 5);
gc.fillPolygon(new double[]{startPosX+20, startPosX+20, startPosX+30, startPosX+30, startPosX+20},
new double[]{startPosY+80, startPosY+10, startPosY+10, startPosY+80, startPosY+80}, 5);
}
}

View File

@ -0,0 +1,77 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class DrawningSpeedboat extends DrawningBoat {
public DrawningSpeedboat(int speed, float weight, Color bodyColor, Color dopColor, boolean bodyKit, boolean wing, boolean sportLine) {
super(speed, weight, bodyColor, 195, 80);
SetBoat(new EntitySpeedboat(speed, weight, bodyColor, dopColor, bodyKit, wing, sportLine));
}
@Override
public void DrawTransport(GraphicsContext gc) {
if (!(GetBoat() instanceof EntitySpeedboat speedboat)) {
return;
}
gc.setStroke(Color.BLACK);
gc.setLineWidth(2);
_startPosX += 25;
_startPosY -= 30;
super.DrawTransport(gc);
_startPosX -= 25;
_startPosY += 30;
if (speedboat.GetWing()) {
gc.setFill(speedboat.GetDopColor());
gc.fillRect(_startPosX, _startPosY, 20, 80);
gc.strokeRect(_startPosX, _startPosY, 20, 80);
gc.setFill(speedboat.GetBodyColor());
gc.fillRect(_startPosX + 20, _startPosY + 20, 10, 40);
gc.strokeRect(_startPosX + 20, _startPosY + 20, 10, 40);
}
_startPosX += 25;
_startPosY += 10;
if (speedboat.GetBodyKit()) {
double[] bodyKitX = {
_startPosX + 120,
_startPosX + 155,
_startPosX + 120,
_startPosX + 120,
_startPosX + 145,
_startPosX + 120
};
double[] bodyKitY = {
_startPosY + 10,
_startPosY + 30,
_startPosY + 50,
_startPosY + 45,
_startPosY + 30,
_startPosY + 15
};
gc.setFill(speedboat.GetDopColor());
gc.fillPolygon(bodyKitX, bodyKitY, 6);
}
if (speedboat.GetSportLine()) {
double[] sportLineX = {
_startPosX + 70,
_startPosX + 80,
_startPosX + 120,
_startPosX + 110
};
double[] sportLineY = {
_startPosY,
_startPosY,
_startPosY + 60,
_startPosY + 60
};
gc.setFill(speedboat.GetDopColor());
gc.fillPolygon(sportLineX, sportLineY, 4);
gc.setFill(Color.BROWN);
gc.fillOval(_startPosX + 10, _startPosY + 10, 110, 40);
}
_startPosX -= 25;
_startPosY -= 10;
}
}

View File

@ -0,0 +1,32 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.paint.Color;
import java.util.Random;
public class EntityBoat {
private int _speed;
private float _weight;
private Color _bodyColor;
public int GetSpeed()
{
return _speed;
}
public float GetWeight()
{
return _weight;
}
public Color GetBodyColor()
{
return _bodyColor;
}
public float GetStep()
{
return _speed * 100 / _weight;
}
public EntityBoat(int speed, float weight, Color bodyColor) {
Random random = new Random();
_speed = speed <= 0 ? random.nextInt(5) + 25 : speed;
_weight = weight <= 0 ? random.nextInt(30) + 70 : weight;
_bodyColor = bodyColor;
}
}

View File

@ -0,0 +1,29 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.paint.Color;
public class EntitySpeedboat extends EntityBoat {
private final Color _dopColor;
private final boolean _bodyKit;
private final boolean _wing;
private final boolean _sportLine;
public Color GetDopColor() {
return _dopColor;
}
public boolean GetBodyKit() {
return _bodyKit;
}
public boolean GetWing() {
return _wing;
}
public boolean GetSportLine() {
return _sportLine;
}
public EntitySpeedboat(int speed, float weight, Color bodyColor, Color dopColor, boolean bodyKit, boolean wing, boolean sportLine) {
super(speed, weight, bodyColor);
_dopColor = dopColor;
_bodyKit = bodyKit;
_wing = wing;
_sportLine = sportLine;
}
}

View File

@ -0,0 +1,74 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.Button;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.io.IOException;
public class FormBoat extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(FormBoat.class.getResource("form-boat-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setTitle("Boat");
stage.setScene(scene);
FirstUpdateGUI(scene);
stage.show();
}
private void FirstUpdateGUI(Scene scene) {
Pane root = (Pane)scene.lookup("#root");
Canvas canvas = (Canvas)scene.lookup("#canvas");
Button buttonCreate = (Button)scene.lookup("#buttonCreate");
Button buttonCreateModif = (Button)scene.lookup("#buttonCreateModif");
Button buttonUp = (Button)scene.lookup("#buttonUp");
Button buttonLeft = (Button)scene.lookup("#buttonLeft");
Button buttonRight = (Button)scene.lookup("#buttonRight");
Button buttonDown = (Button)scene.lookup("#buttonDown");
FlowPane flowPane = (FlowPane)scene.lookup("#flowPane");
root.applyCss();
root.layout();
double flowPaneHeight = flowPane.getHeight();
double buttonCreateHeight = buttonCreate.getHeight();
double buttonCreateWidth = buttonCreate.getWidth();
double rootWidth = root.getWidth();
double rootHeight = root.getHeight();
double rootPadding = 10.0;
double distanceBetweenButtons = 5.0;
double buttonMoveSize = 30.0;
canvas.setWidth(rootWidth);
flowPane.setPrefWidth(rootWidth);
canvas.setHeight(rootHeight - flowPaneHeight);
flowPane.setTranslateY(rootHeight - flowPaneHeight);
buttonCreateModif.setTranslateX(rootPadding + buttonCreateWidth + distanceBetweenButtons);
buttonCreate.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
buttonCreateModif.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
buttonUp.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize * 2.0 - rootPadding -
distanceBetweenButtons);
buttonUp.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 2.0 - distanceBetweenButtons);
buttonDown.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonDown.setTranslateX(rootWidth- rootPadding - buttonMoveSize * 2.0 - distanceBetweenButtons);
buttonLeft.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonLeft.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 3.0 - distanceBetweenButtons * 2.0);
buttonRight.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonRight.setTranslateX(rootWidth - rootPadding - buttonMoveSize);
}
public static void main(String[] args)
{
launch();
}
}

View File

@ -0,0 +1,75 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.Button;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.io.IOException;
public class FormMap extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(FormMap.class.getResource("form-map-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 800, 800);
stage.setTitle("Map");
stage.setScene(scene);
FirstUpdateGUI(scene);
stage.show();
}
private void FirstUpdateGUI(Scene scene) {
Pane root = (Pane)scene.lookup("#root");
Canvas canvas = (Canvas)scene.lookup("#canvas");
Button buttonCreate = (Button)scene.lookup("#buttonCreate");
Button buttonCreateModif = (Button)scene.lookup("#buttonCreateModif");
Button buttonUp = (Button)scene.lookup("#buttonUp");
Button buttonLeft = (Button)scene.lookup("#buttonLeft");
Button buttonRight = (Button)scene.lookup("#buttonRight");
Button buttonDown = (Button)scene.lookup("#buttonDown");
FlowPane flowPane = (FlowPane)scene.lookup("#flowPane");
root.applyCss();
root.layout();
double flowPaneHeight = flowPane.getHeight();
double buttonCreateHeight = buttonCreate.getHeight();
double buttonCreateWidth = buttonCreate.getWidth();
double rootWidth = root.getWidth();
double rootHeight = root.getHeight();
double rootPadding = 10.0;
double distanceBetweenButtons = 5.0;
double buttonMoveSize = 30.0;
canvas.setWidth(rootWidth);
flowPane.setPrefWidth(rootWidth);
canvas.setHeight(rootHeight - flowPaneHeight);
flowPane.setTranslateY(rootHeight - flowPaneHeight);
buttonCreateModif.setTranslateX(rootPadding + buttonCreateWidth + distanceBetweenButtons);
buttonCreate.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
buttonCreateModif.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
buttonUp.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize * 2.0 - rootPadding -
distanceBetweenButtons);
buttonUp.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 2.0 - distanceBetweenButtons);
buttonDown.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonDown.setTranslateX(rootWidth- rootPadding - buttonMoveSize * 2.0 - distanceBetweenButtons);
buttonLeft.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonLeft.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 3.0 - distanceBetweenButtons * 2.0);
buttonRight.setTranslateY(rootHeight - flowPaneHeight - buttonMoveSize - rootPadding);
buttonRight.setTranslateX(rootWidth - rootPadding - buttonMoveSize);
}
public static void main(String[] args)
{
launch();
}
}

View File

@ -0,0 +1,10 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
public interface IDrawningAdditionalElement {
public int deltaYdown = 0;
public int deltaYup = 0;
public void SetNumberOars(int numberOars);
public void DrawOars(GraphicsContext gc, float startPosX, float startPosY);
}

View File

@ -0,0 +1,12 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
public interface IDrawningObject {
public float GetStep();
public IDrawningAdditionalElement GetDrawningOars();
public void SetObject(int x, int y, int width, int height);
public void MoveObject(Direction direction);
public void DrawningObject(GraphicsContext gc);
public float[] GetCurrentPosition();
}

View File

@ -0,0 +1,34 @@
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++;
}
}
}
}

View File

@ -0,0 +1,21 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
public enum NumberOars
{
One,
Two,
Three;
public static NumberOars FromInteger(int intValue) {
switch(intValue) {
case 1:
return One;
case 2:
return Two;
case 3:
return Three;
default:
System.out.println("Error: incorrect value for enum");
return One;
}
}
}

View File

@ -0,0 +1,34 @@
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
public class SimpleMap extends AbstractMap {
protected void DrawBarrierPart(GraphicsContext gc, int i, int j) {
gc.setFill(Color.BLACK);
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.GRAY);
gc.fillRect(i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
}
protected void GenerateMap() {
_map = new int[100][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 < 50) {
int x = _random.nextInt(0, 100);
int y = _random.nextInt(0, 100);
if (_map[x][y] == _freeRoad) {
_map[x][y] = _barrier;
counter++;
}
}
}
}

View File

@ -1,23 +0,0 @@
package com.zyzf.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import java.io.IOException;
public class HelloApplication extends Application {
@Override
public void start(Stage stage) throws IOException {
FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("hello-view.fxml"));
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
stage.setTitle("Hello!");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch();
}
}

View File

@ -1,14 +0,0 @@
package com.zyzf.pibd22_kalyshev_y_v_motorboat_hard;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
public class HelloController {
@FXML
private Label welcomeText;
@FXML
protected void onHelloButtonClick() {
welcomeText.setText("Welcome to JavaFX Application!");
}
}

View File

@ -1,10 +1,10 @@
module com.zyzf.pibd22_kalyshev_y_v_motorboat_hard {
module com.example.pibd22_kalyshev_y_v_motorboat_hard {
requires javafx.controls;
requires javafx.fxml;
requires org.controlsfx.controls;
requires com.dlsc.formsfx;
opens com.zyzf.pibd22_kalyshev_y_v_motorboat_hard to javafx.fxml;
exports com.zyzf.pibd22_kalyshev_y_v_motorboat_hard;
opens com.example.pibd22_kalyshev_y_v_motorboat_hard to javafx.fxml;
exports com.example.pibd22_kalyshev_y_v_motorboat_hard;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

View File

@ -0,0 +1,96 @@
<?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="comboBoxNumOars" value="5" onAction="#ComboBoxNumOfRollers_Changed">
<items>
<FXCollections fx:factory="observableArrayList">
<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="comboBoxOarsType" value="None" onAction="#ComboBoxOrnamentType_Changed">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="None"/>
<String fx:value="Slim"/>
<String fx:value="Large"/>
</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>

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.collections.*?>
<?import javafx.scene.canvas.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<Pane fx:id="root" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.pibd22_kalyshev_y_v_motorboat_hard.ControllerMap">
<Canvas fx:id="canvas" height="400.0" width="400.0">
</Canvas>
<FlowPane fx:id="flowPane" style="-fx-background-color: #31374c;">
<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;">
Oars:
</Label>
<ComboBox fx:id="comboBoxNumOars" value="1">
<items>
<FXCollections fx:factory="observableArrayList">
<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;">
Type:
</Label>
<ComboBox fx:id="comboBoxOarsType" value="None">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="None" />
<String fx:value="Slim" />
<String fx:value="Large" />
</FXCollections>
</items>
</ComboBox>
</FlowPane>
<ComboBox fx:id="comboBoxSelectorMap" onAction="#ComboBoxSelectorMap_Changed" value="Simple map">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="Simple map" />
<String fx:value="My second map" />
</FXCollections>
</items>
</ComboBox>
<Button fx:id="buttonCreate" onAction="#ButtonCreate_Click">
Create
</Button>
<Button fx:id="buttonCreateModif" onAction="#ButtonCreateModif_Click">
Modification
</Button>
<Button fx:id="buttonLeft" minHeight="30" minWidth="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" minHeight="30" minWidth="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" minHeight="30" minWidth="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" minHeight="30" minWidth="30" onAction="#ButtonMove_Click">
<graphic>
<ImageView fitHeight="14.0" fitWidth="14.0" pickOnBounds="true" preserveRatio="true">
<Image url="@/arrowDown.png" />
</ImageView>
</graphic>
</Button>
</Pane>

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.control.Button?>
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
fx:controller="com.zyzf.pibd22_kalyshev_y_v_motorboat_hard.HelloController">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
</padding>
<Label fx:id="welcomeText"/>
<Button text="Hello!" onAction="#onHelloButtonClick"/>
</VBox>