Class BackGroundDrawer

java.lang.Object
megamek.client.ui.widget.BackGroundDrawer

public class BackGroundDrawer extends Object
Background drawer is a class which keeps reference to a single Image and draws it according specified rules. For example, we can order to draw image by fully tiling it over all area, or tile it in a single row or column with desired alignment, or draw it just once. Alignment of drawing can be
  1. logical (top, bottom, center for vertical alignment and left, right, center for horizontal one)
  2. or given by exact number of pixels from top or left borders of area
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Alignment to the center in case of Vertical or single tiling.
    static final int
    Shift right from left border of area by exact number of pixels.
    static final int
    Alignment to the left in case of Vertical or single tiling.
    static final int
    Alignment to the right in case of Vertical or single tiling.
    static final int
    Single copy of image will be drawn.
    static final int
    Image will be tiled over all drawing area.
    static final int
    Image will be tiled into single row over drawing area.
    static final int
    Image will be tiled into single column over drawing area.
    static final int
    Alignment to the bottom in case of Horizontal or single tiling.
    static final int
    Alignment to the centre in case of Horizontal or single tiling.
    static final int
    Shift down from top border of area by exact number of pixels.
    static final int
    Alignment to the top in case of Horizontal or single tiling.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Tiling style is set to NO_TILING | V_ALIGN_CENTER | H_ALIGN_CENTER.
    BackGroundDrawer(Image mainImage, int behavior)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    drawInto(Graphics g, int width, int height)
    Draws image into Graphics with custom tiling type and alignment.
    int
    Returns integer describing behavior of BackgroundDrawer
    Gets image to draw by BackGroundDrawer
    void
    setHAlign(int hAlign)
    Sets horizontal align of tiling
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    void
    setImage(Image mainImage)
    Sets image to draw by BackGroundDrawer
    void
    setTilingType(int type)
    Deprecated, for removal: This API element is subject to removal in a future version.
    void
    setValign(int vAlign)
    Sets vertical align of tiling
    void
    Deprecated, for removal: This API element is subject to removal in a future version.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NO_TILING

      public static final int NO_TILING
      Single copy of image will be drawn.
      See Also:
    • TILING_VERTICAL

      public static final int TILING_VERTICAL
      Image will be tiled into single column over drawing area.
      See Also:
    • TILING_HORIZONTAL

      public static final int TILING_HORIZONTAL
      Image will be tiled into single row over drawing area.
      See Also:
    • TILING_BOTH

      public static final int TILING_BOTH
      Image will be tiled over all drawing area.
      See Also:
    • V_ALIGN_TOP

      public static final int V_ALIGN_TOP
      Alignment to the top in case of Horizontal or single tiling.
      See Also:
    • V_ALIGN_CENTER

      public static final int V_ALIGN_CENTER
      Alignment to the centre in case of Horizontal or single tiling.
      See Also:
    • V_ALIGN_BOTTOM

      public static final int V_ALIGN_BOTTOM
      Alignment to the bottom in case of Horizontal or single tiling.
      See Also:
    • V_ALIGN_EXACT

      public static final int V_ALIGN_EXACT
      Shift down from top border of area by exact number of pixels. (default 0 pixels)
      See Also:
    • H_ALIGN_LEFT

      public static final int H_ALIGN_LEFT
      Alignment to the left in case of Vertical or single tiling.
      See Also:
    • H_ALIGN_CENTER

      public static final int H_ALIGN_CENTER
      Alignment to the center in case of Vertical or single tiling.
      See Also:
    • H_ALIGN_RIGHT

      public static final int H_ALIGN_RIGHT
      Alignment to the right in case of Vertical or single tiling.
      See Also:
    • H_ALIGN_EXACT

      public static final int H_ALIGN_EXACT
      Shift right from left border of area by exact number of pixels. (default 0 pixels)
      See Also:
  • Constructor Details

    • BackGroundDrawer

      public BackGroundDrawer(Image mainImage, int behavior)
      Parameters:
      mainImage - image to draw by BackGroundDrawer.
      behavior - Integer value specifying way of tiling and alignment. For example: BackGroundDrawer(myImage, BackGroundDrawer.TILING_VERTICAL | BackGroundDrawer.H_ALIGN_RIGHT);
    • BackGroundDrawer

      public BackGroundDrawer(Image mainImage)
      Tiling style is set to NO_TILING | V_ALIGN_CENTER | H_ALIGN_CENTER.
      Parameters:
      mainImage - image to draw by BackGroundDrawer.
  • Method Details

    • setImage

      public void setImage(Image mainImage)
      Sets image to draw by BackGroundDrawer
    • getImage

      public Image getImage()
      Gets image to draw by BackGroundDrawer
    • setTilingType

      @Deprecated(since="0.51.0", forRemoval=true) public void setTilingType(int type)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets type of tiling.
      Parameters:
      type - Possible values: NO_TILING, TILING_BOTH, TILING_VERTICAL, TILING_HORIZONTAL.
    • setValign

      public void setValign(int vAlign)
      Sets vertical align of tiling
      Parameters:
      vAlign - Must be V_ALIGN_TOP, V_ALIGN_CENTER, V_ALIGN_BOTTOM
    • setHAlign

      public void setHAlign(int hAlign)
      Sets horizontal align of tiling
      Parameters:
      hAlign - Must be H_ALIGN_LEFT, H_ALIGN_CENTER, H_ALIGN_RIGHT
    • setValignExactAt

      @Deprecated(since="0.51.0", forRemoval=true) public void setValignExactAt(int y)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets exact vertical alignment exactly at "y" pixels
    • setHAlignExactAt

      @Deprecated(since="0.51.0", forRemoval=true) public void setHAlignExactAt(int x)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets exact horizontal alignment exactly at "x" pixels
    • getBehavior

      public int getBehavior()
      Returns integer describing behavior of BackgroundDrawer
    • drawInto

      public void drawInto(Graphics g, int width, int height)
      Draws image into Graphics with custom tiling type and alignment.
      Parameters:
      g - Graphics to which draw to.
      width - Width of the drawing area.
      height - Height of the drawing area.