Top Description Inners Fields Constructors Methods
com.openhtmltopdf.css.style

public Class CalculatedStyle

extends Object
Class Inheritance
Known Direct Subclasses
com.openhtmltopdf.css.style.EmptyStyle
Imports
java.awt.Cursor, java.util.ArrayList, .Collections, .List, .Objects, java.util.logging.Level, java.util.stream.Collectors, com.openhtmltopdf.context.StyleReference, com.openhtmltopdf.css.constants.CSSName, .IdentValue, com.openhtmltopdf.css.newmatch.CascadedStyle, com.openhtmltopdf.css.parser.CSSPrimitiveValue, .CounterData, .FSColor, .FSFunction, .FSRGBColor, .PropertyValue, com.openhtmltopdf.css.parser.property.PrimitivePropertyBuilders, com.openhtmltopdf.css.sheet.PropertyDeclaration, com.openhtmltopdf.css.style.derived.BorderPropertySet, .CountersValue, .DerivedValueFactory, .FSLinearGradient, .FunctionValue, .LengthValue, .ListValue, .NumberValue, .RectPropertySet, com.openhtmltopdf.css.value.FontSpecification, com.openhtmltopdf.layout.BoxBuilder, .LayoutContext, .SharedContext, com.openhtmltopdf.layout.counter.RootCounterContext, com.openhtmltopdf.newtable.TableBox, com.openhtmltopdf.render.Box, .FSFont, .FSFontMetrics, .RenderingContext, com.openhtmltopdf.util.LogMessageId, .ThreadCtx, .WebDoc, .WebDocLocations, .XRLog, .XRRuntimeException

A set of properties that apply to a single Element, derived from all matched properties following the rules for CSS cascade, inheritance, importance, specificity and sequence. A property retrieved by name should always have exactly one value in this class (e.g. one-one map). Some methods to retrieve property values from an instance of this class require a valid com.openhtmltopdf.layout.LayoutContext be given to them.

This is the go to class for working with a resolved style. Generally, you can get a instance for a box by calling:
Authors
Torbjoern Gannholm, Patrick Wright

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static enum

Field Summary

Modifier and TypeField and Description
private BorderPropertySet
private boolean
private final Map<String, CalculatedStyle>
_childCache

Cache child styles of this style that have the same cascaded properties

private final FSDerivedValue[]
_derivedValuesById

Our main array of property values defined in this style, keyed by the CSSName assigned ID.

private FontSpecification
_font

The derived Font for this style

private FSFont
private FSFontMetrics
private float
private boolean
private RectPropertySet
private boolean
private RectPropertySet
private boolean
private CalculatedStyle
_parent

The parent-style we inherit from

public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
protected
CalculatedStyle()

Default constructor; as the instance is immutable after use, don't use this for class instantiation externally.

private
CalculatedStyle(CalculatedStyle
PARAM
parent
,
CascadedStyle
PARAM
matched
)

Constructor for the CalculatedStyle object.

Method Summary

Modifier and TypeMethod and Description
public FSColor
asColor(CSSName cssName)

public float
asFloat(CSSName cssName)

public Length
public String
asString(CSSName cssName)

public String[]
private void
private void
private void
public int
public CalculatedStyle
createAnonymousStyle(IdentValue display)

This method derives a style for an anonymous child box with an overriden value for the display property.

private void
derive(CascadedStyle matched)

This method should result in the element for this style having a derived value for all specified (in stylesheets, style attribute, other non CSS attrs, etc) primitive CSS properties.

public CalculatedStyle

Returns:

The derived child style
deriveStyle
(CascadedStyle
the CascadedStyle to apply
matched
)

Derives a child style from this style.

private FSDerivedValue
public boolean
public int
private String
public FSColor

Returns:

The backgroundColor value
getBackgroundColor
()

Convenience property accessor; returns a Color initialized with the background color value; Uses the actual value (computed actual value) for this element.

public List<CalculatedStyle.BackgroundContainer>
getBackgroundImages()

Gets the values of the background properties and combines in a list of BackgroundContainer values.

public IdentValue
public BorderPropertySet
public int
private static BorderPropertySet
public int
public RectPropertySet
public RectPropertySet
public FSColor

Returns:

The color value
getColor
()

Convenience property accessor; returns a Color initialized with the foreground color Uses the actual value (computed actual value) for this element.

public int
public List<CounterData>
public List<CounterData>
public static int
getCSSMaxHeight(CssContext c, Box box)

Aims to get the correct resolved max-height for a box in dots unit.

public static int
getCSSMaxWidth(CssContext c, Box box)

Aims to get the correct resolved max-width for a box in dots unit.

public Cursor
public FSDerivedValue[]
public IdentValue
public float

Returns:

TODO
getFloatPropertyProportionalHeight
(CSSName cssName, float parentHeight, CssContext ctx)

public float
getFloatPropertyProportionalTo(CSSName cssName, float baseValue, CssContext ctx)

public float

Returns:

TODO
getFloatPropertyProportionalWidth
(CSSName cssName, float parentWidth, CssContext ctx)

public FontSpecification
public FontSpecification
public FSFont
getFSFont(CssContext cssContext)

public FSFontMetrics
public float
public IdentValue

Returns:

The ident value
getIdent
(CSSName
PARAM
cssName
)

Gets the ident attribute of the CalculatedStyle object

public FSLinearGradient
getLinearGradient(PropertyValue value, CssContext cssContext, int boxWidth, int boxHeight)

public float
public int
getMarginBorderPadding(CssContext cssCtx, int cbWidth, int which)

private static RectPropertySet
getMarginProperty(CalculatedStyle style, CSSName shorthandProp, CSSName.CSSSideProperties sides, float cbWidth, CssContext ctx, boolean useCache)

public RectPropertySet

Returns:

The marginWidth value
getMarginRect
(float cbWidth, CssContext ctx)

Convenience property accessor; returns a Border initialized with the four-sided margin width.

public RectPropertySet
getMarginRect(float cbWidth, CssContext ctx, boolean useCache)

public int
getMaxHeight(CssContext c, int cbHeight)

public int
getMaxWidth(CssContext c, int cbWidth)

public int
getMinHeight(CssContext c, int cbHeight)

public int
getMinWidth(CssContext c, int cbWidth)

private static RectPropertySet
getPaddingProperty(CalculatedStyle style, CSSName shorthandProp, CSSName.CSSSideProperties sides, float cbWidth, CssContext ctx, boolean useCache)

public RectPropertySet

Returns:

The paddingWidth value
getPaddingRect
(float cbWidth, CssContext ctx, boolean useCache)

Convenience property accessor; returns a Border initialized with the four-sided padding width.

public RectPropertySet
getPaddingRect(float cbWidth, CssContext ctx)

public CalculatedStyle

Returns:

Returns the parent style
getParent
()

Returns the parent style.

public int
public String
public String

Returns:

TODO
getStringProperty
(CSSName cssName)

public List<IdentValue>
public IdentValue
public IdentValue
public boolean
public boolean
public boolean
private void
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean

Returns:

true for border-box, false for content-box.
isBorderBox
()

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean

Returns:

The ident value
isIdent
(CSSName
PARAM
cssName
,
IdentValue
PARAM
val
)

Gets the ident attribute of the CalculatedStyle object

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
isLength(CSSName cssName)

Todo

doc

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public boolean

Returns:

true if the element is visible
isVisible
(RenderingContext
null or the current renderingContext. If null, then the -fs-table-paginate-repeated-visible logic will not work.
renderingContext
,
Box
the element for which the visibility should be determined. Only required if -fs-table-paginate-repeated-visible is specified.
thisElement
)

Determine if the element is visible.

public boolean
public boolean
private static RectPropertySet
newRectInstance(CalculatedStyle style, CSSName shorthand, CSSName.CSSSideProperties sides, float cbWidth, CssContext ctx)

public CalculatedStyle
overrideStyle(CascadedStyle matched)

Override this style with specified styles.

public CalculatedStyle
overrideStyle(IdentValue display)

Override this style with specified styles.

public boolean
private IdentValue
public String

Returns:

The borderWidth value
toString
()

Overrides java.lang.Object.toString.

Converts to a String representation of the object.

public FSDerivedValue
valueByName(CSSName
The CSS property name, e.g. "font-family"
cssName
)

Returns a FSDerivedValue by name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait