done lab 6
This commit is contained in:
parent
2cdbfa66e5
commit
2df2b62be9
@ -5,7 +5,6 @@ import com.projectairfighter.drawnings.*;
|
|||||||
import com.projectairfighter.entities.EntityAirFighter;
|
import com.projectairfighter.entities.EntityAirFighter;
|
||||||
import com.projectairfighter.entities.EntityWarPlane;
|
import com.projectairfighter.entities.EntityWarPlane;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
@ -34,7 +33,7 @@ public class FormConstructor extends Application {
|
|||||||
private Constructor<EntityWarPlane, IDrawableExtras> constructor;
|
private Constructor<EntityWarPlane, IDrawableExtras> constructor;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void generatePlane(ActionEvent event) {
|
private void generatePlane() {
|
||||||
if (constructor == null) {
|
if (constructor == null) {
|
||||||
constructor = createAirFighterDrawable();
|
constructor = createAirFighterDrawable();
|
||||||
}
|
}
|
||||||
@ -55,7 +54,7 @@ public class FormConstructor extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void buttonGoToForm(ActionEvent event) {
|
public void buttonGoToForm() {
|
||||||
FormWarPlaneCollection formWarPlaneCollection = FormWarPlaneCollection.getFormWarPlaneCollection();
|
FormWarPlaneCollection formWarPlaneCollection = FormWarPlaneCollection.getFormWarPlaneCollection();
|
||||||
if (drawningWarPlane != null && formWarPlaneCollection != null) {
|
if (drawningWarPlane != null && formWarPlaneCollection != null) {
|
||||||
formWarPlaneCollection.createObject(drawningWarPlane);
|
formWarPlaneCollection.createObject(drawningWarPlane);
|
||||||
@ -71,44 +70,45 @@ public class FormConstructor extends Application {
|
|||||||
canvas = (Canvas) loader.getNamespace().get("canvas");
|
canvas = (Canvas) loader.getNamespace().get("canvas");
|
||||||
Scene scene = new Scene(root, 900, 500);
|
Scene scene = new Scene(root, 900, 500);
|
||||||
primaryStage.setTitle("Информация о самолете");
|
primaryStage.setTitle("Информация о самолете");
|
||||||
|
primaryStage.setResizable(false);
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Constructor<EntityWarPlane, IDrawableExtras> createAirFighterDrawable() {
|
private Constructor<EntityWarPlane, IDrawableExtras> createAirFighterDrawable() {
|
||||||
Constructor<EntityWarPlane, IDrawableExtras> drawable = new Constructor<>();
|
Constructor<EntityWarPlane, IDrawableExtras> drawable = new Constructor<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
EntityWarPlane plane = createRandomPlane();
|
||||||
|
if (plane == null) return null;
|
||||||
|
drawable.addAirFighter(plane);
|
||||||
|
drawable.addDrawingEngines(plane.getEngineDrawing());
|
||||||
|
}
|
||||||
|
|
||||||
|
return drawable;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityWarPlane createRandomPlane() {
|
||||||
|
Random random = new Random();
|
||||||
|
int randomPlane = random.nextInt(1, 3);
|
||||||
IDrawableExtras[] engineDrawings = {
|
IDrawableExtras[] engineDrawings = {
|
||||||
new EllipticalEngineDrawing(),
|
new EllipticalEngineDrawing(),
|
||||||
new TriangleEngineDrawing(),
|
new TriangleEngineDrawing(),
|
||||||
new RectangleEngineDrawing()
|
new RectangleEngineDrawing()
|
||||||
};
|
};
|
||||||
|
|
||||||
Random random = new Random();
|
IDrawableExtras engineDrawing = engineDrawings[new Random().nextInt(engineDrawings.length)];
|
||||||
for (int i = 0; i < 3; i++) {
|
engineDrawing.setCountEngines(random.nextInt(7));
|
||||||
EntityWarPlane plane = createRandomPlane();
|
|
||||||
if (plane == null) return null;
|
|
||||||
drawable.addAirFighter(plane);
|
|
||||||
IDrawableExtras engineDrawing = engineDrawings[random.nextInt(engineDrawings.length)];
|
|
||||||
engineDrawing.setCountEngines(random.nextInt(7));
|
|
||||||
drawable.addDrawingEngines(engineDrawing);
|
|
||||||
}
|
|
||||||
|
|
||||||
return drawable;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private EntityWarPlane createRandomPlane() {
|
|
||||||
Random random = new Random();
|
|
||||||
int randomPlane = random.nextInt(1, 3);
|
|
||||||
|
|
||||||
return switch (randomPlane) {
|
return switch (randomPlane) {
|
||||||
case 1 -> new EntityWarPlane(random.nextInt(200) + 100,
|
case 1 -> new EntityWarPlane(random.nextInt(200) + 100,
|
||||||
random.nextInt(2000) + 1000,
|
random.nextInt(2000) + 1000,
|
||||||
getColor());
|
getColor(), engineDrawing);
|
||||||
case 2 -> new EntityAirFighter(
|
case 2 -> new EntityAirFighter(
|
||||||
random.nextInt(200) + 100,
|
random.nextInt(200) + 100,
|
||||||
random.nextInt(2000) + 1000,
|
random.nextInt(2000) + 1000,
|
||||||
getColor(),
|
getColor(),
|
||||||
|
engineDrawing,
|
||||||
getColor(),
|
getColor(),
|
||||||
random.nextBoolean(),
|
random.nextBoolean(),
|
||||||
random.nextBoolean());
|
random.nextBoolean());
|
||||||
|
@ -17,6 +17,7 @@ import javafx.scene.paint.Color;
|
|||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class FormPlaneConfig extends Application implements Initializable {
|
public class FormPlaneConfig extends Application implements Initializable {
|
||||||
@ -53,25 +54,23 @@ public class FormPlaneConfig extends Application implements Initializable {
|
|||||||
});
|
});
|
||||||
|
|
||||||
countEngine.valueProperty().addListener((obs, oldVal, newVal) -> {
|
countEngine.valueProperty().addListener((obs, oldVal, newVal) -> {
|
||||||
if (plane != null && plane.getEngineDrawing() != null) {
|
if (plane != null && plane.entityWarPlane.getEngineDrawing() != null) {
|
||||||
canvas.getGraphicsContext2D().clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
|
canvas.getGraphicsContext2D().clearRect(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||||
plane.getEngineDrawing().setCountEngines(newVal);
|
plane.entityWarPlane.getEngineDrawing().setCountEngines(newVal);
|
||||||
drawObject();
|
drawObject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
checkBoxRockets.selectedProperty().addListener((obs, wasSelected, isSelected) -> {
|
checkBoxRockets.selectedProperty().addListener((obs, wasSelected, isSelected) -> {
|
||||||
if (plane instanceof DrawningAirFighter) {
|
if (plane instanceof DrawningAirFighter) {
|
||||||
EntityAirFighter fighter = (EntityAirFighter) plane.entityWarPlane;
|
((EntityAirFighter) plane.entityWarPlane).setBodyRockets(isSelected);
|
||||||
fighter.setBodyRockets(isSelected);
|
|
||||||
drawObject();
|
drawObject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
checkBoxWings.selectedProperty().addListener((obs, wasSelected, isSelected) -> {
|
checkBoxWings.selectedProperty().addListener((obs, wasSelected, isSelected) -> {
|
||||||
if (plane instanceof DrawningAirFighter) {
|
if (plane instanceof DrawningAirFighter) {
|
||||||
EntityAirFighter fighter = (EntityAirFighter) plane.entityWarPlane;
|
((EntityAirFighter) plane.entityWarPlane).setAdditionalWings(isSelected);
|
||||||
fighter.setAdditionalWings(isSelected);
|
|
||||||
drawObject();
|
drawObject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -87,6 +86,7 @@ public class FormPlaneConfig extends Application implements Initializable {
|
|||||||
canvas = (Canvas) loader.getNamespace().get("canvas");
|
canvas = (Canvas) loader.getNamespace().get("canvas");
|
||||||
Scene scene = new Scene(root, 799, 251);
|
Scene scene = new Scene(root, 799, 251);
|
||||||
stage.setTitle("Создание объекта");
|
stage.setTitle("Создание объекта");
|
||||||
|
stage.setResizable(false);
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.show();
|
stage.show();
|
||||||
}
|
}
|
||||||
@ -194,35 +194,46 @@ public class FormPlaneConfig extends Application implements Initializable {
|
|||||||
|
|
||||||
if (db.hasString()) {
|
if (db.hasString()) {
|
||||||
String droppedText = db.getString();
|
String droppedText = db.getString();
|
||||||
|
if (engine == null) {
|
||||||
|
IDrawableExtras[] engineDrawings = {
|
||||||
|
new EllipticalEngineDrawing(),
|
||||||
|
new TriangleEngineDrawing(),
|
||||||
|
new RectangleEngineDrawing()
|
||||||
|
};
|
||||||
|
engine = engineDrawings[new Random().nextInt(engineDrawings.length)];
|
||||||
|
engine.setCountEngines(countEngine.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
switch (droppedText) {
|
switch (droppedText) {
|
||||||
case "Простой":
|
case "Простой":
|
||||||
plane = new DrawningWarPlane(speed.getValue(), weight.getValue(), Color.WHITE);
|
plane = new DrawningWarPlane(speed.getValue(), weight.getValue(), Color.WHITE, engine);
|
||||||
plane.getEngineDrawing().setCountEngines(countEngine.getValue());
|
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case "Продвинутый":
|
case "Продвинутый":
|
||||||
plane = new DrawningAirFighter(speed.getValue(), weight.getValue(), Color.WHITE, Color.BLACK, checkBoxRockets.isSelected(), checkBoxWings.isSelected());
|
plane = new DrawningAirFighter(speed.getValue(), weight.getValue(), Color.WHITE, engine, Color.BLACK, checkBoxRockets.isSelected(), checkBoxWings.isSelected());
|
||||||
plane.getEngineDrawing().setCountEngines(countEngine.getValue());
|
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case "Прямоугольная":
|
case "Прямоугольная":
|
||||||
engine = new RectangleEngineDrawing();
|
engine = new RectangleEngineDrawing();
|
||||||
engine.setCountEngines(countEngine.getValue());
|
engine.setCountEngines(countEngine.getValue());
|
||||||
plane.setEngineDrawing(engine);
|
plane.entityWarPlane.setEngineDrawing(engine);
|
||||||
|
plane.entityWarPlane.setEngineDrawing(engine);
|
||||||
engine.drawEngine(canvas.getGraphicsContext2D(), plane.entityWarPlane.getBodyColor(), 0, 0);
|
engine.drawEngine(canvas.getGraphicsContext2D(), plane.entityWarPlane.getBodyColor(), 0, 0);
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case "Треугольная":
|
case "Треугольная":
|
||||||
engine = new TriangleEngineDrawing();
|
engine = new TriangleEngineDrawing();
|
||||||
engine.setCountEngines(countEngine.getValue());
|
engine.setCountEngines(countEngine.getValue());
|
||||||
plane.setEngineDrawing(engine);
|
plane.entityWarPlane.setEngineDrawing(engine);
|
||||||
|
plane.entityWarPlane.setEngineDrawing(engine);
|
||||||
engine.drawEngine(canvas.getGraphicsContext2D(), plane.entityWarPlane.getBodyColor(), 0, 0);
|
engine.drawEngine(canvas.getGraphicsContext2D(), plane.entityWarPlane.getBodyColor(), 0, 0);
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case "Овальная":
|
case "Овальная":
|
||||||
engine = new EllipticalEngineDrawing();
|
engine = new EllipticalEngineDrawing();
|
||||||
engine.setCountEngines(countEngine.getValue());
|
engine.setCountEngines(countEngine.getValue());
|
||||||
plane.setEngineDrawing(engine);
|
plane.entityWarPlane.setEngineDrawing(engine);
|
||||||
|
plane.entityWarPlane.setEngineDrawing(engine);
|
||||||
engine.drawEngine(canvas.getGraphicsContext2D(), plane.entityWarPlane.getBodyColor(), 0, 0);
|
engine.drawEngine(canvas.getGraphicsContext2D(), plane.entityWarPlane.getBodyColor(), 0, 0);
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
|
@ -3,16 +3,21 @@ package com.projectairfighter;
|
|||||||
import com.projectairfighter.collectiongenericobjects.*;
|
import com.projectairfighter.collectiongenericobjects.*;
|
||||||
import com.projectairfighter.drawnings.DrawningWarPlane;
|
import com.projectairfighter.drawnings.DrawningWarPlane;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.event.ActionEvent;
|
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.canvas.Canvas;
|
import javafx.scene.canvas.Canvas;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -68,7 +73,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void comboBoxSelectorCompany(ActionEvent event) {
|
private void comboBoxSelectorCompany() {
|
||||||
splitPane.getItems().get(1).setDisable(true);
|
splitPane.getItems().get(1).setDisable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +90,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void buttonRemovePlaneClicked(ActionEvent event) {
|
private void buttonRemovePlaneClicked() {
|
||||||
String text = textBox.getText();
|
String text = textBox.getText();
|
||||||
if (text == null || text.isEmpty() || company == null) return;
|
if (text == null || text.isEmpty() || company == null) return;
|
||||||
|
|
||||||
@ -110,14 +115,14 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void buttonRefresh(ActionEvent event) {
|
private void buttonRefresh() {
|
||||||
if (company == null) return;
|
if (company == null) return;
|
||||||
|
|
||||||
company.show(canvasWarPlane);
|
company.show(canvasWarPlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void buttonGoToCheck(ActionEvent event) {
|
private void buttonGoToCheck() {
|
||||||
if (company == null) return;
|
if (company == null) return;
|
||||||
|
|
||||||
DrawningWarPlane warPlane = null;
|
DrawningWarPlane warPlane = null;
|
||||||
@ -136,7 +141,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void buttonGoFormConstructor(ActionEvent event) {
|
private void buttonGoFormConstructor() {
|
||||||
if (company == null) return;
|
if (company == null) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -154,7 +159,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void buttonGoToFormWithDeleteObject(ActionEvent event){
|
private void buttonGoToFormWithDeleteObject() {
|
||||||
if (!removedPlanesStack.isEmpty()) {
|
if (!removedPlanesStack.isEmpty()) {
|
||||||
goToFormAirFighter(removedPlanesStack.get(new Random().nextInt(0, removedPlanesStack.size())));
|
goToFormAirFighter(removedPlanesStack.get(new Random().nextInt(0, removedPlanesStack.size())));
|
||||||
} else {
|
} else {
|
||||||
@ -164,7 +169,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void buttonGoToFormCreate(ActionEvent event) {
|
private void buttonGoToFormCreate() {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("FormPlaneConfig.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("FormPlaneConfig.fxml"));
|
||||||
Parent root = loader.load();
|
Parent root = loader.load();
|
||||||
@ -177,7 +182,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void goToFormAirFighter(DrawningWarPlane plane){
|
private void goToFormAirFighter(DrawningWarPlane plane) {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("FormAirFighter.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("FormAirFighter.fxml"));
|
||||||
Parent root = loader.load();
|
Parent root = loader.load();
|
||||||
@ -192,7 +197,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void buttonCollectionAdd(ActionEvent event) {
|
void buttonCollectionAdd() {
|
||||||
if (textFieldCollectionName.getText().isEmpty() || (!radioButtonList.isSelected() && !radioButtonMassive.isSelected())) {
|
if (textFieldCollectionName.getText().isEmpty() || (!radioButtonList.isSelected() && !radioButtonMassive.isSelected())) {
|
||||||
showError("Не все данные заполнены");
|
showError("Не все данные заполнены");
|
||||||
return;
|
return;
|
||||||
@ -210,7 +215,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void buttonCollectionDel(ActionEvent event) {
|
void buttonCollectionDel() {
|
||||||
if (listViewCollection.getSelectionModel().getSelectedIndex() < 0 || listViewCollection.getSelectionModel().getSelectedItem() == null) {
|
if (listViewCollection.getSelectionModel().getSelectedIndex() < 0 || listViewCollection.getSelectionModel().getSelectedItem() == null) {
|
||||||
showError("Коллекция не выбрана");
|
showError("Коллекция не выбрана");
|
||||||
return;
|
return;
|
||||||
@ -228,9 +233,99 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
refreshListBoxItems();
|
refreshListBoxItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Обработка нажатия "Сохранение"
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
private void saveToolStripMenuItem() {
|
||||||
|
Stage mainStage = (Stage) splitPane.getScene().getWindow();
|
||||||
|
|
||||||
|
Stage dialog = new Stage();
|
||||||
|
dialog.setResizable(false);
|
||||||
|
dialog.initOwner(mainStage);
|
||||||
|
dialog.initModality(Modality.APPLICATION_MODAL); // Блокируем доступ к основному окну
|
||||||
|
dialog.setTitle("Выберите коллекцию для сохранения");
|
||||||
|
|
||||||
|
VBox layout = new VBox(10);
|
||||||
|
layout.setAlignment(Pos.CENTER);
|
||||||
|
|
||||||
|
ToggleGroup toggleGroup = new ToggleGroup();
|
||||||
|
|
||||||
|
for (String collection : listViewCollection.getItems()) {
|
||||||
|
RadioButton radioButton = new RadioButton(collection);
|
||||||
|
radioButton.setPadding(new Insets(5));
|
||||||
|
radioButton.setToggleGroup(toggleGroup);
|
||||||
|
layout.getChildren().add(radioButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
RadioButton allCollections = new RadioButton("Все коллекции");
|
||||||
|
Button submitButton = new Button("Сохранить");
|
||||||
|
allCollections.setToggleGroup(toggleGroup);
|
||||||
|
layout.getChildren().addAll(allCollections, submitButton);
|
||||||
|
|
||||||
|
submitButton.setOnAction(e -> {
|
||||||
|
if (toggleGroup.getSelectedToggle() == null || storageCollection.keys().isEmpty()) {
|
||||||
|
showError("Не выбрана коллекция или выбранная коллекция пуста");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileChooser fileChooser = new FileChooser();
|
||||||
|
fileChooser.setTitle("Сохранить данные");
|
||||||
|
fileChooser.getExtensionFilters().addAll(
|
||||||
|
new FileChooser.ExtensionFilter("Text Files (*.txt)", "*.txt")
|
||||||
|
);
|
||||||
|
|
||||||
|
File selectedFile = fileChooser.showSaveDialog(null);
|
||||||
|
if (selectedFile != null) {
|
||||||
|
boolean success;
|
||||||
|
RadioButton selectedRadioButton = (RadioButton) toggleGroup.getSelectedToggle();
|
||||||
|
if (selectedRadioButton.getText().equals("Все коллекции"))
|
||||||
|
success = storageCollection.saveData(selectedFile.getAbsolutePath());
|
||||||
|
else
|
||||||
|
success = storageCollection.saveData(selectedFile.getAbsolutePath(), selectedRadioButton.getText());
|
||||||
|
if (success) {
|
||||||
|
showAlert("Сохранение прошло успешно", "Результат", Alert.AlertType.INFORMATION);
|
||||||
|
} else {
|
||||||
|
showAlert("Не сохранилось", "Результат", Alert.AlertType.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialog.close(); // Закрыть диалог после сохранения
|
||||||
|
});
|
||||||
|
|
||||||
|
Scene scene = new Scene(layout, 250, 200);
|
||||||
|
dialog.setScene(scene);
|
||||||
|
dialog.showAndWait(); // Показываем диалог и ждем закрытия
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Обработка кнопки загрузки
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
private void loadToolStripMenuItem() {
|
||||||
|
FileChooser fileChooser = new FileChooser();
|
||||||
|
fileChooser.setTitle("Открыть текстовый файл");
|
||||||
|
|
||||||
|
// Настройка фильтра расширений для выбора только текстовых файлов
|
||||||
|
FileChooser.ExtensionFilter txtFilter = new FileChooser.ExtensionFilter("Text Files (*.txt)", "*.txt");
|
||||||
|
fileChooser.getExtensionFilters().add(txtFilter);
|
||||||
|
|
||||||
|
// Отображение диалога открытия файла
|
||||||
|
File selectedFile = fileChooser.showOpenDialog(null);
|
||||||
|
if (selectedFile != null) {
|
||||||
|
boolean success = storageCollection.loadData(selectedFile.getAbsolutePath());
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
refreshListBoxItems();
|
||||||
|
showAlert("Загрузка прошла успешно", "Результат", Alert.AlertType.INFORMATION);
|
||||||
|
} else {
|
||||||
|
showAlert("Загрузка не выполнена", "Результат", Alert.AlertType.ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshListBoxItems() {
|
private void refreshListBoxItems() {
|
||||||
listViewCollection.getItems().clear();
|
listViewCollection.getItems().clear();
|
||||||
for (String colName : storageCollection.Keys()) {
|
for (String colName : storageCollection.keys()) {
|
||||||
if (colName != null && !colName.isEmpty()) {
|
if (colName != null && !colName.isEmpty()) {
|
||||||
listViewCollection.getItems().add(colName);
|
listViewCollection.getItems().add(colName);
|
||||||
}
|
}
|
||||||
@ -238,7 +333,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void buttonCreateCompany(ActionEvent event) {
|
void buttonCreateCompany() {
|
||||||
if (listViewCollection.getSelectionModel().getSelectedIndex() < 0 || listViewCollection.getSelectionModel().getSelectedItem() == null) {
|
if (listViewCollection.getSelectionModel().getSelectedIndex() < 0 || listViewCollection.getSelectionModel().getSelectedItem() == null) {
|
||||||
showAlert("Коллекция не выбрана");
|
showAlert("Коллекция не выбрана");
|
||||||
return;
|
return;
|
||||||
@ -275,6 +370,14 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
alert.showAndWait();
|
alert.showAndWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showAlert(String message, String title, Alert.AlertType alertType) {
|
||||||
|
Alert alert = new Alert(alertType);
|
||||||
|
alert.setTitle(title);
|
||||||
|
alert.setHeaderText(null);
|
||||||
|
alert.setContentText(message);
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
|
|
||||||
private void showError(String message) {
|
private void showError(String message) {
|
||||||
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
alert.setTitle("Ошибка");
|
alert.setTitle("Ошибка");
|
||||||
@ -295,6 +398,7 @@ public class FormWarPlaneCollection extends Application implements Initializable
|
|||||||
comboBox.getItems().addAll("Хранилище");
|
comboBox.getItems().addAll("Хранилище");
|
||||||
Scene scene = new Scene(root, 1292, 795);
|
Scene scene = new Scene(root, 1292, 795);
|
||||||
primaryStage.setTitle("Коллекция истребителей");
|
primaryStage.setTitle("Коллекция истребителей");
|
||||||
|
primaryStage.setResizable(false);
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,12 @@ public class Constructor<T extends EntityWarPlane, U extends IDrawableExtras> {
|
|||||||
public DrawningWarPlane createDrawing() {
|
public DrawningWarPlane createDrawing() {
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
int entityIndex = rnd.nextInt(0, 3);
|
int entityIndex = rnd.nextInt(0, 3);
|
||||||
int engineCount = rnd.nextInt(0, 3);
|
|
||||||
|
|
||||||
T selectedPlane = planes.get(entityIndex);
|
T selectedPlane = planes.get(entityIndex);
|
||||||
U selectedEngineCount = drawingEngines.get(engineCount);
|
|
||||||
|
|
||||||
return (selectedPlane instanceof EntityAirFighter) ?
|
return (selectedPlane instanceof EntityAirFighter) ?
|
||||||
new DrawningAirFighter((EntityAirFighter) selectedPlane, selectedEngineCount) :
|
new DrawningAirFighter((EntityAirFighter) selectedPlane) :
|
||||||
new DrawningWarPlane(selectedPlane, selectedEngineCount);
|
new DrawningWarPlane(selectedPlane);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlaneInfo() {
|
public String getPlaneInfo() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.projectairfighter.collectiongenericobjects;
|
package com.projectairfighter.collectiongenericobjects;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T> {
|
public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T> {
|
||||||
private T[] collection;
|
private T[] collection;
|
||||||
@ -11,7 +12,6 @@ public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public int getMaxCount() {
|
public int getMaxCount() {
|
||||||
return collection.length;
|
return collection.length;
|
||||||
}
|
}
|
||||||
@ -21,14 +21,9 @@ public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T> {
|
|||||||
public void setMaxCount(int value){
|
public void setMaxCount(int value){
|
||||||
if (value < 0) return;
|
if (value < 0) return;
|
||||||
|
|
||||||
// Создание нового массива с указанным размером
|
|
||||||
T[] newCollection = (T[]) new Object[value];
|
T[] newCollection = (T[]) new Object[value];
|
||||||
|
|
||||||
// Копирование элементов из старого массива в новый
|
|
||||||
// Math.min используется, чтобы избежать ArrayIndexOutOfBoundsException
|
|
||||||
System.arraycopy(collection, 0, newCollection, 0, Math.min(collection.length, value));
|
System.arraycopy(collection, 0, newCollection, 0, Math.min(collection.length, value));
|
||||||
|
|
||||||
// Присваивание нового массива переменной collection
|
|
||||||
collection = newCollection;
|
collection = newCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +40,36 @@ public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CollectionType getCollectionType() {
|
||||||
|
return CollectionType.Massive;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<T> getItems() {
|
||||||
|
return () -> new Iterator<>() {
|
||||||
|
private int currentIndex = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return currentIndex < collection.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T next() {
|
||||||
|
if (!hasNext()) {
|
||||||
|
throw new NoSuchElementException();
|
||||||
|
}
|
||||||
|
return collection[currentIndex++];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
throw new UnsupportedOperationException("Оператор не поддерживается");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int insert(T obj) {
|
public int insert(T obj) {
|
||||||
return insert(obj, 0);
|
return insert(obj, 0);
|
||||||
|
@ -4,7 +4,9 @@ import com.projectairfighter.drawnings.DrawningWarPlane;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
import static com.projectairfighter.drawnings.ExtensionDrawningPlane.createDrawingPlane;
|
||||||
|
import static com.projectairfighter.drawnings.ExtensionDrawningPlane.getDataForSave;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Класс-хранилище коллекций.
|
* Класс-хранилище коллекций.
|
||||||
@ -20,17 +22,32 @@ public class StorageCollection<T extends DrawningWarPlane> {
|
|||||||
/**
|
/**
|
||||||
* Ключевое слово, с которого должен начинаться файл
|
* Ключевое слово, с которого должен начинаться файл
|
||||||
*/
|
*/
|
||||||
private final String collectionKey = "CollectionsStorage";
|
private static final String COLLECTION_KEY = "CollectionsStorage";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Разделитель для записи ключа и значения элемента словаря
|
* Ключевое слово, с которого должен начинаться файл с определнной коллекцией
|
||||||
*/
|
*/
|
||||||
private final String separatorForKeyValue = "|";
|
private static final String COLLECTION_KEY_ONE_COL = "OneCollectionsStorage";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Разделитель для записей коллекции данных в файл
|
* Разделитель для записи ключа и значения элемента словаря для всех коллекций
|
||||||
*/
|
*/
|
||||||
private final String separatorItems = ";";
|
private static final String SEPARATOR_FOR_KEY_VALUE_ALL_COL = "&";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Разделитель для записи ключа и значения элемента словаря для определенной коллекции
|
||||||
|
*/
|
||||||
|
private static final String SEPARATOR_FOR_KEY_VALUE_ONE_TYPE_COL = "#";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Разделитель для записей коллекции данных в файл для всех коллекций
|
||||||
|
*/
|
||||||
|
private static final String SEPARATOR_ITEMS_ALL_COL = ";";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Разделитель для записей коллекции данных в файл для определенных коллекций
|
||||||
|
*/
|
||||||
|
private static final String SEPARATOR_ITEMS_ONE_TYPE_COL = "/";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,12 +55,12 @@ public class StorageCollection<T extends DrawningWarPlane> {
|
|||||||
*
|
*
|
||||||
* @return Список названий коллекций.
|
* @return Список названий коллекций.
|
||||||
*/
|
*/
|
||||||
public List<String> Keys() {
|
public List<String> keys() {
|
||||||
return new ArrayList<>(storages.keySet());
|
return new ArrayList<>(storages.keySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Конструктор.
|
* Конструктор
|
||||||
*/
|
*/
|
||||||
public StorageCollection() {
|
public StorageCollection() {
|
||||||
storages = new HashMap<>();
|
storages = new HashMap<>();
|
||||||
@ -67,7 +84,6 @@ public class StorageCollection<T extends DrawningWarPlane> {
|
|||||||
return;
|
return;
|
||||||
case List:
|
case List:
|
||||||
storages.put(name, new ListGenericObjects<>());
|
storages.put(name, new ListGenericObjects<>());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,89 +120,173 @@ public class StorageCollection<T extends DrawningWarPlane> {
|
|||||||
* @return Элемент коллекции или null, если коллекция с данным названием отсутствует или индекс некорректен.
|
* @return Элемент коллекции или null, если коллекция с данным названием отсутствует или индекс некорректен.
|
||||||
*/
|
*/
|
||||||
public T getElement(String name, int index) {
|
public T getElement(String name, int index) {
|
||||||
return this.get(name).get(index);
|
return storages.get(name).get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Сохранение информации в файл
|
* Сохранение информации в файл
|
||||||
|
* @param path путь к файлу
|
||||||
|
* @return результат сохранения
|
||||||
*/
|
*/
|
||||||
public boolean saveData(String filename) {
|
public boolean saveData(String path) {
|
||||||
// Проверяем, не пуста ли коллекция
|
|
||||||
if (storages.isEmpty()) {
|
if (storages.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Удаляем файл, если он существует
|
File file = new File(path);
|
||||||
File file = new File(filename);
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
||||||
// Записываем ключ коллекции
|
writer.write(COLLECTION_KEY);
|
||||||
writer.write(collectionKey);
|
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
|
|
||||||
// Итерируемся по коллекциям
|
|
||||||
for (Map.Entry<String, ICollectionGenericObjects<T>> entry : storages.entrySet()) {
|
for (Map.Entry<String, ICollectionGenericObjects<T>> entry : storages.entrySet()) {
|
||||||
// Пропускаем пустые коллекции
|
|
||||||
if (entry.getValue().getCount() == 0) {
|
if (entry.getValue().getCount() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(entry.getKey());
|
sb.append(entry.getKey());
|
||||||
sb.append(separatorForKeyValue);
|
sb.append(SEPARATOR_FOR_KEY_VALUE_ALL_COL);
|
||||||
sb.append(entry.getValue().getCollectionType());
|
sb.append(entry.getValue().getCollectionType());
|
||||||
sb.append(separatorForKeyValue);
|
sb.append(SEPARATOR_FOR_KEY_VALUE_ALL_COL);
|
||||||
sb.append(entry.getValue().getMaxCount());
|
sb.append(entry.getValue().getMaxCount());
|
||||||
sb.append(separatorForKeyValue);
|
sb.append(SEPARATOR_FOR_KEY_VALUE_ALL_COL);
|
||||||
|
|
||||||
// Сохраняем каждый элемент в коллекции
|
|
||||||
for (T item : entry.getValue().getItems()) {
|
for (T item : entry.getValue().getItems()) {
|
||||||
if (item == null) continue; // Проверка на null
|
if (item == null) continue;
|
||||||
String data = item.getDataForSave();
|
String data = getDataForSave(item);
|
||||||
if (data == null || data.isEmpty()) continue;
|
|
||||||
|
if (data.isEmpty()) continue;
|
||||||
sb.append(data);
|
sb.append(data);
|
||||||
sb.append(separatorItems);
|
sb.append(SEPARATOR_ITEMS_ALL_COL);
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write(sb.toString());
|
writer.write(sb.toString());
|
||||||
writer.newLine();
|
writer.newLine();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сохранение в файл по имени коллекции
|
||||||
|
* @param path путь к файлу
|
||||||
|
* @param collection название коллекции для сохранения
|
||||||
|
* @return результат сохранения
|
||||||
|
*/
|
||||||
|
public boolean saveData(String path, String collection) {
|
||||||
|
if (storages.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(path);
|
||||||
|
if (file.exists()) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
|
||||||
|
writer.write(COLLECTION_KEY_ONE_COL);
|
||||||
|
writer.newLine();
|
||||||
|
|
||||||
|
for (Map.Entry<String, ICollectionGenericObjects<T>> entry : storages.entrySet()) {
|
||||||
|
if ((entry.getValue().getCount() == 0) || !entry.getKey().equals(collection)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(entry.getKey());
|
||||||
|
sb.append(SEPARATOR_FOR_KEY_VALUE_ONE_TYPE_COL);
|
||||||
|
sb.append(entry.getValue().getCollectionType());
|
||||||
|
sb.append(SEPARATOR_FOR_KEY_VALUE_ONE_TYPE_COL);
|
||||||
|
sb.append(entry.getValue().getMaxCount());
|
||||||
|
sb.append(SEPARATOR_FOR_KEY_VALUE_ONE_TYPE_COL);
|
||||||
|
|
||||||
|
for (T item : entry.getValue().getItems()) {
|
||||||
|
if (item == null) continue;
|
||||||
|
String data = getDataForSave(item);
|
||||||
|
|
||||||
|
if (data.isEmpty()) continue;
|
||||||
|
sb.append(data);
|
||||||
|
sb.append(SEPARATOR_ITEMS_ONE_TYPE_COL);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.write(sb.toString());
|
||||||
|
writer.newLine();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Обработка данных в файле
|
||||||
|
* @param recordLine строка данных для обработки
|
||||||
|
* @param keyValueSeparator разделитель ключа и значения
|
||||||
|
* @param itemSeparator разделитель свойств
|
||||||
|
* @return результат обработки
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private boolean processRecord(String recordLine, String keyValueSeparator, String itemSeparator) {
|
||||||
|
String[] record = recordLine.split(keyValueSeparator);
|
||||||
|
if (record.length != 4) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CollectionType collectionType = CollectionType.valueOf(record[1]);
|
||||||
|
ICollectionGenericObjects<T> collection = StorageCollection.createCollection(collectionType);
|
||||||
|
if (collection == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
collection.setMaxCount(Integer.parseInt(record[2]));
|
||||||
|
|
||||||
|
String[] items = record[3].split(itemSeparator, -1);
|
||||||
|
for (String elem : items) {
|
||||||
|
T ship = (T) createDrawingPlane(elem);
|
||||||
|
if (ship != null && collection.insert(ship) == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
storages.put(record[0], collection);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Загрузка информации из файла
|
* Загрузка информации из файла
|
||||||
*/
|
*/
|
||||||
public boolean loadData(String filename) {
|
public boolean loadData(String filename) {
|
||||||
if (!new File(filename).exists()) return false;
|
File file = new File(filename);
|
||||||
|
if (!file.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(filename))) {
|
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
|
||||||
String str = reader.readLine();
|
String str = br.readLine();
|
||||||
if (!collectionKey.equals(str)) return false;
|
if (str == null) {
|
||||||
storages.clear();
|
return false;
|
||||||
while ((str = reader.readLine()) != null) {
|
}
|
||||||
String[] record = str.split(Pattern.quote(separatorForKeyValue));
|
|
||||||
if (record.length != 4) continue;
|
if (str.equals(COLLECTION_KEY)) {
|
||||||
CollectionType collectionType = CollectionType.valueOf(record[1]);
|
while ((str = br.readLine()) != null) {
|
||||||
ICollectionGenericObjects<T> collection = createCollection(collectionType);
|
if (!processRecord(str, SEPARATOR_FOR_KEY_VALUE_ALL_COL, SEPARATOR_ITEMS_ALL_COL)) {
|
||||||
if (collection == null) return false;
|
return false;
|
||||||
collection.setMaxCount(Integer.parseInt(record[2]));
|
}
|
||||||
String[] items = record[3].split(Pattern.quote(separatorItems));
|
}
|
||||||
for (String item : items) {
|
} else if (str.equals(COLLECTION_KEY_ONE_COL)) {
|
||||||
T plane = item.createDrawingPlane(); // Нужна соответствующая реализация
|
while ((str = br.readLine()) != null) {
|
||||||
if (plane != null && collection.insert(plane) == -1) return false;
|
if (!processRecord(str, SEPARATOR_FOR_KEY_VALUE_ONE_TYPE_COL, SEPARATOR_ITEMS_ONE_TYPE_COL)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
storages.put(record[0], collection);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -195,14 +295,11 @@ public class StorageCollection<T extends DrawningWarPlane> {
|
|||||||
/**
|
/**
|
||||||
* Создание коллекции по типу
|
* Создание коллекции по типу
|
||||||
*/
|
*/
|
||||||
private ICollectionGenericObjects<T> createCollection(CollectionType collectionType) {
|
private static <T> ICollectionGenericObjects<T> createCollection(CollectionType collectionType) {
|
||||||
switch (collectionType) {
|
return switch (collectionType) {
|
||||||
case Massive:
|
case Massive -> new MassiveGenericObjects<>();
|
||||||
return new MassiveGenericObjects<>();
|
case List -> new ListGenericObjects<>();
|
||||||
case List:
|
default -> null;
|
||||||
return new ListGenericObjects<>();
|
};
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ import javafx.scene.canvas.GraphicsContext;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
public class DrawningAirFighter extends DrawningWarPlane {
|
public class DrawningAirFighter extends DrawningWarPlane {
|
||||||
public DrawningAirFighter(int speed, double weight, Color bodyColor, Color
|
public DrawningAirFighter(int speed, double weight, Color bodyColor, IDrawableExtras engineDrawing, Color
|
||||||
additionalColor, boolean bodyRockets, boolean additionalWings) {
|
additionalColor, boolean bodyRockets, boolean additionalWings) {
|
||||||
super(speed, weight, bodyColor);
|
super(speed, weight, bodyColor, engineDrawing);
|
||||||
entityWarPlane = new EntityAirFighter(speed, weight, bodyColor, additionalColor, bodyRockets, additionalWings);
|
entityWarPlane = new EntityAirFighter(speed, weight, bodyColor, engineDrawing, additionalColor, bodyRockets, additionalWings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawningAirFighter(EntityAirFighter entityAirFighter, IDrawableExtras engineDrawing) {
|
public DrawningAirFighter(EntityAirFighter entityAirFighter) {
|
||||||
super(entityAirFighter, engineDrawing);
|
super(entityAirFighter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawningAirFighter(EntityWarPlane entityWarPlane) {
|
public DrawningAirFighter(EntityWarPlane entityWarPlane) {
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package com.projectairfighter.drawnings;
|
package com.projectairfighter.drawnings;
|
||||||
|
|
||||||
import com.projectairfighter.entities.EntityAirFighter;
|
|
||||||
import com.projectairfighter.entities.EntityWarPlane;
|
import com.projectairfighter.entities.EntityWarPlane;
|
||||||
import javafx.scene.canvas.GraphicsContext;
|
import javafx.scene.canvas.GraphicsContext;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class DrawningWarPlane {
|
public class DrawningWarPlane {
|
||||||
// Сущность
|
// Сущность
|
||||||
public EntityWarPlane entityWarPlane;
|
public EntityWarPlane entityWarPlane;
|
||||||
@ -21,28 +18,18 @@ public class DrawningWarPlane {
|
|||||||
|
|
||||||
private final int drawningAirFighterWidth = 157;
|
private final int drawningAirFighterWidth = 157;
|
||||||
private final int drawningAirFighterHeight = 140;
|
private final int drawningAirFighterHeight = 140;
|
||||||
|
|
||||||
private IDrawableExtras engineDrawing;
|
|
||||||
public Integer getPosX(){
|
public Integer getPosX(){
|
||||||
return startPosX;
|
return startPosX;
|
||||||
}
|
}
|
||||||
public Integer getPosY(){
|
public Integer getPosY(){
|
||||||
return startPosY;
|
return startPosY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDrawableExtras getEngineDrawing() {
|
|
||||||
return engineDrawing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth(){
|
public int getWidth(){
|
||||||
return drawningAirFighterWidth;
|
return drawningAirFighterWidth;
|
||||||
}
|
}
|
||||||
public int getHeight(){
|
public int getHeight(){
|
||||||
return drawningAirFighterHeight;
|
return drawningAirFighterHeight;
|
||||||
}
|
}
|
||||||
public void setEngineDrawing(IDrawableExtras engineDrawing) {
|
|
||||||
this.engineDrawing = engineDrawing;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected DrawningWarPlane() {
|
protected DrawningWarPlane() {
|
||||||
pictureWidth = 0;
|
pictureWidth = 0;
|
||||||
@ -51,22 +38,8 @@ public class DrawningWarPlane {
|
|||||||
startPosY = null;
|
startPosY = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawningWarPlane(int speed, double weight, Color bodyColor) {
|
public DrawningWarPlane(int speed, double weight, Color bodyColor, IDrawableExtras engineDrawing) {
|
||||||
entityWarPlane = new EntityWarPlane(speed, weight, bodyColor);
|
entityWarPlane = new EntityWarPlane(speed, weight, bodyColor, engineDrawing);
|
||||||
IDrawableExtras[] engineDrawings = {
|
|
||||||
new EllipticalEngineDrawing(),
|
|
||||||
new TriangleEngineDrawing(),
|
|
||||||
new RectangleEngineDrawing()
|
|
||||||
};
|
|
||||||
|
|
||||||
Random random = new Random();
|
|
||||||
engineDrawing = engineDrawings[random.nextInt(engineDrawings.length)];
|
|
||||||
engineDrawing.setCountEngines(random.nextInt(7));
|
|
||||||
}
|
|
||||||
|
|
||||||
public DrawningWarPlane(EntityWarPlane entityWarPlane, IDrawableExtras engineDrawing){
|
|
||||||
this.entityWarPlane = entityWarPlane;
|
|
||||||
this.engineDrawing = engineDrawing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawningWarPlane(EntityWarPlane entityWarPlane)
|
public DrawningWarPlane(EntityWarPlane entityWarPlane)
|
||||||
@ -75,8 +48,8 @@ public class DrawningWarPlane {
|
|||||||
this.entityWarPlane = entityWarPlane;
|
this.entityWarPlane = entityWarPlane;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setPictureSize(int width, int height) {
|
public void setPictureSize(int width, int height) {
|
||||||
if (width <= drawningAirFighterWidth || height <= drawningAirFighterHeight) return false;
|
if (width <= drawningAirFighterWidth || height <= drawningAirFighterHeight) return;
|
||||||
pictureWidth = width;
|
pictureWidth = width;
|
||||||
pictureHeight = height;
|
pictureHeight = height;
|
||||||
if (startPosX != null && startPosY != null) {
|
if (startPosX != null && startPosY != null) {
|
||||||
@ -87,7 +60,6 @@ public class DrawningWarPlane {
|
|||||||
startPosY = pictureHeight - drawningAirFighterHeight;
|
startPosY = pictureHeight - drawningAirFighterHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(int x, int y) {
|
public void setPosition(int x, int y) {
|
||||||
@ -141,7 +113,7 @@ public class DrawningWarPlane {
|
|||||||
|
|
||||||
if (pictureWidth == 0 || pictureHeight == 0) return;
|
if (pictureWidth == 0 || pictureHeight == 0) return;
|
||||||
|
|
||||||
engineDrawing.drawEngine(gc, entityWarPlane.getBodyColor(), getPosX(), getPosY());
|
entityWarPlane.getEngineDrawing().drawEngine(gc, entityWarPlane.getBodyColor(), getPosX(), getPosY());
|
||||||
|
|
||||||
gc.setFill(entityWarPlane.getBodyColor());
|
gc.setFill(entityWarPlane.getBodyColor());
|
||||||
gc.setStroke(entityWarPlane.getBodyColor());
|
gc.setStroke(entityWarPlane.getBodyColor());
|
||||||
@ -173,29 +145,4 @@ public class DrawningWarPlane {
|
|||||||
new double[]{startPosY + 79, startPosY + 133, startPosY + 133, startPosY + 79}, 4);
|
new double[]{startPosY + 79, startPosY + 133, startPosY + 133, startPosY + 79}, 4);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String SEPARATOR_FOR_OBJECT = ":";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Создание объекта из строки.
|
|
||||||
*
|
|
||||||
* @param info Строка с данными для создания объекта.
|
|
||||||
* @return Объект.
|
|
||||||
*/
|
|
||||||
public static DrawningWarPlane createDrawingPlane(String info) {
|
|
||||||
String[] strs = info.split(SEPARATOR_FOR_OBJECT);
|
|
||||||
EntityWarPlane plane = EntityAirFighter.createEntityAirFighter(strs);
|
|
||||||
if (plane != null) {
|
|
||||||
return new DrawningAirFighter(plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
plane = EntityWarPlane.createEntityWarPlane(strs);
|
|
||||||
if (plane != null) {
|
|
||||||
return new DrawningWarPlane(plane);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract String getDataForSave();
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,11 @@ public class EllipticalEngineDrawing implements IDrawableExtras {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCountEngines() {
|
||||||
|
return engineCount.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawEngine(GraphicsContext gc, Color color, int startPosX, int startPosY) {
|
public void drawEngine(GraphicsContext gc, Color color, int startPosX, int startPosY) {
|
||||||
double engineWidth = 6;
|
double engineWidth = 6;
|
||||||
|
@ -9,5 +9,5 @@ public enum EngineCount {
|
|||||||
|
|
||||||
EngineCount(int Value) { value = Value; }
|
EngineCount(int Value) { value = Value; }
|
||||||
|
|
||||||
public int getValue() { return value; }
|
public int getValue() { return this.value; }
|
||||||
}
|
}
|
||||||
|
@ -5,5 +5,6 @@ import javafx.scene.paint.Color;
|
|||||||
|
|
||||||
public interface IDrawableExtras {
|
public interface IDrawableExtras {
|
||||||
void setCountEngines(int countEngines);
|
void setCountEngines(int countEngines);
|
||||||
|
int getCountEngines();
|
||||||
void drawEngine(GraphicsContext gc, Color color, int startPosX, int startPosY);
|
void drawEngine(GraphicsContext gc, Color color, int startPosX, int startPosY);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,11 @@ public class RectangleEngineDrawing implements IDrawableExtras {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCountEngines() {
|
||||||
|
return engineCount.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawEngine(GraphicsContext gc, Color color, int startPosX, int startPosY) {
|
public void drawEngine(GraphicsContext gc, Color color, int startPosX, int startPosY) {
|
||||||
double engineWidth = 6;
|
double engineWidth = 6;
|
||||||
|
@ -21,6 +21,11 @@ public class TriangleEngineDrawing implements IDrawableExtras {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCountEngines() {
|
||||||
|
return engineCount.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawEngine(GraphicsContext gc, Color color, int startPosX, int startPosY) {
|
public void drawEngine(GraphicsContext gc, Color color, int startPosX, int startPosY) {
|
||||||
double engineWidth = 6;
|
double engineWidth = 6;
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.projectairfighter.entities;
|
package com.projectairfighter.entities;
|
||||||
|
|
||||||
|
import com.projectairfighter.drawnings.EllipticalEngineDrawing;
|
||||||
|
import com.projectairfighter.drawnings.IDrawableExtras;
|
||||||
|
import com.projectairfighter.drawnings.RectangleEngineDrawing;
|
||||||
|
import com.projectairfighter.drawnings.TriangleEngineDrawing;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
public class EntityAirFighter extends EntityWarPlane {
|
public class EntityAirFighter extends EntityWarPlane {
|
||||||
@ -34,9 +38,9 @@ public class EntityAirFighter extends EntityWarPlane {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Конструктор
|
// Конструктор
|
||||||
public EntityAirFighter(int speed, double weight, Color bodyColor, Color
|
public EntityAirFighter(int speed, double weight, Color bodyColor, IDrawableExtras engineDrawing, Color
|
||||||
additionalColor, boolean bodyRockets, boolean additionalWings){
|
additionalColor, boolean bodyRockets, boolean additionalWings){
|
||||||
super(speed, weight, bodyColor);
|
super(speed, weight, bodyColor, engineDrawing);
|
||||||
this.additionalColor = additionalColor;
|
this.additionalColor = additionalColor;
|
||||||
this.bodyRockets = bodyRockets;
|
this.bodyRockets = bodyRockets;
|
||||||
this.additionalWings = additionalWings;
|
this.additionalWings = additionalWings;
|
||||||
@ -51,10 +55,12 @@ public class EntityAirFighter extends EntityWarPlane {
|
|||||||
"EntityAirFighter",
|
"EntityAirFighter",
|
||||||
String.valueOf(getSpeed()),
|
String.valueOf(getSpeed()),
|
||||||
String.valueOf(getWeight()),
|
String.valueOf(getWeight()),
|
||||||
getBodyColor().toString(), // Здесь предполагается, что у вас есть метод toString, возвращающий имя цвета
|
String.valueOf(getBodyColor()),
|
||||||
getAdditionalColor().toString(), // Аналогично для дополнительного цвета
|
String.valueOf(getEngineDrawing().getCountEngines()),
|
||||||
String.valueOf(hasBodyRockets()),
|
getEngineDrawing().getClass().getSimpleName(),
|
||||||
String.valueOf(hasAdditionalWings())
|
String.valueOf(additionalColor),
|
||||||
|
String.valueOf(bodyRockets),
|
||||||
|
String.valueOf(additionalWings)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,17 +68,26 @@ public class EntityAirFighter extends EntityWarPlane {
|
|||||||
* Создание объекта из массива строк
|
* Создание объекта из массива строк
|
||||||
*/
|
*/
|
||||||
public static EntityAirFighter createEntityAirFighter(String[] strs) {
|
public static EntityAirFighter createEntityAirFighter(String[] strs) {
|
||||||
if (strs.length != 7 || !"EntityAirFighter".equals(strs[0])) {
|
if (strs.length != 9 || !"EntityAirFighter".equals(strs[0])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int speed = Integer.parseInt(strs[1]);
|
int speed = Integer.parseInt(strs[1]);
|
||||||
double weight = Double.parseDouble(strs[2]);
|
double weight = Double.parseDouble(strs[2]);
|
||||||
Color bodyColor = Color.valueOf(strs[3]); // Здесь предполагается, что Color.valueOf может обработать имя цвета
|
Color bodyColor = Color.valueOf(strs[3]);
|
||||||
Color additionalColor = Color.valueOf(strs[4]);
|
int countEngines = Integer.parseInt(strs[4]);
|
||||||
boolean bodyRockets = Boolean.parseBoolean(strs[5]);
|
IDrawableExtras engineDrawing = switch (strs[5]) {
|
||||||
boolean additionalWings = Boolean.parseBoolean(strs[6]);
|
case "RectangleEngineDrawing" -> new RectangleEngineDrawing();
|
||||||
|
case "TriangleEngineDrawing" -> new TriangleEngineDrawing();
|
||||||
|
case "EllipticalEngineDrawing" -> new EllipticalEngineDrawing();
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
Color additionalColor = Color.valueOf(strs[6]);
|
||||||
|
boolean bodyRockets = Boolean.parseBoolean(strs[7]);
|
||||||
|
boolean additionalWings = Boolean.parseBoolean(strs[8]);
|
||||||
|
|
||||||
return new EntityAirFighter(speed, weight, bodyColor, additionalColor, bodyRockets, additionalWings);
|
if (engineDrawing != null) engineDrawing.setCountEngines(countEngines);
|
||||||
|
|
||||||
|
return new EntityAirFighter(speed, weight, bodyColor, engineDrawing, additionalColor, bodyRockets, additionalWings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package com.projectairfighter.entities;
|
package com.projectairfighter.entities;
|
||||||
|
|
||||||
|
import com.projectairfighter.drawnings.EllipticalEngineDrawing;
|
||||||
|
import com.projectairfighter.drawnings.IDrawableExtras;
|
||||||
|
import com.projectairfighter.drawnings.RectangleEngineDrawing;
|
||||||
|
import com.projectairfighter.drawnings.TriangleEngineDrawing;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
public class EntityWarPlane {
|
public class EntityWarPlane {
|
||||||
@ -9,31 +13,43 @@ public class EntityWarPlane {
|
|||||||
private double weight;
|
private double weight;
|
||||||
// Основной цвет
|
// Основной цвет
|
||||||
private Color bodyColor;
|
private Color bodyColor;
|
||||||
|
private IDrawableExtras engineDrawing;
|
||||||
|
|
||||||
public double getStep() {
|
public double getStep() {
|
||||||
return speed * 100 / weight;
|
return speed * 100 / weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getBodyColor() {
|
public Color getBodyColor() {
|
||||||
return bodyColor;
|
return bodyColor;
|
||||||
}
|
}
|
||||||
|
public int getSpeed() {
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
public double getWeight() {
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
|
public IDrawableExtras getEngineDrawing() {
|
||||||
|
return engineDrawing;
|
||||||
|
}
|
||||||
|
|
||||||
public void setBodyColor(Color bodyColor)
|
public void setBodyColor(Color bodyColor)
|
||||||
{
|
{
|
||||||
this.bodyColor = bodyColor;
|
this.bodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpeed(int speed) {
|
public void setSpeed(int speed) {
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeight(double weight) {
|
public void setWeight(double weight) {
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
}
|
}
|
||||||
|
public void setEngineDrawing(IDrawableExtras engineDrawing) {
|
||||||
|
this.engineDrawing = engineDrawing;
|
||||||
|
}
|
||||||
|
|
||||||
public EntityWarPlane(int speed, double weight, Color bodyColor){
|
public EntityWarPlane(int speed, double weight, Color bodyColor, IDrawableExtras engineDrawing){
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.bodyColor = bodyColor;
|
this.bodyColor = bodyColor;
|
||||||
|
this.engineDrawing = engineDrawing;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -44,7 +60,9 @@ public class EntityWarPlane {
|
|||||||
"EntityWarPlane",
|
"EntityWarPlane",
|
||||||
String.valueOf(speed),
|
String.valueOf(speed),
|
||||||
String.valueOf(weight),
|
String.valueOf(weight),
|
||||||
getBodyColor().toString()
|
getBodyColor().toString(),
|
||||||
|
String.valueOf(engineDrawing.getCountEngines()),
|
||||||
|
engineDrawing.getClass().getSimpleName()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,13 +72,23 @@ public class EntityWarPlane {
|
|||||||
* @return Объект класса EntityWarPlane или null, если строка недействительна.
|
* @return Объект класса EntityWarPlane или null, если строка недействительна.
|
||||||
*/
|
*/
|
||||||
public static EntityWarPlane createEntityWarPlane(String[] strs) {
|
public static EntityWarPlane createEntityWarPlane(String[] strs) {
|
||||||
if (strs.length != 4 || !strs[0].equals("EntityWarPlane")) {
|
if (strs.length != 6 || !strs[0].equals("EntityWarPlane")) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int speed = Integer.parseInt(strs[1]);
|
int speed = Integer.parseInt(strs[1]);
|
||||||
double weight = Double.parseDouble(strs[2]);
|
double weight = Double.parseDouble(strs[2]);
|
||||||
Color bodyColor = Color.valueOf(strs[3]); // Должен быть реализован метод valueOf для Color
|
Color bodyColor = Color.valueOf(strs[3]);
|
||||||
|
int countEngine = Integer.parseInt(strs[4]);
|
||||||
|
IDrawableExtras engineDrawing = switch (strs[5]) {
|
||||||
|
case "RectangleEngineDrawing" -> new RectangleEngineDrawing();
|
||||||
|
case "TriangleEngineDrawing" -> new TriangleEngineDrawing();
|
||||||
|
case "EllipticalEngineDrawing" -> new EllipticalEngineDrawing();
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
|
||||||
return new EntityWarPlane(speed, weight, bodyColor);
|
if (engineDrawing != null) engineDrawing.setCountEngines(countEngine);
|
||||||
|
|
||||||
|
return new EntityWarPlane(speed, weight, bodyColor, engineDrawing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,97 +1,94 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.canvas.Canvas?>
|
<?import javafx.scene.canvas.*?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.control.ComboBox?>
|
<?import javafx.scene.input.*?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.control.ListView?>
|
<?import javafx.scene.text.*?>
|
||||||
<?import javafx.scene.control.Menu?>
|
|
||||||
<?import javafx.scene.control.MenuBar?>
|
|
||||||
<?import javafx.scene.control.MenuItem?>
|
|
||||||
<?import javafx.scene.control.RadioButton?>
|
|
||||||
<?import javafx.scene.control.SplitPane?>
|
|
||||||
<?import javafx.scene.control.TextField?>
|
|
||||||
<?import javafx.scene.control.ToggleGroup?>
|
|
||||||
<?import javafx.scene.input.KeyCodeCombination?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.text.Text?>
|
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="795.0" prefWidth="1292.0" xmlns="http://javafx.com/javafx/19.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.projectairfighter.FormWarPlaneCollection">
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="795.0"
|
||||||
<children>
|
prefWidth="1292.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
<SplitPane dividerPositions="0.811965811965812" layoutX="1.0" layoutY="27.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="765.0" prefWidth="1292.0">
|
fx:controller="com.projectairfighter.FormWarPlaneCollection">
|
||||||
<items>
|
<SplitPane dividerPositions="0.811965811965812" layoutX="1.0" layoutY="27.0" maxHeight="-Infinity"
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="698.0" prefWidth="965.0">
|
maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="765.0" prefWidth="1292.0">
|
||||||
<children>
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="698.0" prefWidth="965.0">
|
||||||
<Canvas fx:id="canvasWarPlane" height="763.0" width="1044.0" />
|
<Canvas fx:id="canvasWarPlane" height="763.0" width="1044.0"/>
|
||||||
</children>
|
</AnchorPane>
|
||||||
</AnchorPane>
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="196.0">
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="196.0">
|
<SplitPane dividerPositions="0.43889618922470436" orientation="VERTICAL" prefHeight="763.0"
|
||||||
<children>
|
prefWidth="237.0">
|
||||||
<SplitPane dividerPositions="0.43889618922470436" orientation="VERTICAL" prefHeight="763.0" prefWidth="237.0">
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
|
||||||
<items>
|
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Инструменты" AnchorPane.leftAnchor="14.0"
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
|
AnchorPane.topAnchor="6.0"/>
|
||||||
<children>
|
<TextField fx:id="textFieldCollectionName" layoutX="6.0" layoutY="49.0" prefHeight="25.0"
|
||||||
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="Инструменты" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="6.0" />
|
prefWidth="224.0"/>
|
||||||
<TextField fx:id="textFieldCollectionName" layoutX="6.0" layoutY="49.0" prefHeight="25.0" prefWidth="224.0" />
|
<RadioButton fx:id="radioButtonMassive" layoutX="25.0" layoutY="77.0" mnemonicParsing="false"
|
||||||
<RadioButton fx:id="radioButtonMassive" layoutX="25.0" layoutY="77.0" mnemonicParsing="false" text="Массив">
|
text="Массив">
|
||||||
<toggleGroup>
|
<toggleGroup>
|
||||||
<ToggleGroup fx:id="toggle" />
|
<ToggleGroup fx:id="toggle"/>
|
||||||
</toggleGroup>
|
</toggleGroup>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton fx:id="radioButtonList" layoutX="141.0" layoutY="77.0" mnemonicParsing="false" text="Список" toggleGroup="$toggle" />
|
<RadioButton fx:id="radioButtonList" layoutX="141.0" layoutY="77.0" mnemonicParsing="false"
|
||||||
<Button layoutX="6.0" layoutY="101.0" mnemonicParsing="false" onAction="#buttonCollectionAdd" prefHeight="25.0" prefWidth="224.0" text="Добавить в коллекцию" />
|
text="Список" toggleGroup="$toggle"/>
|
||||||
<Button layoutX="6.0" layoutY="299.0" mnemonicParsing="false" onAction="#buttonCollectionDel" prefHeight="25.0" prefWidth="224.0" text="Удалить коллекцию" />
|
<Button layoutX="6.0" layoutY="101.0" mnemonicParsing="false" onAction="#buttonCollectionAdd"
|
||||||
<ListView fx:id="listViewCollection" layoutX="6.0" layoutY="136.0" prefHeight="155.0" prefWidth="224.0" />
|
prefHeight="25.0" prefWidth="224.0" text="Добавить в коллекцию"/>
|
||||||
<Label layoutX="56.0" layoutY="26.0" text="Название коллекции" />
|
<Button layoutX="6.0" layoutY="299.0" mnemonicParsing="false" onAction="#buttonCollectionDel"
|
||||||
</children>
|
prefHeight="25.0" prefWidth="224.0" text="Удалить коллекцию"/>
|
||||||
|
<ListView fx:id="listViewCollection" layoutX="6.0" layoutY="136.0" prefHeight="155.0"
|
||||||
|
prefWidth="224.0"/>
|
||||||
|
<Label layoutX="56.0" layoutY="26.0" text="Название коллекции"/>
|
||||||
|
</AnchorPane>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
|
||||||
|
<SplitPane fx:id="splitPane" dividerPositions="0.18691588785046728" layoutY="-8.0"
|
||||||
|
orientation="VERTICAL" prefHeight="430.0" prefWidth="237.0">
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="116.0" prefWidth="235.0">
|
||||||
|
<ComboBox fx:id="comboBox" layoutX="6.0" layoutY="15.0"
|
||||||
|
onAction="#comboBoxSelectorCompany" prefHeight="25.0"
|
||||||
|
prefWidth="224.0"/>
|
||||||
|
<Button layoutX="6.0" layoutY="46.0" mnemonicParsing="false"
|
||||||
|
onAction="#buttonCreateCompany" prefHeight="25.0" prefWidth="224.0"
|
||||||
|
text="Создать компанию"/>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
|
<AnchorPane disable="true" minHeight="0.0" minWidth="0.0" prefHeight="312.0"
|
||||||
<children>
|
prefWidth="235.0">
|
||||||
<SplitPane fx:id="splitPane" dividerPositions="0.18691588785046728" layoutY="-8.0" orientation="VERTICAL" prefHeight="430.0" prefWidth="237.0">
|
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="5.0" layoutY="12.0"
|
||||||
<items>
|
mnemonicParsing="false" onAction="#buttonGoToFormCreate"
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="116.0" prefWidth="235.0">
|
prefHeight="35.0" prefWidth="224.0" text="Добавление самолета"/>
|
||||||
<children>
|
<TextField fx:id="textBox" layoutX="6.0" layoutY="132.0" prefHeight="25.0"
|
||||||
<ComboBox fx:id="comboBox" layoutX="6.0" layoutY="15.0" onAction="#comboBoxSelectorCompany" prefHeight="25.0" prefWidth="224.0" />
|
prefWidth="224.0"/>
|
||||||
<Button layoutX="6.0" layoutY="46.0" mnemonicParsing="false" onAction="#buttonCreateCompany" prefHeight="25.0" prefWidth="224.0" text="Создать компанию" />
|
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="6.0" layoutY="162.0"
|
||||||
</children>
|
mnemonicParsing="false" onAction="#buttonRemovePlaneClicked"
|
||||||
</AnchorPane>
|
prefHeight="35.0" prefWidth="224.0" text="Удалить истребитель"/>
|
||||||
<AnchorPane disable="true" minHeight="0.0" minWidth="0.0" prefHeight="312.0" prefWidth="235.0">
|
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="6.0" layoutY="215.0"
|
||||||
<children>
|
mnemonicParsing="false" onAction="#buttonGoToCheck" prefHeight="35.0"
|
||||||
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="5.0" layoutY="12.0" mnemonicParsing="false" onAction="#buttonGoToFormCreate" prefHeight="35.0" prefWidth="224.0" text="Добавление самолета" />
|
prefWidth="224.0" text="Передать на тесты"/>
|
||||||
<TextField fx:id="textBox" layoutX="6.0" layoutY="132.0" prefHeight="25.0" prefWidth="224.0" />
|
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="6.0" layoutY="300.0"
|
||||||
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="6.0" layoutY="162.0" mnemonicParsing="false" onAction="#buttonRemovePlaneClicked" prefHeight="35.0" prefWidth="224.0" text="Удалить истребитель" />
|
mnemonicParsing="false" onAction="#buttonRefresh" prefHeight="35.0"
|
||||||
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="6.0" layoutY="215.0" mnemonicParsing="false" onAction="#buttonGoToCheck" prefHeight="35.0" prefWidth="224.0" text="Передать на тесты" />
|
prefWidth="224.0" text="Обновить"/>
|
||||||
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="6.0" layoutY="300.0" mnemonicParsing="false" onAction="#buttonRefresh" prefHeight="35.0" prefWidth="224.0" text="Обновить" />
|
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="6.0" layoutY="90.0"
|
||||||
<Button alignment="CENTER" contentDisplay="CENTER" layoutX="6.0" layoutY="90.0" mnemonicParsing="false" onAction="#buttonGoFormConstructor" prefHeight="35.0" prefWidth="224.0" text="Добавить через конструктор" />
|
mnemonicParsing="false" onAction="#buttonGoFormConstructor"
|
||||||
<Button layoutX="6.0" layoutY="257.0" mnemonicParsing="false" onAction="#buttonGoToFormWithDeleteObject" prefHeight="35.0" text="Передать на тесты удаленный объект" />
|
prefHeight="35.0" prefWidth="224.0" text="Добавить через конструктор"/>
|
||||||
</children>
|
<Button layoutX="6.0" layoutY="257.0" mnemonicParsing="false"
|
||||||
</AnchorPane>
|
onAction="#buttonGoToFormWithDeleteObject" prefHeight="35.0"
|
||||||
</items>
|
text="Передать на тесты удаленный объект"/>
|
||||||
</SplitPane>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</items>
|
</SplitPane>
|
||||||
</SplitPane>
|
</AnchorPane>
|
||||||
</children>
|
</SplitPane>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</items>
|
</SplitPane>
|
||||||
</SplitPane>
|
<MenuBar prefHeight="25.0" prefWidth="1292.0">
|
||||||
<MenuBar prefHeight="25.0" prefWidth="1292.0">
|
<Menu mnemonicParsing="false" text="Файл">
|
||||||
<menus>
|
<MenuItem mnemonicParsing="false" onAction="#saveToolStripMenuItem" text="Сохранить">
|
||||||
<Menu mnemonicParsing="false" text="Файл">
|
<accelerator>
|
||||||
<items>
|
<KeyCodeCombination alt="UP" code="S" control="DOWN" meta="UP" shift="UP" shortcut="UP"/>
|
||||||
<MenuItem mnemonicParsing="false" text="Сохранить">
|
</accelerator>
|
||||||
<accelerator>
|
</MenuItem>
|
||||||
<KeyCodeCombination alt="UP" code="S" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
|
<MenuItem mnemonicParsing="false" onAction="#loadToolStripMenuItem" text="Загрузить">
|
||||||
</accelerator></MenuItem>
|
<accelerator>
|
||||||
<MenuItem mnemonicParsing="false" text="Загрузить">
|
<KeyCodeCombination alt="UP" code="L" control="DOWN" meta="UP" shift="UP" shortcut="UP"/>
|
||||||
<accelerator>
|
</accelerator>
|
||||||
<KeyCodeCombination alt="UP" code="L" control="DOWN" meta="UP" shift="UP" shortcut="UP" />
|
</MenuItem>
|
||||||
</accelerator>
|
</Menu>
|
||||||
</MenuItem>
|
</MenuBar>
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
</menus>
|
|
||||||
</MenuBar>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user