Compare commits
No commits in common. "Laba3" and "master" have entirely different histories.
3
.idea/dictionaries/zyzf.xml
generated
3
.idea/dictionaries/zyzf.xml
generated
@ -1,3 +0,0 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="zyzf" />
|
||||
</component>
|
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -1,6 +1,5 @@
|
||||
<?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
generated
124
.idea/uiDesigner.xml
generated
@ -1,124 +0,0 @@
|
||||
<?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>
|
30
PIbd-22_Kalyshev_Y_V_MotorBoat_Hard.iml
Normal file
30
PIbd-22_Kalyshev_Y_V_MotorBoat_Hard.iml
Normal file
@ -0,0 +1,30 @@
|
||||
<?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>
|
@ -4,27 +4,49 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="2d1216e0-b7d3-4ac2-84ce-a7bb2dc057ec" name="Changes" comment="" />
|
||||
<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>
|
||||
<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="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectId" id="2GZGMEhxNuxaGk45kFR2jtFs8iE" />
|
||||
<component name="ProjectId" id="2GajoRqizwxNpAzsDBkYvL8dopf" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
@ -34,18 +56,17 @@
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.WIDTH": "590"
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true"
|
||||
}
|
||||
}]]></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="2d1216e0-b7d3-4ac2-84ce-a7bb2dc057ec" name="Changes" comment="" />
|
||||
<created>1666588645694</created>
|
||||
<changelist id="3d7ff202-9cad-4078-bd8f-498ca8bb863e" name="Changes" comment="" />
|
||||
<created>1666633764627</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1666588645694</updated>
|
||||
<updated>1666633764627</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
4
pom.xml
4
pom.xml
@ -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.example</groupId>
|
||||
<groupId>com.zyzf</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.example.pibd22_kalyshev_y_v_motorboat_hard/com.example.pibd22_kalyshev_y_v_motorboat_hard.HelloApplication
|
||||
com.zyzf.pibd22_kalyshev_y_v_motorboat_hard/com.zyzf.pibd22_kalyshev_y_v_motorboat_hard.HelloApplication
|
||||
</mainClass>
|
||||
<launcher>app</launcher>
|
||||
<jlinkZipName>app</jlinkZipName>
|
||||
|
@ -1,109 +0,0 @@
|
||||
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);
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
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.ColorPicker;
|
||||
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 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;
|
||||
@FXML
|
||||
private Button buttonSelectBoat;
|
||||
@FXML
|
||||
private ColorPicker bodyColorPicker;
|
||||
@FXML
|
||||
private ColorPicker dopColorPicker;
|
||||
private final double rootPadding = 10.0;
|
||||
private DrawningBoat _boat;
|
||||
private boolean bodyColorPickerChanged = false;
|
||||
private boolean dopColorPickerChanged = false;
|
||||
public DrawningBoat GetSelectedBoat()
|
||||
{
|
||||
return _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();
|
||||
if (!bodyColorPickerChanged) {
|
||||
bodyColorPicker.setValue(Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
}
|
||||
_boat = new DrawningBoat(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||
bodyColorPicker.getValue());
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
@FXML
|
||||
void ButtonCreateModif_Click() {
|
||||
Random rnd = new Random();
|
||||
if (!bodyColorPickerChanged) {
|
||||
bodyColorPicker.setValue(Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
}
|
||||
if (!dopColorPickerChanged) {
|
||||
dopColorPicker.setValue(Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
}
|
||||
_boat = new DrawningSpeedboat(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||
bodyColorPicker.getValue(),
|
||||
dopColorPicker.getValue(),
|
||||
(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 ComboBoxType_Changed() {
|
||||
if (_boat != null) {
|
||||
ChangeDrawningOars();
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
@FXML
|
||||
private void ComboBoxNumOars_Changed() {
|
||||
if (_boat != null) {
|
||||
_boat.GetDrawningOars().SetNumberOars(Integer.parseInt(comboBoxNumOars.getValue()));
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
@FXML
|
||||
private void BodyColorPicker_Changed()
|
||||
{
|
||||
bodyColorPickerChanged = true;
|
||||
}
|
||||
@FXML
|
||||
private void DopColorPicker_Changed()
|
||||
{
|
||||
dopColorPickerChanged = true;
|
||||
}
|
||||
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);
|
||||
|
||||
buttonSelectBoat.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
|
||||
buttonSelectBoat.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 3.0 -
|
||||
distanceBetweenButtons * 3.0 - buttonSelectBoat.getWidth());
|
||||
}
|
||||
private void Draw() {
|
||||
GraphicsContext gc = canvas.getGraphicsContext2D();
|
||||
gc.clearRect(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()));
|
||||
}
|
||||
}
|
@ -1,243 +0,0 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Stack;
|
||||
|
||||
public class ControllerMapWithSetBoats {
|
||||
@FXML
|
||||
private Pane root;
|
||||
@FXML
|
||||
private Canvas canvas;
|
||||
@FXML
|
||||
private Pane paneRight;
|
||||
@FXML
|
||||
private Label labelTools;
|
||||
@FXML
|
||||
private ComboBox<String> comboBoxSelectorMap;
|
||||
@FXML
|
||||
private Button buttonAddBoat;
|
||||
@FXML
|
||||
private TextField textFieldPosition;
|
||||
@FXML
|
||||
private Button buttonLeft;
|
||||
@FXML
|
||||
private Button buttonRight;
|
||||
@FXML
|
||||
private Button buttonUp;
|
||||
@FXML
|
||||
private Button buttonDown;
|
||||
private MapWithSetBoatsGeneric<DrawningObjectBoat, AbstractMap> _mapBoatsCollectionGeneric;
|
||||
@FXML
|
||||
public void initialize() {
|
||||
textFieldPosition.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
if (Objects.equals(newValue, "")) {
|
||||
return;
|
||||
}
|
||||
if (newValue.length() > 2) {
|
||||
String s = newValue.substring(0, 2);
|
||||
textFieldPosition.setText(s);
|
||||
}
|
||||
if (!newValue.matches("[0-9]+")) {
|
||||
textFieldPosition.setText(oldValue);
|
||||
}
|
||||
});
|
||||
|
||||
root.widthProperty().addListener((obs, oldVal, newVal) -> {
|
||||
UpdateGUI();
|
||||
});
|
||||
|
||||
root.heightProperty().addListener((obs, oldVal, newVal) -> {
|
||||
UpdateGUI();
|
||||
});
|
||||
}
|
||||
@FXML
|
||||
public void ComboBoxSelectorMap_Changed() {
|
||||
AbstractMap map = switch (comboBoxSelectorMap.getValue()) {
|
||||
case "Simple map" -> new SimpleMap();
|
||||
case "My second map" -> new MySecondMap();
|
||||
default -> null;
|
||||
};
|
||||
if (map != null) {
|
||||
_mapBoatsCollectionGeneric = new MapWithSetBoatsGeneric<DrawningObjectBoat, AbstractMap>(
|
||||
(int)canvas.getWidth(), (int)canvas.getHeight(), map, DrawningObjectBoat.class, canvas.getGraphicsContext2D());
|
||||
} else {
|
||||
_mapBoatsCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
@FXML
|
||||
public void ButtonAddBoat_Click() throws IOException {
|
||||
if (_mapBoatsCollectionGeneric == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Stage stageBoat = new Stage();
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(FormBoat.class.getResource("form-boat-view.fxml"));
|
||||
Scene sceneBoat = new Scene(fxmlLoader.load(), 500, 400);
|
||||
|
||||
FirstUpdateBoatGUI(sceneBoat, stageBoat, fxmlLoader);
|
||||
|
||||
stageBoat.setTitle("Boat");
|
||||
stageBoat.setScene(sceneBoat);
|
||||
stageBoat.show();
|
||||
}
|
||||
@FXML
|
||||
private void ButtonRemoveBoat_Click() {
|
||||
String stringPosition = textFieldPosition.getText();
|
||||
if (stringPosition == null || stringPosition.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Alert removeAlert = new Alert(Alert.AlertType.CONFIRMATION, "Remove object?", ButtonType.YES, ButtonType.NO);
|
||||
removeAlert.showAndWait();
|
||||
|
||||
Alert infoAlert;
|
||||
if (removeAlert.getResult() == ButtonType.YES) {
|
||||
int pos = Integer.parseInt(stringPosition);
|
||||
if (_mapBoatsCollectionGeneric.Delete(pos) != null) {
|
||||
infoAlert = new Alert(Alert.AlertType.INFORMATION, "Object removed", ButtonType.OK);
|
||||
_mapBoatsCollectionGeneric.ShowSet();
|
||||
} else {
|
||||
infoAlert = new Alert(Alert.AlertType.INFORMATION, "Failed to remove object", ButtonType.OK);
|
||||
}
|
||||
} else {
|
||||
infoAlert = new Alert(Alert.AlertType.INFORMATION, "Remove operation canceled", ButtonType.OK);
|
||||
}
|
||||
infoAlert.showAndWait();
|
||||
}
|
||||
@FXML
|
||||
private void ButtonShowStorage_Click() {
|
||||
if (_mapBoatsCollectionGeneric == null) {
|
||||
return;
|
||||
}
|
||||
_mapBoatsCollectionGeneric.ShowSet();
|
||||
}
|
||||
@FXML
|
||||
private void ButtonShowOnMap_Click() {
|
||||
if (_mapBoatsCollectionGeneric == null) {
|
||||
return;
|
||||
}
|
||||
_mapBoatsCollectionGeneric.ShowOnMap();
|
||||
}
|
||||
@FXML
|
||||
private void ButtonMove_Click(ActionEvent event) {
|
||||
if (_mapBoatsCollectionGeneric == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String buttonName = ((Button) event.getSource()).getId();
|
||||
Direction dir = switch (buttonName) {
|
||||
case "buttonUp" -> Direction.Up;
|
||||
case "buttonDown" -> Direction.Down;
|
||||
case "buttonLeft" -> Direction.Left;
|
||||
case "buttonRight" -> Direction.Right;
|
||||
default -> Direction.None;
|
||||
};
|
||||
_mapBoatsCollectionGeneric.MoveObject(dir);
|
||||
}
|
||||
private void UpdateGUI() {
|
||||
double rootWidth = root.getWidth();
|
||||
double rootHeight = root.getHeight();
|
||||
double rightPaneWidth = paneRight.getWidth();
|
||||
|
||||
canvas.setWidth(rootWidth - rightPaneWidth);
|
||||
canvas.setHeight(rootHeight);
|
||||
|
||||
paneRight.setTranslateX(rootWidth - rightPaneWidth);
|
||||
paneRight.setPrefHeight(rootHeight);
|
||||
|
||||
int _distanceBetweenMoveButtons = 5;
|
||||
double moveButtonsSize = 30.0;
|
||||
double moveButtonsXMargin = (rightPaneWidth - moveButtonsSize * 3.0 - _distanceBetweenMoveButtons * 2.0) / 2.0;
|
||||
|
||||
int rightPaneMargin = 5;
|
||||
buttonUp.setTranslateY(rootHeight - moveButtonsSize * 2.0 - _distanceBetweenMoveButtons - rightPaneMargin);
|
||||
buttonUp.setTranslateX(rootWidth - moveButtonsSize * 2.0 - moveButtonsXMargin - _distanceBetweenMoveButtons);
|
||||
|
||||
buttonDown.setTranslateY(rootHeight - moveButtonsSize - rightPaneMargin);
|
||||
buttonDown.setTranslateX(rootWidth - moveButtonsSize * 2.0 - moveButtonsXMargin - _distanceBetweenMoveButtons);
|
||||
|
||||
buttonLeft.setTranslateY(rootHeight - moveButtonsSize - rightPaneMargin);
|
||||
buttonLeft.setTranslateX(rootWidth - moveButtonsSize * 3.0 - moveButtonsXMargin - _distanceBetweenMoveButtons * 2.0);
|
||||
|
||||
buttonRight.setTranslateY(rootHeight - moveButtonsSize - rightPaneMargin);
|
||||
buttonRight.setTranslateX(rootWidth - moveButtonsSize - moveButtonsXMargin);
|
||||
}
|
||||
private void FirstUpdateBoatGUI(Scene scene, Stage stageBoat, FXMLLoader fxmlLoader) {
|
||||
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");
|
||||
Button buttonSelectBoat = (Button) scene.lookup("#buttonSelectBoat");
|
||||
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);
|
||||
|
||||
buttonSelectBoat.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
|
||||
buttonSelectBoat.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 3.0 -
|
||||
distanceBetweenButtons * 3.0 - buttonSelectBoat.getWidth());
|
||||
|
||||
buttonSelectBoat.setOnAction(e ->
|
||||
{
|
||||
stageBoat.close();
|
||||
ControllerBoat controllerBoat = fxmlLoader.getController();
|
||||
DrawningObjectBoat boat = new DrawningObjectBoat(controllerBoat.GetSelectedBoat());
|
||||
|
||||
Alert alert;
|
||||
if (_mapBoatsCollectionGeneric.Add(boat) != -1) {
|
||||
alert = new Alert(Alert.AlertType.INFORMATION, "Object added", ButtonType.OK);
|
||||
_mapBoatsCollectionGeneric.ShowSet();
|
||||
} else {
|
||||
alert = new Alert(Alert.AlertType.ERROR, "Failed to add object", ButtonType.OK);
|
||||
}
|
||||
alert.showAndWait();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
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.Label;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ControllerSetMixedBoats {
|
||||
@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 Button buttonCreate;
|
||||
@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;
|
||||
private SetMixedBoatsGeneric<EntityBoat, IDrawningAdditionalElement> _setMixedBoats;
|
||||
@FXML
|
||||
public void initialize() {
|
||||
_setMixedBoats = new SetMixedBoatsGeneric<>(40, EntityBoat.class, IDrawningAdditionalElement.class);
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
_setMixedBoats.AddBoat(CreateRandomBoat());
|
||||
_setMixedBoats.AddAdditionalElement(CreateRandomAdditionalElement());
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
}
|
||||
public EntityBoat CreateRandomBoat() {
|
||||
Random rnd = new Random();
|
||||
return new EntityBoat(rnd.nextInt(200) + 100, rnd.nextInt(1000) + 1000,
|
||||
Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
}
|
||||
public IDrawningAdditionalElement CreateRandomAdditionalElement() {
|
||||
Random rnd = new Random();
|
||||
int oarsType = rnd.nextInt(0, 3);
|
||||
int numOars = rnd.nextInt(4, 7);
|
||||
IDrawningAdditionalElement additionalElement;
|
||||
switch (oarsType) {
|
||||
case 1 ->
|
||||
additionalElement = new DrawningSlimOars(Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
case 2 ->
|
||||
additionalElement = new DrawningLargeOars(Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
default ->
|
||||
additionalElement = new DrawningOars(Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)));
|
||||
}
|
||||
additionalElement.SetNumberOars(numOars);
|
||||
|
||||
return additionalElement;
|
||||
}
|
||||
@FXML
|
||||
void ButtonCreate_Click() {
|
||||
_boat = _setMixedBoats.GetRandomBoat();
|
||||
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();
|
||||
}
|
||||
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);
|
||||
|
||||
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());
|
||||
if (_boat != null) {
|
||||
_boat.DrawTransport(gc);
|
||||
}
|
||||
}
|
||||
private void SetData() {
|
||||
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());
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
public enum Direction {
|
||||
None,
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
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 DrawningBoat(EntityBoat boat, IDrawningAdditionalElement additionalElement) {
|
||||
_boat = boat;
|
||||
_drawningOars = additionalElement;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
|
||||
public class DrawningObjectBoat implements IDrawningObject {
|
||||
private DrawningBoat _boat = null;
|
||||
public DrawningBoat GetBoat()
|
||||
{
|
||||
return _boat;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
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;
|
||||
super.DrawTransport(gc);
|
||||
_startPosX -= 25;
|
||||
|
||||
if (speedboat.GetWing()) {
|
||||
gc.setFill(speedboat.GetDopColor());
|
||||
gc.fillRect(_startPosX, _startPosY+30, 20, 80);
|
||||
gc.strokeRect(_startPosX, _startPosY+30, 20, 80);
|
||||
gc.setFill(speedboat.GetBodyColor());
|
||||
gc.fillRect(_startPosX + 20, _startPosY + 50, 10, 40);
|
||||
gc.strokeRect(_startPosX + 20, _startPosY + 50, 10, 40);
|
||||
}
|
||||
_startPosX += 25;
|
||||
if (speedboat.GetBodyKit()) {
|
||||
double[] bodyKitX = {
|
||||
_startPosX + 120,
|
||||
_startPosX + 155,
|
||||
_startPosX + 120,
|
||||
_startPosX + 120,
|
||||
_startPosX + 145,
|
||||
_startPosX + 120
|
||||
};
|
||||
double[] bodyKitY = {
|
||||
_startPosY + 50,
|
||||
_startPosY + 70,
|
||||
_startPosY + 90,
|
||||
_startPosY + 85,
|
||||
_startPosY + 70,
|
||||
_startPosY + 55
|
||||
};
|
||||
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 + 40,
|
||||
_startPosY + 40,
|
||||
_startPosY + 100,
|
||||
_startPosY + 100
|
||||
};
|
||||
gc.setFill(speedboat.GetDopColor());
|
||||
gc.fillPolygon(sportLineX, sportLineY, 4);
|
||||
gc.setFill(Color.BROWN);
|
||||
gc.fillOval(_startPosX + 10, _startPosY + 50, 110, 40);
|
||||
}
|
||||
_startPosX -= 25;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
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");
|
||||
Button buttonSelectBoat = (Button)scene.lookup("#buttonSelectBoat");
|
||||
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);
|
||||
|
||||
buttonSelectBoat.setTranslateY(rootHeight - flowPaneHeight - buttonCreateHeight - rootPadding);
|
||||
buttonSelectBoat.setTranslateX(rootWidth - rootPadding - buttonMoveSize * 3.0 -
|
||||
distanceBetweenButtons * 3.0 - buttonSelectBoat.getWidth());
|
||||
}
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch();
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
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.*;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class FormMapWithSetBoats extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(FormBoat.class.getResource("form-map-with-set-boats-view.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 1000, 540);
|
||||
|
||||
FirstUpdateGUI(scene);
|
||||
|
||||
stage.setTitle("Map with a set of objects");
|
||||
stage.setScene(scene);
|
||||
|
||||
stage.show();
|
||||
}
|
||||
|
||||
private void FirstUpdateGUI(Scene scene) {
|
||||
Pane root = (Pane)scene.lookup("#root");
|
||||
Canvas canvas = (Canvas)scene.lookup("#canvas");
|
||||
Pane paneRight = (Pane)scene.lookup("#paneRight");
|
||||
Label labelTools = (Label)scene.lookup("#labelTools");
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<String> comboBoxSelectorMap = (ComboBox<String>)scene.lookup("#comboBoxSelectorMap");
|
||||
Button buttonAddBoat = (Button)scene.lookup("#buttonAddBoat");
|
||||
TextField textFieldPosition = (TextField)scene.lookup("#textFieldPosition");
|
||||
Button buttonRemoveBoat = (Button)scene.lookup("#buttonRemoveBoat");
|
||||
Button buttonShowStorage = (Button)scene.lookup("#buttonShowStorage");
|
||||
Button buttonShowOnMap = (Button)scene.lookup("#buttonShowOnMap");
|
||||
Button buttonUp = (Button)scene.lookup("#buttonUp");
|
||||
Button buttonLeft = (Button)scene.lookup("#buttonLeft");
|
||||
Button buttonRight = (Button)scene.lookup("#buttonRight");
|
||||
Button buttonDown = (Button)scene.lookup("#buttonDown");
|
||||
|
||||
root.applyCss();
|
||||
root.layout();
|
||||
|
||||
double paneRightPadding = 5.0;
|
||||
double rootWidth = root.getWidth();
|
||||
double rootHeight = root.getHeight();
|
||||
double standardWidth = buttonRemoveBoat.getWidth();
|
||||
double standardHeight = buttonRemoveBoat.getHeight();
|
||||
double paneRightWidth = standardWidth + paneRightPadding * 2;
|
||||
|
||||
canvas.setWidth(rootWidth - paneRightWidth);
|
||||
canvas.setHeight(rootHeight);
|
||||
paneRight.setPrefWidth(paneRightWidth);
|
||||
paneRight.setPrefHeight(rootHeight);
|
||||
paneRight.setTranslateX(rootWidth - paneRightWidth);
|
||||
|
||||
double topMargin = labelTools.getHeight();
|
||||
|
||||
comboBoxSelectorMap.setTranslateX(paneRightPadding);
|
||||
comboBoxSelectorMap.setTranslateY(topMargin);
|
||||
topMargin += standardHeight + paneRightPadding * 3.0;
|
||||
|
||||
buttonAddBoat.setPrefWidth(standardWidth);
|
||||
buttonAddBoat.setTranslateX(paneRightPadding);
|
||||
buttonAddBoat.setTranslateY(topMargin);
|
||||
topMargin += standardHeight + paneRightPadding;
|
||||
|
||||
textFieldPosition.setPrefWidth(standardWidth);
|
||||
textFieldPosition.setTranslateX(paneRightPadding);
|
||||
textFieldPosition.setTranslateY(topMargin);
|
||||
topMargin += standardHeight + paneRightPadding;
|
||||
|
||||
buttonRemoveBoat.setTranslateX(paneRightPadding);
|
||||
buttonRemoveBoat.setTranslateY(topMargin);
|
||||
topMargin += standardHeight + paneRightPadding * 3.0;
|
||||
|
||||
buttonShowStorage.setPrefWidth(standardWidth);
|
||||
buttonShowStorage.setTranslateX(paneRightPadding);
|
||||
buttonShowStorage.setTranslateY(topMargin);
|
||||
topMargin += standardHeight + paneRightPadding;
|
||||
|
||||
buttonShowOnMap.setPrefWidth(standardWidth);
|
||||
buttonShowOnMap.setTranslateX(paneRightPadding);
|
||||
buttonShowOnMap.setTranslateY(topMargin);
|
||||
|
||||
int _distanceBetweenMoveButtons = 5;
|
||||
double moveButtonsSize = 30.0;
|
||||
double moveButtonsXMargin = (paneRightWidth - moveButtonsSize * 3.0 - _distanceBetweenMoveButtons * 2.0) / 2.0;
|
||||
|
||||
buttonUp.setTranslateY(rootHeight - moveButtonsSize * 2.0 - _distanceBetweenMoveButtons - paneRightPadding);
|
||||
buttonUp.setTranslateX(rootWidth - moveButtonsSize * 2.0 - moveButtonsXMargin - _distanceBetweenMoveButtons);
|
||||
|
||||
buttonDown.setTranslateY(rootHeight - moveButtonsSize - paneRightPadding);
|
||||
buttonDown.setTranslateX(rootWidth - moveButtonsSize * 2.0 - moveButtonsXMargin - _distanceBetweenMoveButtons);
|
||||
|
||||
buttonLeft.setTranslateY(rootHeight - moveButtonsSize - paneRightPadding);
|
||||
buttonLeft.setTranslateX(rootWidth - moveButtonsSize * 3.0 - moveButtonsXMargin - _distanceBetweenMoveButtons * 2.0);
|
||||
|
||||
buttonRight.setTranslateY(rootHeight - moveButtonsSize - paneRightPadding);
|
||||
buttonRight.setTranslateX(rootWidth - moveButtonsSize - moveButtonsXMargin);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
launch();
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
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 FormSetMixedBoats extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(FormSetMixedBoats.class.getResource("form-set-mixed-boats-view.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
|
||||
|
||||
stage.setTitle("Set mixed boats");
|
||||
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 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 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);
|
||||
|
||||
buttonCreate.setTranslateY(rootHeight - flowPaneHeight - rootPadding - buttonCreateHeight);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
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);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
|
||||
public interface IDrawningObject {
|
||||
public float GetStep();
|
||||
public void SetObject(int x, int y, int width, int height);
|
||||
public void MoveObject(Direction direction);
|
||||
public void DrawningObject(GraphicsContext gc);
|
||||
public float[] GetCurrentPosition();
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class MapWithSetBoatsGeneric <T extends IDrawningObject, U extends AbstractMap> {
|
||||
private final int _pictureWidth;
|
||||
private final int _pictureHeight;
|
||||
private final int _placeSizeWidth = 400;
|
||||
private final int _placeSizeHeight = 150;
|
||||
private final SetBoatsGeneric<T> _setBoats;
|
||||
private GraphicsContext _graphicsContext = null;
|
||||
private final U _map;
|
||||
public MapWithSetBoatsGeneric(int picWidth, int picHeight, U map, Class<T> objectT, GraphicsContext gc) {
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_setBoats = new SetBoatsGeneric<T>(width * height, objectT);
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_map = map;
|
||||
_graphicsContext = gc;
|
||||
}
|
||||
public int Add(T boat)
|
||||
{
|
||||
return _setBoats.Insert(boat);
|
||||
}
|
||||
public T Delete(int position)
|
||||
{
|
||||
return _setBoats.Remove(position);
|
||||
}
|
||||
public T Get(int position)
|
||||
{
|
||||
return _setBoats.Get(position);
|
||||
}
|
||||
public void ShowOnMap() {
|
||||
Shaking();
|
||||
for (int i = 0; i < _setBoats.GetCount(); i++) {
|
||||
var armoredVehicle = _setBoats.Get(i);
|
||||
if (armoredVehicle != null) {
|
||||
_map.CreateMap(_pictureWidth, _pictureHeight, armoredVehicle, _graphicsContext);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void ShowSet() {
|
||||
DrawBackground();
|
||||
DrawBoats();
|
||||
}
|
||||
public void MoveObject(Direction direction) {
|
||||
if (_map != null) {
|
||||
_map.MoveObject(direction);
|
||||
}
|
||||
}
|
||||
private void Shaking() {
|
||||
int j = _setBoats.GetCount() - 1;
|
||||
for (int i = 0; i < _setBoats.GetCount(); i++) {
|
||||
if (_setBoats.Get(i) == null) {
|
||||
for (; j > i; j--) {
|
||||
var boat = _setBoats.Get(j);
|
||||
if (boat != null) {
|
||||
_setBoats.Insert(boat, i);
|
||||
_setBoats.Remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j <= i) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DrawBackground() {
|
||||
_graphicsContext.setFill(Color.rgb(80, 94, 102));
|
||||
_graphicsContext.fillRect(0, 0, _pictureWidth, _pictureHeight);
|
||||
|
||||
_graphicsContext.setStroke(Color.BLACK);
|
||||
_graphicsContext.setLineWidth(3);
|
||||
_graphicsContext.setFill(Color.rgb(127, 104, 88));
|
||||
|
||||
_graphicsContext.beginPath();
|
||||
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) {
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j) {
|
||||
_graphicsContext.moveTo(i * _placeSizeWidth, j * _placeSizeHeight);
|
||||
_graphicsContext.lineTo(i * _placeSizeWidth + _placeSizeWidth / 2.0F, j * _placeSizeHeight);
|
||||
_graphicsContext.stroke();
|
||||
if (j == _pictureHeight / _placeSizeHeight) {
|
||||
_graphicsContext.fillRect(0, j * _placeSizeHeight + 2, _pictureWidth, _pictureHeight - j * _placeSizeHeight);
|
||||
}
|
||||
}
|
||||
if (i == _pictureWidth / _placeSizeWidth - 1) {
|
||||
_graphicsContext.fillRect(i * _placeSizeWidth + _placeSizeWidth / 2.0F, 0, _pictureWidth - (i * _placeSizeWidth + _placeSizeWidth / 2.0F), _pictureHeight);
|
||||
}
|
||||
else {
|
||||
_graphicsContext.fillRect(i * _placeSizeWidth + _placeSizeWidth / 2.0F, 0, _placeSizeWidth / 2.0F, _pictureHeight);
|
||||
}
|
||||
_graphicsContext.moveTo(i * _placeSizeWidth, 0);
|
||||
_graphicsContext.lineTo(i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
|
||||
_graphicsContext.stroke();
|
||||
_graphicsContext.closePath();
|
||||
}
|
||||
}
|
||||
private void DrawBoats() {
|
||||
int yNumOfPlaces = _pictureHeight / _placeSizeHeight;
|
||||
int xNumOfPlaces = _pictureWidth / _placeSizeWidth;
|
||||
|
||||
int RowIndex = 0;
|
||||
int ColumnIndex = 0;
|
||||
|
||||
for (int i = 0; i < _setBoats.GetCount(); i++) {
|
||||
if (_setBoats.Get(i) != null) {
|
||||
float[] position = _setBoats.Get(i).GetCurrentPosition();
|
||||
_setBoats.Get(i).SetObject(ColumnIndex *_placeSizeWidth,
|
||||
RowIndex * _placeSizeHeight + (_placeSizeHeight - (int)(position[3]-position[1])) - 70,
|
||||
_pictureWidth, _pictureHeight);
|
||||
_setBoats.Get(i).DrawningObject(_graphicsContext);
|
||||
}
|
||||
if (ColumnIndex == xNumOfPlaces-1) {
|
||||
ColumnIndex = 0;
|
||||
RowIndex++;
|
||||
} else {
|
||||
ColumnIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SetBoatsGeneric<T> {
|
||||
private final T[] _places;
|
||||
public int GetCount()
|
||||
{
|
||||
return _places.length;
|
||||
}
|
||||
public SetBoatsGeneric(int count, Class<T> objectT) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final T[] places = (T[]) Array.newInstance(objectT, count);
|
||||
_places = places;
|
||||
}
|
||||
public int Insert(T boat)
|
||||
{
|
||||
return Insert(boat, 0);
|
||||
}
|
||||
public int Insert(T boat, int position) {
|
||||
if (position < 0 || position > _places.length) {
|
||||
return -1;
|
||||
}
|
||||
int emptyCellIndex = -1;
|
||||
if (_places[position] != null) {
|
||||
for (int i = position + 1; i < GetCount(); i++) {
|
||||
if (_places[i] == null) {
|
||||
emptyCellIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (emptyCellIndex != -1) {
|
||||
for (int i = emptyCellIndex; i > position; i--) {
|
||||
_places[i] = _places[i - 1];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_places[position] = boat;
|
||||
return position;
|
||||
}
|
||||
|
||||
if (emptyCellIndex == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
_places[position] = boat;
|
||||
return position;
|
||||
}
|
||||
}
|
||||
public T Remove(int position) {
|
||||
if (position < 0 || position >= GetCount()) {
|
||||
return null;
|
||||
}
|
||||
T removedObject = _places[position];
|
||||
_places[position] = null;
|
||||
return removedObject;
|
||||
}
|
||||
public T Get(int position) {
|
||||
if (position < 0 || position >= GetCount()) {
|
||||
return null;
|
||||
}
|
||||
return _places[position];
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Random;
|
||||
|
||||
public class SetMixedBoatsGeneric<T extends EntityBoat, U extends IDrawningAdditionalElement> {
|
||||
private final T[] _boats;
|
||||
private final U[] _additionalElements;
|
||||
private final int _maxCount;
|
||||
private int _boatsCount;
|
||||
private int _additionalElementsCount;
|
||||
public SetMixedBoatsGeneric(int maxCount, Class<T> objectT, Class<U> objectU) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final T[] boats = (T[]) Array.newInstance(objectT, maxCount);
|
||||
_boats = boats;
|
||||
@SuppressWarnings("unchecked")
|
||||
final U[] additionalElements = (U[]) Array.newInstance(objectU, maxCount);
|
||||
_additionalElements = additionalElements;
|
||||
_maxCount = maxCount;
|
||||
_boatsCount = 0;
|
||||
_additionalElementsCount = 0;
|
||||
}
|
||||
public boolean AddBoat(T boat) {
|
||||
if (_boatsCount == _maxCount) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
_boats[_boatsCount] = boat;
|
||||
_boatsCount++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean AddAdditionalElement(U additionalElement) {
|
||||
if (_additionalElementsCount == _maxCount) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
_additionalElements[_additionalElementsCount] = additionalElement;
|
||||
_additionalElementsCount++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public DrawningBoat GetRandomBoat() {
|
||||
if (_boatsCount == 0 || _additionalElementsCount == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Random random = new Random();
|
||||
T randomBoat = _boats[random.nextInt(0, _boatsCount)];
|
||||
U randomAdditionalElement = _additionalElements[random.nextInt(0, _additionalElementsCount)];
|
||||
|
||||
return new DrawningBoat(randomBoat, randomAdditionalElement);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
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!");
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
module com.example.pibd22_kalyshev_y_v_motorboat_hard {
|
||||
module com.zyzf.pibd22_kalyshev_y_v_motorboat_hard {
|
||||
requires javafx.controls;
|
||||
requires javafx.fxml;
|
||||
|
||||
requires org.controlsfx.controls;
|
||||
requires com.dlsc.formsfx;
|
||||
|
||||
opens com.example.pibd22_kalyshev_y_v_motorboat_hard to javafx.fxml;
|
||||
exports com.example.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
opens com.zyzf.pibd22_kalyshev_y_v_motorboat_hard to javafx.fxml;
|
||||
exports com.zyzf.pibd22_kalyshev_y_v_motorboat_hard;
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 245 B |
Binary file not shown.
Before Width: | Height: | Size: 257 B |
Binary file not shown.
Before Width: | Height: | Size: 254 B |
Binary file not shown.
Before Width: | Height: | Size: 234 B |
@ -1,101 +0,0 @@
|
||||
<?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?>
|
||||
<?import javafx.scene.control.ColorPicker?>
|
||||
<Pane xmlns:fx="http://javafx.com/fxml" fx:id="root" fx:controller="com.example.pibd22_kalyshev_y_v_motorboat_hard.ControllerBoat">
|
||||
<Canvas fx:id="canvas">
|
||||
</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>
|
||||
<ColorPicker fx:id="bodyColorPicker" onAction="#BodyColorPicker_Changed"/>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
DopColor:
|
||||
</Label>
|
||||
<ColorPicker fx:id="dopColorPicker" onAction="#DopColorPicker_Changed"/>
|
||||
<Label style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5;">
|
||||
Oars:
|
||||
</Label>
|
||||
<ComboBox fx:id="comboBoxNumOars" value="1" onAction="#ComboBoxNumOars_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="#ComboBoxType_Changed">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="None"/>
|
||||
<String fx:value="Large"/>
|
||||
<String fx:value="Slim"/>
|
||||
</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>
|
||||
<Button fx:id="buttonSelectBoat">
|
||||
Select
|
||||
</Button>
|
||||
</Pane>
|
@ -1,72 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.canvas.Canvas?>
|
||||
|
||||
<?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.control.TextField?>
|
||||
<?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.ControllerMapWithSetBoats">
|
||||
<Canvas fx:id="canvas">
|
||||
</Canvas>
|
||||
<Pane fx:id="paneRight" style="-fx-background-color: #31374c;">
|
||||
<Label fx:id="labelTools" style="-fx-text-fill: #b8becc; -fx-padding: 5 5 5 5; -fx-font-weight: bold;">
|
||||
Tools
|
||||
</Label>
|
||||
<ComboBox fx:id="comboBoxSelectorMap" value="Simple map" onAction="#ComboBoxSelectorMap_Changed">
|
||||
<items>
|
||||
<FXCollections fx:factory="observableArrayList">
|
||||
<String fx:value="Simple map"/>
|
||||
<String fx:value="My second map"/>
|
||||
</FXCollections>
|
||||
</items>
|
||||
</ComboBox>
|
||||
<Button fx:id="buttonAddBoat" onAction="#ButtonAddBoat_Click">
|
||||
Add boat
|
||||
</Button>
|
||||
<TextField fx:id="textFieldPosition" />
|
||||
<Button fx:id="buttonRemoveBoat" onAction="#ButtonRemoveBoat_Click">
|
||||
Remove boat
|
||||
</Button>
|
||||
<Button fx:id="buttonShowStorage" onAction="#ButtonShowStorage_Click">
|
||||
Show storage
|
||||
</Button>
|
||||
<Button fx:id="buttonShowOnMap" onAction="#ButtonShowOnMap_Click">
|
||||
Show on map
|
||||
</Button>
|
||||
</Pane>
|
||||
<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>
|
||||
|
@ -1,66 +0,0 @@
|
||||
<?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.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.ControllerSetMixedBoats">
|
||||
<Canvas fx:id="canvas">
|
||||
</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>
|
||||
</FlowPane>
|
||||
<Button fx:id="buttonCreate" onAction="#ButtonCreate_Click">
|
||||
Create
|
||||
</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>
|
@ -0,0 +1,16 @@
|
||||
<?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>
|
Loading…
x
Reference in New Issue
Block a user