Class Config

java.lang.Object
com.teamten.typeset.Config

public class Config extends Object
Stores all the configuration metadata about the book. This includes strings like the title of the book, font descriptions, and page sizes.
  • Field Details

  • Constructor Details

    • Config

      public Config()
  • Method Details

    • testConfig

      public static Config 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

      public void addString(Config.Key key, String value)
      Adds a string value to the configuration.
      Throws:
      IllegalArgumentException - if the key is not for strings.
    • addFont

      public void addFont(Config.Key key, TypefaceVariantSize value)
      Adds a font value to the configuration.
      Throws:
      IllegalArgumentException - if the key is not for fonts.
    • addTypeface

      public void addTypeface(Config.Key key, Typeface value)
      Adds a typeface value to the configuration.
      Throws:
      IllegalArgumentException - if the key is not for typefaces.
    • addDistance

      public void addDistance(Config.Key key, long value)
      Adds a distance value to the configuration.
      Throws:
      IllegalArgumentException - if the key is not for distances.
    • add

      public void add(Config.Key key, String value)
      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

      @Nullable public @Nullable String getString(Config.Key key)
      Gets the string value for the key, or null if not in the configuration.
      Throws:
      IllegalArgumentException - if the key is not for strings.
    • getString

      @NotNull public @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.
      Throws:
      IllegalArgumentException - if the key is not for strings.
    • getFont

      public TypefaceVariantSize getFont(Config.Key key)
      Gets the font value for the key, or null if not in the configuration.
      Throws:
      IllegalArgumentException - if the key is not for fonts.
    • getTypeface

      public Typeface getTypeface(Config.Key key)
      Gets the typeface value for the key, or null if not in the configuration.
      Throws:
      IllegalArgumentException - if the key is not for typefaces.
    • getDistance

      public long getDistance(Config.Key key)
      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 from Config.Key.PAGE_WIDTH.
    • getPageHeight

      public long getPageHeight()
      Gets the page height in scaled points from Config.Key.PAGE_HEIGHT.
    • getPageMarginTop

      public long getPageMarginTop()
      Gets the page top margin in scaled points from Config.Key.PAGE_MARGIN_TOP.
    • getPageMarginBottom

      public long getPageMarginBottom()
      Gets the page bottom margin in scaled points from Config.Key.PAGE_MARGIN_BOTTOM.
    • getPageMarginOuter

      public long getPageMarginOuter()
      Gets the page outer margin in scaled points from Config.Key.PAGE_MARGIN_OUTER.
    • getPageMarginInner

      public long getPageMarginInner()
      Gets the page inner margin in scaled points from Config.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.