java.lang.Object
megamek.common.alphaStrike.cardDrawer.ASCard
Direct Known Subclasses:
ASHeatTrackingCard, ASLargeAeroCard, ASProtoMekCard, ASVehicleCard

public class ASCard extends Object
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 Details

    • WIDTH

      public static final int WIDTH
      See Also:
    • HEIGHT

      public static final int HEIGHT
      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

      protected static final Color DARKGRAY
    • BACKGROUND_GRAY

      protected static final Color BACKGROUND_GRAY
    • element

      protected final ASCardDisplayable element
    • fluffImage

      protected final Image fluffImage
    • lightFont

      protected Font lightFont
    • boldFont

      protected Font boldFont
    • blackFont

      protected Font blackFont
    • modelFont

      protected Font modelFont
    • chassisFont

      protected Font chassisFont
    • headerFont

      protected Font headerFont
    • valueFont

      protected Font valueFont
    • specialsFont

      protected Font specialsFont
    • pointValueHeaderFont

      protected Font pointValueHeaderFont
    • pointValueFont

      protected Font pointValueFont
    • hitsTitleFont

      protected Font hitsTitleFont
    • alphaStrikeStatsFont

      protected Font alphaStrikeStatsFont
    • valueConfig

      protected StringDrawer.StringDrawerConfig valueConfig
    • hitsTitleConfig

      protected StringDrawer.StringDrawerConfig hitsTitleConfig
    • specialsHeaderConfig

      protected StringDrawer.StringDrawerConfig 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

      protected ASCard(ASCardDisplayable element)
      Constructs and initializes the ASCard. Do not use directly, use createCard instead.
  • Method Details

    • createCard

      public static ASCard createCard(@Nullable 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. 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

      public BufferedImage getCardImage(float scale)
      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

      public BufferedImage getCardImage(int width)
      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(since="0.51.0", forRemoval=true) public BufferedImage 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

      public void setFont(Font newFont)
    • initialize

      protected void initialize()
      Initializes some values for the card. Overridden for some card types.
    • initializeFonts

      protected void initializeFonts(Font lightFont, Font boldFont, Font blackFont)
      Initializes fonts and configs. Overridden for some card types.
    • drawCard

      public final void drawCard(Graphics g)
      This method controls drawing the card.
    • drawModelChassis

      protected void drawModelChassis(Graphics2D g)
      Write model, chassis and squad size. Overridden for some card types.
    • paintBaseInfo

      protected void paintBaseInfo(Graphics2D g)
      Write base info. Overridden for some card types.
    • paintDamage

      protected void paintDamage(Graphics2D g)
      Write the ground unit damage block. Overridden for some card types.
    • paintHeat

      protected void paintHeat(Graphics2D g)
      Write the heat block. The subclass for heat tracking cards overrides this to paint content.
    • paintArmor

      protected void paintArmor(Graphics2D g)
      Write the armor block. Overridden for some card types.
    • paintPipLines

      protected void paintPipLines(Graphics2D g, int leftX, int y, Color fillColor, int pipCount)
    • paintSpecial

      protected void paintSpecial(Graphics2D g)
      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

      protected void paintPointValue(Graphics2D g)
      Write the point value. Overridden in Large Aero cards.
    • paintHits

      protected void paintHits(Graphics2D g)
      Write the critical hits block. Subclasses override to provide content.
    • drawDamagePip

      protected void drawDamagePip(Graphics2D g, int x, int y)
      Draws a crit damage pip at the provided coordinates (x is left-aligned, y centered).
      Parameters:
      g - The Graphics2D to draw to
      x - the horizontal position (left edge of the damage pip!)
      y - the vertical position (center of the damage pip!)
    • paintCardBackground

      protected void paintCardBackground(Graphics2D g, boolean isFlipSide)
      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 to
      isFlipSide - True for the card backside (Large Aerospace units)