Package com.teamten.typeset
Class Config
java.lang.Object
com.teamten.typeset.Config
Stores all the configuration metadata about the book. This includes strings like the title of the
book, font descriptions, and page sizes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Various keys that can be used in this configuration. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Config.Key key, String value) Parses the value appropriately for the key type and adds it to the configuration.void
addDistance
(Config.Key key, long value) Adds a distance value to the configuration.void
addFont
(Config.Key key, TypefaceVariantSize value) Adds a font value to the configuration.void
addString
(Config.Key key, String value) Adds a string value to the configuration.void
addTypeface
(Config.Key key, Typeface value) Adds a typeface value to the configuration.void
Fill the configuration with default values so that each document doesn't have to define them all.long
The height of the text on the page.long
The width of the text on the page.long
getDistance
(Config.Key key) Gets the distance value for the key in scaled units, or throws if not in the configuration.getFont
(Config.Key key) Gets the font value for the key, or null if not in the configuration.long
Gets the page height in scaled points fromConfig.Key.PAGE_HEIGHT
.long
Gets the page bottom margin in scaled points fromConfig.Key.PAGE_MARGIN_BOTTOM
.long
Gets the page inner margin in scaled points fromConfig.Key.PAGE_MARGIN_INNER
.long
Gets the page outer margin in scaled points fromConfig.Key.PAGE_MARGIN_OUTER
.long
Gets the page top margin in scaled points fromConfig.Key.PAGE_MARGIN_TOP
.long
Gets the page width in scaled points fromConfig.Key.PAGE_WIDTH
.@Nullable String
getString
(Config.Key key) Gets the string value for the key, or null if not in the configuration.@NotNull String
getString
(Config.Key key, String defaultValue) Gets the string value for the key, or the provided default value if not in the configuration.getTypeface
(Config.Key key) Gets the typeface value for the key, or null if not in the configuration.static Config
A configuration suitable for quick tests.
-
Field Details
-
TOC_STYLE_CLASSIC
- See Also:
-
TOC_STYLE_MODERN
- See Also:
-
-
Constructor Details
-
Config
public Config()
-
-
Method Details
-
testConfig
A configuration suitable for quick tests. -
fillWithDefaults
public void fillWithDefaults()Fill the configuration with default values so that each document doesn't have to define them all. -
addString
Adds a string value to the configuration.- Throws:
IllegalArgumentException
- if the key is not for strings.
-
addFont
Adds a font value to the configuration.- Throws:
IllegalArgumentException
- if the key is not for fonts.
-
addTypeface
Adds a typeface value to the configuration.- Throws:
IllegalArgumentException
- if the key is not for typefaces.
-
addDistance
Adds a distance value to the configuration.- Throws:
IllegalArgumentException
- if the key is not for distances.
-
add
Parses the value appropriately for the key type and adds it to the configuration.- Throws:
IllegalArgumentException
- if the value cannot be parsed for the given type.
-
getString
Gets the string value for the key, or null if not in the configuration.- Throws:
IllegalArgumentException
- if the key is not for strings.
-
getString
Gets the string value for the key, or the provided default value if not in the configuration.- Throws:
IllegalArgumentException
- if the key is not for strings.
-
getFont
Gets the font value for the key, or null if not in the configuration.- Throws:
IllegalArgumentException
- if the key is not for fonts.
-
getTypeface
Gets the typeface value for the key, or null if not in the configuration.- Throws:
IllegalArgumentException
- if the key is not for typefaces.
-
getDistance
Gets the distance value for the key in scaled units, or throws if not in the configuration.- Throws:
IllegalArgumentException
- if the key is not for distances or the value not in the configuration.
-
getPageWidth
public long getPageWidth()Gets the page width in scaled points fromConfig.Key.PAGE_WIDTH
. -
getPageHeight
public long getPageHeight()Gets the page height in scaled points fromConfig.Key.PAGE_HEIGHT
. -
getPageMarginTop
public long getPageMarginTop()Gets the page top margin in scaled points fromConfig.Key.PAGE_MARGIN_TOP
. -
getPageMarginBottom
public long getPageMarginBottom()Gets the page bottom margin in scaled points fromConfig.Key.PAGE_MARGIN_BOTTOM
. -
getPageMarginOuter
public long getPageMarginOuter()Gets the page outer margin in scaled points fromConfig.Key.PAGE_MARGIN_OUTER
. -
getPageMarginInner
public long getPageMarginInner()Gets the page inner margin in scaled points fromConfig.Key.PAGE_MARGIN_INNER
. -
getBodyWidth
public long getBodyWidth()The width of the text on the page. This is computed from the page width and page margin. -
getBodyHeight
public long getBodyHeight()The height of the text on the page. This is computed from the page height and page margin.
-