API / geotoolkit / attributes / TextStyle / 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)
↳
TextStyle
Methods
Css Properties
| Name | Type | Description |
|---|---|---|
alignment | AlignmentStyle | Alignment |
autosize | boolean | Auto font size on high definition display |
background | string | Background style |
background | FillStyle | Background style |
background-color | string | Color in CSS form |
background-evenoddmode | boolean | Even-odd fill mode |
background-fillpattern | Pattern | Pattern |
background-fillpattern-containername | string | An 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-patternname | string | Name of this pattern for indexing |
background-fillpattern-scalable | boolean | Flag that sets scalability of the pattern coordinates, or relative to the shape it is filling (It is not supported) |
background-foreground | string | Foreground color |
background-pattern | Pattern | Pattern |
baseline | BaseLineStyle | Base line |
color | string | Color in CSS form |
fill | FillStyle | Text fill style |
font | string | Font see |
fonturl | string | The place from which the font will be loaded, if null - uses system fonts. It can be base64 with url keyword |
lineheight | string | number | Line height |
multiline | boolean | Allow multi-line text |
outline | string | Outline style |
outline | LineStyle | Outline style |
outline-color | string | Color in CSS form |
outline-fill | string | Optional fill style to be used to fill lines generated with this style |
outline-fill | FillStyle | Optional fill style to be used to fill lines generated with this style |
outline-linecap | CapStyle | The line cap style |
outline-linedashoffset | number | Line dash offset of dashed line |
outline-linejoin | JoinStyle | The line join style |
outline-pixelsnapmode | boolean | Pixel Snap Mode, default( |
outline-scalable | boolean | True if width should depend on transformation |
outline-unit | string | Optional unit for the width |
outline-width | number | string | The line thickness |
overflowwrap | OverflowWrapStyle | Overflow wrap |
strikethrough | string | Strikethrough style |
strikethrough | LineStyle | Strikethrough style |
textoverflow | TextOverflowStyle | Text overflow |
underline | string | Underline style |
underline | LineStyle | Underline style |
underlineoffset | string | number | Underline offset distance |
whitespace | WhiteSpaceStyle | White space |
wordbreak | WordBreakStyle | Word break |
Constructors
• new TextStyle(color?, baseLine?, alignment?, font?, autoSize?, multiline?, shadow?)
Create TextStyle
| Name | Type | Description |
|---|---|---|
Optional color | Type | text color or a json object |
Optional baseLine | BaseLineStyle | base line. |
Optional alignment | AlignmentStyle | alignment. |
Optional font | string | font. |
Optional autoSize | boolean | auto font size on high definition display. |
Optional multiline | boolean | allow multi-line text |
Optional shadow | Shadow | JSON for displaying shadow |
ColoredStyle.constructor
Methods
▸ clone(): TextStyle
All inheritors should implement copy constructor or provide custom implementation for this method
this
▸ Protected copyConstructor(src, deepCopy?): TextStyle
copy constructor
| Name | Type | Description |
|---|---|---|
src | TextStyle | Source to copy from |
Optional deepCopy | boolean | deep copy |
this
▸ dispose(): void
Dispose.
void
▸ getAlignment(): AlignmentStyle
Return text alignment
alignment in CSS format
▸ getAutoSize(): boolean
Return text auto size
boolean
▸ getBackground(): FillStyle
Gets background style
background style
▸ getBaseLine(): BaseLineStyle
Return current text baseline
baseline in CSS format
▸ getClassName(): string
string
▸ getColor(): string
Returns color
string
color in CSS form
▸ getFillStyle(): FillStyle
Gets text fill style
text fill style
▸ getFont(): string
Return font
string
font in CSS format
▸ getFontFamily(): string
Return Font family
string
▸ getFontSize(): string
Return Font size
string
▸ getFontStyle(): string
Return Font style
string
▸ getFontWeight(): string
Return Font weight
string
▸ getLineHeight(): string | number
Return line height see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
string | number
lineHeight
▸ getMultiLine(): boolean
true if text is multiline
boolean
multiline
▸ getOutline(): LineStyle
Gets outline style
outline style
▸ getOverflowWrap(): OverflowWrapStyle
Return text overflow-wrap CSS rule
▸ getProcessedFont(): Object
Return an object results of the inline font string.
Object
| Name | Type | Description |
|---|---|---|
fontfamily | string | font family |
fontlineheight | string | line height |
fontsize | string | font size (ex: 12px) |
fontstyle | string | font weight (normal, italic, etc.) |
fontweight | string | font weight (normal, bold, etc.) |
▸ getProperties(context?): OptionsOut
Gets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional context | ISerializationContext | serialization context |
properties
▸ getRgbaColor(): RgbaColor
Return RGBA color
color
▸ getShadow(): Shadow
Gets all properties pertaining to shadow
JSON with offsetX, offsetY, color and blur properties
▸ getStrikethrough(): LineStyle
Gets strikethrough style
strikethrough style
▸ getTextOverflow(): TextOverflowStyle
Return text text-overflow CSS rule
▸ getTimeStamp(): number
Gets time stamp
number
timeStamp
▸ getUnderline(): LineStyle
Gets underline style
underline style
▸ getUnderlineOffset(): string | number
Gets underline offset distance
string | number
underline offset distance
▸ getWhiteSpace(): WhiteSpaceStyle
Return text white-space CSS rule
▸ getWordBreak(): WordBreakStyle
Return text word-break CSS rule
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
▸ invalidate(): TextStyle
notify the node that the style is invalidated
this
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): TextStyle
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | Style | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: TextStyle, args: EventMap[E]) => void | function to be called |
this
▸ 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.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: TextStyle, args: EventMap[E]) => void | to be called |
this
▸ setAlignment(alignment): TextStyle
Sets text alignment
| Name | Type | Description |
|---|---|---|
alignment | AlignmentStyle | in CSS format |
▸ setAutoSize(autoSize): TextStyle
Sets auto size
| Name | Type | Description |
|---|---|---|
autoSize | boolean | autosize enable or not |
▸ setBackground(style): TextStyle
Sets background style
| Name | Type | Description |
|---|---|---|
style | Type | background style |
this
▸ setBaseLine(baseLine): TextStyle
Sets base line, for alignment Text use AnchorType
| Name | Type | Description |
|---|---|---|
baseLine | BaseLineStyle | in CSS format |
▸ setColor(color): TextStyle
Sets color
| Name | Type | Description |
|---|---|---|
color | string | RgbaColor | HsvColor | HlsColor | in CSS string form or RgbaColor object |
this
▸ setFillStyle(fill): TextStyle
Sets text fill style
| Name | Type | Description |
|---|---|---|
fill | Type | text fill style |
this
▸ setFont(font): TextStyle
Sets font
| Name | Type | Description |
|---|---|---|
font | string | Font | font in CSS or JSON format |
▸ setFontFamily(fontFamily): TextStyle
Set Font family
| Name | Type | Description |
|---|---|---|
fontFamily | string | font family |
▸ setFontSize(fontSize): TextStyle
Set Font size
| Name | Type | Description |
|---|---|---|
fontSize | string | font size |
▸ setFontStyle(fontStyle): TextStyle
Set Font style
| Name | Type | Description |
|---|---|---|
fontStyle | string | font style |
▸ setFontWeight(fontWeight): TextStyle
Set Font weight
| Name | Type | Description |
|---|---|---|
fontWeight | string | font weight |
▸ setLineHeight(lineHeight): TextStyle
Sets line height see https://developer.mozilla.org/en-US/docs/Web/CSS/line-height
| Name | Type | Description |
|---|---|---|
lineHeight | string | number | line height |
this
▸ setMultiLine(multiLine): TextStyle
Allows text to be printed along multiple lines.
| Name | Type | Description |
|---|---|---|
multiLine | boolean | allow text to be printed along multiple lines or not |
this
▸ setOutline(style): TextStyle
Sets outline style
| Name | Type | Description |
|---|---|---|
style | Type | outline style |
▸ setOverflowWrap(overflowWrap): TextStyle
Set text overflow-wrap CSS rule
| Name | Type | Description |
|---|---|---|
overflowWrap | OverflowWrapStyle | overflow wrap in CSS format |
▸ setProperties(properties?): TextStyle
Sets all the properties pertaining to this object
| Name | Type | Description |
|---|---|---|
Optional properties | Options | An object containing the properties to set |
this
▸ setShadow(shadow): TextStyle
Sets all properties pertaining to shadow
this
▸ setSilent(bool, force?): TextStyle
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
Optional force | boolean | true if parent should be invalidated immediately |
this
▸ setStrikethrough(style): TextStyle
Sets strikethrough style
| Name | Type | Description |
|---|---|---|
style | Type | strikethrough style use 'inherit' keyword as line style color, in case if color should inherit its value from text style. |
this
▸ setTextOverflow(textOverflow): TextStyle
Set text text-overflow CSS rule
| Name | Type | Description |
|---|---|---|
textOverflow | TextOverflowStyle | text overflow in CSS format |
▸ setUnderline(style): TextStyle
Sets underline style
| Name | Type | Description |
|---|---|---|
style | Type | underline style use 'inherit' keyword as line style color, in case if color should inherit its value from text style. |
this
▸ setUnderlineOffset(offset): TextStyle
Sets underline offset distance, see https://developer.mozilla.org/en-US/docs/Web/CSS/text-underline-offset
| Name | Type | Description |
|---|---|---|
offset | string | number | underline offset distance |
this
▸ setWhiteSpace(whiteSpace): TextStyle
Set text white-space CSS rule
| Name | Type | Description |
|---|---|---|
whiteSpace | WhiteSpaceStyle | white space in CSS format |
▸ setWordBreak(wordBreak): TextStyle
Set text word-break CSS rule
| Name | Type | Description |
|---|---|---|
wordBreak | WordBreakStyle | word break in CSS format |
▸ toGrayScale(clone?): TextStyle
Clone the instance in grayscale style, or convert itself if [clone] is false.
| Name | Type | Description |
|---|---|---|
Optional clone | boolean | clone instance if true, default is true |
▸ toString(): string
string
▸ updateTimeStamp(silent?): TextStyle
Update time stamp to indicate that style has been changed.
| Name | Type | Description |
|---|---|---|
Optional silent | boolean | silent mode. If this parameter equals to true then style doesn't send invalidate event |
this
▸ Static fromObject(object): TextStyle
Create or get text style from object
| Name | Type | Description |
|---|---|---|
object | Type | object can be in format of constructor of TextStyle |
▸ Static getClassName(): string
string
▸ Static isStyleNotificationEnabled(): boolean
Return status of the global notification for all styles.
boolean
ColoredStyle.isStyleNotificationEnabled
▸ 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
});| Name | Type | Description |
|---|---|---|
node | IStyleListener | node |
textStyle | TextStyle | instance of node property |
object | Type | contains text style |
Optional merge | boolean | merge flag |
Optional invalidateMethod | AttributeCallback<EventDispatcher> | optional invalidate method |
textStyle