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

    • snapTo

      default Point snapTo(Point p, boolean force, boolean onlyCenter)
      Parameters:
      onlyCenter - If true, snaps only to the center, never to the edge or corner.
      Returns:
      The nearest grid location to the given point. This can for instance snap to center, edge or corner, depending on settings and arguments.
    • snapTo

      default Point snapTo(Point p, boolean force)
      See Also:
    • 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)
    • getMaxPixelsPerRangeUnit

      default int getMaxPixelsPerRangeUnit(Point p)
      Return an estimation of the maximum number of pixels per range unit for the grid that applies at the specified point. Does not need to be exact, but must defer on the larger side to ensure fast range-checking by QTree lookup finds all target pieces.
      Returns:
      maximum number of pixels per range unit.
    • 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()