[API](/solutions/geotoolkit/geotoolkit_js/apis/readme) / [geotoolkit](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit) / [attributes](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.attributes) / [PatternFactory](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.attributes#patternfactory) / PatternFactory

# Class: PatternFactory

[attributes](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.attributes).[PatternFactory](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.attributes#patternfactory).PatternFactory

Service to provide reusable patterns

## Table of contents

Constructors
- [new PatternFactory()](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.attributes.patternfactory.patternfactory.md#new patternfactory())


Methods
| [addAlias](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#addalias) | [addPattern](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#addpattern) | [clear](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#clear) |
|  --- | --- | --- |
| [clearAliases](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#clearaliases) | [createPattern](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#createpattern) | [getCategories](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#getcategories) |
| [getLoadTimeout](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#getloadtimeout) | [getNames](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#getnames) | [getPattern](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#getpattern) |
| [getPatterns](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#getpatterns) | [removeAlias](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#removealias) | [removeCategory](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#removecategory) |
| [removePattern](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#removepattern) | [setLoadTimeout](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#setloadtimeout) | [getDefaultContainerName](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#getdefaultcontainername) |
| [getInstance](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#getinstance) | [setDefaultContainerName](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory#setdefaultcontainername) |


## Contents

Constructors
#### new PatternFactory()

• **new PatternFactory**()

Methods
#### addAlias

▸ **addAlias**(`base`, `alias`, `category?`): `void`

Adds pattern alias to a specific or default category

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `base` | `string` | original pattern name |
| `alias` | `string` | `string`[] | name(s) of the original name |
| `Optional` `category` | `string` | category name |


#### Returns

`void`

#### addPattern

▸ **addPattern**(`src`, `options`): [`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern)

Adds a new pattern with the specified options and registers it on factory. Requires pattern name
note: if the pattern already exist it will override it.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `src` | `string` | `HTMLImageElement` | [`Group`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.group.group)<[`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node)&gt; | image src |
| `options` | `string` | [`AddPatternOptions`](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.attributes#patternfactory#addpatternoptions) | pattern options or pattern name. |


#### Returns

[`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern)

#### clear

▸ **clear**(): `void`

Remove all patterns and categories

#### Returns

`void`

#### clearAliases

▸ **clearAliases**(`category?`): `void`

Removes all or specified category aliases

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `Optional` `category` | `string` | category name |


#### Returns

`void`

#### createPattern

▸ **createPattern**(`src`, `options?`): [`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern)

Simply creates pattern by source without registering at factory

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `src` | `string` | `HTMLImageElement` | [`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern) | [`Group`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.group.group)<[`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node)&gt; | image src |
| `Optional` `options` | [`CreatePatternOptions`](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.attributes#patternfactory#createpatternoptions) | pattern object, image url, image from DOM element or the image patterns options |


#### Returns

[`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern)

#### getCategories

▸ **getCategories**(): `string`[]

return an array with all the categories

#### Returns

`string`[]

#### getLoadTimeout

▸ **getLoadTimeout**(): `number`

Gets pattern load timeout

#### Returns

`number`

number

#### getNames

▸ **getNames**(`category?`): `string`[]

Return the list of pattern names contained in all or specific category

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `Optional` `category` | `string` | category name |


#### Returns

`string`[]

pattern names

#### getPattern

▸ **getPattern**(`name`, `category?`): [`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern)

Returns the pattern of specific category and name. Creates a new one if it doesn't exist

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `name` | `string` | pattern name |
| `Optional` `category` | `string` | category name |


#### Returns

[`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern)

#### getPatterns

▸ **getPatterns**(`category?`): [`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern)[]

Returns all image patterns contained in all or specific category

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `Optional` `category` | `string` | category name |


#### Returns

[`Pattern`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.pattern.pattern)[]

The patterns

#### removeAlias

▸ **removeAlias**(`alias`, `category?`): `void`

Removes a pattern alias from specific or default category

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `alias` | `string` | name |
| `Optional` `category` | `string` | category name |


#### Returns

`void`

#### removeCategory

▸ **removeCategory**(`name`): `void`

Removes a category

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `name` | `string` | name of the Pattern |


#### Returns

`void`

#### removePattern

▸ **removePattern**(`name`, `category?`): `void`

Removes a pattern from this service

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `name` | `string` | pattern name |
| `Optional` `category` | `string` | category name |


#### Returns

`void`

#### setLoadTimeout

▸ **setLoadTimeout**(`timeout`): [`PatternFactory`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory)

Sets pattern load timeout

#### Parameters

| Name  | Type  |
|  --- | --- |
| `timeout` | `number` |


#### Returns

[`PatternFactory`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory)

this

#### getDefaultContainerName

▸ `Static` **getDefaultContainerName**(): `string`

Returns default container name

#### Returns

`string`

default container name

#### getInstance

▸ `Static` **getInstance**(): [`PatternFactory`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory)

Returns instance of the registry

#### Returns

[`PatternFactory`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory)

pattern factory

#### setDefaultContainerName

▸ `Static` **setDefaultContainerName**(`name`): [`PatternFactory`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory)

Set Default container name

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `name` | `string` | default container name |


#### Returns

[`PatternFactory`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.attributes.patternfactory.patternfactory)