boxes/BoxBase. BoxBase

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(parentopt)

BoxBase constructor

Parameters:
NameTypeAttributesDescription
parentmodule:boxes/BoxBase.BoxBase<optional>

Another BoxBase object used to determine the value of properties not
locally set.

Members

alternativeColor :string

The color used to draw text when a cell is in alternative state.

Type:
  • string

backColor :string

The background color

Type:
  • string

bgGradient :module:AWT.Gradient

The background gradient. Default is null.

borderColor :string

The color of the border.

Type:
  • string

borderStroke :module:AWT.Stroke

The stroke used to draw the border.

defaultValues :object

Default values

Type:
  • object

dontFill :boolean

Wheter the cell's background should be painted or not. This property has no effect on
hosted components.

Type:
  • boolean

dynFontSize :number

The current font size of this BoxBase. Can be dynamically adjusted when drawing.

Type:
  • number

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.

inactiveColor :string

The color used to draw text when a cell is in inactive state.

Type:
  • string

markerStroke :module:AWT.Stroke

The stroke used to draw a border around marked cells.

parent :module:boxes/BoxBase.BoxBase

The parent BoxBase object

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.

Type:
  • number

shadow :boolean

Whether the text should have a shadow or not

Type:
  • boolean

shadowColor :string

The color used to draw a shadow below regular text.

Type:
  • string

textColor :string

The color used to write text.

Type:
  • string

textMargin :number

The margin to respect between text elements and the limits of the cell or other elements.

Type:
  • number

transparent :boolean

Whether the cell's background (and its hosted component, if any) should be transparent

Type:
  • boolean

Methods

get(property) → {any}

Gets the value of the specified property, scanning down to parents and prototype if not defined.

Parameters:
NameTypeDescription
propertystring

The property to retrieve

Returns:
  • The object or value associated to this property
Type: 
any

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:
  • The resulting object, with minimal attrributes
Type: 
object

getCSS(cssopt, inactiveopt, inverseopt, alternativeopt) → {object}

Gets the properties defined in this BoxBase as a collection of CSS attributes

Parameters:
NameTypeAttributesDefaultDescription
cssobject<optional>

An optional set of initial CSS properties

inactiveboolean<optional>
false

When true, get CSS attributes for an inactive cell

inverseboolean<optional>
false

When true, get CSS attributes for an inverse cell

alternativeboolean<optional>
false

When true, get CSS attributes for an alternative cell

Returns:
Type: 
object

getOwn(property) → {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:
NameTypeDescription
propertystring

The property to retrieve

Returns:
  • The object or value associated to this property
Type: 
any

prepareText(ctx, text, maxWidth, maxHeight) → {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:
NameTypeDescription
ctxexternal:CanvasRenderingContext2D

The canvas rendering context used to draw the text.

textstring

The text to drawn.

maxWidthnumber

Maximum width

maxHeightnumber

Maximum height

Returns:
  • An array of objects representing lines of text. Each object has a text
    member with the text displayed in the line, and a size member with the line module:AWT.Dimension
Type: 
Array.<object>

set(property, value)

Sets the value of a specific property.

Parameters:
NameTypeDescription
propertystring

The property name.

valueany

Depends on the type of property

setAttributes(data) → {module:boxes/BoxBase.BoxBase}

Reads the properties of this BoxBase from a data object

Parameters:
NameTypeDescription
dataobject

The data object to be parsed

setProperties($xml)

Loads the BoxBase settings from a specific JQuery XML element

Parameters:
NameTypeDescription
$xmlexternal:jQuery

The XML element to parse