Class: Instance

Instance


new Instance(configs)

图中的最小单元

Parameters:
Name Type Description
configs Instance~Configs

最小单元的一些通用属性配置

Extends

  • EventTarget

Members


_isHit :boolean

当前单元碰撞检测状态

Type:
  • boolean

_isMoving :boolean

当前单元移动状态

Type:
  • boolean

_isTargeting :boolean

当前单元选中状态

Type:
  • boolean

_jflow :JFlow

canvas上 jflow 实体

Type:

backgroundColor :string

填充颜色 默认 transparent

Type:
  • string

borderColor :string

边框颜色 默认 transparent

Type:
  • string

borderWidth :number

边的宽度 默认是 0

Type:
  • number

opacity :number

透明度

Type:
  • number

shadowBlur :string

阴影扩散范围 默认 5

Type:
  • string

shadowColor :string

阴影颜色 空就不显示阴影

Type:
  • string

shadowOffsetX :string

阴影偏移 X

Type:
  • string

shadowOffsetY :string

阴影偏移 Y

Type:
  • string

visible :boolean

元素可见 默认 true

Type:
  • boolean

Methods


bubbleEvent(customEvent)

冒泡事件

Parameters:
Name Type Description
customEvent JFlowEvent

自定义事件


calculateToRealWorld(point)

反算回页面的像素坐标

Parameters:
Name Type Description
point Array.<Number>
Returns:

世界坐标

Type
Array.<Number>

getBoundingDimension()

获取宽高

Returns:
  • demension 宽高

    Type
    Object
  • demension.width 宽

    Type
    number
  • demension.height 高

    Type
    number

getBoundingRect()

计算当前的最大外接矩形的

Returns:

[leftx, lefty, rightx, righty]

Type
Array.<number>

getCenter()

获取当前所在层级的坐标

Returns:

坐标

Type
Array.<Number>

getIntersectionsInFourDimension()

计算当前连线接入点的位置

Returns:
  • intersection 交叉点

    Type
    Object
  • intersection[DIRECTION.TOP] 上

    Type
    number
  • intersection[DIRECTION.BOTTOM] 下

    Type
    number
  • intersection[DIRECTION.LEFT] 上

    Type
    number
  • intersection[DIRECTION.RIGHT] 右

    Type
    number

isHit(point)

判断当前单元是否被命中

Parameters:
Name Type Description
point Array.<number>
Returns:
Type
Boolean

onEnterViewbox()

当节点离开可视区域的回调


onLeaveViewbox()

当节点离开可视区域的回调


recalculateUp()

从当前布局中删除虚拟布局节点


render(ctx)

绘制单元

Parameters:
Name Type Description
ctx Context2d

setConfig(configs)

改变当前配置

Parameters:
Name Type Description
configs Configs

The string containing two comma-separated numbers.

Type Definitions


Configs

Type:
  • object
Properties:
Name Type Description
borderWidth number

边的宽度 默认是 2

borderColor string

边框颜色 默认 black

color string

填充颜色 默认 white

shadowColor string

阴影颜色

shadowBlur string

阴影扩散范围

shadowOffsetX string

阴影偏移 X

shadowOffsetX string

阴影偏移 Y

Events


contextclick

点击事件(冒泡)

Type: object
Properties:
Name Type Description
event Event

原始事件

target Instance

右键对象

jflow JFlow

当前JFlow对象

topLayerPoint Array.<number>

jflow坐标系上的位置

bubbles Boolean

冒泡


contextclick

右键事件(冒泡)

Type: object
Properties:
Name Type Description
event Event

原始事件

target Instance

右键对象

jflow JFlow

当前JFlow对象

topLayerPoint Array.<number>

jflow坐标系上的位置

bubbles Boolean

冒泡


dblclick

右键事件

Type: object
Properties:
Name Type Description
event Event

原始事件

target Instance

右键对象

jflow JFlow

当前JFlow对象

topLayerPoint Array.<number>

jflow坐标系上的位置

bubbles Boolean

冒泡


dragenter

dragenter 进入事件

Type: object
Properties:
Name Type Description
event Event

原始事件

instance Object

dragenter的对象

target target

drag 携带的对象(特指从外面拖进canvas的对象)


dragleave

dragleave 退出事件

Type: object
Properties:
Name Type Description
event Event

原始事件

instance Object

dragleave的对象

target target

drag 携带的对象(特指从外面拖进canvas的对象)


dragover

dragover 进入事件

Type: object
Properties:
Name Type Description
event Event

原始事件

instance Object

dragover的对象

target target

drag 携带的对象(特指从外面拖进canvas的对象)


mouseenter

鼠标移入事件

Type: object
Properties:
Name Type Description
instance Instance

移入的对象


mouseleave

鼠标移出事件

Type: object
Properties:
Name Type Description
instance Instance

移入的对象