twaver
Class Point

java.lang.Object
  extended by twaver.Point
All Implemented Interfaces:
IStruct, ISerializable

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

点对象,用于描述二维坐标点信息,包含x,y两个参数


Field Summary
 float x
          x坐标
 float y
          y坐标
 
Constructor Summary
Point()
          点对象,用于描述二维坐标点信息,包含x,y两个参数
Point(double x, double y)
          构造函数
Point(float x, float y)
          构造函数
Point(Point src)
          构造函数
 
Method Summary
static double calculateDistance(double x, double y)
          计算坐标点距离原点距离
 Point clone()
          拷贝一份新的数据,避免对原始数据的更改
 void deserialize(java.lang.String string)
          反序列化属性,根据字符串生成对象的属性
 double distance(double px, double py)
          两点距离
 double distance(Point p2)
          两点距离
 boolean equals(float x, float y)
          是否为相同坐标位置
 boolean equals(java.lang.Object o)
           
 double getDistance()
           
 int hashCode()
           
 boolean isEmpty()
           
 void negate()
          取反,正坐标变成负坐标
 Point offset(double dx, double dy)
          偏移坐标
 Point offset(float dx, float dy)
          偏移坐标
 Point offset(Point offset)
          偏移坐标
 java.lang.String serialize()
          序列化该对象
 void set(double x, double y)
          设置坐标点位置
 void set(float x, float y)
          设置坐标点位置
 void set(Point p)
          设置坐标点位置
 java.lang.String toString()
           
 Point translate(float dx, float dy)
          偏移坐标,与offset(float, float)相同
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public float x
x坐标


y

public float y
y坐标

Constructor Detail

Point

public Point()
点对象,用于描述二维坐标点信息,包含x,y两个参数


Point

public Point(double x,
             double y)
构造函数

Parameters:
x - x坐标
y - y坐标

Point

public Point(float x,
             float y)
构造函数

Parameters:
x - x坐标
y - y坐标

Point

public Point(Point src)
构造函数

Parameters:
src - 坐标点
Method Detail

set

public void set(Point p)
设置坐标点位置

Parameters:
p - 坐位置

set

public void set(float x,
                float y)
设置坐标点位置

Parameters:
x - x坐标
y - y坐标

set

public void set(double x,
                double y)
设置坐标点位置

Parameters:
x - x坐标
y - y坐标

negate

public void negate()
取反,正坐标变成负坐标


offset

public Point offset(Point offset)
偏移坐标

Parameters:
offset - 偏移量
Returns:
self

offset

public Point offset(double dx,
                    double dy)
偏移坐标

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

offset

public Point offset(float dx,
                    float dy)
偏移坐标

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

translate

public Point translate(float dx,
                       float dy)
偏移坐标,与offset(float, float)相同

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

equals

public final boolean equals(float x,
                            float y)
是否为相同坐标位置

Parameters:
x - x坐标
y - y坐标
Returns:
是否为相同坐标位置

equals

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

distance

public double distance(Point p2)
两点距离

Parameters:
p2 - 另一点
Returns:
两点距离

distance

public double distance(double px,
                       double py)
两点距离

Parameters:
px - x坐标
py - y坐标
Returns:
两点距离

getDistance

public double getDistance()
Returns:
坐标点距离原点距离

calculateDistance

public static double calculateDistance(double x,
                                       double y)
计算坐标点距离原点距离

Parameters:
x - x坐标
y - y坐标
Returns:
计算坐标点距离原点距离

isEmpty

public boolean isEmpty()
Returns:
是否为原点

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public Point 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 string)
Description copied from interface: ISerializable
反序列化属性,根据字符串生成对象的属性

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