Interface MapGrid

All Known Subinterfaces:
GeometricGrid
All Known Implementing Classes:
HexGrid, RegionGrid, SquareGrid, ZonedGrid

public interface MapGrid
A MapGrid overlays a map board to constrain the legal locations of GamePieces
  • Method Details

    • snapTo

      Point snapTo(Point p)
      Returns:
      the nearest grid location to the given point
    • isLocationRestricted

      boolean isLocationRestricted(Point p)
      Returns:
      true if the given point may not be a local location. I.e., if this grid will attempt to snap it to the nearest grid location
    • locationName

      String locationName(Point p)
      Returns:
      a string describing the location containing the given point
    • localizedLocationName

      String localizedLocationName(Point p)
    • getLocation

      Point getLocation(String location) throws MapGrid.BadCoords
      Returns:
      A point p such that locationName(p).equals(location).
      Throws:
      MapGrid.BadCoords - if the location is not valid or formatted incorrectly.
    • range

      int range(Point p1, Point p2)
      Returns:
      the range between two points, in some unit appropriate to the grid (e.g. hexes or squares)
    • isVisible

      boolean isVisible()
      Whether this grid should be drawn on the map
    • draw

      void draw(Graphics g, Rectangle bounds, Rectangle visibleRect, double scale, boolean reversed)
      Draw the grid
      Parameters:
      bounds - the boundaries of the grid (in magnified coordinates)
      scale - the magnification factor
    • getGridNumbering

      GridNumbering getGridNumbering()