twaver.model
Class Node

java.lang.Object
  extended by twaver.model.Data
      extended by twaver.model.Element
          extended by twaver.model.Node
All Implemented Interfaces:
IChildList, IData, IHandler<PropertyChangeEvent>, IListener<PropertyChangeEvent>, Identifiable
Direct Known Subclasses:
Group, ShapeNode, Subnetwork

public class Node
extends Element

节点类型,可以设置图片,添加跟随者 默认对应的UI类是 NodeUI


Field Summary
protected  Position anchorPosition
          挂载点位置
protected  Size calculateSize
          网元计算大小,网元计算大小不一定等于size,默认网元大小为空,网元计算大小则为网元图片的宽高 此外网元计算大小也不一定等于网元的显示大小,网元的显示大小由一系列样式决定
protected  int contentType
          内容类型,默认为图片,表示网元呈现主体,可设置为图片或者图形类型 Consts.CONTENT_TYPE_IMAGE, Consts.CONTENT_TYPE_SHAPE
protected  Node host
          宿主节点,一个节点跟随另一个节点拖动而移动,被跟随的节点称为宿主节点
protected  java.lang.Object image
          图片属性
protected  boolean invalidateAnchorPointFlag
          挂载点变化标志
protected  boolean invalidateImageFlag
          图片无效标志
protected  boolean invalidateSizeFlag
          网元大小无效标志
protected  Point location
          节点坐标
protected  Size size
          网元大小,网元大小不一定等于网元计算大小calculateSize,默认网元大小为空,网元计算大小则为网元图片的宽高
 
Fields inherited from class twaver.model.Element
alarmState, attachments, layerId, name, uiClass
 
Fields inherited from class twaver.model.Data
parent
 
Constructor Summary
Node()
          构造函数
 
Method Summary
 boolean addFollower(Node follower)
          添加跟随者,网元被拖动时,跟随者也会被拖动,以下两行代码作用相同:
 Rect calculateBounds()
          计算网元范围,网元计算范围与实际显示范围不一定相同,网元实际显示范围与呈现样式有关 calculateSize
 void checkLinkAgent()
          重新检查所有连线的代理节点
 void clearFollowers()
          清除跟随者
 HashList<Link> getAgentLinks()
          所有的代理连线
 Point getAnchorPoint()
          获取挂载点坐标
 Position getAnchorPosition()
          挂载点位置
 Size getCalculateSize()
          网元计算大小, calculateSize
 int getContentType()
          获取内容类型,默认为图片,表示网元呈现主体,可设置为图片或者图形类型 Consts.CONTENT_TYPE_IMAGE, Consts.CONTENT_TYPE_SHAPE
 int getFollowerCount()
          获取跟随者数量
 int getFollowerIndex(Node child)
          获取跟随者的索引号
 HashList<Node> getFollowers()
          获取所有的跟随者,结果可能为null
 HashList<Node> getFollowers(boolean create)
          获取所有的跟随者
 HashList<Link> getFromAgentLinks()
          获取起始端所有的代理连线
 HashList<Link> getFromLinks()
          获取所有起始端连线
 Node getHost()
          获取宿主节点
 java.lang.Object getImage()
          获取网元图片
 HashList<Link> getLinks()
          获取该节点上所有的连线
 Point getLocation()
          节点坐标
 HashList<Link> getLoopedLinks()
          获取节点左右的自环
 Size getSize()
          获取网元大小,@see size
 Size getSize(boolean calculate)
          获取网元大小,如果calculate参数为true,返回网元计算大小calculateSize,否则返回网元大小size
 HashList<Link> getToAgentLinks()
          获取结束端所有代理连线
 HashList<Link> getToLinks()
          获取所有结束端连线
 float getX()
          节点x坐标
 float getY()
          节点y坐标
 boolean hasAgentLinks()
          是否有代理连线相连
 boolean hasFollowers()
          是否拥有跟随者
 boolean invalidateVisibility()
          无效网元的可见状态
 void onParentChanged(Data oldParent, Data newParent)
           
 boolean removeFollower(Node follower)
          删除跟随者
 boolean setAnchorPosition(Position anchorPosition)
          设置挂载点位置
 boolean setContentType(int contentType)
          设置内容类型,默认为图片,表示网元呈现主体,可设置为图片或者图形类型 Consts.CONTENT_TYPE_IMAGE, Consts.CONTENT_TYPE_SHAPE contentType getContentType()
 void setFollowerIndex(Node child, int index)
          设置跟随者索引位置
 boolean setHost(Node host)
          设置宿主节点,与addFollower(Node)可以实现相同的功能,以下两行代码作用相同:
 boolean setImage(java.lang.Object image)
          设置网元图片,支持多种类型,栅格图片,gif动画,Drawable实现类,IImage实现类 通常图片先进行全局注册Utils.registerImage(String, IImage),然后通过注册名称使用,比如:
 boolean setLocation(double x, double y)
          设置节点坐标
 boolean setLocation(Point location)
          设置节点坐标
 boolean setSize(double width, double height)
          设置网元大小,@see setSize(Size)
 boolean setSize(Size size)
          设置网元大小
 Node[] toFollowers()
          获取跟随者数组
protected  void validateSize()
          计算网元大小, calculateSize
 
Methods inherited from class twaver.model.Element
addAttachment, clearAttachments, firePropertyChangeEvent, getAlarmState, getAlarmState, getAttachment, getAttachments, getLayerId, getName, getStyle, getStyles, getStyles, getUIClass, hasAlarm, hasAttachment, hasStyle, isVisible, isVisible, removeAttachment, removeStyle, setAlarmState, setLayerId, setName, setStyle, setUIClass, updateAttachment, updateAttachment
 
Methods inherited from class twaver.model.Data
addChild, addChild, beforeEvent, clearChildren, get, getChildAt, getChildIndex, getChildren, getChildrenCount, getId, getParent, getProperties, getProperties, hasChildren, hashCode, isDescendantOf, onChildAdd, onChildRemove, onChildrenClear, onEvent, remove, removeChild, set, setChildIndex, setListener, setParent, setParent, setProperty, toChildren, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

image

protected java.lang.Object image
图片属性


invalidateImageFlag

protected transient boolean invalidateImageFlag
图片无效标志


invalidateSizeFlag

protected transient boolean invalidateSizeFlag
网元大小无效标志


invalidateAnchorPointFlag

protected transient boolean invalidateAnchorPointFlag
挂载点变化标志


size

protected Size size
网元大小,网元大小不一定等于网元计算大小calculateSize,默认网元大小为空,网元计算大小则为网元图片的宽高

See Also:
calculateSize

calculateSize

protected transient Size calculateSize
网元计算大小,网元计算大小不一定等于size,默认网元大小为空,网元计算大小则为网元图片的宽高 此外网元计算大小也不一定等于网元的显示大小,网元的显示大小由一系列样式决定

See Also:
size

anchorPosition

protected Position anchorPosition
挂载点位置


contentType

protected int contentType
内容类型,默认为图片,表示网元呈现主体,可设置为图片或者图形类型 Consts.CONTENT_TYPE_IMAGE, Consts.CONTENT_TYPE_SHAPE

See Also:
setContentType(int)

host

protected Node host
宿主节点,一个节点跟随另一个节点拖动而移动,被跟随的节点称为宿主节点


location

protected Point location
节点坐标

Constructor Detail

Node

public Node()
构造函数

Method Detail

getImage

public java.lang.Object getImage()
获取网元图片

Returns:
网元图片

setImage

public boolean setImage(java.lang.Object image)
设置网元图片,支持多种类型,栅格图片,gif动画,Drawable实现类,IImage实现类 通常图片先进行全局注册Utils.registerImage(String, IImage),然后通过注册名称使用,比如:
 Utils.registerImage("node", "/twaver/resource/images/node.png");
 node.setImage("node");
 

Parameters:
image - 图片,可以是已注册的图片名称,或IImage, Bitmap, Drawable, URL以及资源id等等
Returns:
是否设置成功
See Also:
IImage, Utils.registerImage(String, IImage)

setContentType

public boolean setContentType(int contentType)
设置内容类型,默认为图片,表示网元呈现主体,可设置为图片或者图形类型 Consts.CONTENT_TYPE_IMAGE, Consts.CONTENT_TYPE_SHAPE contentType getContentType()

Parameters:
contentType -
Returns:
是否设置成功

getContentType

public int getContentType()
获取内容类型,默认为图片,表示网元呈现主体,可设置为图片或者图形类型 Consts.CONTENT_TYPE_IMAGE, Consts.CONTENT_TYPE_SHAPE

Returns:
网元内容类型
See Also:
setContentType(int)

addFollower

public boolean addFollower(Node follower)
添加跟随者,网元被拖动时,跟随者也会被拖动,以下两行代码作用相同:
 host.addFollower(follower);
 follower.setHost(host);
 

Parameters:
follower - 跟随者
Returns:
是否添加成功
See Also:
setHost(Node), removeFollower(Node)

removeFollower

public boolean removeFollower(Node follower)
删除跟随者

Parameters:
follower - 跟随者
Returns:
是否删除成功
See Also:
addFollower(Node)

getFollowers

public HashList<Node> getFollowers()
获取所有的跟随者,结果可能为null

Returns:
所有的跟随者
See Also:
getFollowers(boolean)

getFollowers

public HashList<Node> getFollowers(boolean create)
获取所有的跟随者

Parameters:
create - 如果followers为null,且create参数为true,则创建一个空的集合
Returns:
跟随者集合

hasFollowers

public boolean hasFollowers()
是否拥有跟随者

Returns:
是否拥有跟随者

toFollowers

public Node[] toFollowers()
获取跟随者数组

Returns:
跟随者数组

clearFollowers

public void clearFollowers()
清除跟随者


getFollowerIndex

public int getFollowerIndex(Node child)
获取跟随者的索引号

Parameters:
child - 跟随节点
Returns:
跟随者的索引号

setFollowerIndex

public void setFollowerIndex(Node child,
                             int index)
设置跟随者索引位置

Parameters:
child -
index -

getFollowerCount

public int getFollowerCount()
获取跟随者数量

Returns:
跟随者数量

getFromLinks

public HashList<Link> getFromLinks()
获取所有起始端连线

Returns:
所有起始端连线

getToLinks

public HashList<Link> getToLinks()
获取所有结束端连线

Returns:
所有结束端连线

getLinks

public HashList<Link> getLinks()
获取该节点上所有的连线

Returns:
该节点上所有的连线

getLoopedLinks

public HashList<Link> getLoopedLinks()
获取节点左右的自环

Returns:
节点左右的自环

getFromAgentLinks

public HashList<Link> getFromAgentLinks()
获取起始端所有的代理连线

Returns:
起始端所有的代理连线

getToAgentLinks

public HashList<Link> getToAgentLinks()
获取结束端所有代理连线

Returns:
结束端所有代理连线

hasAgentLinks

public boolean hasAgentLinks()
是否有代理连线相连

Returns:
是否有代理连线相连

getAgentLinks

public HashList<Link> getAgentLinks()
所有的代理连线

Returns:
所有的代理连线

onParentChanged

public void onParentChanged(Data oldParent,
                            Data newParent)
Specified by:
onParentChanged in interface IChildList
Overrides:
onParentChanged in class Data

checkLinkAgent

public void checkLinkAgent()
重新检查所有连线的代理节点


getHost

public Node getHost()
获取宿主节点

Returns:
宿主节点

setHost

public boolean setHost(Node host)
设置宿主节点,与addFollower(Node)可以实现相同的功能,以下两行代码作用相同:
 host.addFollower(follower);
 follower.setHost(host);
 

Parameters:
host - 宿主节点
Returns:
是否设置成功

getX

public float getX()
节点x坐标

Returns:
节点x坐标

getY

public float getY()
节点y坐标

Returns:
节点y坐标

getLocation

public Point getLocation()
节点坐标

Returns:
节点坐标

setLocation

public boolean setLocation(Point location)
设置节点坐标

Parameters:
location - 节点坐标
Returns:
是否设置成功

setLocation

public boolean setLocation(double x,
                           double y)
设置节点坐标

Parameters:
x - x坐标
y - y坐标
Returns:
是否设置成功

getAnchorPosition

public Position getAnchorPosition()
挂载点位置

Returns:
挂载点位置

setAnchorPosition

public boolean setAnchorPosition(Position anchorPosition)
设置挂载点位置

Parameters:
anchorPosition - 挂载点位置
Returns:
是否设置成功

getAnchorPoint

public Point getAnchorPoint()
获取挂载点坐标

Returns:
挂载点坐标

setSize

public boolean setSize(Size size)
设置网元大小

Parameters:
size - 网元大小,对于图片支持等比缩放,比如下面的代码,表示设置网元宽度40像素,高度按图片比例缩放
 node.setSize(40, -1);
 
Returns:
是否设置成功

setSize

public boolean setSize(double width,
                       double height)
设置网元大小,@see setSize(Size)

Parameters:
width - 宽度
height - 高度
Returns:
是否设置成功

getSize

public Size getSize()
获取网元大小,@see size

Returns:
网元大小

getSize

public Size getSize(boolean calculate)
获取网元大小,如果calculate参数为true,返回网元计算大小calculateSize,否则返回网元大小size

Parameters:
calculate - 是否返回网元计算大小
Returns:
网元大小

getCalculateSize

public Size getCalculateSize()
网元计算大小, calculateSize

Returns:
网元计算大小

validateSize

protected void validateSize()
计算网元大小, calculateSize


calculateBounds

public Rect calculateBounds()
计算网元范围,网元计算范围与实际显示范围不一定相同,网元实际显示范围与呈现样式有关 calculateSize

Returns:
网元计算范围

invalidateVisibility

public boolean invalidateVisibility()
Description copied from class: Element
无效网元的可见状态

Overrides:
invalidateVisibility in class Element
Returns:
是否设置成功