twaver.network
Class LinkUI

java.lang.Object
  extended by twaver.core.network.BaseUI<T>
      extended by twaver.network.ElementUI<Link>
          extended by twaver.network.LinkUI
All Implemented Interfaces:
twaver.core.network.IUI<Link,Canvas,Paint>, Identifiable, IPathUI

public class LinkUI
extends ElementUI<Link>
implements IPathUI

连线UI元素,用于绘制连线,主体使用图形元素(ShapeUI)

See Also:
Link

Field Summary
protected  ShapeUI body
          连线主体元素
protected  LabelUI linkBundleLabel
          连线绑定时,显示文本标签
 
Fields inherited from class twaver.network.ElementUI
alarm, isLayouting, label, network
 
Fields inherited from class twaver.core.network.BaseUI
anchorPoint, bodyOffsetX, bodyOffsetY, bounds, data, invalidateAnchorPointFlag, invalidateLocationFlag, invalidateRenderFlag, invalidateSizeFlag, location, stateOutline, stateOutlineColor, visible
 
Constructor Summary
LinkUI(Link link, Network network)
          连线UI元素,用于绘制连线,主体使用图形元素(ShapeUI)
 
Method Summary
protected  void calculatePath(java.util.List<PathSegment> pathSegments)
          生成线段图形数据,该函数会计算连线的路径,包括节点边缘对齐,连线展开分布,自环等多种样式,具体的计算操作交由#drawLink(Rect, Rect, List)和#drawLoopedLink(Rect, List)处理 生成的结果将存放在传入的pathSegments参数中
 void checkPoints()
          检查连线,是否需要重新生成路径和图形
protected  void createChildren()
          创建孩子元素,比如文本标签,告警标签等等
protected  boolean doValidate()
          执行生效动作,比如孩子元素的位置布局,范围大小的确定等等
protected  void drawLink(Rect fromBounds, Rect toBounds, java.util.List<PathSegment> pathSegments)
          绘制连线,仅用于非自环的情况,计算连线的路径,存放在pathSegments参数中
protected  void drawLoopedLink(Rect agentBounds, java.util.List<PathSegment> pathSegments)
          计算自环时连线的走向,结果存放在参数pathSegments中
 float getLength()
          路径长度
 float getLineWidth()
          路径线条宽度
 Point getLinkBundleOffset()
          获取连线绑定偏移量 如果该连线不参与捆绑,或者连线没有展开,则返回null
 java.util.List<PathSegment> getPathSegments()
          获取路径
 void invalidateLinkBundle()
          无效连线绑定状态
 void invalidatePoints()
          无效连线路径,调用此方法后,连线会在需要的时候重新生成路径和图形
 boolean isDrawBackground()
           
 boolean isDrawOutline()
           
 boolean isInvalidatePoints()
          连线是否无效
 boolean isLayoutByAnchorPoint()
           
 boolean isLayoutByPath()
          是否沿线布局
 boolean isRelativeLocation()
           
protected  boolean onElementPropertyChange(java.lang.String propertyName, PropertyChangeEvent evt)
          网元属性变化时,调用此函数
protected  boolean onLinkPropertyChange(java.lang.String propertyName, PropertyChangeEvent evt)
          连线属性变化处理函数
protected  void resetShape()
           
protected  void resetStyles()
          重新加载网元UI的所有样式
protected  void validateLinkBundle()
          生效连线绑定
protected  void validatePoints()
          生成连线图形数据,生成Path图形
 
Methods inherited from class twaver.network.ElementUI
addChild, checkAttachments, createAttachmentUI, drawChildren, drawSendToBottomChildren, drawShowOnTop, getBody, getBodyBounds, getBooleanStyle, getChildren, getColorStyle, getFloatStyle, getId, getInsetsStyle, getIntStyle, getNetwork, getShaderStyle, getStringStyle, getStyle, getUIBounds, hasChildOnTop, hitTest, initialize, intersect, invalidateStyle, invalidateStyles, invalidateUI, isInitialized, isVisible, layout, measure, onBodyChange, onDraw, onDrawBody, onElementPropertyChange, removeChild, setBody, setChildIndex, setLayoutByAnchorPoint, setRenderColor, setSelected, setSelectionBorder, setSelectionBorderColor, validate
 
Methods inherited from class twaver.core.network.BaseUI
checkBackground, checkOutline, draw, drawBackgroundAndBorder, drawBody, drawStateOutline, drawStateOutline, getAnchorPoint, getAnchorPosition, getAngle, getBackgroundColor, getBounds, getCornerRadius, getData, getLocation, getMeasuredHeight, getMeasuredWidth, getOffset, getOutlineColor, getOutlineWidth, getRenderColor, getSelectionBorder, getSelectionBorderColor, getStateOutline, getStateOutlineColor, intersect, intersectPointer, invalidateAnchorPoint, invalidateLocation, invalidatePointer, invalidateRender, invalidateSize, isDrawStateOutline, isInvalidate, isInvalidateAnchorPoint, isInvalidateLocation, isInvalidateSize, isRotatable, isSelected, isShowOnTop, measureAnchorPosition, onDrawBackgroundAndBorder, perLocation, resetPaint, setAnchorPosition, setBackgroundColor, setBackgroundShader, setBounds, setBounds, setCornerRadius, setData, setLocation, setLocation, setMeasuredSize, setOffset, setOutline, setOutlineColor, setPadding, setPointerVisible, setPointerWidth, setRotatable, setShowOnTop, setStateOutline, setStateOutlineColor, setVisible, styleSelectionPaint, toAbsoluteRect, toLocalPoint, toLocalRect, validateLocation, validatePointer, validateRender
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

body

protected ShapeUI body
连线主体元素


linkBundleLabel

protected LabelUI linkBundleLabel
连线绑定时,显示文本标签

Constructor Detail

LinkUI

public LinkUI(Link link,
              Network network)
连线UI元素,用于绘制连线,主体使用图形元素(ShapeUI)

Parameters:
link - 连线元素
network - 拓扑图
Method Detail

invalidateLinkBundle

public void invalidateLinkBundle()
无效连线绑定状态

See Also:
validateLinkBundle()

validateLinkBundle

protected void validateLinkBundle()
生效连线绑定

See Also:
invalidateLinkBundle()

resetStyles

protected void resetStyles()
Description copied from class: ElementUI
重新加载网元UI的所有样式

Overrides:
resetStyles in class ElementUI<Link>

isDrawBackground

public boolean isDrawBackground()
Overrides:
isDrawBackground in class twaver.core.network.BaseUI<Link>

isDrawOutline

public boolean isDrawOutline()
Overrides:
isDrawOutline in class twaver.core.network.BaseUI<Link>

createChildren

protected void createChildren()
Description copied from class: ElementUI
创建孩子元素,比如文本标签,告警标签等等

Overrides:
createChildren in class ElementUI<Link>
See Also:
ElementUI.initialize()

validatePoints

protected void validatePoints()
生成连线图形数据,生成Path图形

See Also:
calculatePath(List)

calculatePath

protected void calculatePath(java.util.List<PathSegment> pathSegments)
生成线段图形数据,该函数会计算连线的路径,包括节点边缘对齐,连线展开分布,自环等多种样式,具体的计算操作交由#drawLink(Rect, Rect, List)和#drawLoopedLink(Rect, List)处理 生成的结果将存放在传入的pathSegments参数中

Parameters:
pathSegments - 计算结果存放在此集合中
See Also:
validatePoints(), drawLink(Rect, Rect, List), drawLoopedLink(Rect, List)

drawLink

protected void drawLink(Rect fromBounds,
                        Rect toBounds,
                        java.util.List<PathSegment> pathSegments)
绘制连线,仅用于非自环的情况,计算连线的路径,存放在pathSegments参数中

Parameters:
fromBounds - 起始端节点大小
toBounds - 终端节点大小
pathSegments -
See Also:
calculatePath(List)

drawLoopedLink

protected void drawLoopedLink(Rect agentBounds,
                              java.util.List<PathSegment> pathSegments)
计算自环时连线的走向,结果存放在参数pathSegments中

Parameters:
agentBounds -
pathSegments -

getLinkBundleOffset

public Point getLinkBundleOffset()
获取连线绑定偏移量 如果该连线不参与捆绑,或者连线没有展开,则返回null

Returns:
连线绑定偏移量

onElementPropertyChange

protected boolean onElementPropertyChange(java.lang.String propertyName,
                                          PropertyChangeEvent evt)
Description copied from class: ElementUI
网元属性变化时,调用此函数

Overrides:
onElementPropertyChange in class ElementUI<Link>
Parameters:
propertyName - 属性名
evt - 属性变化事件
Returns:
是否需要重绘
See Also:
ElementUI.onElementPropertyChange(PropertyChangeEvent)

onLinkPropertyChange

protected boolean onLinkPropertyChange(java.lang.String propertyName,
                                       PropertyChangeEvent evt)
连线属性变化处理函数

Parameters:
propertyName - 属性名称
evt - 属性变化事件
Returns:
是否处理

isLayoutByAnchorPoint

public boolean isLayoutByAnchorPoint()
Overrides:
isLayoutByAnchorPoint in class twaver.core.network.BaseUI<Link>

doValidate

protected boolean doValidate()
Description copied from class: ElementUI
执行生效动作,比如孩子元素的位置布局,范围大小的确定等等

Overrides:
doValidate in class ElementUI<Link>
Returns:
是否需要生效
See Also:
ElementUI.layout(), ElementUI.measure()

checkPoints

public void checkPoints()
检查连线,是否需要重新生成路径和图形

See Also:
invalidatePoints(), validatePoints()

invalidatePoints

public void invalidatePoints()
无效连线路径,调用此方法后,连线会在需要的时候重新生成路径和图形

See Also:
checkPoints(), isInvalidatePoints(), validatePoints()

isInvalidatePoints

public boolean isInvalidatePoints()
连线是否无效

Returns:
连线是否无效
See Also:
invalidatePoints(), checkPoints(), validatePoints()

getPathSegments

public java.util.List<PathSegment> getPathSegments()
Description copied from interface: IPathUI
获取路径

Specified by:
getPathSegments in interface IPathUI
Returns:
获取路径集合

isLayoutByPath

public boolean isLayoutByPath()
Description copied from interface: IPathUI
是否沿线布局

Specified by:
isLayoutByPath in interface IPathUI
Returns:
是否沿线布局

getLength

public float getLength()
Description copied from interface: IPathUI
路径长度

Specified by:
getLength in interface IPathUI
Returns:
路径长度

getLineWidth

public float getLineWidth()
Description copied from interface: IPathUI
路径线条宽度

Specified by:
getLineWidth in interface IPathUI
Returns:
路径线条宽度

resetShape

protected void resetShape()
Overrides:
resetShape in class twaver.core.network.BaseUI<Link>

isRelativeLocation

public boolean isRelativeLocation()
Overrides:
isRelativeLocation in class twaver.core.network.BaseUI<Link>