API / geotoolkit / attributes / TextStyle / TextStyle

Class: TextStyle

attributes.TextStyle.TextStyle

Defines a collection of text properties. Constructor can be TextStyle(color,baseLine,alignment,font) or TextStyle(font) or TextStyle(baseLine, alignment)

Hierarchy

Table of contents

Constructors
Methods
Css Properties
Name Type Description
alignmentAlignmentStyleAlignment
autosizebooleanAuto font size on high definition display
backgroundstringBackground style
backgroundFillStyleBackground style
background-colorstringColor in CSS form
background-evenoddmodebooleanEven-odd fill mode
background-fillpatternPatternPattern
background-fillpattern-containernamestringAn optional container name, which creates an image pattern. This parameter is used for serialization if you want to save are reference to pattern instead of the pattern itself
background-fillpattern-patternnamestringName of this pattern for indexing
background-fillpattern-scalablebooleanFlag that sets scalability of the pattern coordinates, or relative to the shape it is filling (It is not supported)
background-foregroundstringForeground color
background-patternPatternPattern
baselineBaseLineStyleBase line
colorstringColor in CSS form
fillFillStyleText fill style
fontstringFont see
fonturlstringThe place from which the font will be loaded, if null - uses system fonts. It can be base64 with url keyword
lineheightstring | numberLine height
multilinebooleanAllow multi-line text
outlinestringOutline style
outlineLineStyleOutline style
outline-colorstringColor in CSS form
outline-fillstringOptional fill style to be used to fill lines generated with this style
outline-fillFillStyleOptional fill style to be used to fill lines generated with this style
outline-linecapCapStyleThe line cap style
outline-linedashoffsetnumberLine dash offset of dashed line
outline-linejoinJoinStyleThe line join style
outline-pixelsnapmodebooleanPixel Snap Mode, default(
outline-scalablebooleanTrue if width should depend on transformation
outline-unitstringOptional unit for the width
outline-widthnumber | stringThe line thickness
overflowwrapOverflowWrapStyleOverflow wrap
strikethroughstringStrikethrough style
strikethroughLineStyleStrikethrough style
textoverflowTextOverflowStyleText overflow
underlinestringUnderline style
underlineLineStyleUnderline style
underlineoffsetstring | numberUnderline offset distance
whitespaceWhiteSpaceStyleWhite space
wordbreakWordBreakStyleWord break

Contents

Constructors

new TextStyle(color, baseLine, alignment, font, autoSize, multiline, shadow)

new TextStyle(color?, baseLine?, alignment?, font?, autoSize?, multiline?, shadow?)

Create TextStyle

Parameters

Name Type Description
Optional colorTypetext color or a json object
Optional baseLineBaseLineStylebase line.
Optional alignmentAlignmentStylealignment.
Optional fontstringfont.
Optional autoSizebooleanauto font size on high definition display.
Optional multilinebooleanallow multi-line text
Optional shadowShadowJSON for displaying shadow

Overrides

ColoredStyle.constructor

Methods

clone

clone(): TextStyle

All inheritors should implement copy constructor or provide custom implementation for this method

Returns

TextStyle

this

Overrides

ColoredStyle.clone


copyConstructor

Protected copyConstructor(src, deepCopy?): TextStyle

copy constructor

Parameters

Name Type Description
srcTextStyleSource to copy from
Optional deepCopybooleandeep copy

Returns

TextStyle

this

Overrides

ColoredStyle.copyConstructor


dispose

dispose(): void

Dispose.

Returns

void

Inherited from

ColoredStyle.dispose


getAlignment

getAlignment(): AlignmentStyle

Return text alignment

Returns

AlignmentStyle

alignment in CSS format


getAutoSize

getAutoSize(): boolean

Return text auto size

Returns

boolean


getBackground

getBackground(): FillStyle

Gets background style

Returns

FillStyle

background style


getBaseLine

getBaseLine(): BaseLineStyle

Return current text baseline

Returns

BaseLineStyle

baseline in CSS format


getClassName

getClassName(): string

Returns

string

Inherited from

ColoredStyle.getClassName


getColor

getColor(): string

Returns color

Returns

string

color in CSS form

Inherited from

ColoredStyle.getColor


getFillStyle

getFillStyle(): FillStyle

Gets text fill style

Returns

FillStyle

text fill style


getFont

getFont(): string

Return font

Returns

string

font in CSS format


getFontFamily

getFontFamily(): string

Return Font family

Returns

string


getFontSize

getFontSize(): string

Return Font size

Returns

string


getFontStyle

getFontStyle(): string

Return Font style

Returns

string


getFontWeight

getFontWeight(): string

Return Font weight

Returns

string


getLineHeight

getLineHeight(): string | number

Return line height see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height

Returns

string | number

lineHeight


getMultiLine

getMultiLine(): boolean

true if text is multiline

Returns

boolean

multiline


getOutline

getOutline(): LineStyle

Gets outline style

Returns

LineStyle

outline style


getOverflowWrap

getOverflowWrap(): OverflowWrapStyle

Return text overflow-wrap CSS rule

Returns

OverflowWrapStyle


getProcessedFont

getProcessedFont(): Object

Return an object results of the inline font string.

Returns

Object

NameTypeDescription
fontfamilystringfont family
fontlineheightstringline height
fontsizestringfont size (ex: 12px)
fontstylestringfont weight (normal, italic, etc.)
fontweightstringfont weight (normal, bold, etc.)

getProperties

getProperties(context?): OptionsOut

Gets all the properties pertaining to this object

Parameters

Name Type Description
Optional contextISerializationContextserialization context

Returns

OptionsOut

properties

Overrides

ColoredStyle.getProperties


getRgbaColor

getRgbaColor(): RgbaColor

Return RGBA color

Returns

RgbaColor

color

Inherited from

ColoredStyle.getRgbaColor


getShadow

getShadow(): Shadow

Gets all properties pertaining to shadow

Returns

Shadow

JSON with offsetX, offsetY, color and blur properties

Inherited from

ColoredStyle.getShadow


getStrikethrough

getStrikethrough(): LineStyle

Gets strikethrough style

Returns

LineStyle

strikethrough style


getTextOverflow

getTextOverflow(): TextOverflowStyle

Return text text-overflow CSS rule

Returns

TextOverflowStyle


getTimeStamp

getTimeStamp(): number

Gets time stamp

Returns

number

timeStamp

Inherited from

ColoredStyle.getTimeStamp


getUnderline

getUnderline(): LineStyle

Gets underline style

Returns

LineStyle

underline style


getUnderlineOffset

getUnderlineOffset(): string | number

Gets underline offset distance

Returns

string | number

underline offset distance


getWhiteSpace

getWhiteSpace(): WhiteSpaceStyle

Return text white-space CSS rule

Returns

WhiteSpaceStyle


getWordBreak

getWordBreak(): WordBreakStyle

Return text word-break CSS rule

Returns

WordBreakStyle


hasEventListener

hasEventListener(type, callback?): boolean

Check if a list of event listeners for this type contains this listener

Parameters

Name Type Description
typestringtype of event or property
Optional callbackFunctionto be called, if null, check if any callback is registered

Returns

boolean

Inherited from

ColoredStyle.hasEventListener


invalidate

invalidate(): TextStyle

notify the node that the style is invalidated

Returns

TextStyle

this

Inherited from

ColoredStyle.invalidate


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

ColoredStyle.isDisposed


isSilent

isSilent(): boolean

Return true if the event dispatcher doesn't notify any events

Returns

boolean

Inherited from

ColoredStyle.isSilent


notify

notify<E>(type, source, args?): TextStyle

Notify listeners

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEevent types
sourceStyleof the event
Optional argsEventMap[E]arguments of the event

Returns

TextStyle

this

Inherited from

ColoredStyle.notify


off

off<E>(type?, callback?): TextStyle

Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
Optional typeEtype of the event
Optional callback(eventType: E, sender: TextStyle, args: EventMap[E]) => voidfunction to be called

Returns

TextStyle

this

Inherited from

ColoredStyle.off


on

on<E>(type, callback): TextStyle

Attach listener on event that will be called whenever the specified event is delivered to the target

If the callback function is already in the list of event listeners for this target, the function is not added a second time.

If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.

Type parameters

NameType
Eextends string

Parameters

Name Type Description
typeEtype of event or property
callback(eventType: E, sender: TextStyle, args: EventMap[E]) => voidto be called

Returns

TextStyle

this

Inherited from

ColoredStyle.on


setAlignment

setAlignment(alignment): TextStyle

Sets text alignment

Parameters

Name Type Description
alignmentAlignmentStylein CSS format

Returns

TextStyle


setAutoSize

setAutoSize(autoSize): TextStyle

Sets auto size

Parameters

Name Type Description
autoSizebooleanautosize enable or not

Returns

TextStyle


setBackground

setBackground(style): TextStyle

Sets background style

Parameters

Name Type Description
styleTypebackground style

Returns

TextStyle

this


setBaseLine

setBaseLine(baseLine): TextStyle

Sets base line, for alignment Text use AnchorType

Parameters

Name Type Description
baseLineBaseLineStylein CSS format

Returns

TextStyle


setColor

setColor(color): TextStyle

Sets color

Parameters

Name Type Description
colorstring | RgbaColor | HsvColor | HlsColorin CSS string form or RgbaColor object

Returns

TextStyle

this

Inherited from

ColoredStyle.setColor


setFillStyle

setFillStyle(fill): TextStyle

Sets text fill style

Parameters

Name Type Description
fillTypetext fill style

Returns

TextStyle

this


setFont

setFont(font): TextStyle

Sets font

Parameters

Name Type Description
fontstring | Fontfont in CSS or JSON format

Returns

TextStyle


setFontFamily

setFontFamily(fontFamily): TextStyle

Set Font family

Parameters

Name Type Description
fontFamilystringfont family

Returns

TextStyle


setFontSize

setFontSize(fontSize): TextStyle

Set Font size

Parameters

Name Type Description
fontSizestringfont size

Returns

TextStyle


setFontStyle

setFontStyle(fontStyle): TextStyle

Set Font style

Parameters

Name Type Description
fontStylestringfont style

Returns

TextStyle


setFontWeight

setFontWeight(fontWeight): TextStyle

Set Font weight

Parameters

Name Type Description
fontWeightstringfont weight

Returns

TextStyle


setLineHeight

setLineHeight(lineHeight): TextStyle

Sets line height see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height

Parameters

Name Type Description
lineHeightstring | numberline height

Returns

TextStyle

this


setMultiLine

setMultiLine(multiLine): TextStyle

Allows text to be printed along multiple lines.

Parameters

Name Type Description
multiLinebooleanallow text to be printed along multiple lines or not

Returns

TextStyle

this


setOutline

setOutline(style): TextStyle

Sets outline style

Parameters

Name Type Description
styleTypeoutline style

Returns

TextStyle


setOverflowWrap

setOverflowWrap(overflowWrap): TextStyle

Set text overflow-wrap CSS rule

Parameters

Name Type Description
overflowWrapOverflowWrapStyleoverflow wrap in CSS format

Returns

TextStyle


setProperties

setProperties(properties?): TextStyle

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptionsAn object containing the properties to set

Returns

TextStyle

this

Overrides

ColoredStyle.setProperties


setShadow

setShadow(shadow): TextStyle

Sets all properties pertaining to shadow

Parameters

Name Type Description
shadowPartial<Merge<Shadow, { color?: string | RgbaColor }>>data

Returns

TextStyle

this

Inherited from

ColoredStyle.setShadow


setSilent

setSilent(bool, force?): TextStyle

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode
Optional forcebooleantrue if parent should be invalidated immediately

Returns

TextStyle

this

Inherited from

ColoredStyle.setSilent


setStrikethrough

setStrikethrough(style): TextStyle

Sets strikethrough style

Parameters

Name Type Description
styleTypestrikethrough style use 'inherit' keyword as line style color, in case if color should inherit its value from text style.

Returns

TextStyle

this


setTextOverflow

setTextOverflow(textOverflow): TextStyle

Set text text-overflow CSS rule

Parameters

Name Type Description
textOverflowTextOverflowStyletext overflow in CSS format

Returns

TextStyle


setUnderline

setUnderline(style): TextStyle

Sets underline style

Parameters

Name Type Description
styleTypeunderline style use 'inherit' keyword as line style color, in case if color should inherit its value from text style.

Returns

TextStyle

this


setUnderlineOffset

setUnderlineOffset(offset): TextStyle

Sets underline offset distance, see https://developer.mozilla.org/en-US/docs/Web/CSS/text-underline-offset

Parameters

Name Type Description
offsetstring | numberunderline offset distance

Returns

TextStyle

this


setWhiteSpace

setWhiteSpace(whiteSpace): TextStyle

Set text white-space CSS rule

Parameters

Name Type Description
whiteSpaceWhiteSpaceStylewhite space in CSS format

Returns

TextStyle


setWordBreak

setWordBreak(wordBreak): TextStyle

Set text word-break CSS rule

Parameters

Name Type Description
wordBreakWordBreakStyleword break in CSS format

Returns

TextStyle


toGrayScale

toGrayScale(clone?): TextStyle

Clone the instance in grayscale style, or convert itself if [clone] is false.

Parameters

Name Type Description
Optional clonebooleanclone instance if true, default is true

Returns

TextStyle

Overrides

ColoredStyle.toGrayScale


toString

toString(): string

Returns

string


updateTimeStamp

updateTimeStamp(silent?): TextStyle

Update time stamp to indicate that style has been changed.

Parameters

Name Type Description
Optional silentbooleansilent mode. If this parameter equals to true then style doesn't send invalidate event

Returns

TextStyle

this

Inherited from

ColoredStyle.updateTimeStamp


fromObject

Static fromObject(object): TextStyle

Create or get text style from object

Parameters

Name Type Description
objectTypeobject can be in format of constructor of TextStyle

Returns

TextStyle


getClassName

Static getClassName(): string

Returns

string

Inherited from

ColoredStyle.getClassName


isStyleNotificationEnabled

Static isStyleNotificationEnabled(): boolean

Return status of the global notification for all styles.

Returns

boolean

Inherited from

ColoredStyle.isStyleNotificationEnabled


mergeFromObject

Static mergeFromObject(node, textStyle, object, merge?, invalidateMethod?): TextStyle

Merge textstyle object with existing instance

Example

// after mergeFromObject() text shape will change only color property
import {Text} from '@int/geotoolkit/scene/shapes/Text';
import {TextStyle} from '@int/geotoolkit/attributes/TextStyle';
const t1 = new TextStyle({
'color': KnownColors.Black,
'alignment': 'center',
'font': '42px Arial'
});
const t2 = {
'color': 'red'
};
const textStyle = TextStyle.mergeFromObject(null, t1, t2, true);
const text = new Text({
'text': 'Alphabetical',
'ax': 185,
'ay': 50,
'textStyle': textStyle,
'alignment': AnchorType.Center
});

Parameters

Name Type Description
nodeIStyleListenernode
textStyleTextStyleinstance of node property
objectTypecontains text style
Optional mergebooleanmerge flag
Optional invalidateMethodAttributeCallback<EventDispatcher>optional invalidate method

Returns

TextStyle

textStyle