Mochalov D.V. Hard LabWork04 #4

Closed
b0n3l3sS wants to merge 6 commits from LabWork04 into LabWork03
5 changed files with 0 additions and 63 deletions
Showing only changes of commit 9262f67b28 - Show all commits

View File

@ -9,7 +9,6 @@ public class FormLocomotive extends JComponent{
return SelectedLocomotive;
}
public void SetLocomotive(DrawningObjectLocomotive locomotive){
// TODO добавлен геттер в drawningobjectlocomotive
_locomotive = locomotive.GetDrawningLocomotive();
repaint();
}

View File

@ -9,9 +9,6 @@ import java.util.HashMap;
public class FormMapWithSetLocomotives extends JComponent {
private BufferedImage bufferImg = null;
/// Объект от класса карты с набором объектов
//private MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap> _mapLocomotivesCollectionGeneric;
/// Словарь для выпадающего списка
private final HashMap<String, AbstractMap> _mapsDict = new HashMap<>() {
{
@ -29,12 +26,8 @@ public class FormMapWithSetLocomotives extends JComponent {
TextField textFieldNewMapName;
JComboBox mapSelectComboBox;
DefaultListModel<String> 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<DrawningObjectLocomotive, AbstractMap>
(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);

View File

@ -13,9 +13,6 @@ public class MapWithSetLocomotivesGeneric
private final int _placeSizeWidth = 210;
/// Размер занимаемого объектом места (высота)
private final int _placeSizeHeight = 90;
/// Набор объектов
//TODO переделал на public, узнать так ли вообще надо?
public final SetLocomotivesGeneric<T> _setLocomotives;
// Список удаленных объектов

View File

@ -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;

View File

@ -42,22 +42,8 @@ public class SetLocomotivesGeneric <T>
}
return _places.get(position);
}
/// Проход по набору до первого пустого
public Iterable<T> GetLocomotives()
{
/*for (var locomotive : _places)
{
if (locomotive != null)
{
yield return locomotive;
}
else
{
yield break;
}
}*/
return _places;
}
}