Class PMSimpleLabel

java.lang.Object
megamek.client.ui.widget.picmap.PMSimpleLabel
All Implemented Interfaces:
PMElement, PMLabel
Direct Known Subclasses:
PMMultiLineLabel, PMValueLabel

public class PMSimpleLabel extends Object implements PMLabel
  • Field Details

    • width

      public int width
    • outlined

      protected boolean outlined
    • drawScale

      protected double drawScale
      The factor the text is enlarged by, so it is drawn at that size rather than magnified and left blocky.
  • Constructor Details

  • Method Details

    • setString

      public void setString(String s)
      Specified by:
      setString in interface PMLabel
    • setColor

      public void setColor(Color c)
      Specified by:
      setColor in interface PMLabel
    • moveTo

      public void moveTo(int x, int y)
      Specified by:
      moveTo in interface PMLabel
    • translate

      public void translate(int x, int y)
      Description copied from interface: PMElement
      Translates element by x and y.
      Specified by:
      translate in interface PMElement
    • drawInto

      public void drawInto(Graphics g)
      Description copied from interface: PMElement
      Draws element into specified Graphics.
      Specified by:
      drawInto in interface PMElement
    • drawOutlinedString

      protected void drawOutlinedString(Graphics g, String text, int atX, int atY)
      Draws the label, ringed with a contrasting outline when it is outlined. A label over a location striped for a critical hit would otherwise have to compete with the stripes drawn underneath it.

      When the label is enlarged, its position and font are scaled here and it is drawn at that size, so its text renders crisply rather than being magnified through the component's transform and left blocky.

    • setOutlined

      public void setOutlined(boolean outlined)
      Rings the label with a contrasting outline, for when what is drawn under it would drown it out.
    • setDrawScale

      public void setDrawScale(double scale)
      Description copied from interface: PMLabel
      Sets the factor the label's text is enlarged by, so it can be drawn at that size rather than magnified through the component's transform, which would leave it blocky. 1.0 draws it at its natural size.
      Specified by:
      setDrawScale in interface PMLabel
    • setVisible

      public void setVisible(boolean v)
      Description copied from interface: PMElement
      Sets visibility of element
      Specified by:
      setVisible in interface PMElement
    • getBounds

      public Rectangle getBounds()
      Specified by:
      getBounds in interface PMElement
      Returns:
      bounding box of element.
    • getSize

      public Dimension getSize()
      Specified by:
      getSize in interface PMLabel
    • getDescent

      public int getDescent()
      Specified by:
      getDescent in interface PMLabel