# Class Caption

java.lang.Object
uk.ac.starlink.ttools.plot2.Caption

@Equality public abstract class Caption extends 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(String txt)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`Caption`
`append(Caption other)`
Concatenates 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`
`equals(Object o)`
`int`
`hashCode()`
`abstract String`
`toLatex()`
Returns the LaTeX representation of the caption.
`String`
`toText()`
Returns the plain text representation of the caption.

### Methods inherited from class Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Caption

protected Caption(String txt)
Constructor.

Parameters:
  `txt` - plain text caption content

## Method Details

### toText

public String toText()
Returns the plain text representation of the caption.

Returns:
  plain text content

### toLatex

public abstract 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 class `Object`

### equals

public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

### createCaption

public static Caption createCaption(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(String txt, String latex)
Constructs a caption for which the LaTeX representation is supplied explicitly.

Parameters:
  `txt` - plain text representation
  `latex` - LaTeX representation
Returns:
  new caption

### createCaption

public static Caption createCaption(String txt, UnaryOperator<String> toLatexFunc)
Constructs a caption for which the LaTeX representation will be generated lazily from the plain text.

Parameters:
  `txt` - plain text caption
  `toLatexFunc` - function that maps plain text to latex
Returns:
  new caption