2022-11-06 18:08:19 +04:00
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
//класс для хранения коллекции карт
|
2022-11-06 17:32:49 +04:00
|
|
|
|
public class MapsCollection
|
|
|
|
|
{
|
2022-11-06 18:08:19 +04:00
|
|
|
|
//словарь (хранилище) с картами
|
|
|
|
|
public HashMap<String, MapWithSetPlanesGeneric<DrawningObjectPlane, AbstractMap>> _mapStorage;
|
|
|
|
|
|
|
|
|
|
//возвращение списка названий карт
|
|
|
|
|
public List<String> Keys;
|
|
|
|
|
|
|
|
|
|
//ширина окна отрисовки
|
|
|
|
|
private final int _pictureWidth;
|
|
|
|
|
|
|
|
|
|
//высота окна отрисовки
|
|
|
|
|
private final int _pictureHeight;
|
|
|
|
|
|
|
|
|
|
//конструктор
|
|
|
|
|
public MapsCollection(int pictureWidth, int pictureHeight)
|
|
|
|
|
{
|
|
|
|
|
Keys = new ArrayList<String>(_mapStorage.keySet());
|
|
|
|
|
_mapStorage = new HashMap<>();
|
|
|
|
|
_pictureWidth = pictureWidth;
|
|
|
|
|
_pictureHeight = pictureHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//добавление карты
|
|
|
|
|
public void AddMap(String name, AbstractMap map)
|
|
|
|
|
{
|
|
|
|
|
if(_mapStorage.containsKey(name))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_mapStorage.put(name, new MapWithSetPlanesGeneric<>(_pictureWidth, _pictureHeight, map));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//удаление карты
|
|
|
|
|
public void DelMap(String name)
|
|
|
|
|
{
|
|
|
|
|
_mapStorage.remove(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Доступ к аэродрому
|
|
|
|
|
public MapWithSetPlanesGeneric<DrawningObjectPlane, AbstractMap> Get(String name, int index)
|
|
|
|
|
{
|
|
|
|
|
if(_mapStorage.containsKey(name))
|
|
|
|
|
{
|
|
|
|
|
return _mapStorage.get(name).GetPlaneInList(index);
|
|
|
|
|
}
|
2022-11-06 17:32:49 +04:00
|
|
|
|
|
2022-11-06 18:08:19 +04:00
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-11-06 17:32:49 +04:00
|
|
|
|
}
|