Last updated

API / geotoolkit / axis / TickGenerator / TickGenerator

Class: TickGenerator

axis.TickGenerator.TickGenerator

Define a base class for tick generators. Toolkit provides several tick generators to help generate numeric labels.
It generates ticks and labels based on the tick info and tickgrades. Axis uses the TickGenerator while creating the axis. Please refer to Axes and Grids Tutorial in CarnacJS for examples of the different tick generators supported.
A tick generator mainly provides the positions of sequential ticks as well as the informational data associated with tick positions.

Hierarchy

Implements

Table of contents

Constructors
Methods
Css Properties
Name Type Description
labelstylesTextStyleAn object containing label style for specified grades
labelstyles-alignmentAlignmentStyleAlignment
labelstyles-autosizebooleanAuto font size on high definition display
labelstyles-backgroundstringBackground style
labelstyles-backgroundFillStyleBackground style
labelstyles-background-colorstringColor in CSS form
labelstyles-background-evenoddmodebooleanEven-odd fill mode
labelstyles-background-fillpatternPatternPattern
labelstyles-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
labelstyles-background-fillpattern-patternnamestringName of this pattern for indexing
labelstyles-background-fillpattern-scalablebooleanFlag that sets scalability of the pattern coordinates, or relative to the shape it is filling (It is not supported)
labelstyles-background-foregroundstringForeground color
labelstyles-background-patternPatternPattern
labelstyles-baselineBaseLineStyleBase line
labelstyles-colorstringColor in CSS form
labelstyles-fillFillStyleText fill style
labelstyles-fontstringFont see
labelstyles-fonturlstringThe place from which the font will be loaded, if null - uses system fonts. It can be base64 with url keyword
labelstyles-lineheightstring | numberLine height
labelstyles-multilinebooleanAllow multi-line text
labelstyles-outlinestringOutline style
labelstyles-outlineLineStyleOutline style
labelstyles-outline-colorstringColor in CSS form
labelstyles-outline-fillstringOptional fill style to be used to fill lines generated with this style
labelstyles-outline-fillFillStyleOptional fill style to be used to fill lines generated with this style
labelstyles-outline-linecapCapStyleThe line cap style
labelstyles-outline-linedashoffsetnumberLine dash offset of dashed line
labelstyles-outline-linejoinJoinStyleThe line join style
labelstyles-outline-pixelsnapmodebooleanPixel Snap Mode, default(
labelstyles-outline-scalablebooleanTrue if width should depend on transformation
labelstyles-outline-unitstringOptional unit for the width
labelstyles-outline-widthnumber | stringThe line thickness
labelstyles-overflowwrapOverflowWrapStyleOverflow wrap
labelstyles-strikethroughstringStrikethrough style
labelstyles-strikethroughLineStyleStrikethrough style
labelstyles-textoverflowTextOverflowStyleText overflow
labelstyles-underlinestringUnderline style
labelstyles-underlineLineStyleUnderline style
labelstyles-underlineoffsetstring | numberUnderline offset distance
labelstyles-whitespaceWhiteSpaceStyleWhite space
labelstyles-wordbreakWordBreakStyleWord break
taganyTag user can specify info associated with current object
tickstylesLineStyleAn object containing tick styles for specified grades

Contents

Constructors

new TickGenerator(options)

new TickGenerator(options?)

Parameters

Name Type
Optional optionsOptions

Overrides

EventDispatcher.constructor

Methods

clone

clone(): TickGenerator

All subclasses should override copyConstructor or provide custom implementation for this method

Returns

TickGenerator

clone


connectStyle

connectStyle(style, type, callback): TickGenerator

Connects style.

This convenience method subscribes a listener to given style for the specified type.
And automatically un-subscribes listener if node is disposed to prevent memory leaks

Parameters

Name Type Description
styleEventDispatcherconnect style
typestringtype of event or property
callbackAttributeCallback<EventDispatcher>function to be called

Returns

TickGenerator

Implementation of

IStyleListener.connectStyle


copyConstructor

Protected copyConstructor(src, deepCopy?): TickGenerator

Copy constructor

Parameters

Name Type Description
srcTickGeneratorSource to copy from
Optional deepCopybooleandeep copy

Returns

TickGenerator

this


disconnectStyle

disconnectStyle(style, type, callback): TickGenerator

Disconnect style

This convenience method un-subscribes a listener to given style for the specified type.

Parameters

Name Type Description
styleEventDispatcherconnect style
typestringtype of event or property
callbackAttributeCallback<EventDispatcher>function to be called

Returns

TickGenerator

Implementation of

IStyleListener.disconnectStyle


dispose

dispose(): void

Disposes this node, once disposes a node should not be used anymore.
Clear all listeners, and disconnect styles to avoid memory leaks.
Also aggressively 'cleanup' this node by setting some of its members to null.

Returns

void

Overrides

EventDispatcher.dispose


execute

execute(delegate): TickGenerator

Executes delegate and returns the result

Parameters

Name Type Description
delegate(this: TickGenerator) => voidexecute delegate and return the result

Returns

TickGenerator

execute<T>(delegate): T

Type parameters

Name
T

Parameters

Name Type
delegate(this: TickGenerator) => T

Returns

T


formatLabel

formatLabel(parent, orient, tickInfo, tickIndex, modelValue): string

Formats label text. This method must be overridden in the base classes and the the base class method must be called first.

Parameters

Name Type Description
parentIModelparent axis or grid
orientOrientationorientation
tickInfoTickInfoan info about tick
tickIndexnumbertickIndex tick index from 0 to count-1, which resetLabels returns
modelValuenumbermodel value

Returns

string

formatted label text


getAdjustLabelAnchor

getAdjustLabelAnchor(grade): boolean

Gets adjust label anchor flag for specified label grade

Parameters

Name Type Description
gradestringlabel grade

Returns

boolean

label anchor flag ("true" by default for any grade)


getBoundingBox

getBoundingBox(tickInfo, orient, labelPos, labelText?): Rect

Returns bounding box of label

Parameters

Name Type Description
tickInfoTickInfoinfo about the tick
orientOrientationorientation
labelPosnumberlabel position along index direction
Optional labelTextstringlabel text. If not defined labelPos.toString() is used.

Returns

Rect

bbox bounding box


getClassName

getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName


getFormatLabelHandler

getFormatLabelHandler(): LabelFormatHandler

Returns label format handler

Returns

LabelFormatHandler


getGrades

getGrades(): string[]

Returns valid Tick string : "edge", "major", "intermediate", "minor"

Returns

string[]

array of known Tick string


getInvalidateMethod

Protected getInvalidateMethod(): AttributeCallback<EventDispatcher>

invalidate Method

Returns

AttributeCallback<EventDispatcher>

method to invalidate this object


getLabelAnchorType

getLabelAnchorType(grade, transformation?): AnchorType

Gets label anchor type

Parameters

Name Type Description
gradestringtick grade
Optional transformationTransformationoptional transformation from model to device. It is used only for custom label anchor handler

Returns

AnchorType


getLabelRotationAngle

getLabelRotationAngle(tickGrade): number

Returns label rotation angle

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types

Returns

number

label rotation angle


getLabelStyle

getLabelStyle(tickGrade): TextStyle

Returns label style

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types

Returns

TextStyle

label style


getLabelValueTransformer

getLabelValueTransformer(): ValueTransformer | (modelValue: number) => number

Gets label value transformer (by default: 'undefined' - no transformation is applied to a value)

Returns

ValueTransformer | (modelValue: number) => number

transformer label value transformer


getMaxLabelMetrics

getMaxLabelMetrics(parent, orientation, tickInfo, fromValue, toValue): Dimension

Returns maximum label metrics. For internal use only

Parameters

Name Type Description
parentIModelparent axis or grid
orientationOrientationorientation
tickInfoTickInfoinfo about tick position
fromValuenumbergenerate labels from
toValuenumbergenerate labels to

Returns

Dimension


getMaxLabels

Protected getMaxLabels(tickInfo, orient, fromValue, toValue): { type: string ; value: string | number }[]

Returns max labels for each type of grades

Parameters

Name Type Description
tickInfoTickInfoinfo about the tick
orientOrientationorientation
fromValuenumbergenerate labels from
toValuenumbergenerate labels to

Returns

{ type: string ; value: string | number }[]


getNeatLimits

getNeatLimits(min, max, options): Limits

Return nice limits, default implementation is for linear model space

Parameters

Name Type
minnumber
maxnumber
optionsObject
Optional options.preciseboolean
options.sizenumber
options.spannumber

Returns

Limits

Implementation of

INeatLimitsProvider.getNeatLimits


getProperties

getProperties(): OptionsOut

Gets all the properties pertaining to this object

Returns

OptionsOut

properties


getTag

getTag(): any

Returns tag

Returns

any

the tag


getTickSize

getTickSize(grade): number

Returns the size of specified tick

Parameters

Name Type Description
gradestringGrade of the tick to get the size see TickGenerator.getGrades for valid Tick types

Returns

number


getTickStyle

getTickStyle(tickGrade): LineStyle

Returns tick style

Parameters

Name Type Description
tickGradestringTick Grade see TickGenerator.getGrades for valid Tick types

Returns

LineStyle

line style


getVisibleLabelGrades

getVisibleLabelGrades(supported): string[]

Return an array of the visible label grades

Parameters

Name Type Description
supportedstring[]supported grades see TickGenerator.getGrades for valid Tick types

Returns

string[]

the visible grades


getVisibleTickGrades

getVisibleTickGrades(supported): string[]

Returns an array of the visible tick grades

Parameters

Name Type Description
supportedstring[]supported grades see TickGenerator.getGrades for valid Tick types

Returns

string[]

the visible grades


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

EventDispatcher.hasEventListener


isDisposed

isDisposed(): boolean

Returns whether this object has been disposed

Returns

boolean

Inherited from

EventDispatcher.isDisposed


isSilent

isSilent(): boolean

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

Returns

boolean

Inherited from

EventDispatcher.isSilent


isValid

isValid(parent, orient, tickInfo): boolean

Verify tick generator parameters to have better label distribution

Parameters

Name Type Description
parentIModelparent axis or grid
orientOrientationorientation
tickInfoTickInfotick info

Returns

boolean

true if no label intersection


isVisibleLabelGrade

isVisibleLabelGrade(tickGrade): boolean

Returns visibility of label for a specific tick grade

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types

Returns

boolean

true if label is visible


isVisibleTickGrade

isVisibleTickGrade(tickGrade): boolean

Returns visibility of tick for a specific tick grade

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types

Returns

boolean

true if the tick is visible


nextLabel

nextLabel(parent, orient, tickInfo, tickIndex): number

Generates information about next label

Parameters

Name Type Description
parentIModelparent axis or grid
orientOrientationorientation
tickInfoTickInfoinfo about tick
tickIndexnumbertickIndex tick index from 0 to count-1, which resetLabels returns

Returns

number

the model position of the label


nextTick

nextTick(parent, orient, tickInfo, tickIndex): number

Generates information about next tick

Parameters

Name Type Description
parentIModelparent axis or grid
orientOrientationorientation
tickInfoTickInfoinfo about tick
tickIndexnumbertick index from 0 to count-1, which resetTicks returns

Returns

number

the model position of the tick


notify

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

Notify listeners

Type parameters

NameType
Eextends string

Parameters

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

Returns

TickGenerator

this

Overrides

EventDispatcher.notify


off

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

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: TickGenerator, args: EventMap[E]) => voidfunction to be called

Returns

TickGenerator

this

Overrides

EventDispatcher.off


on

on<E>(type, callback): TickGenerator

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: TickGenerator, args: EventMap[E]) => voidto be called

Returns

TickGenerator

this

Overrides

EventDispatcher.on


reset

reset(parent, orient, tickInfo): string[]

Resets tick generator

Parameters

Name Type Description
parentIModelparent axis or grid
orientOrientationorientation
tickInfoTickInfotick info

Returns

string[]

a supported tick grade list


resetAsync

resetAsync(parent, orient, tickInfo, callback): void

Resets tick generator asynchronously

Parameters

Name Type Description
parentIModelparent axis or grid
orientOrientationorientation
tickInfoTickInfotick info
callback(x: string[]) => voidcalls when asynchronous reset is done

Returns

void


resetLabels

resetLabels(parent, orient, tickInfo): number

Reset labels. This method is called to start iteration by labels. The implementation also sets appropriate TextStyle on labels.

Parameters

Name Type Description
parentIModelparent axis or grid
orientOrientationorientation
tickInfoTickInfoan info about labels. This information is used to pass and receive information about the current tick or label

Returns

number

labels count for the current tick type


resetMaxLabels

resetMaxLabels(): TickGenerator

Reset max label info

Returns

TickGenerator

this


resetTicks

resetTicks(parent, orient, tickInfo): number

Resets ticks. This method is called to start iteration by ticks. The implementation also sets appropriate LineStyle on the ticks as well as their tick size.

Parameters

Name Type Description
parentIModelparent axis or grid
orientOrientationorientation
tickInfoTickInfoan info about labels. This information is used to pass and receive information about the current tick or label

Returns

number

ticks count for the current tick type. The implementation returns 0 if the ticks can not be drawn; a positive number otherwise.


setAdjustLabelAnchor

setAdjustLabelAnchor(grade, flag): TickGenerator

Sets adjust label anchor flag for specified label grade

Parameters

Name Type Description
gradestringlabel grade
flagbooleanadjust label anchor flag

Returns

TickGenerator

this


setFormatLabelHandler

setFormatLabelHandler(handler): TickGenerator

Sets label format handler

Parameters

Name Type Description
handlerLabelFormatHandlerhandler

Returns

TickGenerator

this


setLabelAnchorType

setLabelAnchorType(grade, anchorType): TickGenerator

Sets label anchor type

Parameters

Name Type Description
gradestringtick grade
anchorTypeAnchorType | AnchorStyleHandleranchorType

Returns

TickGenerator

this


setLabelRotationAngle

setLabelRotationAngle(tickGrade, angle): TickGenerator

Sets label rotation angle

Example

// user can customize the label rotation angle based on tick grade.
tickGenerator.setLabelRotationAngle('major', -Math.PI / 2);

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types
anglenumberlabel rotation angle, in radians

Returns

TickGenerator

this


setLabelStyle

setLabelStyle(tickGrade, labelStyle?, merge?): TickGenerator

Sets label style

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types
Optional labelStyleTypetick text style
Optional mergebooleantrue if you want to merge labelStyle with existing attribute, false by default

Returns

TickGenerator

this


setLabelValueTransformer

setLabelValueTransformer(transformer): TickGenerator

Sets label value transformer (optional)

Parameters

Name Type Description
transformerValueTransformer | (modelValue: number) => numberlabel value transformer

Returns

TickGenerator

this


setProperties

setProperties(properties?): TickGenerator

Sets all the properties pertaining to this object

Parameters

Name Type Description
Optional propertiesOptionsAn object containing the properties to set

Returns

TickGenerator

this


setSilent

setSilent(bool): TickGenerator

Set silent mode

Parameters

Name Type Description
boolbooleanflag to enable silent mode

Returns

TickGenerator

this

Inherited from

EventDispatcher.setSilent


setTag

setTag(tag): TickGenerator

Sets tag

Parameters

Name Type Description
taganyuser can specify info associated with current object

Returns

TickGenerator

this


setTickOptions

setTickOptions(properties?, tickGrade?): TickGenerator

Sets all the properties pertaining to this tick

Parameters

Name Type Description
Optional propertiesRecord<string, TickOptions>An object containing the properties to set
Optional tickGradestringTick grade

Returns

TickGenerator

this


setTickSize

setTickSize(grade, size): TickGenerator

Changes the size of specified ticks

Parameters

Name Type Description
gradestringGrade of the tick to set the size see TickGenerator.getGrades for valid Tick types
sizenumberNew size

Returns

TickGenerator

this


setTickStyle

setTickStyle(tickGrade, lineStyle?, merge?): TickGenerator

Sets tick style

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types
Optional lineStyleTypeline style for the tick
Optional mergebooleantrue if you want to merge lineStyle with existing attribute, false by default

Returns

TickGenerator

this


setVisibleLabelGrade

setVisibleLabelGrade(tickGrade, visible): TickGenerator

Sets visibility of label for a specific tick grade Implementation of the reset should check visibility of the labels.

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types
visiblebooleantick label visibility flag

Returns

TickGenerator

this


setVisibleTickGrade

setVisibleTickGrade(tickGrade, visible): TickGenerator

Sets visibility of tick for a specific tick grade Implementation of the reset should check visibility of the ticks

Parameters

Name Type Description
tickGradestringTick grade see TickGenerator.getGrades for valid Tick types
visiblebooleantick grade visibility flag

Returns

TickGenerator

this


getClassName

Static getClassName(): string

Returns

string

Inherited from

EventDispatcher.getClassName