public class Rectangle
extends java.lang.Object
implements java.io.Serializable
矩形类。
该类主要用来描述地图显示时,用户请求的地图图片的大小范围(单位是像素)。
限定符和类型 | 字段和说明 |
---|---|
Point |
leftTop
左上角坐标。
|
Point |
rightBottom
右下角坐标。
|
构造器和说明 |
---|
Rectangle()
默认构造函数。
|
Rectangle(int left, int top, int right, int bottom)
带参构造函数。
|
Rectangle(Point leftTop, Point rightBottom)
带参构造函数。
|
Rectangle(Rectangle rect)
拷贝构造函数。
|
限定符和类型 | 方法和说明 |
---|---|
boolean |
equals(java.lang.Object obj)
比较指定对象与当前 Rect 对象是否相等。
|
int |
getBottom()
设置像素矩形对象纵坐标最小值
|
Point |
getCenter()
获取矩形的中心点。
|
int |
getHeight()
获取矩形的高度。
|
int |
getLeft()
获取像素矩形对象的横坐标最小值
|
int |
getRight()
获取像素矩形对象横坐标最大值
|
int |
getTop()
获取像素矩形对象纵坐标最大值
|
int |
getWidth()
获取矩形的宽度。
|
int |
hashCode()
生成哈希码。
|
boolean |
isValid()
判断所获取的矩形宽度和高度是否合法。
|
void |
setBottom(int bottom)
设置像素矩形对象纵坐标最小值
|
Rectangle |
setHeight(int height)
设置宽度。
|
void |
setLeft(int left)
设置像素矩形对象横坐标最小值
|
void |
setRight(int right)
设置像素矩形对象横坐标最大值
|
void |
setTop(int top)
设置像素矩形对象纵坐标最大值
|
Rectangle |
setWidth(int width)
设置宽度。
|
java.lang.String |
toString()
将当前矩形的像素坐标转换为 String 表示形式。
|
void |
zoom(double ratio) |
void |
zoom(int ratio) |
public Rectangle()
默认构造函数。
public Rectangle(Rectangle rect)
拷贝构造函数。
rect
- 具有像素坐标的矩形对象。java.lang.IllegalArgumentException
- 当具有像素坐标的矩形对象为 Null 时抛出异常。public Rectangle(Point leftTop, Point rightBottom)
带参构造函数。
用指定的坐标初始化 Rectangle 类的新实例。
leftTop
- 左上角坐标。rightBottom
- 右下角坐标。java.lang.IllegalArgumentException
- 当左上角坐标或右下角坐标为 Null 时抛出异常。public Rectangle(int left, int top, int right, int bottom)
带参构造函数。
用指定的坐标初始化 Rectangle 类的新实例。
left
- 左上角的横坐标。top
- 左上角的纵坐标。right
- 右下角的横坐标。bottom
- 右下角的纵坐标。public int getWidth()
获取矩形的宽度。
其值为右边界坐标值与左边界坐标值之差。
public Rectangle setWidth(int width)
width
-public int getHeight()
获取矩形的高度。
其值为上边界坐标值与下边界坐标值之差。
public Rectangle setHeight(int height)
height
-public Point getCenter()
获取矩形的中心点。
其 x 坐标为(左边界坐标值+右边界坐标值)/2,y 坐标值为(上边界坐标值+下边界坐标值)/2。
public int hashCode()
生成哈希码。
hashCode
在类中 java.lang.Object
public boolean equals(java.lang.Object obj)
比较指定对象与当前 Rect 对象是否相等。
只有当指定的对象为矩形对象,且与此矩形对象有相同的边界坐标值时才认为两者相等。
equals
在类中 java.lang.Object
obj
- 与当前 Rectangle 对象进行比较的对象。public java.lang.String toString()
将当前矩形的像素坐标转换为 String 表示形式。
toString
在类中 java.lang.Object
public boolean isValid()
判断所获取的矩形宽度和高度是否合法。
public int getLeft()
public void setLeft(int left)
left
- 横坐标最小值public int getRight()
public void setRight(int right)
right
- 横坐标最大值public int getTop()
public void setTop(int top)
top
- 纵坐标最大值public int getBottom()
public void setBottom(int bottom)
bottom
- 纵坐标最小值public void zoom(int ratio)
public void zoom(double ratio)