Drag&Drop + Events
This commit is contained in:
parent
9b156e2f03
commit
691a60e11d
@ -0,0 +1,186 @@
|
|||||||
|
package com.example.doubledeckerbus;
|
||||||
|
|
||||||
|
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.CheckBox;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.Spinner;
|
||||||
|
import javafx.scene.input.*;
|
||||||
|
import javafx.scene.layout.Background;
|
||||||
|
import javafx.scene.layout.Region;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.paint.Paint;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class ControllerBusConfig {
|
||||||
|
DataFormat colorFormat = DataFormat.lookupMimeType("SerializableColor");
|
||||||
|
DataFormat additionalElementFormat = DataFormat.lookupMimeType("IDrawningAdditionalElement");
|
||||||
|
private Stage _stage;
|
||||||
|
private DrawingBus _bus = null;
|
||||||
|
|
||||||
|
private Event<DrawingBus> addBus;
|
||||||
|
|
||||||
|
public void SetStage(Stage stage)
|
||||||
|
{
|
||||||
|
_stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddEvent(Consumer<DrawingBus> ev)
|
||||||
|
{
|
||||||
|
addBus.AddListener(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawBus()
|
||||||
|
{
|
||||||
|
GraphicsContext gc = canvasObject.getGraphicsContext2D();
|
||||||
|
gc.clearRect(0, 0, canvasObject.getWidth(), canvasObject.getHeight());
|
||||||
|
if (_bus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_bus.SetPosition(5, 5, (int)canvasObject.getWidth(), (int)canvasObject.getHeight());
|
||||||
|
_bus.DrawTransport(gc);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button buttonCancel;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Canvas canvasObject;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckBox checkBoxSecondStage;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private CheckBox checkBoxLadder;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Spinner<Integer> spinnerSpeed = new Spinner<>();
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Spinner<Integer> spinnerDoors = new Spinner<>();
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Spinner<Integer> spinnerWeight = new Spinner<>();
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void initialize()
|
||||||
|
{
|
||||||
|
if (colorFormat == null)
|
||||||
|
{
|
||||||
|
colorFormat = new DataFormat("SerializableColor");
|
||||||
|
}
|
||||||
|
if (additionalElementFormat == null)
|
||||||
|
{
|
||||||
|
additionalElementFormat = new DataFormat("IDrawningAdditionalElement");
|
||||||
|
}
|
||||||
|
addBus = new Event<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void ButtonOk_Click(ActionEvent event) {
|
||||||
|
if (_bus != null)
|
||||||
|
{
|
||||||
|
addBus.Broadcast(_bus);
|
||||||
|
}
|
||||||
|
if (_stage != null)
|
||||||
|
{
|
||||||
|
_stage.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void CanvasObject_OnDragDropped(DragEvent event) {
|
||||||
|
Dragboard db = event.getDragboard();
|
||||||
|
switch (db.getString())
|
||||||
|
{
|
||||||
|
case "labelSimpleObject" -> _bus = new DrawingBus(spinnerSpeed.getValue(),
|
||||||
|
spinnerWeight.getValue(), Color.WHITE, spinnerDoors.getValue());
|
||||||
|
case "labelModifiedObject" -> _bus = new DrawingDDB(spinnerSpeed.getValue(),
|
||||||
|
spinnerWeight.getValue(), Color.WHITE, spinnerDoors.getValue(), Color.BLACK,
|
||||||
|
checkBoxSecondStage.isSelected(), checkBoxLadder.isSelected());
|
||||||
|
}
|
||||||
|
event.consume();
|
||||||
|
DrawBus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void CanvasObject_OnDragOver(DragEvent event) {
|
||||||
|
if (event.getDragboard().hasString())
|
||||||
|
{
|
||||||
|
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
|
||||||
|
}
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void LabelBaseColor_OnDragDropped(DragEvent event) {
|
||||||
|
if (_bus == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dragboard db = event.getDragboard();
|
||||||
|
|
||||||
|
_bus.Bus.BodyColor = ((SerializableColor)(db.getContent(colorFormat))).getFXColor();
|
||||||
|
event.consume();
|
||||||
|
DrawBus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void LabelColor_OnDragOver(DragEvent event) {
|
||||||
|
if (event.getDragboard().hasContent(colorFormat))
|
||||||
|
{
|
||||||
|
event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
|
||||||
|
}
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void LabelDopColor_OnDragDropped(DragEvent event) {
|
||||||
|
if (_bus == null || !(_bus.Bus instanceof EntityDDB ddb))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dragboard db = event.getDragboard();
|
||||||
|
|
||||||
|
ddb.ExtraColor = ((SerializableColor)(db.getContent(colorFormat))).getFXColor();
|
||||||
|
event.consume();
|
||||||
|
DrawBus();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void LabelObject_OnDragDetected(MouseEvent event) {
|
||||||
|
Label labelObject = (Label)(event.getSource());
|
||||||
|
Dragboard db = labelObject.startDragAndDrop(TransferMode.ANY);
|
||||||
|
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(((Label)(event.getSource())).getId());
|
||||||
|
db.setContent(content);
|
||||||
|
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void RegionColor_OnDragDetected(MouseEvent event) {
|
||||||
|
Region region = (Region)(event.getSource());
|
||||||
|
Dragboard db = region.startDragAndDrop(TransferMode.ANY);
|
||||||
|
|
||||||
|
Background regionBackground = region.getBackground();
|
||||||
|
Paint regionPaint = regionBackground.getFills().get(0).getFill();
|
||||||
|
if (regionPaint instanceof Color)
|
||||||
|
{
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.put(colorFormat, new SerializableColor((Color)regionPaint));
|
||||||
|
db.setContent(content);
|
||||||
|
}
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,4 @@
|
|||||||
package com.example.doubledeckerbus;
|
package com.example.doubledeckerbus;
|
||||||
import javafx.beans.value.ChangeListener;
|
|
||||||
import javafx.beans.value.ObservableValue;
|
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@ -12,6 +10,7 @@ import javafx.scene.canvas.GraphicsContext;
|
|||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -21,7 +20,7 @@ import java.util.Optional;
|
|||||||
|
|
||||||
public class ControllerMapWithSetBus {
|
public class ControllerMapWithSetBus {
|
||||||
static MapWithSetBusesGeneric<DrawingObjectBus, AbstractMap> _mapBusesCollectionGeneric;
|
static MapWithSetBusesGeneric<DrawingObjectBus, AbstractMap> _mapBusesCollectionGeneric;
|
||||||
private HashMap<String, AbstractMap> _mapsDict = new HashMap<>();
|
private final HashMap<String, AbstractMap> _mapsDict = new HashMap<>();
|
||||||
{
|
{
|
||||||
_mapsDict.put("Простая карта", new SimpleMap());
|
_mapsDict.put("Простая карта", new SimpleMap());
|
||||||
_mapsDict.put("Водная карта", new WaterMap());
|
_mapsDict.put("Водная карта", new WaterMap());
|
||||||
@ -38,30 +37,6 @@ public class ControllerMapWithSetBus {
|
|||||||
static String map_name = "Простая карта";
|
static String map_name = "Простая карта";
|
||||||
protected ObservableList<String> countOfMap = FXCollections.observableArrayList("Простая карта", "Водная карта");
|
protected ObservableList<String> countOfMap = FXCollections.observableArrayList("Простая карта", "Водная карта");
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button buttonAddBus;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button buttonDown;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button buttonLeft;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button buttonRemoveCar;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button buttonRight;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button buttonShowMap;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button buttonShowStorage;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button buttonUp;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Canvas canvasBus;
|
private Canvas canvasBus;
|
||||||
|
|
||||||
@ -91,19 +66,16 @@ public class ControllerMapWithSetBus {
|
|||||||
comboBoxSelectorMap.setItems(countOfMap);
|
comboBoxSelectorMap.setItems(countOfMap);
|
||||||
comboBoxSelectorMap.setValue(map_name);
|
comboBoxSelectorMap.setValue(map_name);
|
||||||
listViewMaps.getSelectionModel().selectedItemProperty()
|
listViewMaps.getSelectionModel().selectedItemProperty()
|
||||||
.addListener(new ChangeListener<String>() {
|
.addListener((observableValue, s, t1) -> {
|
||||||
@Override
|
|
||||||
public void changed(ObservableValue<? extends String> observableValue, String s, String t1) {
|
|
||||||
selected = t1;
|
selected = t1;
|
||||||
showStorage();
|
showStorage();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
listViewMaps.setItems(_mapsCollection.toObserveList());
|
listViewMaps.setItems(_mapsCollection.toObserveList());
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsContext gc;
|
GraphicsContext gc;
|
||||||
private void FirstIncome() {
|
private void FirstIncome() {
|
||||||
if (comboBoxSelectorMap.getValue() != map_name) {
|
if (!Objects.equals(comboBoxSelectorMap.getValue(), map_name)) {
|
||||||
map_name = comboBoxSelectorMap.getValue();
|
map_name = comboBoxSelectorMap.getValue();
|
||||||
switch (map_name) {
|
switch (map_name) {
|
||||||
case "Простая карта" -> map = new SimpleMap();
|
case "Простая карта" -> map = new SimpleMap();
|
||||||
@ -118,17 +90,14 @@ public class ControllerMapWithSetBus {
|
|||||||
|
|
||||||
ObservableList<String> listMaps = FXCollections.observableArrayList();
|
ObservableList<String> listMaps = FXCollections.observableArrayList();
|
||||||
|
|
||||||
for (int i = 0; i < _mapsCollection.Keys().size(); i++)
|
listMaps.addAll(_mapsCollection.Keys());
|
||||||
{
|
|
||||||
listMaps.add(_mapsCollection.Keys().get(i));
|
|
||||||
}
|
|
||||||
listViewMaps.setItems(listMaps);
|
listViewMaps.setItems(listMaps);
|
||||||
|
|
||||||
if (listMaps.size() > 0 && (index == -1 || index >= listMaps.size()))
|
if (listMaps.size() > 0 && (index == -1 || index >= listMaps.size()))
|
||||||
{
|
{
|
||||||
listViewMaps.getSelectionModel().select(0);
|
listViewMaps.getSelectionModel().select(0);
|
||||||
}
|
}
|
||||||
else if (listMaps.size() > 0 && index > -1 && index < listMaps.size())
|
else if (listMaps.size() > 0 && index > -1)
|
||||||
{
|
{
|
||||||
listViewMaps.getSelectionModel().select(index);
|
listViewMaps.getSelectionModel().select(index);
|
||||||
}
|
}
|
||||||
@ -136,14 +105,45 @@ public class ControllerMapWithSetBus {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void ButtonAddBus_Click(ActionEvent event) throws IOException {
|
private void ButtonAddBus_Click(ActionEvent event) throws IOException {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(Form.class.getResource("FormBus.fxml"));
|
if (listViewMaps.getSelectionModel().selectedItemProperty().isNull().get())
|
||||||
Scene scene = new Scene(fxmlLoader.load());
|
{
|
||||||
Form.myStage.setTitle("DoubleDeckerBus");
|
return;
|
||||||
Form.myStage.setScene(scene);
|
}
|
||||||
Form.myStage.show();
|
Stage stageArmoredVehicleConfig = new Stage();
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader(Form.class.getResource("FormBusConfig.fxml"));
|
||||||
|
Scene sceneArmoredVehicle = new Scene(fxmlLoader.load());
|
||||||
|
|
||||||
|
stageArmoredVehicleConfig.setScene(sceneArmoredVehicle);
|
||||||
|
stageArmoredVehicleConfig.show();
|
||||||
|
|
||||||
|
ControllerBusConfig controllerArmoredVehicleConfig = fxmlLoader.getController();
|
||||||
|
controllerArmoredVehicleConfig.AddEvent(this::AddBus);
|
||||||
|
controllerArmoredVehicleConfig.SetStage(stageArmoredVehicleConfig);
|
||||||
|
|
||||||
FirstIncome();
|
FirstIncome();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddBus(DrawingBus bus) {
|
||||||
|
if (listViewMaps.getSelectionModel().selectedItemProperty().isNull().get())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DrawingObjectBus objectArmoredVehicle = new DrawingObjectBus(bus);
|
||||||
|
String selectedMapName = listViewMaps.getSelectionModel().getSelectedItem();
|
||||||
|
|
||||||
|
Alert alert;
|
||||||
|
if (selectedMapName != null && selectedMapName.length() != 0 && _mapsCollection.get(selectedMapName).add(objectArmoredVehicle) != -1)
|
||||||
|
{
|
||||||
|
alert = new Alert(Alert.AlertType.INFORMATION, "Объект добавлен", ButtonType.OK);
|
||||||
|
_mapsCollection.get(selectedMapName).ShowSet(gc);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alert = new Alert(Alert.AlertType.ERROR, "Не удалось добавить объект", ButtonType.OK);
|
||||||
|
}
|
||||||
|
alert.showAndWait();
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void ButtonAddMap_Click(ActionEvent event)
|
private void ButtonAddMap_Click(ActionEvent event)
|
||||||
{
|
{
|
||||||
|
@ -9,10 +9,10 @@ public class DrawingBus {
|
|||||||
public EntityBus Bus;
|
public EntityBus Bus;
|
||||||
|
|
||||||
public IDrawingDoors Doors;
|
public IDrawingDoors Doors;
|
||||||
|
int _speed;
|
||||||
public EntityBus getBus() {
|
float _weight;
|
||||||
return Bus;
|
Color _bodyColor;
|
||||||
}
|
int _countOfDoors;
|
||||||
|
|
||||||
private static final int _null = -1000;
|
private static final int _null = -1000;
|
||||||
protected float _startPosX;
|
protected float _startPosX;
|
||||||
@ -23,15 +23,25 @@ public class DrawingBus {
|
|||||||
private static final int _busHeight = 50;
|
private static final int _busHeight = 50;
|
||||||
|
|
||||||
public DrawingBus(int speed, float weight, Color bodyColor, int countOfDoors) {
|
public DrawingBus(int speed, float weight, Color bodyColor, int countOfDoors) {
|
||||||
Bus = new EntityBus(speed, weight, bodyColor);
|
Bus = CreateBus(speed, weight, bodyColor, countOfDoors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityBus CreateBus(int speed, float weight, Color bodyColor, int countOfDoors) {
|
||||||
|
_speed = speed;
|
||||||
|
_weight = weight;
|
||||||
|
_bodyColor = bodyColor;
|
||||||
|
_countOfDoors = countOfDoors;
|
||||||
|
EntityBus bus = new EntityBus(speed, weight, bodyColor);
|
||||||
switch (new Random().nextInt(3)) {
|
switch (new Random().nextInt(3)) {
|
||||||
case 0 -> Doors = new DrawingTriangleDoors();
|
case 0 -> Doors = new DrawingTriangleDoors();
|
||||||
case 1 -> Doors = new DrawingDoors();
|
case 1 -> Doors = new DrawingDoors();
|
||||||
case 2 -> Doors = new DrawingEllipsoidDoors();
|
case 2 -> Doors = new DrawingEllipsoidDoors();
|
||||||
}
|
}
|
||||||
Doors.setCountOfDoors(countOfDoors);
|
Doors.setCountOfDoors(countOfDoors);
|
||||||
|
return bus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DrawingBus(int speed, float weight, Color bodyColor) {
|
public DrawingBus(int speed, float weight, Color bodyColor) {
|
||||||
Bus = new EntityBus(speed, weight, bodyColor);
|
Bus = new EntityBus(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,26 @@ import javafx.scene.canvas.GraphicsContext;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
public class DrawingDDB extends DrawingBus{
|
public class DrawingDDB extends DrawingBus{
|
||||||
public DrawingDDB(int speed, float weight, Color bodyColor, int countOfDoors, Color extraColor, boolean ladder, boolean secondStage) {
|
Color _extraColor;
|
||||||
|
boolean _ladder;
|
||||||
|
boolean _secondStage;
|
||||||
|
|
||||||
|
public DrawingDDB(int speed, float weight, Color bodyColor, int countOfDoors,
|
||||||
|
Color extraColor, boolean ladder, boolean secondStage) {
|
||||||
super(speed, weight, bodyColor, countOfDoors);
|
super(speed, weight, bodyColor, countOfDoors);
|
||||||
Bus = new EntityDDB(speed, weight, bodyColor, extraColor, ladder, secondStage);
|
Bus = CreateDDB(speed, weight, bodyColor, countOfDoors, extraColor, ladder, secondStage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EntityDDB CreateDDB(int speed, float weight, Color bodyColor, int countOfDoors,
|
||||||
|
Color extraColor, boolean ladder, boolean secondStage) {
|
||||||
|
_speed = speed;
|
||||||
|
_weight = weight;
|
||||||
|
_bodyColor = bodyColor;
|
||||||
|
_countOfDoors = countOfDoors;
|
||||||
|
_extraColor = extraColor;
|
||||||
|
_ladder = ladder;
|
||||||
|
_secondStage = secondStage;
|
||||||
|
return new EntityDDB(speed, weight, bodyColor, extraColor, ladder, secondStage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawingDDB(int speed, float weight, Color bodyColor, Color extraColor, boolean ladder, boolean secondStage) {
|
public DrawingDDB(int speed, float weight, Color bodyColor, Color extraColor, boolean ladder, boolean secondStage) {
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.example.doubledeckerbus;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public class Event<T> {
|
||||||
|
private final Set<Consumer<T>> listeners = new HashSet<>();
|
||||||
|
|
||||||
|
public void AddListener(Consumer<T> listener) {
|
||||||
|
listeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Broadcast(T args) {
|
||||||
|
listeners.forEach(x -> x.accept(args));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package com.example.doubledeckerbus;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
|
public class SerializableColor implements Serializable
|
||||||
|
{
|
||||||
|
private final double red;
|
||||||
|
private final double green;
|
||||||
|
private final double blue;
|
||||||
|
private final double alpha;
|
||||||
|
|
||||||
|
public SerializableColor(Color color)
|
||||||
|
{
|
||||||
|
red = color.getRed();
|
||||||
|
green = color.getGreen();
|
||||||
|
blue = color.getBlue();
|
||||||
|
alpha = color.getOpacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getFXColor()
|
||||||
|
{
|
||||||
|
return new Color(red, green, blue, alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -55,6 +55,7 @@ class SetBusesGeneric<T> {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count() {
|
public int Count() {
|
||||||
return _places.size();
|
return _places.size();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.canvas.Canvas?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.CheckBox?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.Spinner?>
|
||||||
|
<?import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory?>
|
||||||
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
<?import javafx.scene.layout.Region?>
|
||||||
|
<?import javafx.scene.layout.StackPane?>
|
||||||
|
|
||||||
|
<Pane fx:id="root" prefHeight="395.0" prefWidth="642.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.example.doubledeckerbus.ControllerBusConfig">
|
||||||
|
<Pane layoutX="5.0" layoutY="5.0" prefHeight="379.0" prefWidth="307">
|
||||||
|
<Label layoutX="18.0" layoutY="18.0" text="Скорость">
|
||||||
|
Speed:
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="181.0" layoutY="18.0" text="Вес:">
|
||||||
|
Weight:
|
||||||
|
</Label>
|
||||||
|
<Spinner fx:id="spinnerSpeed" layoutX="90.0" layoutY="14.0" prefWidth="70">
|
||||||
|
<valueFactory>
|
||||||
|
<SpinnerValueFactory.IntegerSpinnerValueFactory initialValue="100" max="300" min="100" />
|
||||||
|
</valueFactory>
|
||||||
|
</Spinner>
|
||||||
|
<Spinner fx:id="spinnerWeight" layoutX="222.0" layoutY="14.0" prefWidth="70">
|
||||||
|
<valueFactory>
|
||||||
|
<SpinnerValueFactory.IntegerSpinnerValueFactory initialValue="100" max="2000" min="1000" />
|
||||||
|
</valueFactory>
|
||||||
|
</Spinner>
|
||||||
|
<Pane layoutX="12.0" layoutY="131.0" prefHeight="126.0" prefWidth="280.0">
|
||||||
|
<Region layoutX="25.0" layoutY="9.0" onDragDetected="#RegionColor_OnDragDetected" prefHeight="46.0" prefWidth="46.0" style="-fx-background-color: orangered;" />
|
||||||
|
<Region layoutX="79.0" layoutY="9.0" onDragDetected="#RegionColor_OnDragDetected" prefHeight="46.0" prefWidth="46.0" style="-fx-background-color: yellowgreen;" />
|
||||||
|
<Region layoutX="140.0" layoutY="9.0" onDragDetected="#RegionColor_OnDragDetected" prefHeight="46.0" prefWidth="46.0" style="-fx-background-color: cornflowerblue;" />
|
||||||
|
<Region layoutX="197.0" layoutY="9.0" onDragDetected="#RegionColor_OnDragDetected" prefHeight="46.0" prefWidth="46.0" style="-fx-background-color: yellow;" />
|
||||||
|
<Region layoutX="25.0" layoutY="66.0" onDragDetected="#RegionColor_OnDragDetected" prefHeight="46.0" prefWidth="46.0" style="-fx-background-color: white;" />
|
||||||
|
<Region layoutX="79.0" layoutY="66.0" onDragDetected="#RegionColor_OnDragDetected" prefHeight="46.0" prefWidth="46.0" style="-fx-background-color: gray;" />
|
||||||
|
<Region layoutX="140.0" layoutY="66.0" onDragDetected="#RegionColor_OnDragDetected" prefHeight="46.0" prefWidth="46.0" style="-fx-background-color: black;" />
|
||||||
|
<Region layoutX="197.0" layoutY="66.0" onDragDetected="#RegionColor_OnDragDetected" prefHeight="46.0" prefWidth="46.0" style="-fx-background-color: purple;" />
|
||||||
|
</Pane>
|
||||||
|
<CheckBox fx:id="checkBoxLadder" layoutX="188.0" layoutY="110.0" text="Второй этаж" />
|
||||||
|
<CheckBox fx:id="checkBoxSecondStage" layoutX="8" layoutY="110" prefHeight="18.0" prefWidth="135.0" text="Лестница" />
|
||||||
|
<Label fx:id="labelSimpleObject" alignment="CENTER" layoutX="14.0" layoutY="282.0" onDragDetected="#LabelObject_OnDragDetected" prefHeight="30" prefWidth="127.0" style="-fx-border-color: black;" textOverrun="CLIP">
|
||||||
|
Simple
|
||||||
|
</Label>
|
||||||
|
<Label fx:id="labelModifiedObject" alignment="CENTER" layoutX="165.0" layoutY="282.0" onDragDetected="#LabelObject_OnDragDetected" prefHeight="30" prefWidth="135.0" style="-fx-border-color: black;">
|
||||||
|
Modified
|
||||||
|
</Label>
|
||||||
|
<Label layoutX="101.0" layoutY="56.0" text="Двери">
|
||||||
|
Track rollers
|
||||||
|
</Label>
|
||||||
|
<Spinner fx:id="spinnerDoors" layoutX="150.0" layoutY="52.0" prefWidth="70">
|
||||||
|
<valueFactory>
|
||||||
|
<SpinnerValueFactory.IntegerSpinnerValueFactory initialValue="1" max="5" min="3" />
|
||||||
|
</valueFactory>
|
||||||
|
</Spinner>
|
||||||
|
</Pane>
|
||||||
|
<Label alignment="CENTER" layoutX="356.0" layoutY="52.0" onDragDropped="#LabelBaseColor_OnDragDropped" onDragOver="#LabelColor_OnDragOver" prefHeight="30" prefWidth="127.0" style="-fx-border-color: black;" text="Цвет">
|
||||||
|
Color
|
||||||
|
</Label>
|
||||||
|
<Label alignment="CENTER" layoutX="499.0" layoutY="52.0" onDragDropped="#LabelDopColor_OnDragDropped" onDragOver="#LabelColor_OnDragOver" prefHeight="30" prefWidth="119.0" style="-fx-border-color: black;" text="Доп цвет">
|
||||||
|
Dop Color
|
||||||
|
</Label>
|
||||||
|
<StackPane layoutX="352.0" layoutY="137.0" onDragDropped="#CanvasObject_OnDragDropped" onDragOver="#CanvasObject_OnDragOver" prefHeight="152.0" prefWidth="262.0" style="-fx-border-color: #b8becc; -fx-border-radius: 5; -fx-border-width: 2;">
|
||||||
|
<Canvas fx:id="canvasObject" height="152.0" width="267.0" />
|
||||||
|
</StackPane>
|
||||||
|
<Button fx:id="buttonAdd" layoutX="367.0" layoutY="350.0" onAction="#ButtonOk_Click" prefHeight="26" prefWidth="90" text="Создать">
|
||||||
|
Add
|
||||||
|
</Button>
|
||||||
|
<Button fx:id="buttonCancel" layoutX="522.0" layoutY="350.0" prefHeight="26" prefWidth="90" text="Отмена">
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</Pane>
|
Loading…
Reference in New Issue
Block a user