Package uk.ac.starlink.ttools.plot2
Class Caption
java.lang.Object
uk.ac.starlink.ttools.plot2.Caption
Content of textual item to be rendered somewhere on a plot.
It currently contains the text and LaTeX representation.
Concrete subclasses must supply the LaTeX representation;
a number of createCaption
factory methods are provided
to facilitate this.
Caption equality is assessed on the basis of the primary text value only, not the LaTeX value. In practice, this is likely to be the relevant criterion.
- Since:
- 10 Mar 2020
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConcatenates another caption following this one.static Caption
createCaption
(String txt) Constructs a caption for which the LaTeX representation is the same as the plain text representation.static Caption
createCaption
(String txt, String latex) Constructs a caption for which the LaTeX representation is supplied explicitly.static Caption
createCaption
(String txt, UnaryOperator<String> toLatexFunc) Constructs a caption for which the LaTeX representation will be generated lazily from the plain text.boolean
int
hashCode()
abstract String
toLatex()
Returns the LaTeX representation of the caption.toText()
Returns the plain text representation of the caption.
-
Constructor Details
-
Caption
Constructor.- Parameters:
txt
- plain text caption content
-
-
Method Details
-
toText
Returns the plain text representation of the caption.- Returns:
- plain text content
-
toLatex
Returns the LaTeX representation of the caption.- Returns:
- latex content
-
append
Concatenates another caption following this one. The plain text and latex representations are both just concatenated.- Parameters:
other
- second caption- Returns:
- this caption followed by
other
-
hashCode
public int hashCode() -
equals
-
createCaption
Constructs a caption for which the LaTeX representation is the same as the plain text representation. Currently not quoting is performed, so it is the responsibility of the caller to ensure that the plain text does not contain any LaTeX markup.- Parameters:
txt
- caption content (plain text and latex)- Returns:
- new caption
-
createCaption
Constructs a caption for which the LaTeX representation is supplied explicitly.- Parameters:
txt
- plain text representationlatex
- LaTeX representation- Returns:
- new caption
-
createCaption
Constructs a caption for which the LaTeX representation will be generated lazily from the plain text.- Parameters:
txt
- plain text captiontoLatexFunc
- function that maps plain text to latex- Returns:
- new caption
-