2022-11-15 18:20:34 +04:00
|
|
|
|
import javax.swing.*;
|
2022-12-02 11:17:40 +04:00
|
|
|
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
2022-11-15 18:20:34 +04:00
|
|
|
|
import java.awt.*;
|
2022-11-25 13:49:46 +04:00
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.List;
|
2022-12-15 14:54:34 +04:00
|
|
|
|
import org.apache.logging.log4j.*;
|
2022-11-15 18:20:34 +04:00
|
|
|
|
|
|
|
|
|
public class FormMapWithSetAircrafts implements Form {
|
|
|
|
|
private JPanel MainPane;
|
2022-11-25 13:49:46 +04:00
|
|
|
|
private JButton buttonAddAircraft;
|
2022-11-15 18:20:34 +04:00
|
|
|
|
private JComboBox comboBoxSelectorMap;
|
|
|
|
|
private JTextField textBoxPosition;
|
2022-11-25 13:49:46 +04:00
|
|
|
|
private JButton buttonRemoveAircraft;
|
2022-11-15 18:20:34 +04:00
|
|
|
|
private JButton buttonShowStorage;
|
|
|
|
|
private JButton buttonShowOnMap;
|
|
|
|
|
private JButton upButton;
|
|
|
|
|
private JButton leftButton;
|
|
|
|
|
private JButton rightButton;
|
|
|
|
|
private JButton downButton;
|
|
|
|
|
private JPanel drawPanel;
|
2022-11-25 13:49:46 +04:00
|
|
|
|
private JTextField textBoxNewMapName;
|
|
|
|
|
private JList listBoxMaps;
|
|
|
|
|
private JButton buttonAddMap;
|
|
|
|
|
private JButton buttonDeleteMap;
|
|
|
|
|
private JButton buttonShowDeleted;
|
|
|
|
|
|
2022-12-02 11:17:40 +04:00
|
|
|
|
private JMenuBar menu;
|
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
private MapsCollection _mapsCollection;
|
|
|
|
|
private HashMap<String, AbstractMap> _mapsDict = new HashMap<>(){{
|
|
|
|
|
put( "Простая карта", new SimpleMap() );
|
|
|
|
|
put( "Моя карта", new MyMap() );
|
|
|
|
|
}};
|
2022-11-15 18:20:34 +04:00
|
|
|
|
private Canvas canv = new Canvas(this);
|
2022-11-25 13:49:46 +04:00
|
|
|
|
private Queue<IDrawingObject> deletedAircrafts = new ArrayDeque<>();
|
2022-11-15 18:20:34 +04:00
|
|
|
|
|
2022-12-15 14:54:34 +04:00
|
|
|
|
|
2022-11-15 18:20:34 +04:00
|
|
|
|
JFrame jFrame = getFrame();
|
|
|
|
|
Image img;
|
|
|
|
|
|
2022-12-15 14:54:34 +04:00
|
|
|
|
private Logger _logger;
|
|
|
|
|
|
|
|
|
|
public FormMapWithSetAircrafts(Logger logger) {
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-15 18:20:34 +04:00
|
|
|
|
private JFrame getFrame() {
|
|
|
|
|
JFrame frame = new JFrame();
|
|
|
|
|
frame.setVisible(true);
|
2022-11-25 13:49:46 +04:00
|
|
|
|
frame.setBounds(300, 50, 1000, 750);
|
2022-11-15 18:20:34 +04:00
|
|
|
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
|
return frame;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
private void ReloadMaps()
|
|
|
|
|
{
|
|
|
|
|
int index = listBoxMaps.getSelectedIndex();
|
|
|
|
|
List<String> items = _mapsCollection.getKeys();
|
|
|
|
|
listBoxMaps.setListData(items.toArray());
|
|
|
|
|
if (items.size() > 0 && (index == -1 || index >= items.size()))
|
|
|
|
|
{
|
|
|
|
|
listBoxMaps.setSelectedIndex(0);
|
|
|
|
|
}
|
|
|
|
|
else if (items.size() > 0 && index > -1 && index < items.size())
|
|
|
|
|
{
|
|
|
|
|
listBoxMaps.setSelectedIndex(index);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-15 18:20:34 +04:00
|
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
jFrame.add(MainPane);
|
|
|
|
|
drawPanel.add(canv);
|
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
jFrame.revalidate();
|
|
|
|
|
|
2022-12-02 11:17:40 +04:00
|
|
|
|
menu = new JMenuBar();
|
|
|
|
|
JMenu fileActions = new JMenu("Файл");
|
|
|
|
|
|
|
|
|
|
menu.add(fileActions);
|
|
|
|
|
jFrame.setJMenuBar(menu);
|
|
|
|
|
|
|
|
|
|
JMenuItem saveItem = new JMenuItem("Сохранить");
|
|
|
|
|
JMenuItem loadItem = new JMenuItem("Загрузить");
|
|
|
|
|
JMenuItem saveMapItem = new JMenuItem("Сохранить карту");
|
|
|
|
|
JMenuItem loadMapItem = new JMenuItem("Загрузить карту");
|
|
|
|
|
|
|
|
|
|
fileActions.add(saveItem);
|
|
|
|
|
fileActions.add(loadItem);
|
|
|
|
|
fileActions.add(saveMapItem);
|
|
|
|
|
fileActions.add(loadMapItem);
|
|
|
|
|
|
|
|
|
|
saveItem.addActionListener(e -> {
|
|
|
|
|
JFileChooser chooser = new JFileChooser();
|
|
|
|
|
chooser.setFileFilter(new FileNameExtensionFilter("TXT format", "txt"));
|
|
|
|
|
chooser.showSaveDialog(jFrame);
|
|
|
|
|
|
|
|
|
|
if(chooser.getSelectedFile() == null) return;
|
|
|
|
|
|
|
|
|
|
String path = chooser.getSelectedFile().getAbsolutePath();
|
|
|
|
|
|
2022-12-15 14:54:34 +04:00
|
|
|
|
try {
|
|
|
|
|
_mapsCollection.SaveData(path);
|
|
|
|
|
_logger.info("Данные сохранены в файл " + chooser.getSelectedFile().getAbsolutePath());
|
2022-12-02 11:17:40 +04:00
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Сохранение прошло успешно");
|
2022-12-15 14:54:34 +04:00
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
_logger.error("Ошибка сохранения данных: " + err.getMessage());
|
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Не сохранилось");
|
|
|
|
|
}
|
2022-12-02 11:17:40 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
loadItem.addActionListener(e -> {
|
|
|
|
|
JFileChooser chooser = new JFileChooser();
|
|
|
|
|
chooser.setFileFilter(new FileNameExtensionFilter("TXT format", "txt"));
|
|
|
|
|
chooser.showOpenDialog(jFrame);
|
|
|
|
|
|
|
|
|
|
if(chooser.getSelectedFile() == null) return;
|
|
|
|
|
|
|
|
|
|
String path = chooser.getSelectedFile().getAbsolutePath();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
_mapsCollection.LoadData(path);
|
|
|
|
|
_logger.info("Данные из загружены из файла " + chooser.getSelectedFile().getAbsolutePath());
|
2022-12-02 11:17:40 +04:00
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Загрузка прошла успешно");
|
|
|
|
|
ReloadMaps();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
_logger.error("Ошибка загрузки данных " + chooser.getSelectedFile().getAbsolutePath());
|
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Не загрузилось");
|
|
|
|
|
}
|
2022-12-02 11:17:40 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
saveMapItem.addActionListener(e -> {
|
|
|
|
|
if(_mapsCollection == null) return;
|
|
|
|
|
if(listBoxMaps.getSelectedValue() == null) return;
|
|
|
|
|
|
|
|
|
|
JFileChooser chooser = new JFileChooser();
|
|
|
|
|
chooser.setFileFilter(new FileNameExtensionFilter("TXT format", "txt"));
|
|
|
|
|
chooser.showSaveDialog(jFrame);
|
|
|
|
|
|
|
|
|
|
if(chooser.getSelectedFile() == null) return;
|
|
|
|
|
|
|
|
|
|
String path = chooser.getSelectedFile().getAbsolutePath();
|
|
|
|
|
|
2022-12-15 14:54:34 +04:00
|
|
|
|
try {
|
|
|
|
|
_mapsCollection.SaveMap(path, listBoxMaps.getSelectedValue().toString());
|
|
|
|
|
_logger.info("Карта " + listBoxMaps.getSelectedValue().toString() +
|
|
|
|
|
" сохранена в файл " + chooser.getSelectedFile().getAbsolutePath());
|
2022-12-02 11:17:40 +04:00
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Сохранение прошло успешно");
|
2022-12-15 14:54:34 +04:00
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
_logger.error("Ошибка сохранения карты " + listBoxMaps.getSelectedValue().toString() +
|
|
|
|
|
" в файл " + chooser.getSelectedFile().getAbsolutePath());
|
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Не сохранилось");
|
|
|
|
|
}
|
2022-12-02 11:17:40 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
loadMapItem.addActionListener(e -> {
|
|
|
|
|
JFileChooser chooser = new JFileChooser();
|
|
|
|
|
chooser.setFileFilter(new FileNameExtensionFilter("TXT format", "txt"));
|
|
|
|
|
chooser.showOpenDialog(jFrame);
|
|
|
|
|
|
|
|
|
|
if(chooser.getSelectedFile() == null) return;
|
|
|
|
|
|
|
|
|
|
String path = chooser.getSelectedFile().getAbsolutePath();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
_mapsCollection.LoadMap(path);
|
|
|
|
|
_logger.info("Карта " + listBoxMaps.getSelectedValue().toString() +
|
|
|
|
|
" загружена из файла " + chooser.getSelectedFile().getAbsolutePath());
|
2022-12-02 11:17:40 +04:00
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Загрузка прошла успешно");
|
|
|
|
|
ReloadMaps();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
_logger.error("Ошибка загрузки карты " + listBoxMaps.getSelectedValue().toString() +
|
|
|
|
|
" из файла " + chooser.getSelectedFile().getAbsolutePath());
|
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Не загрузилось");
|
|
|
|
|
}
|
2022-12-02 11:17:40 +04:00
|
|
|
|
});
|
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
_mapsCollection = new MapsCollection(canv.getSize().width, canv.getSize().height);
|
|
|
|
|
comboBoxSelectorMap.removeAllItems();
|
|
|
|
|
|
|
|
|
|
_mapsDict.keySet().forEach(elem -> {
|
|
|
|
|
comboBoxSelectorMap.addItem(elem);
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-15 18:20:34 +04:00
|
|
|
|
comboBoxSelectorMap.setSelectedIndex(-1);
|
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
listBoxMaps.addListSelectionListener(e -> {
|
|
|
|
|
if(listBoxMaps.getSelectedValue() == null) return;
|
|
|
|
|
img = _mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).ShowSet();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
_logger.info("Переход на карту " + listBoxMaps.getSelectedValue().toString());
|
2022-11-25 13:49:46 +04:00
|
|
|
|
canv.repaint();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
buttonAddMap.addActionListener(e -> {
|
|
|
|
|
if (comboBoxSelectorMap.getSelectedIndex() == -1 || textBoxNewMapName.getText() == "")
|
|
|
|
|
{
|
2022-12-15 14:54:34 +04:00
|
|
|
|
_logger.warn("Не получилось добавить карту: не все данные заполнены");
|
2022-11-25 13:49:46 +04:00
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Не все данные заполнены");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!_mapsDict.containsKey(comboBoxSelectorMap.getSelectedItem().toString()))
|
2022-11-15 18:20:34 +04:00
|
|
|
|
{
|
2022-12-15 14:54:34 +04:00
|
|
|
|
_logger.warn("Не получилось добавить карту: нет такой карты");
|
2022-11-25 13:49:46 +04:00
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Нет такой карты");
|
|
|
|
|
return;
|
2022-11-15 18:20:34 +04:00
|
|
|
|
}
|
2022-11-25 13:49:46 +04:00
|
|
|
|
_mapsCollection.AddMap(textBoxNewMapName.getText(),
|
|
|
|
|
_mapsDict.get(comboBoxSelectorMap.getSelectedItem().toString()));
|
2022-12-15 14:54:34 +04:00
|
|
|
|
|
|
|
|
|
_logger.info("Добавлена карта " + textBoxNewMapName.getText());
|
2022-11-25 13:49:46 +04:00
|
|
|
|
ReloadMaps();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
buttonDeleteMap.addActionListener(e -> {
|
|
|
|
|
if (listBoxMaps.getSelectedIndex() == -1)
|
2022-11-15 18:20:34 +04:00
|
|
|
|
{
|
2022-11-25 13:49:46 +04:00
|
|
|
|
return;
|
2022-11-15 18:20:34 +04:00
|
|
|
|
}
|
2022-11-25 13:49:46 +04:00
|
|
|
|
|
|
|
|
|
String mapName = listBoxMaps.getSelectedValue().toString();
|
|
|
|
|
if (JOptionPane.showConfirmDialog(jFrame, "Удалить карту " + mapName,
|
|
|
|
|
"Удаление", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION)
|
2022-11-15 18:20:34 +04:00
|
|
|
|
{
|
2022-11-25 13:49:46 +04:00
|
|
|
|
_mapsCollection.DelMap(mapName);
|
2022-12-15 14:54:34 +04:00
|
|
|
|
_logger.info("Удалена карта " + mapName);
|
2022-11-25 13:49:46 +04:00
|
|
|
|
ReloadMaps();
|
2022-11-15 18:20:34 +04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-29 17:50:40 +04:00
|
|
|
|
buttonAddAircraft.addActionListener(e -> {
|
|
|
|
|
if (listBoxMaps.getSelectedIndex() == -1)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FormAircraftConfig formConfig = new FormAircraftConfig();
|
|
|
|
|
formConfig.run();
|
|
|
|
|
|
|
|
|
|
formConfig.addListener(drawingAircraft -> {
|
|
|
|
|
if(drawingAircraft == null) return;
|
|
|
|
|
|
2022-12-15 14:54:34 +04:00
|
|
|
|
try {
|
|
|
|
|
DrawingObjectAircraft aircraft = new DrawingObjectAircraft(drawingAircraft);
|
|
|
|
|
_mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).addAircraft(aircraft);
|
|
|
|
|
|
|
|
|
|
_logger.info("Добавлен новый объект");
|
2022-11-29 17:50:40 +04:00
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Объект добавлен");
|
|
|
|
|
img = _mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).ShowSet();
|
|
|
|
|
canv.repaint();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
} catch(StorageOverflowException err) {
|
|
|
|
|
_logger.warn("Ошибка добавления: " + err.getMessage());
|
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Ошибка переполнения: " + err.getMessage());
|
|
|
|
|
} catch(Exception err) {
|
|
|
|
|
_logger.fatal("Незивестная ошибка: " + err.getMessage());
|
2022-11-29 17:50:40 +04:00
|
|
|
|
}
|
2022-12-15 14:54:34 +04:00
|
|
|
|
|
2022-11-29 17:50:40 +04:00
|
|
|
|
});
|
2022-11-15 18:20:34 +04:00
|
|
|
|
});
|
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
buttonRemoveAircraft.addActionListener(e -> {
|
2022-11-15 18:20:34 +04:00
|
|
|
|
String text = textBoxPosition.getText();
|
|
|
|
|
if(text.isEmpty()) return;
|
|
|
|
|
|
|
|
|
|
if(JOptionPane.showConfirmDialog(
|
|
|
|
|
jFrame,
|
|
|
|
|
"Вы действительно хотите удалить объект?",
|
|
|
|
|
"Удаление",
|
|
|
|
|
JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) return;
|
|
|
|
|
|
|
|
|
|
int pos;
|
|
|
|
|
try {
|
|
|
|
|
pos = Integer.parseInt(text);
|
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
pos = Integer.parseInt(text);
|
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
String mapName = listBoxMaps.getSelectedValue().toString();
|
|
|
|
|
|
2022-12-15 14:54:34 +04:00
|
|
|
|
try {
|
|
|
|
|
IDrawingObject deleted = _mapsCollection.getMap(mapName).removeAircraft(pos);
|
|
|
|
|
_logger.info("Объект удален");
|
2022-11-15 18:20:34 +04:00
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Объект удален");
|
2022-11-25 13:49:46 +04:00
|
|
|
|
img = _mapsCollection.getMap(mapName).ShowSet();
|
|
|
|
|
deletedAircrafts.add(deleted);
|
2022-11-15 18:20:34 +04:00
|
|
|
|
canv.repaint();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
} catch(AircraftNotFoundException err) {
|
|
|
|
|
_logger.warn("Ошибка добавления: " + err.getMessage());
|
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Ошибка удаления: " + err.getMessage());
|
|
|
|
|
} catch (Exception err) {
|
|
|
|
|
_logger.fatal("Неизвестная ошибка: " + err.getMessage());
|
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Неизвестная ошибка: " + err.getMessage());
|
2022-11-15 18:20:34 +04:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
buttonShowStorage.addActionListener(e -> {
|
2022-11-25 13:49:46 +04:00
|
|
|
|
if(listBoxMaps.getSelectedValue() == null) return;
|
2022-11-15 18:20:34 +04:00
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
img = _mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).ShowSet();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
_logger.info("Показ хранилища");
|
2022-11-15 18:20:34 +04:00
|
|
|
|
canv.repaint();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
buttonShowOnMap.addActionListener(e -> {
|
2022-11-25 13:49:46 +04:00
|
|
|
|
if(listBoxMaps.getSelectedValue() == null) return;
|
|
|
|
|
|
|
|
|
|
img = _mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).ShowOnMap();
|
2022-12-15 14:54:34 +04:00
|
|
|
|
_logger.info("Показ карты");
|
2022-11-25 13:49:46 +04:00
|
|
|
|
canv.repaint();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
buttonShowDeleted.addActionListener(e -> {
|
|
|
|
|
if (listBoxMaps.getSelectedIndex() == -1)
|
2022-11-15 18:20:34 +04:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-25 13:49:46 +04:00
|
|
|
|
if(deletedAircrafts.size() == 0) {
|
|
|
|
|
JOptionPane.showMessageDialog(jFrame, "Очередь пуста");
|
2022-12-15 14:54:34 +04:00
|
|
|
|
_logger.warn("Очередь удаленных объектов пуста");
|
2022-11-25 13:49:46 +04:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DrawingObjectAircraft deleted = (DrawingObjectAircraft) deletedAircrafts.peek();
|
|
|
|
|
|
|
|
|
|
FormAircraft dialog = new FormAircraft(deleted.getAircraft());
|
|
|
|
|
deletedAircrafts.remove();
|
|
|
|
|
dialog.run();
|
|
|
|
|
dialog.setSize(800, 500);
|
|
|
|
|
dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
|
|
|
|
|
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
|
|
|
|
|
|
|
|
dialog.setVisible(true);
|
2022-12-15 14:54:34 +04:00
|
|
|
|
|
|
|
|
|
_logger.info("Показ удаленного объекта");
|
2022-11-15 18:20:34 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
leftButton.addActionListener(e -> {
|
2022-11-25 13:49:46 +04:00
|
|
|
|
if(listBoxMaps.getSelectedValue() == null) return;
|
|
|
|
|
img = _mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).MoveObject(Direction.Left);
|
2022-11-15 18:20:34 +04:00
|
|
|
|
canv.repaint();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
rightButton.addActionListener(e -> {
|
2022-11-25 13:49:46 +04:00
|
|
|
|
if(listBoxMaps.getSelectedValue() == null) return;
|
|
|
|
|
img = _mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).MoveObject(Direction.Right);
|
2022-11-15 18:20:34 +04:00
|
|
|
|
canv.repaint();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
upButton.addActionListener(e -> {
|
2022-11-25 13:49:46 +04:00
|
|
|
|
if(listBoxMaps.getSelectedValue() == null) return;
|
|
|
|
|
img = _mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).MoveObject(Direction.Up);
|
2022-11-15 18:20:34 +04:00
|
|
|
|
canv.repaint();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
downButton.addActionListener(e -> {
|
2022-11-25 13:49:46 +04:00
|
|
|
|
if(listBoxMaps.getSelectedValue() == null) return;
|
|
|
|
|
img = _mapsCollection.getMap(listBoxMaps.getSelectedValue().toString()).MoveObject(Direction.Down);
|
2022-11-15 18:20:34 +04:00
|
|
|
|
canv.repaint();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void Draw(Graphics2D g) {
|
|
|
|
|
if(img == null) return;
|
|
|
|
|
g.drawImage(img, 0, 0, null);
|
|
|
|
|
}
|
|
|
|
|
}
|