Class ASCard
java.lang.Object
megamek.common.alphaStrike.cardDrawer.ASCard
- Direct Known Subclasses:
ASHeatTrackingCard,ASLargeAeroCard,ASProtoMekCard,ASVehicleCard
This class represents the (graphical) card of an AlphaStrike element as available on the MUL. The unit cards have a
standard size of 1050 x 750 but can be resized without loss of quality to any size. A card is created by calling the
static
createCard(ASCardDisplayable). The basic way to obtain a card image after creating the card is
calling the card's getCardImage() method. Other methods can be used to configure the resulting card image.
This class is responsible for painting Infantry cards. Subclasses of ASCard represent the unit cards for other AlphaStrike unit types. It is not necessary to pay any attention to this when obtaining the card but for Large Aerospace units the specific class can be used to have additional functionality for the two card faces of these cards.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Fontprotected static final intprotected intprotected intprotected intprotected intprotected static final Colorprotected intprotected Fontprotected Fontprotected static final intprotected static final intprotected static final floatprotected static final intprotected Fontprotected static final intprotected intprotected intprotected static final Colorprotected final ASCardDisplayableprotected intprotected final Imageprotected intprotected intprotected intprotected Fontstatic final intprotected StringDrawer.StringDrawerConfigprotected Fontprotected Fontprotected Fontprotected Fontprotected Fontstatic final doubleprotected intprotected intprotected intprotected intprotected Fontprotected StringDrawer.StringDrawerConfigprotected StringDrawer.StringDrawerConfigprotected Fontstatic final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedASCard(ASCardDisplayable element) Constructs and initializes the ASCard. -
Method Summary
Modifier and TypeMethodDescriptionstatic ASCardcreateCard(ASCardDisplayable element) Creates an ASCard for the given AlphaStrike unit (either an AlphaStrikeElement or a MekSummary) which can be used to display a typical AlphaStrike element card.final voidThis method controls drawing the card.protected voiddrawDamagePip(Graphics2D g, int x, int y) Draws a crit damage pip at the provided coordinates (x is left-aligned, y centered).protected voidWrite model, chassis and squad size.Deprecated, for removal: This API element is subject to removal in a future version.getCardImage(float scale) Creates and returns an image of the AlphaStrike element's unit card.getCardImage(int width) Creates and returns an image of the AlphaStrike element's unit card.protected voidInitializes some values for the card.protected voidinitializeFonts(Font lightFont, Font boldFont, Font blackFont) Initializes fonts and configs.protected voidWrite the armor block.protected voidWrite base info.protected voidpaintCardBackground(Graphics2D g, boolean isFlipSide) Draws the card background including the AlphaStrike Stats block.protected voidWrite the ground unit damage block.protected voidWrite the heat block.protected voidWrite the critical hits block.protected voidpaintPipLines(Graphics2D g, int leftX, int y, Color fillColor, int pipCount) protected voidWrite the point value.protected voidWrite the special ability block.protected voidpaintSpecialTextLines(Graphics2D g, ASCardDisplayable element, Font font, int x, int y, int width, int lineHeight) Helper method that writes the actual special ability text lines.void
-
Field Details
-
WIDTH
public static final int WIDTH- See Also:
-
HEIGHT
public static final int HEIGHT- See Also:
-
PRINT_SCALE
public static final double PRINT_SCALE- See Also:
-
BORDER
protected static final int BORDER- See Also:
-
ARMOR_PIP_SIZE
protected static final int ARMOR_PIP_SIZE- See Also:
-
DAMAGE_PIP_SIZE
protected static final int DAMAGE_PIP_SIZE- See Also:
-
BOX_WIDTH_WIDE
protected static final int BOX_WIDTH_WIDE- See Also:
-
BOX_CORNER
protected static final int BOX_CORNER- See Also:
-
BOX_STROKE
protected static final float BOX_STROKE- See Also:
-
DARKGRAY
-
BACKGROUND_GRAY
-
element
-
fluffImage
-
lightFont
-
boldFont
-
blackFont
-
modelFont
-
chassisFont
-
headerFont
-
valueFont
-
specialsFont
-
pointValueHeaderFont
-
pointValueFont
-
hitsTitleFont
-
alphaStrikeStatsFont
-
valueConfig
-
hitsTitleConfig
-
specialsHeaderConfig
-
baseInfoBoxHeight
protected int baseInfoBoxHeight -
damageBoxY
protected int damageBoxY -
damageBoxHeight
protected int damageBoxHeight -
armorBoxY
protected int armorBoxY -
armorBoxHeight
protected int armorBoxHeight -
armorBoxWidth
protected int armorBoxWidth -
armorPipSpace
protected int armorPipSpace -
specialBoxX
protected int specialBoxX -
specialBoxY
protected int specialBoxY -
specialBoxWidth
protected int specialBoxWidth -
specialBoxHeight
protected int specialBoxHeight -
fluffXCenter
protected int fluffXCenter -
fluffYCenter
protected int fluffYCenter -
fluffWidth
protected int fluffWidth -
fluffHeight
protected int fluffHeight
-
-
Constructor Details
-
ASCard
Constructs and initializes the ASCard. Do not use directly, use createCard instead.
-
-
Method Details
-
createCard
Creates an ASCard for the given AlphaStrike unit (either an AlphaStrikeElement or a MekSummary) which can be used to display a typical AlphaStrike element card. The element can be null in which case the card will contain a message instead of the element's values; the card image will still have the correct size.Note that depending on unit type this method may return an ASCard object or a subclass object, but it is not necessary to pay attention to this.
- Parameters:
element- The element to display on the card.- Returns:
- The element's ASCard
-
getCardImage
Creates and returns an image of the AlphaStrike element's unit card. The card is drawn in grayscale standard MUL style. The card is scaled with the given scale, values smaller than 1 making the card smaller. This method always fully draws the card so it always reflects the current state of the AlphaStrike element.- Parameters:
scale- The scaling to apply to the card- Returns:
- The unit card image
-
getCardImage
Creates and returns an image of the AlphaStrike element's unit card. The card is drawn in grayscale standard MUL style. The card is scaled to fit the given width. This method always fully draws the card so it always reflects the current state of the AlphaStrike element.- Parameters:
width- The desired width of the card in pixels- Returns:
- The unit card image
-
getCardImage
Deprecated, for removal: This API element is subject to removal in a future version.Creates and returns an image of the AlphaStrike element's unit card. The card is drawn in grayscale standard MUL style. The card will have the standard MUL dimension (1050 x 750 pixels) for all unit types except Large Aerospace units. For those, the two card faces are stacked vertically and the resulting card image has a size of 1050 x 1500. This method always fully draws the card so it always reflects the current state of the AlphaStrike element.- Returns:
- The unit card image
-
setFont
-
initialize
protected void initialize()Initializes some values for the card. Overridden for some card types. -
initializeFonts
Initializes fonts and configs. Overridden for some card types. -
drawCard
This method controls drawing the card. -
drawModelChassis
Write model, chassis and squad size. Overridden for some card types. -
paintBaseInfo
Write base info. Overridden for some card types. -
paintDamage
Write the ground unit damage block. Overridden for some card types. -
paintHeat
Write the heat block. The subclass for heat tracking cards overrides this to paint content. -
paintArmor
Write the armor block. Overridden for some card types. -
paintPipLines
-
paintSpecial
Write the special ability block. Overridden for some card types. -
paintSpecialTextLines
protected void paintSpecialTextLines(Graphics2D g, ASCardDisplayable element, Font font, int x, int y, int width, int lineHeight) Helper method that writes the actual special ability text lines. -
paintPointValue
Write the point value. Overridden in Large Aero cards. -
paintHits
Write the critical hits block. Subclasses override to provide content. -
drawDamagePip
Draws a crit damage pip at the provided coordinates (x is left-aligned, y centered).- Parameters:
g- The Graphics2D to draw tox- the horizontal position (left edge of the damage pip!)y- the vertical position (center of the damage pip!)
-
paintCardBackground
Draws the card background including the AlphaStrike Stats block. When isFlipSide is true, the point value box and logo are omitted and the copyright notice is positioned differently.- Parameters:
g- The Graphics2D to draw toisFlipSide- True for the card backside (Large Aerospace units)
-