twaver
Class PathSegment

java.lang.Object
  extended by twaver.PathSegment
All Implemented Interfaces:
IStruct, ISerializable
Direct Known Subclasses:
PathSegment.LineSegment, PathSegment.MoveSegment, PathSegment.QuadSegment

public class PathSegment
extends java.lang.Object
implements IStruct, ISerializable

路径片段,用于描述路径,包含类型和坐标信息 路径有三种类型:moveTo, lineTo, quadTo,分别对应2D绘制的三种画法:移动画笔,绘制线条,绘制曲线 该类可用于连线的走向,多边形的定义

See Also:
Link.addPathSegement(PathSegment), ShapeNode.addPathSegement(PathSegment)

Nested Class Summary
static class PathSegment.LineSegment
          路径片段,对应路径绘制的Path#lineTo(float, float)方法
static class PathSegment.MoveSegment
          路径片段,对应路径绘制的Path#moveTo(float, float)方法
static class PathSegment.QuadSegment
          路径片段,对应路径绘制的Path#quadTo(float, float, float, float)方法
 
Field Summary
 Point[] points
          坐标点
 int type
          路径片段类型
 
Constructor Summary
PathSegment()
          路径片段,用于描述路径,包含类型和坐标信息 路径有三种类型:moveTo, lineTo, quadTo,分别对应2D绘制的三种画法:移动画笔,绘制线条,绘制曲线 该类可用于连线的走向,多边形的定义
PathSegment(Point[] points, int type)
          构造函数,设置路径坐标点和,片段类型
PathSegment(Point point, int type)
          构造函数
 
Method Summary
 PathSegment clone()
          拷贝一份新的数据,避免对原始数据的更改
 void deserialize(java.lang.String s)
          反序列化属性,根据字符串生成对象的属性
 void draw(Path g, Matrix m)
          绘制路径
 boolean equals(java.lang.Object o)
           
 Point getControlPoint()
           
 Point getFirstPoint()
           
 double getLength(Point prev)
          路径长度
 Point getPoint()
           
 PathSegment getReversePath(PathSegment prev)
          获取反向路径
 boolean isCurve()
           
 PathSegment scale(float xScale, float yScale)
          缩放路径
 java.lang.String serialize()
          序列化该对象
 void set(PathSegment path)
          从指定路径片段拷贝路径参数
 PathSegment translate(float dx, float dy)
          偏移路径
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

public int type
路径片段类型


points

public Point[] points
坐标点

Constructor Detail

PathSegment

public PathSegment()
路径片段,用于描述路径,包含类型和坐标信息 路径有三种类型:moveTo, lineTo, quadTo,分别对应2D绘制的三种画法:移动画笔,绘制线条,绘制曲线 该类可用于连线的走向,多边形的定义

See Also:
Link.addPathSegement(PathSegment), ShapeNode.addPathSegement(PathSegment)

PathSegment

public PathSegment(Point point,
                   int type)
构造函数

Parameters:
point - 路径点坐标
type - 路径类型 Consts.SEGMENT_MOVETO Consts.SEGMENT_LINETO Consts.SEGMENT_QUADTO

PathSegment

public PathSegment(Point[] points,
                   int type)
构造函数,设置路径坐标点和,片段类型

Parameters:
points - 坐标点
type - 类型
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getPoint

public Point getPoint()
Returns:
坐标点,如果是曲线返回第二个点

getFirstPoint

public Point getFirstPoint()
Returns:
第一个坐标点

getControlPoint

public Point getControlPoint()
Returns:
控制点,仅对曲线有用,指曲线的第一个点

draw

public void draw(Path g,
                 Matrix m)
绘制路径

Parameters:
g - 路径
m - 变换矩阵

getLength

public double getLength(Point prev)
路径长度

Parameters:
prev - 上一个路径片段点
Returns:
路径长度

isCurve

public boolean isCurve()
Returns:
是否是曲线

getReversePath

public PathSegment getReversePath(PathSegment prev)
获取反向路径

Parameters:
prev - 上一个路径片段
Returns:
反向路径

translate

public PathSegment translate(float dx,
                             float dy)
偏移路径

Parameters:
dx - x偏移量
dy - y偏移量
Returns:
self

scale

public PathSegment scale(float xScale,
                         float yScale)
缩放路径

Parameters:
xScale - x缩放比例
yScale - y方向缩放比例
Returns:
self

set

public void set(PathSegment path)
从指定路径片段拷贝路径参数

Parameters:
path - 路径片段

clone

public PathSegment clone()
Description copied from interface: IStruct
拷贝一份新的数据,避免对原始数据的更改

Specified by:
clone in interface IStruct
Overrides:
clone in class java.lang.Object
Returns:
新拷贝的数据

serialize

public java.lang.String serialize()
Description copied from interface: ISerializable
序列化该对象

Specified by:
serialize in interface ISerializable
Returns:
字符串

deserialize

public void deserialize(java.lang.String s)
Description copied from interface: ISerializable
反序列化属性,根据字符串生成对象的属性

Specified by:
deserialize in interface ISerializable
Parameters:
s - 字符串