Package org.zkoss.pivot.util.poi
Class StyleFactory
java.lang.Object
org.zkoss.pivot.util.poi.StyleFactory
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortstatic final shortstatic final shortstatic final shortstatic final Stringstatic final booleanstatic final booleanstatic final shortstatic final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.keikai.model.SCellStylecloneCellStyle(io.keikai.model.SCellStyle source) Create a new Cell style, and clones from source CellStyleio.keikai.model.SCellStyleCreate a new Cell styleio.keikai.model.SCellStylecreateCellStyle(String dataFormat) Create a new Cell style with data format.createDataFormat(String format) Returns the data formatio.keikai.model.SFontCreate a new Font.io.keikai.model.SFontBuilderReturns a builder of a new Fontio.keikai.model.SBookgetBook()Returns the bookio.keikai.model.SFontgetOrCreateFont(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.SFontgetOrCreateFont(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.SFontgetOrCreateFont(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.io.keikai.model.SFontgetOrCreateFontWithBoldWeight(short fontBoldWeight) Find the book's default font with the bold attribute; if not found, create it.io.keikai.model.SFontgetOrCreateFontWithColor(short fontColor) Find the book's default font with the color attribute; if not found, create it.io.keikai.model.SFontgetOrCreateFontWithColor(String htmlColor) Find the book's default font with the color attribute; if not found, create it.io.keikai.model.SFontgetOrCreateFontWithHeight(short fontHeightInPoints) Find the book's default font with the height attribute (in points); if not found, create it.io.keikai.model.SFontgetOrCreateFontWithItalic(boolean italic) Find the book's default font with the italic attribute; if not found, create it.io.keikai.model.SFontgetOrCreateFontWithName(String fontName) Find the book's default font with the font name; if not found, create it.io.keikai.model.SFontgetOrCreateFontWithStrikeout(boolean Strikeout) Find the book's default font with the strikeout attribute; if not found, create it.io.keikai.model.SFontgetOrCreateFontWithTypeOffset(short typeOffset) Find the book's default font with the TypeOffset attribute; if not found, create it.io.keikai.model.SFontgetOrCreateFontWithUnderline(byte underline) Find the book's default font with the underline attribute; if not found, create it.io.keikai.model.SCellStyleBuilderReturns a builder of a new Cell styleio.keikai.model.SCellStyleBuilderstyleBuilder(io.keikai.model.SCellStyle source) Returns a builder of a new Cell style, cloned from source CellStylestatic StringtoHtmlColor(short paletteIndex) Returns the HTML color of an Excel palette index, black if out of the palette.
-
Field Details
-
DEFAULT_BOLD_WEIGHT
public static final short DEFAULT_BOLD_WEIGHT- See Also:
-
BOLD_WEIGHT_BOLD
public static final short BOLD_WEIGHT_BOLD- See Also:
-
DEFAULT_COLOR
public static final short DEFAULT_COLOR- See Also:
-
DEFAULT_FONT_HEIGHT_IN_POINTS
public static final short DEFAULT_FONT_HEIGHT_IN_POINTS- See Also:
-
DEFAULT_FONT_NAME
- See Also:
-
DEFAULT_ITALIC
public static final boolean DEFAULT_ITALIC- See Also:
-
DEFAULT_STRIKEOUT
public static final boolean DEFAULT_STRIKEOUT- See Also:
-
DEFAULT_TYPE_OFFSET
public static final short DEFAULT_TYPE_OFFSET- See Also:
-
DEFAULT_UNDERLINE
public static final byte DEFAULT_UNDERLINE- See Also:
-
-
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
Create a new Cell style with data format.- Parameters:
dataFormat-
-
createDataFormat
Returns the data format -
getOrCreateFont
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
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
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
Returns the HTML color of an Excel palette index, black if out of the palette.
-