This commit is contained in:
shadowik 2022-11-29 08:44:44 +04:00
parent 112a806373
commit 728e355b50

View File

@ -59,7 +59,7 @@ public class ControllerMapWithSetBus {
private void initialize(){ private void initialize(){
gc = canvasBus.getGraphicsContext2D(); gc = canvasBus.getGraphicsContext2D();
if (selected != null) { if (selected != null) {
showStorage(); ShowStorage();
} }
if (_mapsCollection == null) if (_mapsCollection == null)
_mapsCollection = new MapsCollection((int) canvasBus.getWidth(), (int) canvasBus.getHeight()); _mapsCollection = new MapsCollection((int) canvasBus.getWidth(), (int) canvasBus.getHeight());
@ -68,7 +68,7 @@ public class ControllerMapWithSetBus {
listViewMaps.getSelectionModel().selectedItemProperty() listViewMaps.getSelectionModel().selectedItemProperty()
.addListener((observableValue, s, t1) -> { .addListener((observableValue, s, t1) -> {
selected = t1; selected = t1;
showStorage(); ShowStorage();
}); });
listViewMaps.setItems(_mapsCollection.toObserveList()); listViewMaps.setItems(_mapsCollection.toObserveList());
} }
@ -109,16 +109,16 @@ public class ControllerMapWithSetBus {
{ {
return; return;
} }
Stage stageArmoredVehicleConfig = new Stage(); Stage stageBus = new Stage();
FXMLLoader fxmlLoader = new FXMLLoader(Form.class.getResource("FormBusConfig.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(Form.class.getResource("FormBusConfig.fxml"));
Scene sceneArmoredVehicle = new Scene(fxmlLoader.load()); Scene sceneBus = new Scene(fxmlLoader.load());
stageArmoredVehicleConfig.setScene(sceneArmoredVehicle); stageBus.setScene(sceneBus);
stageArmoredVehicleConfig.show(); stageBus.show();
ControllerBusConfig controllerArmoredVehicleConfig = fxmlLoader.getController(); ControllerBusConfig controller = fxmlLoader.getController();
controllerArmoredVehicleConfig.AddEvent(this::AddBus); controller.AddEvent(this::AddBus);
controllerArmoredVehicleConfig.SetStage(stageArmoredVehicleConfig); controller.SetStage(stageBus);
FirstIncome(); FirstIncome();
} }
@ -128,20 +128,22 @@ public class ControllerMapWithSetBus {
{ {
return; return;
} }
DrawingObjectBus objectArmoredVehicle = new DrawingObjectBus(bus); DrawingObjectBus objectBus = new DrawingObjectBus(bus);
String selectedMapName = listViewMaps.getSelectionModel().getSelectedItem(); String selectedMapName = listViewMaps.getSelectionModel().getSelectedItem();
Alert alert; Alert alert;
if (selectedMapName != null && selectedMapName.length() != 0 && _mapsCollection.get(selectedMapName).add(objectArmoredVehicle) != -1) if (selectedMapName != null && selectedMapName.length() != 0 && _mapsCollection.get(selectedMapName).add(objectBus) != -1)
{ {
alert = new Alert(Alert.AlertType.INFORMATION, "Объект добавлен", ButtonType.OK); alert = new Alert(Alert.AlertType.INFORMATION, "Объект добавлен", ButtonType.OK);
_mapsCollection.get(selectedMapName).ShowSet(gc); _mapsCollection.get(selectedMapName).ShowSet(gc);
ShowStorage();
} }
else else
{ {
alert = new Alert(Alert.AlertType.ERROR, "Не удалось добавить объект", ButtonType.OK); alert = new Alert(Alert.AlertType.ERROR, "Не удалось добавить объект", ButtonType.OK);
} }
alert.showAndWait(); alert.showAndWait();
} }
@FXML @FXML
@ -165,7 +167,7 @@ public class ControllerMapWithSetBus {
} }
_mapsCollection.AddMap(TextFieldMap.getText(), _mapsDict.get(comboBoxSelectorMap.getValue())); _mapsCollection.AddMap(TextFieldMap.getText(), _mapsDict.get(comboBoxSelectorMap.getValue()));
ReloadMaps(); ReloadMaps();
showStorage(); ShowStorage();
} }
@FXML @FXML
private void ButtonDeleteMap_Click(ActionEvent event) private void ButtonDeleteMap_Click(ActionEvent event)
@ -176,7 +178,7 @@ public class ControllerMapWithSetBus {
} }
_mapsCollection.DelMap(listViewMaps.getSelectionModel().getSelectedItem()); _mapsCollection.DelMap(listViewMaps.getSelectionModel().getSelectedItem());
ReloadMaps(); ReloadMaps();
showStorage(); ShowStorage();
} }
@FXML @FXML
@ -236,19 +238,23 @@ public class ControllerMapWithSetBus {
alert.setContentText("Не удалось удалить объект"); alert.setContentText("Не удалось удалить объект");
option = alert.showAndWait(); option = alert.showAndWait();
} }
showStorage(); ShowStorage();
} }
@FXML @FXML
private void ButtonShowStorage_Click(ActionEvent event) private void ButtonShowStorage_Click(ActionEvent event)
{ {
FirstIncome(); FirstIncome();
showStorage(); ShowStorage();
} }
@FXML @FXML
private void ButtonShowOnMap_Click(ActionEvent event) { private void ButtonShowOnMap_Click(ActionEvent event) {
FirstIncome(); FirstIncome();
ShowMap();
}
private void ShowMap() {
if (selected == null) { if (selected == null) {
return; return;
} }
@ -276,13 +282,13 @@ public class ControllerMapWithSetBus {
_mapsCollection.GetId(selected).MoveObject(dir); _mapsCollection.GetId(selected).MoveObject(dir);
} }
private void showStorage() { private void ShowStorage() {
if (selected == null) if (selected == null)
{ {
return; return;
} }
gc.setFill(Color.WHITE); gc.setFill(Color.WHITE);
gc.fillRect(0, 0, pictureBoxBus.getWidth(), pictureBoxBus.getHeight()); gc.clearRect(0, 0, canvasBus.getWidth(), canvasBus.getHeight());
_mapsCollection.GetId(selected).ShowSet(gc); _mapsCollection.GetId(selected).ShowSet(gc);
} }