Package megamek.client.ui.widget
Class BackGroundDrawer
java.lang.Object
megamek.client.ui.widget.BackGroundDrawer
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
- logical (top, bottom, center for vertical alignment and left, right, center for horizontal one)
- or given by exact number of pixels from top or left borders of area
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intAlignment to the center in case of Vertical or single tiling.static final intShift right from left border of area by exact number of pixels.static final intAlignment to the left in case of Vertical or single tiling.static final intAlignment to the right in case of Vertical or single tiling.static final intSingle copy of image will be drawn.static final intImage will be tiled over all drawing area.static final intImage will be tiled into single row over drawing area.static final intImage will be tiled into single column over drawing area.static final intAlignment to the bottom in case of Horizontal or single tiling.static final intAlignment to the centre in case of Horizontal or single tiling.static final intShift down from top border of area by exact number of pixels.static final intAlignment to the top in case of Horizontal or single tiling. -
Constructor Summary
ConstructorsConstructorDescriptionBackGroundDrawer(Image mainImage) Tiling style is set to NO_TILING | V_ALIGN_CENTER | H_ALIGN_CENTER.BackGroundDrawer(Image mainImage, int behavior) -
Method Summary
Modifier and TypeMethodDescriptionvoidDraws image into Graphics with custom tiling type and alignment.intReturns integer describing behavior of BackgroundDrawergetImage()Gets image to draw by BackGroundDrawervoidsetHAlign(int hAlign) Sets horizontal align of tilingvoidsetHAlignExactAt(int x) Deprecated, for removal: This API element is subject to removal in a future version.voidSets image to draw by BackGroundDrawervoidsetTilingType(int type) Deprecated, for removal: This API element is subject to removal in a future version.voidsetValign(int vAlign) Sets vertical align of tilingvoidsetValignExactAt(int y) Deprecated, for removal: This API element is subject to removal in a future version.
-
Field Details
-
NO_TILING
public static final int NO_TILINGSingle copy of image will be drawn.- See Also:
-
TILING_VERTICAL
public static final int TILING_VERTICALImage will be tiled into single column over drawing area.- See Also:
-
TILING_HORIZONTAL
public static final int TILING_HORIZONTALImage will be tiled into single row over drawing area.- See Also:
-
TILING_BOTH
public static final int TILING_BOTHImage will be tiled over all drawing area.- See Also:
-
V_ALIGN_TOP
public static final int V_ALIGN_TOPAlignment to the top in case of Horizontal or single tiling.- See Also:
-
V_ALIGN_CENTER
public static final int V_ALIGN_CENTERAlignment to the centre in case of Horizontal or single tiling.- See Also:
-
V_ALIGN_BOTTOM
public static final int V_ALIGN_BOTTOMAlignment to the bottom in case of Horizontal or single tiling.- See Also:
-
V_ALIGN_EXACT
public static final int V_ALIGN_EXACTShift 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_LEFTAlignment to the left in case of Vertical or single tiling.- See Also:
-
H_ALIGN_CENTER
public static final int H_ALIGN_CENTERAlignment to the center in case of Vertical or single tiling.- See Also:
-
H_ALIGN_RIGHT
public static final int H_ALIGN_RIGHTAlignment to the right in case of Vertical or single tiling.- See Also:
-
H_ALIGN_EXACT
public static final int H_ALIGN_EXACTShift right from left border of area by exact number of pixels. (default 0 pixels)- See Also:
-
-
Constructor Details
-
BackGroundDrawer
- 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
Tiling style is set to NO_TILING | V_ALIGN_CENTER | H_ALIGN_CENTER.- Parameters:
mainImage- image to draw by BackGroundDrawer.
-
-
Method Details
-
setImage
Sets image to draw by BackGroundDrawer -
getImage
Gets image to draw by BackGroundDrawer -
setTilingType
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, for removal: This API element is subject to removal in a future version.Sets exact vertical alignment exactly at "y" pixels -
setHAlignExactAt
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
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.
-