Class MapImageServiceFacade
- java.lang.Object
-
- ch.sahits.game.graphic.image.impl.MapImageServiceFacade
-
- All Implemented Interfaces:
IMapImageServiceFacade,IMapLocationProviderFacade
public class MapImageServiceFacade extends java.lang.Object implements IMapImageServiceFacade
Facade class for theMapImageService.- Author:
- Andi Hotz, (c) Sahits GmbH, 2016 Created on Apr 25, 2016
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.image.BufferedImagebwMapprivate IMapmapprivate MapImageServicemapService
-
Constructor Summary
Constructors Constructor Description MapImageServiceFacade()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcountLandPixels(javafx.geometry.Point2D point, int radius, java.util.List<ECircleSegment> segments)Count the number of black pixels in a circle aroundpointwithradius.doubledistanceToShore(javafx.geometry.Point2D point, double max)Check the if there is shore within a certain radius ofmax.intgetHeight()Retrieve the height of the map in pixels.javafx.geometry.Point2DgetLocationAtOtherEndOfMap(javafx.geometry.Point2D point)Retrieve a random ponint that is at sea.javafx.geometry.Point2DgetRandomPointAtSea()Retrieve a random ponint that is at sea.javafx.geometry.Point2DgetRandomPointAtSeaNear(javafx.geometry.Point2D location)Retrieve a random ponint that is at sea.intgetWidth()£Retrieve the width of the map in pixels.(package private) voidinit()booleanisOnSea(int x, int y)Check if a location on the image is white meaning it is at sea.
-
-
-
Field Detail
-
map
@Autowired private IMap map
-
mapService
@Autowired private MapImageService mapService
-
bwMap
private java.awt.image.BufferedImage bwMap
-
-
Method Detail
-
init
@PostConstruct void init() throws java.io.IOException
- Throws:
java.io.IOException
-
isOnSea
public boolean isOnSea(int x, int y)Description copied from interface:IMapImageServiceFacadeCheck if a location on the image is white meaning it is at sea.- Specified by:
isOnSeain interfaceIMapImageServiceFacade- Parameters:
x- location to be checkedy- location to be checked- Returns:
- true if the coordinates represent a coordinate at sea.
-
distanceToShore
public double distanceToShore(javafx.geometry.Point2D point, double max) throws java.io.IOExceptionDescription copied from interface:IMapImageServiceFacadeCheck the if there is shore within a certain radius ofmax. If there is the approximate distance is returned.- Specified by:
distanceToShorein interfaceIMapImageServiceFacade- Parameters:
point- that is to be checked.max- maximum radius- Returns:
- maximum radius or approximate distance to the shore, whatever is smaller. If the approximate distance is returned it may be smaller than the actual distance to the nearest land.
- Throws:
java.io.IOException
-
countLandPixels
public int countLandPixels(javafx.geometry.Point2D point, int radius, java.util.List<ECircleSegment> segments) throws java.io.IOExceptionDescription copied from interface:IMapImageServiceFacadeCount the number of black pixels in a circle aroundpointwithradius.- Specified by:
countLandPixelsin interfaceIMapImageServiceFacade- Parameters:
point- center point around which should be checkedradius- radius of the area that should be checked.- Returns:
- number of pixels that represent land.
- Throws:
java.io.IOException
-
getRandomPointAtSea
public javafx.geometry.Point2D getRandomPointAtSea()
Description copied from interface:IMapLocationProviderFacadeRetrieve a random ponint that is at sea.- Specified by:
getRandomPointAtSeain interfaceIMapLocationProviderFacade- Returns:
- point located on the sea.
-
getRandomPointAtSeaNear
public javafx.geometry.Point2D getRandomPointAtSeaNear(javafx.geometry.Point2D location)
Description copied from interface:IMapLocationProviderFacadeRetrieve a random ponint that is at sea.- Specified by:
getRandomPointAtSeaNearin interfaceIMapLocationProviderFacade- Returns:
- point located on the sea.
-
getLocationAtOtherEndOfMap
public javafx.geometry.Point2D getLocationAtOtherEndOfMap(javafx.geometry.Point2D point)
Description copied from interface:IMapImageServiceFacadeRetrieve a random ponint that is at sea.- Specified by:
getLocationAtOtherEndOfMapin interfaceIMapImageServiceFacade- Parameters:
point- near where the random point has to be located.- Returns:
- point located on the sea.
-
getWidth
public int getWidth()
Description copied from interface:IMapImageServiceFacade£Retrieve the width of the map in pixels.- Specified by:
getWidthin interfaceIMapImageServiceFacade- Returns:
- width of the map
-
getHeight
public int getHeight()
Description copied from interface:IMapImageServiceFacadeRetrieve the height of the map in pixels.- Specified by:
getHeightin interfaceIMapImageServiceFacade- Returns:
- height of the map
-
-