BoxBase
Source: BoxBase.js:48
This class contains all the main visual attributes needed to draw AbstractBox objects:
background and foreground colors, gradients, colors for special states (inactive, alternative,
disabled...), margins, fonts, border strokes, etc.
Objects derived from AbstractBox can have inheritance: boxes that act as "containers"
of other boxes (like BoxBag). Most of the attributes of BoxBase can be null,
meaning that the value of the ancestor -or the default value if the box has no ancestors- must
be used.
Constructor
new BoxBase(parent?: module:boxes/BoxBase.BoxBase): BoxBaseBoxBase constructor
Parameters
parent(module:boxes/BoxBase.BoxBase, optional) — Another BoxBase object used to determine the value of properties not
locally set.
Instance Methods
setProperties($xml: external:jQuery)
Loads the BoxBase settings from a specific JQuery XML element
Parameters
$xml(external:jQuery) — The XML element to parse
getAttributes(): object
Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.
Returns
object
setAttributes(data: object): module:boxes/BoxBase.BoxBase
Reads the properties of this BoxBase from a data object
Parameters
data(object) — The data object to be parsed
Returns
get(property: string): any
Gets the value of the specified property, scanning down to parents and prototype if not defined.
Parameters
property(string) — The property to retrieve
Returns
any
set(property: string, value: any)
Sets the value of a specific property.
Parameters
property(string) — The property name.value(any) — Depends on the type of property
getOwn(property: string): any
Gets the value of the specified property, scanning down to parents if not defined, and returning
always an own property (not from prototype)
Parameters
property(string) — The property to retrieve
Returns
any
getCSS(
css?: object,
inactive?: boolean,
inverse?: boolean,
alternative?: boolean,
): object
Gets the properties defined in this BoxBase as a collection of CSS attributes
Parameters
css(object, optional) — An optional set of initial CSS propertiesinactive(boolean, optional, default: false) — Whentrue, get CSS attributes for an inactive cellinverse(boolean, optional, default: false) — Whentrue, get CSS attributes for an inverse cellalternative(boolean, optional, default: false) — Whentrue, get CSS attributes for an alternative cell
Returns
object
prepareText(
ctx: external:CanvasRenderingContext2D,
text: string,
maxWidth: number,
maxHeight: number,
): Array.<object>
This utility method computes the width and height of text lines rendered on an HTML
canvas element, reducing the font size of the BoxBase as needed when they exceed the maximum
width and/or height.
Parameters
ctx(external:CanvasRenderingContext2D) — The canvas rendering context used to draw the text.text(string) — The text to drawn.maxWidth(number) — Maximum widthmaxHeight(number) — Maximum height
Returns
Array.<object>
Instance Fields
parent: module:boxes/BoxBase.BoxBase
The parent BoxBase object
defaultValues: object
Default values
font: module:AWT.Font
Font size can be dynamically reduced to fit the available space if any element using this
BoxBase requests it. When this happen, this field contains the real font currently used
to draw text.
dynFontSize: number
The current font size of this BoxBase. Can be dynamically adjusted when drawing.
resetFontCounter: number
Counts the number of times the dynFontSize has been reset. This is useful to avoid excessive
recursive loops searching the optimal font size.
backColor: string
The background color
bgGradient: module:AWT.Gradient
The background gradient. Default is null.
textColor: string
The color used to write text.
shadowColor: string
The color used to draw a shadow below regular text.
borderColor: string
The color of the border.
inactiveColor: string
The color used to draw text when a cell is in inactive state.
alternativeColor: string
The color used to draw text when a cell is in alternative state.
shadow: boolean
Whether the text should have a shadow or not
transparent: boolean
Whether the cell's background (and its hosted component, if any) should be transparent
dontFill: boolean
Wheter the cell's background should be painted or not. This property has no effect on
hosted components.
textMargin: number
The margin to respect between text elements and the limits of the cell or other elements.
borderStroke: module:AWT.Stroke
The stroke used to draw the border.
markerStroke: module:AWT.Stroke
The stroke used to draw a border around marked cells.