Class DummyCalculationReport
java.lang.Object
megamek.client.ui.clientGUI.calculationReport.DummyCalculationReport
- All Implemented Interfaces:
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface megamek.client.ui.clientGUI.calculationReport.CalculationReport
CalculationReport.LineType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds an empty line to the CalculationReport.Adds a single line to the CalculationReport containing the header for the CalculationReport.Adds a single line to the CalculationReport.Adds a single line to the CalculationReport.Adds a single line to the CalculationReport.Adds a single line to the CalculationReport.Adds a single line to the CalculationReport.addResultLine
(String resultPrefix, double result) Adds a single line to the CalculationReport in the way addLine() does, except the result has a line above it that may e.g.addResultLine
(String type, String resultPrefix, double result) Adds a single line to the CalculationReport in the way addLine() does, except the result has a line above it that may e.g.addResultLine
(String type, String calculation, String result) Adds a single line to the CalculationReport in the way addLine() does, except the result has a line above it that may e.g.addResultLine
(String type, String calculation, String resultPrefix, double result) Adds a single line to the CalculationReport in the way addLine() does, except the result has a line above it that may e.g.addSubHeader
(String text) Adds a single line to the CalculationReport containing a sub-header.void
Discard all lines written to this section (all lines added to the report after callingCalculationReport.startTentativeSection()
).void
End the current section of lines, writing them to the report normally.void
Starts a report section that is tentative, i.e.Returns the CalculationReport as a JComponent that can be added to a dialog or other Swing component.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface megamek.client.ui.clientGUI.calculationReport.CalculationReport
finalizeTentativeSection
-
Constructor Details
-
DummyCalculationReport
public DummyCalculationReport()
-
-
Method Details
-
addLine
Description copied from interface:CalculationReport
Adds a single line to the CalculationReport.- Specified by:
addLine
in interfaceCalculationReport
- Parameters:
type
- The first element of this line, such as "Damage: "calculation
- A calculation or other info, displayed after the typeresult
- 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 interfaceCalculationReport
- Parameters:
type
- The first element of this line, such as "Damage: "calculation
- A calculation or other info, displayed after the typeresultPrefix
- 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
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 interfaceCalculationReport
- 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 interfaceCalculationReport
- Parameters:
type
- The first element of this line, such as "Damage: "calculation
- A calculation or other info, displayed after the typeresultPrefix
- 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
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 interfaceCalculationReport
- 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
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 interfaceCalculationReport
- 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
Description copied from interface:CalculationReport
Adds an empty line to the CalculationReport.- Specified by:
addEmptyLine
in interfaceCalculationReport
- Returns:
- The CalculationReport itself. Enables multiple stringed addLine calls
-
addLine
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 interfaceCalculationReport
- 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
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 interfaceCalculationReport
- Parameters:
result
- A result or other info, displayed on the right side- Returns:
- The CalculationReport itself. Enables multiple stringed addLine calls
-
addSubHeader
Description copied from interface:CalculationReport
Adds a single line to the CalculationReport containing a sub-header.- Specified by:
addSubHeader
in interfaceCalculationReport
- Parameters:
text
- The header text- Returns:
- The CalculationReport itself. Enables multiple stringed addLine calls
-
addHeader
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 interfaceCalculationReport
- Parameters:
text
- The header text- Returns:
- The CalculationReport itself. Enables multiple stringed addLine calls
-
addResultLine
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 interfaceCalculationReport
- Parameters:
type
- The first element of this line, such as "Damage: "calculation
- A calculation or other info, displayed after the typeresult
- A result or other info, displayed on the right side- Returns:
- The CalculationReport itself. Enables multiple stringed addLine calls
-
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 interfaceCalculationReport
- 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 whetherCalculationReport.endTentativeSection()
orCalculationReport.discardTentativeSection()
is called at a later point. All lines added to the report after calling this method are kept separate until eitherCalculationReport.endTentativeSection()
orCalculationReport.discardTentativeSection()
is called. When subsequentlyCalculationReport.endTentativeSection()
is called, the lines of the section are written to the report normally. When subsequentlyCalculationReport.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 interfaceCalculationReport
-
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 interfaceCalculationReport
-
discardTentativeSection
public void discardTentativeSection()Description copied from interface:CalculationReport
Discard all lines written to this section (all lines added to the report after callingCalculationReport.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 interfaceCalculationReport
-
toString
-