Class BackgroundPainter

java.lang.Object
games.stendhal.client.gui.j2d.BackgroundPainter

public class BackgroundPainter extends Object
A painter for a background image that consists of 9 tiles, with the center tile being repeated. The rest of the tiles are the corners and borders in natural order. The sides will be painted with preference to adhering to painted area borders rather than trying to preserve the pattern. Therefore the image should be such that it can tolerate miss tiling at the borders, if the painted area dimensions can not be guaranteed to be multiples of the tile dimensions.
  • Constructor Details

    • BackgroundPainter

      public BackgroundPainter(String image)
      Create a new BackgroundPainter.
      Parameters:
      image - image name. The image dimensions should be multiples of 3. The tiles used for painting will be the image divided uniformly to three in both vertical and horizontal directions
    • BackgroundPainter

      public BackgroundPainter(String image, int leftWidth, int centerWidth, int topHeight, int centerHeight)
      Create a new BackgroundPainter. The tiles used for painting will be cut non-uniformly, so that the grid will be placed according to the given dimensions.
      Parameters:
      image - image name
      leftWidth - width of the left tile row
      centerWidth - width of the center tile row
      topHeight - height of the top tile row
      centerHeight - height of the center tile row
  • Method Details

    • paint

      public void paint(Graphics g, int width, int height)
      Paint an area with the image pattern.
      Parameters:
      g - graphics
      width - width of the painted area
      height - height of the painted area