Class StyleFactory

java.lang.Object
org.zkoss.pivot.util.poi.StyleFactory

public class StyleFactory extends Object
Creates cell styles and fonts in the exported book.

The getOrCreateFontWith* methods and getOrCreateFont(Map) start from the book's default font and change only the properties given, so getOrCreateFontWithBoldWeight(BOLD_WEIGHT_BOLD) is the default font in bold. The overloads that take every property use exactly those.

Author:
Sam
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final short
     
    static final short
     
    static final short
     
    static final short
     
    static final String
     
    static final boolean
     
    static final boolean
     
    static final short
     
    static final byte
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    StyleFactory(io.keikai.model.SBook book)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    io.keikai.model.SCellStyle
    cloneCellStyle(io.keikai.model.SCellStyle source)
    Create a new Cell style, and clones from source CellStyle
    io.keikai.model.SCellStyle
    Create a new Cell style
    io.keikai.model.SCellStyle
    createCellStyle(String dataFormat)
    Create a new Cell style with data format.
    Returns the data format
    io.keikai.model.SFont
    Create a new Font.
    io.keikai.model.SFontBuilder
    Returns a builder of a new Font
    io.keikai.model.SBook
    Returns the book
    io.keikai.model.SFont
    getOrCreateFont(short boldWeight, short color, short fontHeightInPoints, String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
    Finds a font that matches the one with the supplied attributes.
    io.keikai.model.SFont
    getOrCreateFont(io.keikai.model.SFont.Boldweight boldWeight, String htmlColor, int fontHeightInPoints, String name, boolean italic, boolean strikeout, io.keikai.model.SFont.TypeOffset typeOffset, io.keikai.model.SFont.Underline underline)
    Finds a font that matches the one with the supplied attributes.
    io.keikai.model.SFont
    Finds a font that matches the book's default font with the supplied attributes; properties not in the map keep the default font's values.
    io.keikai.model.SFont
    getOrCreateFontWithBoldWeight(short fontBoldWeight)
    Find the book's default font with the bold attribute; if not found, create it.
    io.keikai.model.SFont
    getOrCreateFontWithColor(short fontColor)
    Find the book's default font with the color attribute; if not found, create it.
    io.keikai.model.SFont
    Find the book's default font with the color attribute; if not found, create it.
    io.keikai.model.SFont
    getOrCreateFontWithHeight(short fontHeightInPoints)
    Find the book's default font with the height attribute (in points); if not found, create it.
    io.keikai.model.SFont
    getOrCreateFontWithItalic(boolean italic)
    Find the book's default font with the italic attribute; if not found, create it.
    io.keikai.model.SFont
    Find the book's default font with the font name; if not found, create it.
    io.keikai.model.SFont
    getOrCreateFontWithStrikeout(boolean Strikeout)
    Find the book's default font with the strikeout attribute; if not found, create it.
    io.keikai.model.SFont
    Find the book's default font with the TypeOffset attribute; if not found, create it.
    io.keikai.model.SFont
    Find the book's default font with the underline attribute; if not found, create it.
    io.keikai.model.SCellStyleBuilder
    Returns a builder of a new Cell style
    io.keikai.model.SCellStyleBuilder
    styleBuilder(io.keikai.model.SCellStyle source)
    Returns a builder of a new Cell style, cloned from source CellStyle
    static String
    toHtmlColor(short paletteIndex)
    Returns the HTML color of an Excel palette index, black if out of the palette.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • StyleFactory

      public StyleFactory(io.keikai.model.SBook book)
  • Method Details

    • getBook

      public io.keikai.model.SBook getBook()
      Returns the book
    • styleBuilder

      public io.keikai.model.SCellStyleBuilder styleBuilder()
      Returns a builder of a new Cell style
    • styleBuilder

      public io.keikai.model.SCellStyleBuilder styleBuilder(io.keikai.model.SCellStyle source)
      Returns a builder of a new Cell style, cloned from source CellStyle
    • createCellStyle

      public io.keikai.model.SCellStyle createCellStyle()
      Create a new Cell style
    • cloneCellStyle

      public io.keikai.model.SCellStyle cloneCellStyle(io.keikai.model.SCellStyle source)
      Create a new Cell style, and clones from source CellStyle
    • createCellStyle

      public io.keikai.model.SCellStyle createCellStyle(String dataFormat)
      Create a new Cell style with data format.
      Parameters:
      dataFormat -
    • createDataFormat

      public String createDataFormat(String format)
      Returns the data format
    • getOrCreateFont

      public io.keikai.model.SFont getOrCreateFont(Map<StyleFactory.FontProperty,Object> properties)
      Finds a font that matches the book's default font with the supplied attributes; properties not in the map keep the default font's values. If no match, create a new Font with the supplied attributes.
      Parameters:
      properties - the attributes to change, or null for the default font
    • getOrCreateFontWithBoldWeight

      public io.keikai.model.SFont getOrCreateFontWithBoldWeight(short fontBoldWeight)
      Find the book's default font with the bold attribute; if not found, create it.
    • getOrCreateFontWithColor

      public io.keikai.model.SFont getOrCreateFontWithColor(short fontColor)
      Find the book's default font with the color attribute; if not found, create it.
      Parameters:
      fontColor - an Excel palette index
    • getOrCreateFontWithColor

      public io.keikai.model.SFont getOrCreateFontWithColor(String htmlColor)
      Find the book's default font with the color attribute; if not found, create it.
      Parameters:
      htmlColor - e.g. #FF0000
    • getOrCreateFontWithHeight

      public io.keikai.model.SFont getOrCreateFontWithHeight(short fontHeightInPoints)
      Find the book's default font with the height attribute (in points); if not found, create it.
    • getOrCreateFontWithName

      public io.keikai.model.SFont getOrCreateFontWithName(String fontName)
      Find the book's default font with the font name; if not found, create it.
    • getOrCreateFontWithItalic

      public io.keikai.model.SFont getOrCreateFontWithItalic(boolean italic)
      Find the book's default font with the italic attribute; if not found, create it.
    • getOrCreateFontWithStrikeout

      public io.keikai.model.SFont getOrCreateFontWithStrikeout(boolean Strikeout)
      Find the book's default font with the strikeout attribute; if not found, create it.
    • getOrCreateFontWithTypeOffset

      public io.keikai.model.SFont getOrCreateFontWithTypeOffset(short typeOffset)
      Find the book's default font with the TypeOffset attribute; if not found, create it.
    • getOrCreateFontWithUnderline

      public io.keikai.model.SFont getOrCreateFontWithUnderline(byte underline)
      Find the book's default font with the underline attribute; if not found, create it.
    • getOrCreateFont

      public io.keikai.model.SFont getOrCreateFont(short boldWeight, short color, short fontHeightInPoints, String name, boolean italic, boolean strikeout, short typeOffset, byte underline)
      Finds a font that matches the one with the supplied attributes. If no match, create a new Font with the supplied attributes.
    • getOrCreateFont

      public io.keikai.model.SFont getOrCreateFont(io.keikai.model.SFont.Boldweight boldWeight, String htmlColor, int fontHeightInPoints, String name, boolean italic, boolean strikeout, io.keikai.model.SFont.TypeOffset typeOffset, io.keikai.model.SFont.Underline underline)
      Finds a font that matches the one with the supplied attributes. If no match, create a new Font with the supplied attributes.
    • fontBuilder

      public io.keikai.model.SFontBuilder fontBuilder()
      Returns a builder of a new Font
    • createFont

      public io.keikai.model.SFont createFont()
      Create a new Font.
    • toHtmlColor

      public static String toHtmlColor(short paletteIndex)
      Returns the HTML color of an Excel palette index, black if out of the palette.