Package uk.ac.starlink.ttools.plot2
Class Caption
- java.lang.Object
-
- uk.ac.starlink.ttools.plot2.Caption
-
@Equality public abstract class Caption extends java.lang.Object
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 Modifier Constructor Description protected
Caption(java.lang.String txt)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Caption
append(Caption other)
Concatenates another caption following this one.static Caption
createCaption(java.lang.String txt)
Constructs a caption for which the LaTeX representation is the same as the plain text representation.static Caption
createCaption(java.lang.String txt, java.lang.String latex)
Constructs a caption for which the LaTeX representation is supplied explicitly.static Caption
createCaption(java.lang.String txt, java.util.function.UnaryOperator<java.lang.String> toLatexFunc)
Constructs a caption for which the LaTeX representation will be generated lazily from the plain text.boolean
equals(java.lang.Object o)
int
hashCode()
abstract java.lang.String
toLatex()
Returns the LaTeX representation of the caption.java.lang.String
toText()
Returns the plain text representation of the caption.
-
-
-
Method Detail
-
toText
public java.lang.String toText()
Returns the plain text representation of the caption.- Returns:
- plain text content
-
toLatex
public abstract java.lang.String toLatex()
Returns the LaTeX representation of the caption.- Returns:
- latex content
-
append
public Caption append(Caption other)
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()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
createCaption
public static Caption createCaption(java.lang.String txt)
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
public static Caption createCaption(java.lang.String txt, java.lang.String latex)
Constructs a caption for which the LaTeX representation is supplied explicitly.- Parameters:
txt
- plain text representationlatex
- LaTeX representation- Returns:
- new caption
-
createCaption
public static Caption createCaption(java.lang.String txt, java.util.function.UnaryOperator<java.lang.String> toLatexFunc)
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
-
-