From 9262f67b288ac45cbdb94428d9a95c03fc6f62ca Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Tue, 8 Nov 2022 17:12:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=B0=204=20=D1=85=D0=B0?= =?UTF-8?q?=D1=80=D0=B4,=20=D0=BF=D0=BE=D1=87=D0=B8=D1=89=D0=B5=D0=BD=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FormLocomotive.java | 1 - FormMapWithSetLocomotives.java | 44 ------------------------------- MapWithSetLocomotivesGeneric.java | 3 --- MapsCollection.java | 1 - SetLocomotivesGeneric.java | 14 ---------- 5 files changed, 63 deletions(-) diff --git a/FormLocomotive.java b/FormLocomotive.java index eb1cb24..53a92cc 100644 --- a/FormLocomotive.java +++ b/FormLocomotive.java @@ -9,7 +9,6 @@ public class FormLocomotive extends JComponent{ return SelectedLocomotive; } public void SetLocomotive(DrawningObjectLocomotive locomotive){ - // TODO добавлен геттер в drawningobjectlocomotive _locomotive = locomotive.GetDrawningLocomotive(); repaint(); } diff --git a/FormMapWithSetLocomotives.java b/FormMapWithSetLocomotives.java index 4806d24..f091664 100644 --- a/FormMapWithSetLocomotives.java +++ b/FormMapWithSetLocomotives.java @@ -9,9 +9,6 @@ import java.util.HashMap; public class FormMapWithSetLocomotives extends JComponent { private BufferedImage bufferImg = null; - /// Объект от класса карты с набором объектов - //private MapWithSetLocomotivesGeneric _mapLocomotivesCollectionGeneric; - /// Словарь для выпадающего списка private final HashMap _mapsDict = new HashMap<>() { { @@ -29,12 +26,8 @@ public class FormMapWithSetLocomotives extends JComponent { TextField textFieldNewMapName; JComboBox mapSelectComboBox; DefaultListModel mapsListModel = new DefaultListModel<>(); - JScrollPane listScroller = new JScrollPane(); - JList listBoxMaps; - //TODO - public FormMapWithSetLocomotives() { formFrame = new JFrame("Form Map With SetLocomotives"); @@ -60,34 +53,9 @@ public class FormMapWithSetLocomotives extends JComponent { }; mapSelectComboBox = new JComboBox(maps); mapSelectComboBox.setEditable(true); - /*mapSelectComboBox.addActionListener(e -> { - AbstractMap map = null; - String item = (String)mapSelectComboBox.getSelectedItem(); - switch (item) { - case "Simple Map": - map = new SimpleMap(); - break; - case "Spike Map": - map = new SpikeMap(); - break; - case "Rail Map": - map = new RailMap(); - break; - } - if (map != null) - { - _mapLocomotivesCollectionGeneric = new MapWithSetLocomotivesGeneric - (600, 500, map); - } - else - { - _mapLocomotivesCollectionGeneric = null; - } - });*/ statusPanel.add(mapSelectComboBox); // Initialization - // TODO _mapsCollection = new MapsCollection(600, 500); mapSelectComboBox.removeAllItems(); for (var elem : _mapsDict.keySet()) @@ -101,11 +69,9 @@ public class FormMapWithSetLocomotives extends JComponent { // логика добавления if (mapSelectComboBox.getSelectedIndex() == -1 || textFieldNewMapName.getText() == null) { - //MessageBox.Show("Не все данные заполнены", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); JOptionPane.showMessageDialog(null, "Not all data is complete!"); return; } - //TODO фиг знает как этот комбобокс работает, может не найдет карту if (!_mapsDict.containsKey(mapSelectComboBox.getSelectedItem().toString())) { JOptionPane.showMessageDialog(null, "No such map"); @@ -119,7 +85,6 @@ public class FormMapWithSetLocomotives extends JComponent { // ListBox для созданных карт listBoxMaps = new JList(mapsListModel); listBoxMaps.addListSelectionListener(e -> { - //TODO фиг знает как этот лист работает, может не вернет ничего if(listBoxMaps.getSelectedValue() == null) return; bufferImg = _mapsCollection.Get(listBoxMaps.getSelectedValue().toString()).ShowSet(); repaint(); @@ -138,7 +103,6 @@ public class FormMapWithSetLocomotives extends JComponent { { return; } - //TODO фиг знает как этот лист работает, может не вернет ничего if(listBoxMaps.getSelectedValue().toString() == null) return; _mapsCollection.DelMap(listBoxMaps.getSelectedValue().toString()); ReloadMaps(); @@ -161,7 +125,6 @@ public class FormMapWithSetLocomotives extends JComponent { dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); DrawningObjectLocomotive locomotive = new DrawningObjectLocomotive(formLocomotive.getSelectedLocomotive()); - //TODO if (_mapsCollection.Get(listBoxMaps.getSelectedValue().toString()).Plus(locomotive)!= -1) { JOptionPane.showMessageDialog(formFrame, "Object added", "Success", JOptionPane.OK_CANCEL_OPTION); bufferImg = _mapsCollection.Get(listBoxMaps.getSelectedValue().toString()).ShowSet(); @@ -195,7 +158,6 @@ public class FormMapWithSetLocomotives extends JComponent { return; } int position = Integer.parseInt(finalMaskedTextFieldPosition.getText()); - //TODO if (_mapsCollection.Get(listBoxMaps.getSelectedValue().toString()).Minus(position) != null) { JOptionPane.showMessageDialog(formFrame, "Object removed", "Success", JOptionPane.OK_CANCEL_OPTION); bufferImg = _mapsCollection.Get(listBoxMaps.getSelectedValue().toString()).ShowSet(); @@ -210,7 +172,6 @@ public class FormMapWithSetLocomotives extends JComponent { JButton showStorageButton = new JButton("Show Storage"); showStorageButton.addActionListener(e -> { // логика просмотра - //TODO if (listBoxMaps.getSelectedIndex() == -1) { return; @@ -223,7 +184,6 @@ public class FormMapWithSetLocomotives extends JComponent { JButton showOnMapButton = new JButton("Show On Map"); showOnMapButton.addActionListener(e -> { // логика просмотра - //TODO if (listBoxMaps.getSelectedIndex() == -1) { return; @@ -234,7 +194,6 @@ public class FormMapWithSetLocomotives extends JComponent { statusPanel.add(showOnMapButton); ActionListener moveButtonListener = new ActionListener() { - //TODO @Override public void actionPerformed(ActionEvent e) { if (listBoxMaps.getSelectedIndex() == -1) @@ -299,15 +258,12 @@ public class FormMapWithSetLocomotives extends JComponent { if (locomotive != null) { JDialog dialog = new JDialog(formFrame, "Deleted", true); FormLocomotive formLocomotive = new FormLocomotive(dialog); - // TODO чтобы передать локомотив в форму добавляем метод в formlocomotive formLocomotive.SetLocomotive(locomotive); dialog.setSize(800, 500); dialog.setContentPane(formLocomotive); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); - } - }); statusPanel.add(showDeletedButton); diff --git a/MapWithSetLocomotivesGeneric.java b/MapWithSetLocomotivesGeneric.java index 4a8f5e6..a30b6c6 100644 --- a/MapWithSetLocomotivesGeneric.java +++ b/MapWithSetLocomotivesGeneric.java @@ -13,9 +13,6 @@ public class MapWithSetLocomotivesGeneric private final int _placeSizeWidth = 210; /// Размер занимаемого объектом места (высота) private final int _placeSizeHeight = 90; - - /// Набор объектов - //TODO переделал на public, узнать так ли вообще надо? public final SetLocomotivesGeneric _setLocomotives; // Список удаленных объектов diff --git a/MapsCollection.java b/MapsCollection.java index a041983..4aae1fa 100644 --- a/MapsCollection.java +++ b/MapsCollection.java @@ -40,7 +40,6 @@ public class MapsCollection { return null; } // Доп.индексатор из задания - // TODO поле setlocomotives в mapwithsetlocomotivesgeneric было изменено на public public DrawningObjectLocomotive Get (String name, int position) { if (_mapStorages.containsKey(name)) return _mapStorages.get(name)._setLocomotives.Get(position); else return null; diff --git a/SetLocomotivesGeneric.java b/SetLocomotivesGeneric.java index 4a8a13f..72f1f94 100644 --- a/SetLocomotivesGeneric.java +++ b/SetLocomotivesGeneric.java @@ -42,22 +42,8 @@ public class SetLocomotivesGeneric } return _places.get(position); } - - - /// Проход по набору до первого пустого public Iterable GetLocomotives() { - /*for (var locomotive : _places) - { - if (locomotive != null) - { - yield return locomotive; - } - else - { - yield break; - } - }*/ return _places; } }