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 aParagraphContent
. 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 moreFontWeightAndStyle.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FontWeightAndStyle.FontDecoration
A single font decoration element, that can be used to describe a font.
-
Field Summary
Fields Modifier and Type Field Description static FontWeightAndStyle
H1
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER
,FontWeightAndStyle.FontDecoration.STRONG
}.static FontWeightAndStyle
H2
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER
,FontWeightAndStyle.FontDecoration.UNDERLINE
}.static FontWeightAndStyle
H3
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER
,FontWeightAndStyle.FontDecoration.EMPHASIZED
}.static FontWeightAndStyle
H4
an unmodifiable set of {FontWeightAndStyle.FontDecoration.STRONG
}.static FontWeightAndStyle
H5
an unmodifiable set of {FontWeightAndStyle.FontDecoration.UNDERLINE
}.static FontWeightAndStyle
H6
an unmodifiable set of {FontWeightAndStyle.FontDecoration.EMPHASIZED
}.
-
Constructor Summary
Constructors Constructor Description FontWeightAndStyle()
Create 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 ofother
and augmented with the given additional decorations.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(FontWeightAndStyle.FontDecoration decoration)
Expand the font with an additional decoration.static FontWeightAndStyle
emphasized()
boolean
equals(Object obj)
implements the contract ofObject.equals(Object)
.static FontWeightAndStyle
forHeader(int header)
String
getCssStyles()
int
hashCode()
implements the contract ofObject.hashCode()
.boolean
is(FontWeightAndStyle.FontDecoration fd)
boolean
isEmphasized()
boolean
isLarger()
boolean
isSmaller()
boolean
isStrong()
boolean
isUnderline()
Iterator<FontWeightAndStyle.FontDecoration>
iterator()
implements the contract ofIterable
.static FontWeightAndStyle
larger()
static FontWeightAndStyle
normal()
static FontWeightAndStyle
smaller()
static FontWeightAndStyle
strong()
static FontWeightAndStyle
underline()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
H1
public static final FontWeightAndStyle H1
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER
,FontWeightAndStyle.FontDecoration.STRONG
}.
-
H2
public static final FontWeightAndStyle H2
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER
,FontWeightAndStyle.FontDecoration.UNDERLINE
}.
-
H3
public static final FontWeightAndStyle H3
an unmodifiable set of {FontWeightAndStyle.FontDecoration.LARGER
,FontWeightAndStyle.FontDecoration.EMPHASIZED
}.
-
H4
public static final FontWeightAndStyle H4
an unmodifiable set of {FontWeightAndStyle.FontDecoration.STRONG
}.
-
H5
public static final FontWeightAndStyle H5
an unmodifiable set of {FontWeightAndStyle.FontDecoration.UNDERLINE
}.
-
H6
public static final FontWeightAndStyle H6
an unmodifiable set of {FontWeightAndStyle.FontDecoration.EMPHASIZED
}.
-
-
Constructor Detail
-
FontWeightAndStyle
public FontWeightAndStyle()
Create an empty set of font decorations.
-
FontWeightAndStyle
public FontWeightAndStyle(FontWeightAndStyle.FontDecoration... decorations)
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 ofother
and augmented with the given additional decorations. The new set is expandable with more decorations viaadd(FontDecoration)
.- Parameters:
other
- cloned objectadditionalDecorations
- initial decorations
-
-
Method Detail
-
add
public void add(FontWeightAndStyle.FontDecoration decoration)
Expand the font with an additional decoration.- Parameters:
decoration
- additional decoration.
-
is
public boolean is(FontWeightAndStyle.FontDecoration fd)
- 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
public static FontWeightAndStyle underline()
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.UNDERLINE
.
-
strong
public static FontWeightAndStyle strong()
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.STRONG
.
-
emphasized
public static FontWeightAndStyle emphasized()
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.EMPHASIZED
.
-
smaller
public static FontWeightAndStyle smaller()
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.SMALLER
.
-
larger
public static FontWeightAndStyle larger()
- Returns:
- a newly created set with one element
FontWeightAndStyle.FontDecoration.LARGER
.
-
normal
public static FontWeightAndStyle normal()
- Returns:
- a newly created empty set
-
forHeader
public static final FontWeightAndStyle forHeader(int header)
-
hashCode
public int hashCode()
implements the contract ofObject.hashCode()
.
-
equals
public boolean equals(Object obj)
implements the contract ofObject.equals(Object)
.
-
iterator
public Iterator<FontWeightAndStyle.FontDecoration> iterator()
implements the contract ofIterable
.- Specified by:
iterator
in interfaceIterable<FontWeightAndStyle.FontDecoration>
-
getCssStyles
public String getCssStyles()
- Returns:
- a semicolon-separated list of css styles. There is no trailing semicolon in the returned string.
-
-