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.BufferedImage
bwMap
private IMap
map
private MapImageService
mapService
-
Constructor Summary
Constructors Constructor Description MapImageServiceFacade()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
countLandPixels(javafx.geometry.Point2D point, int radius, java.util.List<ECircleSegment> segments)
Count the number of black pixels in a circle aroundpoint
withradius
.double
distanceToShore(javafx.geometry.Point2D point, double max)
Check the if there is shore within a certain radius ofmax
.int
getHeight()
Retrieve the height of the map in pixels.javafx.geometry.Point2D
getLocationAtOtherEndOfMap(javafx.geometry.Point2D point)
Retrieve a random ponint that is at sea.javafx.geometry.Point2D
getRandomPointAtSea()
Retrieve a random ponint that is at sea.javafx.geometry.Point2D
getRandomPointAtSeaNear(javafx.geometry.Point2D location)
Retrieve a random ponint that is at sea.int
getWidth()
£Retrieve the width of the map in pixels.(package private) void
init()
boolean
isOnSea(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:IMapImageServiceFacade
Check if a location on the image is white meaning it is at sea.- Specified by:
isOnSea
in 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.IOException
Description copied from interface:IMapImageServiceFacade
Check the if there is shore within a certain radius ofmax
. If there is the approximate distance is returned.- Specified by:
distanceToShore
in 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.IOException
Description copied from interface:IMapImageServiceFacade
Count the number of black pixels in a circle aroundpoint
withradius
.- Specified by:
countLandPixels
in 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:IMapLocationProviderFacade
Retrieve a random ponint that is at sea.- Specified by:
getRandomPointAtSea
in interfaceIMapLocationProviderFacade
- Returns:
- point located on the sea.
-
getRandomPointAtSeaNear
public javafx.geometry.Point2D getRandomPointAtSeaNear(javafx.geometry.Point2D location)
Description copied from interface:IMapLocationProviderFacade
Retrieve a random ponint that is at sea.- Specified by:
getRandomPointAtSeaNear
in interfaceIMapLocationProviderFacade
- Returns:
- point located on the sea.
-
getLocationAtOtherEndOfMap
public javafx.geometry.Point2D getLocationAtOtherEndOfMap(javafx.geometry.Point2D point)
Description copied from interface:IMapImageServiceFacade
Retrieve a random ponint that is at sea.- Specified by:
getLocationAtOtherEndOfMap
in 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:
getWidth
in interfaceIMapImageServiceFacade
- Returns:
- width of the map
-
getHeight
public int getHeight()
Description copied from interface:IMapImageServiceFacade
Retrieve the height of the map in pixels.- Specified by:
getHeight
in interfaceIMapImageServiceFacade
- Returns:
- height of the map
-
-