<< Click to Display Table of Contents >>

 

 

new sg.symbols.TextSymbol(text, font, color)

 

 

Description

create a new TextSymbol object (with parameters).

 

Position

Symbol.js

 

 

Parameters

 

Parameter

Type

Description

text_or_json

String

text content

font

sg.Font

text font

color

sg.Font

text color

 

 

Constants

 

Constants

Description

ALIGN_END

align to end

ALIGN_MIDDLE

align to middle

ALIGN_START

align to start

DECORATION_LINETHROUGH

linethrough decoration

DECORATION_OVERLINE

overline decoration

DECORATION_UNDERLINE

underline decoration

 

 

Properties

 

Properties

Type

Description

align

String

definition of text alignment.

angle

Number

definition of rotation angle.

decoration

sg.Color

definition of text decoration

font

sg.Font

definition of font

kerning

String

determine whether to adjust the spacing between characters

rotated

Boolean

determine whether every character in the text string is rotated

text

String

definition of text content

type

String

The type of symbol.

xoffset

Number

definition of the x offset.

yoffset

Number

definition of the y offset.

 

 

Methods

 

Methods

Type

Description

setAlign(align)

String

define text alignment. See the Constants table for valid values.

The default value: ALIGN_MIDDLE

Name

Type

Description

align

String

The text alignment.

setAngle(angle)

Number

define rotation angle

Name

Type

Description

angle

Number

Angle value between 0 and 359

setColor(color)

sg.Color

define text color

Name

Type

Description

color

sg.Color

Symbol color

setFont(font)

sg.Font

define text font

Name

Type

Description

font

sg.Font

Text font.

setKerning(kerning)

String

define whether to adjust characters spacing.

Name

Type

Description

kerning

String

Set for kerning.

setOffset(x,y)

Number

define offset in x and y direction

Name

Type

Description

x

Number

X offset value in pixels

y

Number

y offset value in pixels

setRotated(rotated)

Boolean

define whether every character in the text string is rotated

Name

Type

Description

rotated

Boolean

True: Rotate

False: Do not rotate.

setText(text)

String

define text content

Name

Type

Description

text

String

The text string.

 

Example

 

<script type="text/javascript" src="scripts/Symbol.js"></script>

// example 1

var color = new sg.Color(255, 0, 0, 1);

var font =new sg.symbols.Font(24,sg.symbols.Font.STYLE_NORMAL,sg.symbols.Font.VARIANT_NORMAL,sg.symbols.Font.WEIGHT_NORMAL,"arial");

 

var TextSymbol = new sg.symbols.TextSymbol(“abcd”, font, color);

 

// example 2

var color = new sg.Color(255, 0, 0, 1);

var font =new sg.symbols.Font(24,sg.symbols.Font.STYLE_NORMAL,sg.symbols.Font.VARIANT_NORMAL,sg.symbols.Font.WEIGHT_NORMAL,"arial");

 

var TextSymbol = new sg.symbols.TextSymbol();

TextSymbol.setColor(color);

TextSymbol.setFont(font);

TextSymbol.setText(“abcd”);

 

 

See live demo

 


©2015 Supergeo Technologies Inc.