Class DummyCalculationReport

java.lang.Object
megamek.client.ui.clientGUI.calculationReport.DummyCalculationReport
All Implemented Interfaces:
CalculationReport

public class DummyCalculationReport extends Object implements CalculationReport
This is a Calculation Report that can be used when the report that comes with a calculation isn't going to be used. It saves time and memory by doing nothing with any passed parameters. Its toString() and toJComponent() methods yield a short explanatory message as String and JLabel, respectively, and so can be called safely.
  • Constructor Details

    • DummyCalculationReport

      public DummyCalculationReport()
  • Method Details

    • addLine

      public CalculationReport addLine(String type, String calculation, String result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport.
      Specified by:
      addLine in interface CalculationReport
      Parameters:
      type - The first element of this line, such as "Damage: "
      calculation - A calculation or other info, displayed after the type
      result - A result or other info, displayed on the right side
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addLine

      public CalculationReport addLine(String type, String calculation, String resultPrefix, double result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport. This method performs rounding to a single decimal digit on the result and writes resultPrefix in front of it.
      Specified by:
      addLine in interface CalculationReport
      Parameters:
      type - The first element of this line, such as "Damage: "
      calculation - A calculation or other info, displayed after the type
      resultPrefix - A text to be display immediately in front of the result, such as "= "
      result - A numerical result which will be rounded to a single decimal, e.g. 25.1
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addLine

      public CalculationReport addLine(String type, String resultPrefix, double result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport. This method performs rounding to a single decimal digit on the result and writes resultPrefix in front of it. This line has only two elements, the type ("Damage: ") and the result displayed on the right side.
      Specified by:
      addLine in interface CalculationReport
      Parameters:
      type - The first element of this line, such as "Damage: "
      resultPrefix - A text to be display immediately in front of the result, such as "= "
      result - A numerical result which will be rounded to a single decimal, e.g. 25.1
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addResultLine

      public CalculationReport addResultLine(String type, String calculation, String resultPrefix, double result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport in the way addLine() does, except the result has a line above it that may e.g. indicate a summary of previous values. This method performs rounding to a single decimal digit on the result and writes resultPrefix in front of it.
      Specified by:
      addResultLine in interface CalculationReport
      Parameters:
      type - The first element of this line, such as "Damage: "
      calculation - A calculation or other info, displayed after the type
      resultPrefix - A text to be display immediately in front of the result, such as "= "
      result - A numerical result which will be rounded to a single decimal, e.g. 25.1
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addResultLine

      public CalculationReport addResultLine(String type, String resultPrefix, double result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport in the way addLine() does, except the result has a line above it that may e.g. indicate a summary of previous values. This line has only two elements, the type ("Damage: ") and the result displayed on the right side. This method performs rounding to a single decimal digit on the result and writes resultPrefix in front of it.
      Specified by:
      addResultLine in interface CalculationReport
      Parameters:
      type - The first element of this line, such as "Damage: "
      resultPrefix - A text to be display immediately in front of the result, such as "= "
      result - A numerical result which will be rounded to a single decimal, e.g. 25.1
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addResultLine

      public CalculationReport addResultLine(String resultPrefix, double result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport in the way addLine() does, except the result has a line above it that may e.g. indicate a summary of previous values. This line has only one element, the result displayed on the right side. This method performs rounding to a single decimal digit on the result and writes resultPrefix in front of it.
      Specified by:
      addResultLine in interface CalculationReport
      Parameters:
      resultPrefix - A text to be display immediately in front of the result, such as "= "
      result - A numerical result which will be rounded to a single decimal, e.g. 25.1
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addEmptyLine

      public CalculationReport addEmptyLine()
      Description copied from interface: CalculationReport
      Adds an empty line to the CalculationReport.
      Specified by:
      addEmptyLine in interface CalculationReport
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addLine

      public CalculationReport addLine(String type, String result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport. This line has only two elements, the type ("Damage: ") and a result displayed on the right side.
      Specified by:
      addLine in interface CalculationReport
      Parameters:
      type - The first element of this line, such as "Damage: "
      result - A result or other info, displayed on the right side
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addLine

      public CalculationReport addLine(String result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport. This line only has one element displayed on the right side.
      Specified by:
      addLine in interface CalculationReport
      Parameters:
      result - A result or other info, displayed on the right side
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addSubHeader

      public CalculationReport addSubHeader(String text)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport containing a sub-header.
      Specified by:
      addSubHeader in interface CalculationReport
      Parameters:
      text - The header text
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addHeader

      public CalculationReport addHeader(String text)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport containing the header for the CalculationReport. This would typically be used as the first line but can be used anywhere in the CalculationReport and multiple times.
      Specified by:
      addHeader in interface CalculationReport
      Parameters:
      text - The header text
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • addResultLine

      public CalculationReport addResultLine(String type, String calculation, String result)
      Description copied from interface: CalculationReport
      Adds a single line to the CalculationReport in the way addLine() does, except the result has a line above it that may e.g. indicate a summary of previous values.
      Specified by:
      addResultLine in interface CalculationReport
      Parameters:
      type - The first element of this line, such as "Damage: "
      calculation - A calculation or other info, displayed after the type
      result - A result or other info, displayed on the right side
      Returns:
      The CalculationReport itself. Enables multiple stringed addLine calls
    • toJComponent

      public JComponent toJComponent()
      Description copied from interface: CalculationReport
      Returns the CalculationReport as a JComponent that can be added to a dialog or other Swing component.
      Specified by:
      toJComponent in interface CalculationReport
      Returns:
      The CalculationReport wrapped in a JComponent form.
    • startTentativeSection

      public void startTentativeSection()
      Description copied from interface: CalculationReport
      Starts a report section that is tentative, i.e. that may be added or discarded depending on whether CalculationReport.endTentativeSection() or CalculationReport.discardTentativeSection() is called at a later point. All lines added to the report after calling this method are kept separate until either CalculationReport.endTentativeSection() or CalculationReport.discardTentativeSection() is called. When subsequently CalculationReport.endTentativeSection() is called, the lines of the section are written to the report normally. When subsequently CalculationReport.discardTentativeSection() is called, all lines in the section are discarded (not written to the report). Note that calling this method multiple times has no further effect. The first consecutive call of this method stays the one that marks the start of the section. Not more than a single section is maintained at any time.
      Specified by:
      startTentativeSection in interface CalculationReport
    • endTentativeSection

      public void endTentativeSection()
      Description copied from interface: CalculationReport
      End the current section of lines, writing them to the report normally. Note that when a section has been ended and no new section begun, calling this method again has no effect.
      Specified by:
      endTentativeSection in interface CalculationReport
    • discardTentativeSection

      public void discardTentativeSection()
      Description copied from interface: CalculationReport
      Discard all lines written to this section (all lines added to the report after calling CalculationReport.startTentativeSection()). Note that when a section has been ended and no new section begun, calling this method again has no effect.
      Specified by:
      discardTentativeSection in interface CalculationReport
    • toString

      public String toString()
      Overrides:
      toString in class Object