Appearance
@jtopo/core / RegSystem
Class: RegSystem
用于注册自定义的类、图形、函数
自定义的类需要序列化时,需要先注册
Table of contents
Constructors
Methods
- getClass
- getEmptyInstance
- getFunction
- getObjectClassName
- getShape
- getShapes
- hasShapeInstance
- newInstance
- regClass
- regFunction
- regShape
Constructors
constructor
new RegSystem()
Methods
getClass
Static
getClass(name
): (...args
: any
[]) => any
获取自定义的类
Parameters
Name | Type | Description |
---|---|---|
name | string | 类名 |
Returns
fn
类
new getClass(...args
)
Parameters
Name | Type |
---|---|
...args | any [] |
getEmptyInstance
Static
getEmptyInstance(className
): Object
获取空实例
Parameters
Name | Type |
---|---|
className | string |
Returns
Object
getFunction
Static
getFunction(name
): Function
获取自定义的函数
Parameters
Name | Type | Description |
---|---|---|
name | string | 函数名 |
Returns
Function
函数
getObjectClassName
Static
getObjectClassName(instance
): string
获取实例的类名
Parameters
Name | Type | Description |
---|---|---|
instance | Object | 实例 |
Returns
string
类名
getShape
Static
getShape(name
): Shape
获取自定义图形(实例)
Parameters
Name | Type | Description |
---|---|---|
name | string | 图形名 例: com.myapp.MyShape |
Returns
图形
getShapes
Static
getShapes(packageName
): any
[]
获取某个包中的所有图形(实例)
Parameters
Name | Type | Description |
---|---|---|
packageName | string | 包名 |
Returns
any
[]
hasShapeInstance
Static
hasShapeInstance(name
): boolean
Parameters
Name | Type |
---|---|
name | string |
Returns
boolean
newInstance
Static
newInstance(fullClassName
): any
Parameters
Name | Type |
---|---|
fullClassName | string |
Returns
any
regClass
Static
regClass(packageName
, name
, clazz
): void
注册自定义的类 (类必须提供默认不带参数的构造函数)
Parameters
Name | Type | Description |
---|---|---|
packageName | string | 包名 |
name | string | 类名 |
clazz | (...args : any []) => any | 类 |
Returns
void
regFunction
Static
regFunction(packageName
, name
, fn
): void
注册自定义的函数
Parameters
Name | Type | Description |
---|---|---|
packageName | string | 包名 |
name | string | 函数名 |
fn | Function | 函数 |
Returns
void
regShape
Static
regShape(packageName
, name
, shape
): void
注册自定义的图形(实例)
例: regShape('com.myapp', 'MyShape', MyShape);
Parameters
Name | Type | Description |
---|---|---|
packageName | string | 包名 |
name | string | 图形名 |
shape | Shape | 图形 |
Returns
void