Package de.hsh.graja.util.comment
Class FontWeightAndStyle
java.lang.Object
de.hsh.graja.util.comment.FontWeightAndStyle
- All Implemented Interfaces:
Serializable,Iterable<FontWeightAndStyle.FontDecoration>
public class FontWeightAndStyle
extends Object
implements Iterable<FontWeightAndStyle.FontDecoration>, Serializable
This class describes a font weight or a font style in an InlineContent or a ParagraphContent.
It is possible to adapt the size of the font, the weight (strong, or emphasized) and the style (underline).
An instance of this class is comprised of a set of one or more FontWeightAndStyle.FontDecoration elements.
Usage example:
ParagraphContent p= new ParagraphContent(includeSpec, "Summary", FontWeightAndStyle.H1)); p.addItem(InlineContent.format(includeSpec, "%s", FontWeightAndStyle.smaller(), "this is a minor remark"));
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumA single font decoration element, that can be used to describe a font. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FontWeightAndStylean unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER,FontWeightAndStyle.FontDecoration.STRONG}.static final FontWeightAndStylean unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER,FontWeightAndStyle.FontDecoration.UNDERLINE}.static final FontWeightAndStylean unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER,FontWeightAndStyle.FontDecoration.EMPHASIZED}.static final FontWeightAndStylean unmodifiable set of {FontWeightAndStyle.FontDecoration.STRONG}.static final FontWeightAndStylean unmodifiable set of {FontWeightAndStyle.FontDecoration.UNDERLINE}.static final FontWeightAndStylean unmodifiable set of {FontWeightAndStyle.FontDecoration.EMPHASIZED}. -
Constructor Summary
ConstructorsConstructorDescriptionCreate an empty set of font decorations.FontWeightAndStyle(FontWeightAndStyle.FontDecoration... decorations) Create a new font with the given decorations.FontWeightAndStyle(FontWeightAndStyle other, FontWeightAndStyle.FontDecoration... additionalDecorations) Create a new font as a clone ofotherand augmented with the given additional decorations. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(FontWeightAndStyle.FontDecoration decoration) Expand the font with an additional decoration.static FontWeightAndStylebooleanimplements the contract ofObject.equals(Object).static final FontWeightAndStyleforHeader(int header) inthashCode()implements the contract ofObject.hashCode().booleanbooleanbooleanisLarger()booleanbooleanisStrong()booleaniterator()implements the contract ofIterable.static FontWeightAndStylelarger()static FontWeightAndStylenormal()static FontWeightAndStylesmaller()static FontWeightAndStylestrong()static FontWeightAndStyleMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
H1
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER,FontWeightAndStyle.FontDecoration.STRONG}. -
H2
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER,FontWeightAndStyle.FontDecoration.UNDERLINE}. -
H3
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER,FontWeightAndStyle.FontDecoration.EMPHASIZED}. -
H4
an unmodifiable set of {FontWeightAndStyle.FontDecoration.STRONG}. -
H5
an unmodifiable set of {FontWeightAndStyle.FontDecoration.UNDERLINE}. -
H6
an unmodifiable set of {FontWeightAndStyle.FontDecoration.EMPHASIZED}.
-
-
Constructor Details
-
FontWeightAndStyle
public FontWeightAndStyle()Create an empty set of font decorations. -
FontWeightAndStyle
Create a new font with the given decorations. The new set is expandable with more decorations viaadd(FontDecoration).- Parameters:
decorations- initial decorations
-
FontWeightAndStyle
public FontWeightAndStyle(FontWeightAndStyle other, FontWeightAndStyle.FontDecoration... additionalDecorations) Create a new font as a clone ofotherand augmented with the given additional decorations. The new set is expandable with more decorations viaadd(FontDecoration).- Parameters:
other- cloned objectadditionalDecorations- initial decorations
-
-
Method Details
-
add
Expand the font with an additional decoration.- Parameters:
decoration- additional decoration.
-
is
- Parameters:
fd- a decoration to search for- Returns:
- true, if this instance contains the given decoration
-
isStrong
public boolean isStrong()- Returns:
- true, if this font contains the decoration
FontWeightAndStyle.FontDecoration.STRONG.
-
isEmphasized
public boolean isEmphasized()- Returns:
- true, if this font contains the decoration
FontWeightAndStyle.FontDecoration.EMPHASIZED.
-
isUnderline
public boolean isUnderline()- Returns:
- true, if this font contains the decoration
FontWeightAndStyle.FontDecoration.UNDERLINE.
-
isLarger
public boolean isLarger()- Returns:
- true, if this font contains the decoration
FontWeightAndStyle.FontDecoration.LARGER.
-
isSmaller
public boolean isSmaller()- Returns:
- true, if this font contains the decoration
FontWeightAndStyle.FontDecoration.SMALLER.
-
underline
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.UNDERLINE.
-
strong
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.STRONG.
-
emphasized
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.EMPHASIZED.
-
smaller
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.SMALLER.
-
larger
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.LARGER.
-
normal
- Returns:
- a newly created empty set
-
forHeader
-
hashCode
public int hashCode()implements the contract ofObject.hashCode(). -
equals
implements the contract ofObject.equals(Object). -
iterator
implements the contract ofIterable.- Specified by:
iteratorin interfaceIterable<FontWeightAndStyle.FontDecoration>
-
getCssStyles
- Returns:
- a semicolon-separated list of css styles. There is no trailing semicolon in the returned string.
-