public class MapController extends ControllerWithMenu
Modifier and Type | Field and Description |
---|---|
private Position |
destinationPos
The starting position of a bestTour
|
private java.util.List<Shop> |
displayedShops
The shops currently displayed on the map
|
private static java.lang.String |
LOCATION_SERVICE_URL
URL of the service used to geolocalise a user
|
private java.util.List<Shop> |
shops
All the shops that can be displayed on the map
|
private Position |
startingPos
The starting position of a bestTour
|
private MapView |
view |
master
Constructor and Description |
---|
MapController(ControllerMaster master)
Class constructor that retrieve the shops from the database and
instantiate the view
|
Modifier and Type | Method and Description |
---|---|
void |
clearFilters()
Reset the displayedShops list to all the shops/
|
void |
filterShops(FilterData data)
Filter the shops of displayedShops with de filterData given by the view.
|
void |
findBestRoute(GroceryList groceryList)
Finds the best route from the start position to the end position to buy all the
products in the grocery list, then shows it.
|
private void |
geoLocalise()
GeoLocalises the user using his IP Address
|
java.util.List<Product> |
getProducts()
Returns a list of all the product available in the database.
|
private Shop |
getShopByID(int shopId)
Returns the shop corresponding to a shopID,
if no such shop is found it throws an NoSuchException
|
java.util.List<Shop> |
getShops() |
Position |
getUserPosition()
Returns the user position.
|
void |
importShopArticles(int shopId)
Called when the user clicks on the import button of a shop.
|
void |
onExportArticles(int shopId)
Called when the user clicks on the export button of a shop.
|
void |
onPositionsForTourReady(Position start,
Position end)
Called when the starting and the destination position have been
clicked on the map.
|
void |
removeBestTourPositions() |
void |
updateUserPosition(Position position)
Updates the user position.
|
onHelpViewStatusChanged, onLogout, onShowAllGroceryLists, onShowAllRecipes, onShowEditProfile, onShowHelp, onShowMap, setView
isHelpOpen
private static final java.lang.String LOCATION_SERVICE_URL
private MapView view
private java.util.List<Shop> shops
private java.util.List<Shop> displayedShops
private Position startingPos
private Position destinationPos
public MapController(ControllerMaster master)
master
- ControllerMasterprivate void geoLocalise()
public final void updateUserPosition(Position position)
position
- user position (latitude, longitude).public void onExportArticles(int shopId)
shopId
- public void importShopArticles(int shopId)
shopId
- private Shop getShopByID(int shopId) throws NoSuchShopException
shopId
- NoSuchShopException
public Position getUserPosition()
public void onPositionsForTourReady(Position start, Position end)
start
- end
- public void findBestRoute(GroceryList groceryList)
groceryList
- public void removeBestTourPositions()
public java.util.List<Product> getProducts()
public void filterShops(FilterData data)
data
- A name, a distance, opening days, an opening time and an product listpublic void clearFilters()
public java.util.List<Shop> getShops()