twaver.network
Class ShapeUI

java.lang.Object
  extended by twaver.core.network.BaseUI<T>
      extended by twaver.network.UI<Path>
          extended by twaver.network.ShapeUI
All Implemented Interfaces:
twaver.core.network.IUI<Path,Canvas,Paint>

public class ShapeUI
extends UI<Path>

图形UI元素,用于绘制图形,比如多边形,线条 图形数据源为Path类型,也可以使用PathSegment作为数据

See Also:
Path, PathSegment

Field Summary
 
Fields inherited from class twaver.network.UI
elementUI
 
Fields inherited from class twaver.core.network.BaseUI
anchorPoint, bodyOffsetX, bodyOffsetY, bounds, data, invalidateAnchorPointFlag, invalidateLocationFlag, invalidateRenderFlag, invalidateSizeFlag, location, stateOutline, stateOutlineColor, visible
 
Constructor Summary
ShapeUI(ElementUI<?> elementUI)
          构造函数,图形UI元素,用于绘制图形,比如多边形,线条,用于LinkUI, ShapeNodeUI, Shape样式的节点twaver.model.Node#setContentType(twaver.Consts.CONTENT_TYPE_SHAPE)以及ShapeAttachment
 
Method Summary
protected  void drawArrows(Canvas canvas, Paint paint)
          绘制箭头
protected  void drawBodySelection(Canvas canvas, Paint paint)
          绘制主体选中效果
 void drawBodyStateOutline(Canvas canvas, Paint paint, int stateOutlineColor, float stateOutline)
          绘制主体状态边框,指定边框宽度和颜色
protected  void drawShape(Canvas canvas, Paint paint, float tolerance)
          绘制图形
 java.util.List<ArrowInfo> getArrows()
          箭头数据
 float[] getDashPattern()
           
 int getFillColor()
          填充颜色
 IShader getFillShader()
          填充着色器,比如渐变
 float getLineWidth()
          线总宽度,等于线宽加上边线外框(stroke + strokeOutline * 2),适用于图形不填充时,呈现为线条的时
 java.util.List<PathSegment> getPathSegments()
          路径片段,twaver内部都使用PathSegment作为图形数据
 float getStroke()
          边线宽度
 Cap getStrokeCap()
          端点样式
 int getStrokeColor()
          边线颜色
 Join getStrokeJoin()
          拐点样式
 float getStrokeOutline()
          边线外框宽度
 int getStrokeOutlineColor()
          边线外框颜色
 IShader getStrokeShader()
          边线着色器,比如渐变
 boolean intersect(Point point)
          点相交
 boolean intersect(Rect rect)
          矩形相交
 void invalidateArrows()
          无效箭头
 boolean isByPathSegments()
          图形数据源是否是PathSegment集合
 boolean isClosePath()
          是否闭合图形
 void measure()
           
protected  void onDrawBody(Canvas canvas, Paint paint, boolean drawSelectionOnBody, boolean drawStateOutlineOnBody)
          绘制主体
 void resetPaint(Paint paint)
          重置画笔
 boolean setClosePath(boolean closePath)
          是否闭合
 boolean setDashPattern(float[] dashPattern)
           
 boolean setFillColor(int fillColor)
          设置填充颜色
 void setFillShader(IShader fillShader)
          设置填充着色器,比如渐变
 boolean setPathSegment(java.util.List<PathSegment> paths)
          设置图形数据
 boolean setPathSegment(java.util.List<PathSegment> paths, boolean forceInvalidate)
          设置图形数据
 boolean setShapeType(java.lang.String type)
          设置图形类型,可以注册自己的图形
 boolean setSize(Size size)
          设置图形的尺寸,准确地说是缩放比例,因为twaver默认图形都是限定在1X1的范围内,所以等同于图形的尺寸
 boolean setStroke(float stroke)
          设置边线宽度
 boolean setStrokeCap(Cap strokeCap)
          设置端点样式
 boolean setStrokeColor(int strokeColor)
          设置边线颜色
 boolean setStrokeJoin(Join strokeJoin)
          设置拐点样式
 boolean setStrokeOutline(float strokeOutline)
          设置边线外框宽度
 boolean setStrokeOutlineColor(int strokeOutlineColor)
          设置边线外框颜色
 void setStrokeShader(IShader strokeShader)
          设置边线着色器,比如渐变
 boolean validate()
           
protected  void validateArrows()
          生效箭头图形
protected  void validateShape()
          生效图形
 
Methods inherited from class twaver.network.UI
drawBodyStateOutline, getElementUI, getPosition, invalidateSize, isSendToBottom, setPosition, setSendToBottom
 
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, intersectPointer, invalidateAnchorPoint, invalidateLocation, invalidatePointer, invalidateRender, isDrawBackground, isDrawOutline, isDrawStateOutline, isInvalidate, isInvalidateAnchorPoint, isInvalidateLocation, isInvalidateSize, isLayoutByAnchorPoint, isRelativeLocation, isRotatable, isSelected, isShowOnTop, isVisible, measureAnchorPosition, onDraw, onDrawBackgroundAndBorder, perLocation, resetShape, setAnchorPosition, setBackgroundColor, setBackgroundShader, setBounds, setBounds, setCornerRadius, setData, setLayoutByAnchorPoint, setLocation, setLocation, setMeasuredSize, setOffset, setOutline, setOutlineColor, setPadding, setPointerVisible, setPointerWidth, setRenderColor, setRotatable, setSelected, setSelectionBorder, setSelectionBorderColor, 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
 

Constructor Detail

ShapeUI

public ShapeUI(ElementUI<?> elementUI)
构造函数,图形UI元素,用于绘制图形,比如多边形,线条,用于LinkUI, ShapeNodeUI, Shape样式的节点twaver.model.Node#setContentType(twaver.Consts.CONTENT_TYPE_SHAPE)以及ShapeAttachment

Parameters:
elementUI - 网元UI对象
See Also:
Link, LinkUI, ShapeNode, ShapeNodeUI, Node.setContentType(int), Consts.CONTENT_TYPE_SHAPE
Method Detail

getDashPattern

public float[] getDashPattern()

setDashPattern

public boolean setDashPattern(float[] dashPattern)

setStrokeJoin

public boolean setStrokeJoin(Join strokeJoin)
设置拐点样式

Parameters:
strokeJoin - 边线拐点样式
Returns:
是否设置成功
See Also:
getStrokeJoin()

getStrokeJoin

public Join getStrokeJoin()
拐点样式

Returns:
拐点样式
See Also:
setStrokeJoin(Join)

setStrokeCap

public boolean setStrokeCap(Cap strokeCap)
设置端点样式

Parameters:
strokeCap - 端点样式
Returns:
是否设置成功
See Also:
getStrokeCap()

getStrokeCap

public Cap getStrokeCap()
端点样式

Returns:
端点样式
See Also:
setStrokeCap(Cap)

setClosePath

public boolean setClosePath(boolean closePath)
是否闭合

Parameters:
closePath - 是否闭合
Returns:
是否设置成功
See Also:
isClosePath()

isClosePath

public boolean isClosePath()
是否闭合图形

Returns:
是否闭合

setStrokeOutline

public boolean setStrokeOutline(float strokeOutline)
设置边线外框宽度

Parameters:
strokeOutline -
Returns:
是否设置成功
See Also:
getStrokeOutline(), setStrokeOutlineColor(int)

getStrokeOutline

public float getStrokeOutline()
边线外框宽度

Returns:
边线外框宽度

setStrokeOutlineColor

public boolean setStrokeOutlineColor(int strokeOutlineColor)
设置边线外框颜色

Parameters:
strokeOutlineColor -
Returns:
是否设置成功
See Also:
getStrokeOutlineColor(), setStrokeOutline(float)

getStrokeOutlineColor

public int getStrokeOutlineColor()
边线外框颜色

Returns:
边线外框颜色
See Also:
setStrokeOutlineColor(int)

setSize

public boolean setSize(Size size)
设置图形的尺寸,准确地说是缩放比例,因为twaver默认图形都是限定在1X1的范围内,所以等同于图形的尺寸

Parameters:
size - 图形的尺寸
Returns:
是否设置成功

setShapeType

public boolean setShapeType(java.lang.String type)
设置图形类型,可以注册自己的图形

Parameters:
type - 图形类型
Returns:
是否设置成功
See Also:
Utils.registerShape(String, List), Consts#SHAPE_***

validateShape

protected void validateShape()
生效图形


validate

public boolean validate()
Specified by:
validate in interface twaver.core.network.IUI<Path,Canvas,Paint>
Overrides:
validate in class twaver.core.network.BaseUI<Path>

measure

public void measure()
Specified by:
measure in class twaver.core.network.BaseUI<Path>

onDrawBody

protected void onDrawBody(Canvas canvas,
                          Paint paint,
                          boolean drawSelectionOnBody,
                          boolean drawStateOutlineOnBody)
Description copied from class: UI
绘制主体

Overrides:
onDrawBody in class UI<Path>
drawSelectionOnBody - 是否绘制选中效果
drawStateOutlineOnBody - 是否绘制边框
See Also:
UI.drawBodySelection(Canvas, Paint), UI.drawBodyStateOutline(Canvas, Paint)

drawBodyStateOutline

public void drawBodyStateOutline(Canvas canvas,
                                 Paint paint,
                                 int stateOutlineColor,
                                 float stateOutline)
Description copied from class: UI
绘制主体状态边框,指定边框宽度和颜色

Overrides:
drawBodyStateOutline in class UI<Path>
stateOutlineColor - 状态边框宽度
stateOutline - 状态边框颜色
See Also:
UI.drawBodyStateOutline(Canvas, Paint)

drawBodySelection

protected void drawBodySelection(Canvas canvas,
                                 Paint paint)
Description copied from class: UI
绘制主体选中效果

Overrides:
drawBodySelection in class UI<Path>

drawShape

protected void drawShape(Canvas canvas,
                         Paint paint,
                         float tolerance)
绘制图形

Parameters:
canvas -
paint -
tolerance - 容差,用于点选

getLineWidth

public float getLineWidth()
线总宽度,等于线宽加上边线外框(stroke + strokeOutline * 2),适用于图形不填充时,呈现为线条的时

Returns:
线总宽度

getStroke

public float getStroke()
边线宽度

Returns:
边线宽度

setStroke

public boolean setStroke(float stroke)
设置边线宽度

Parameters:
stroke - 边线宽度
Returns:
是否设置成功

getFillColor

public int getFillColor()
填充颜色

Returns:
填充颜色
See Also:
setFillColor(int)

setFillColor

public boolean setFillColor(int fillColor)
设置填充颜色

Parameters:
fillColor -
Returns:
是否设置成功
See Also:
getFillColor()

setFillShader

public void setFillShader(IShader fillShader)
设置填充着色器,比如渐变

Parameters:
fillShader -

getFillShader

public IShader getFillShader()
填充着色器,比如渐变

Returns:
填充着色器

getStrokeShader

public IShader getStrokeShader()
边线着色器,比如渐变

Returns:
边线着色器

setStrokeShader

public void setStrokeShader(IShader strokeShader)
设置边线着色器,比如渐变

Parameters:
strokeShader -

getStrokeColor

public int getStrokeColor()
边线颜色

Returns:
边线颜色

setStrokeColor

public boolean setStrokeColor(int strokeColor)
设置边线颜色

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

intersect

public boolean intersect(Rect rect)
Description copied from class: UI
矩形相交

Specified by:
intersect in interface twaver.core.network.IUI<Path,Canvas,Paint>
Overrides:
intersect in class UI<Path>
Parameters:
rect - 相交矩形

intersect

public boolean intersect(Point point)
Description copied from class: UI
点相交

Specified by:
intersect in interface twaver.core.network.IUI<Path,Canvas,Paint>
Overrides:
intersect in class UI<Path>
Parameters:
point - 相交点

resetPaint

public void resetPaint(Paint paint)
Description copied from class: UI
重置画笔

Overrides:
resetPaint in class UI<Path>

isByPathSegments

public boolean isByPathSegments()
图形数据源是否是PathSegment集合

Returns:
图形数据源是否是PathSegment集合
See Also:
getPathSegments()

getPathSegments

public java.util.List<PathSegment> getPathSegments()
路径片段,twaver内部都使用PathSegment作为图形数据

Returns:
路径片段集合
See Also:
isByPathSegments()

setPathSegment

public boolean setPathSegment(java.util.List<PathSegment> paths)
设置图形数据

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

setPathSegment

public boolean setPathSegment(java.util.List<PathSegment> paths,
                              boolean forceInvalidate)
设置图形数据

Parameters:
paths -
forceInvalidate - 是否强制生效,内部会转换成Path对象
Returns:
是否设置成功

getArrows

public java.util.List<ArrowInfo> getArrows()
箭头数据

Returns:
箭头数据

invalidateArrows

public void invalidateArrows()
无效箭头


drawArrows

protected void drawArrows(Canvas canvas,
                          Paint paint)
绘制箭头

Parameters:
canvas -
paint -

validateArrows

protected void validateArrows()
生效箭头图形