LabWork4 PIbd-21 Zacharchenko #4
@ -4,6 +4,8 @@ import javafx.beans.InvalidationListener;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
@ -60,21 +62,31 @@ public class ControllerBus {
|
||||
@FXML
|
||||
protected ChoiceBox<Integer> choiceDoors;
|
||||
|
||||
@FXML
|
||||
private ColorPicker bodyColorPicker;
|
||||
|
||||
@FXML
|
||||
private ColorPicker extraColorPicker;
|
||||
|
||||
|
||||
@FXML
|
||||
void ButtonCreate_Click(ActionEvent event) {
|
||||
pictureBoxBus.widthProperty().addListener(listener);
|
||||
pictureBoxBus.heightProperty().addListener(listener);
|
||||
|
||||
Random rnd = new Random();
|
||||
|
||||
_bus = new DrawingBus(rnd.nextInt(100, 300), rnd.nextFloat(1000, 2000),
|
||||
Color.rgb(rnd.nextInt(256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)), choiceDoors.getValue());
|
||||
_bus.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), (int) pictureBoxBus.getWidth(), (int) pictureBoxBus.getHeight());
|
||||
bodyColorPicker.getValue(), choiceDoors.getValue());
|
||||
_bus.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100),
|
||||
(int) pictureBoxBus.getWidth(), (int) pictureBoxBus.getHeight());
|
||||
BorderChanged();
|
||||
}
|
||||
|
||||
void SetData() {
|
||||
Random rnd = new Random();
|
||||
_bus.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), (int) pictureBoxBus.getWidth(), (int) pictureBoxBus.getHeight());
|
||||
_bus.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100),
|
||||
(int) pictureBoxBus.getWidth(), (int) pictureBoxBus.getHeight());
|
||||
statusSpeed.setText("Скорость: %s".formatted(_bus.Bus.Speed));
|
||||
statusWeight.setText("Вес: %s".formatted(_bus.Bus.Weight));
|
||||
statusColor.setText("Цвет: %s".formatted(_bus.Bus.BodyColor));
|
||||
@ -128,10 +140,8 @@ public class ControllerBus {
|
||||
pictureBoxBus.heightProperty().addListener(listener);
|
||||
Random rnd = new Random();
|
||||
_bus = new DrawingDDB(rnd.nextInt(300), rnd.nextInt(2000),
|
||||
Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)),
|
||||
choiceDoors.getValue(),
|
||||
Color.rgb(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)),
|
||||
rnd.nextBoolean(), rnd.nextBoolean());
|
||||
bodyColorPicker.getValue(), choiceDoors.getValue(),
|
||||
extraColorPicker.getValue(), rnd.nextBoolean(), rnd.nextBoolean());
|
||||
SetData();
|
||||
BorderChanged();
|
||||
}
|
||||
@ -168,6 +178,5 @@ public class ControllerBus {
|
||||
Form.myStage.setTitle("DoubleDeckerBus");
|
||||
Form.myStage.setScene(scene);
|
||||
Form.myStage.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -82,8 +82,10 @@ public class ControllerMapWithSetBus {
|
||||
|
||||
@FXML
|
||||
private void initialize(){
|
||||
// canvasBus.setWidth(pictureBoxBus.getWidth());
|
||||
// canvasBus.setWidth(pictureBoxBus.getHeight());
|
||||
gc = canvasBus.getGraphicsContext2D();
|
||||
if (selected != null) {
|
||||
showStorage();
|
||||
}
|
||||
if (_mapsCollection == null)
|
||||
_mapsCollection = new MapsCollection((int) canvasBus.getWidth(), (int) canvasBus.getHeight());
|
||||
comboBoxSelectorMap.setItems(countOfMap);
|
||||
@ -93,6 +95,7 @@ public class ControllerMapWithSetBus {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends String> observableValue, String s, String t1) {
|
||||
selected = t1;
|
||||
showStorage();
|
||||
}
|
||||
});
|
||||
listViewMaps.setItems(_mapsCollection.toObserveList());
|
||||
@ -100,7 +103,6 @@ public class ControllerMapWithSetBus {
|
||||
|
||||
GraphicsContext gc;
|
||||
private void FirstIncome() {
|
||||
gc = canvasBus.getGraphicsContext2D();
|
||||
if (comboBoxSelectorMap.getValue() != map_name) {
|
||||
map_name = comboBoxSelectorMap.getValue();
|
||||
switch (map_name) {
|
||||
@ -132,8 +134,6 @@ public class ControllerMapWithSetBus {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@FXML
|
||||
private void ButtonAddBus_Click(ActionEvent event) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(Form.class.getResource("FormBus.fxml"));
|
||||
@ -165,6 +165,7 @@ public class ControllerMapWithSetBus {
|
||||
}
|
||||
_mapsCollection.AddMap(TextFieldMap.getText(), _mapsDict.get(comboBoxSelectorMap.getValue()));
|
||||
ReloadMaps();
|
||||
showStorage();
|
||||
}
|
||||
@FXML
|
||||
private void ButtonDeleteMap_Click(ActionEvent event)
|
||||
@ -175,7 +176,7 @@ public class ControllerMapWithSetBus {
|
||||
}
|
||||
_mapsCollection.DelMap(listViewMaps.getSelectionModel().getSelectedItem());
|
||||
ReloadMaps();
|
||||
|
||||
showStorage();
|
||||
}
|
||||
|
||||
@FXML
|
||||
@ -235,19 +236,14 @@ public class ControllerMapWithSetBus {
|
||||
alert.setContentText("Не удалось удалить объект");
|
||||
option = alert.showAndWait();
|
||||
}
|
||||
showStorage();
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void ButtonShowStorage_Click(ActionEvent event)
|
||||
{
|
||||
FirstIncome();
|
||||
if (selected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gc.setFill(Color.WHITE);
|
||||
gc.fillRect(0, 0, pictureBoxBus.getWidth(), pictureBoxBus.getHeight());
|
||||
_mapsCollection.GetId(selected).ShowSet(gc);
|
||||
showStorage();
|
||||
}
|
||||
|
||||
@FXML
|
||||
@ -280,7 +276,15 @@ public class ControllerMapWithSetBus {
|
||||
_mapsCollection.GetId(selected).MoveObject(dir);
|
||||
}
|
||||
|
||||
|
||||
private void showStorage() {
|
||||
if (selected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gc.setFill(Color.WHITE);
|
||||
gc.fillRect(0, 0, pictureBoxBus.getWidth(), pictureBoxBus.getHeight());
|
||||
_mapsCollection.GetId(selected).ShowSet(gc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,6 @@ class SetBusesGeneric<T> {
|
||||
if (bus != null){
|
||||
result.add(bus);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
<?import javafx.scene.canvas.Canvas?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ChoiceBox?>
|
||||
<?import javafx.scene.control.ColorPicker?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
@ -27,6 +28,8 @@
|
||||
<Label fx:id="statusSpeed" text="Скорость:" />
|
||||
<Label fx:id="statusWeight" text="Вес:" />
|
||||
<Label fx:id="statusColor" text="Цвет:" />
|
||||
<ColorPicker fx:id="bodyColorPicker" />
|
||||
<ColorPicker fx:id="extraColorPicker" />
|
||||
<Label text="Колл-во дверей:" />
|
||||
<ChoiceBox fx:id="choiceDoors" prefHeight="24.0" prefWidth="58.0" />
|
||||
</children>
|
||||
|
Loading…
Reference in New Issue
Block a user