-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectangle.java
68 lines (61 loc) · 2.1 KB
/
Rectangle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* Copyright (C), 2015-2018, XXX有限公司
* FileName: Rectangle
* Author: youkun
* Date: 2018/12/13 3:54
* Description:
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
import java.util.ArrayList;
/**
* 〈一句话功能简述〉<br>
* 〈〉
*
* @author youkun
* @create 2018/12/13
* @since 1.0.0
*/
public class Rectangle {
public double maxX;
public double minX;
public double maxY;
public double minY;
public ArrayList<Tweet> userList;
public Rectangle(double maxX, double minX, double maxY, double minY) {
this.maxX = maxX;
this.minX = minX;
this.maxY = maxY;
this.minY = minY;
}
public double getArea() {
return (maxX-minX) * (maxY - minY);
}
public void updateRec(Tweet post) {
if(!this.isUserHere(post)) {
if ((post.Userlocation[0] - this.maxX) * post.Userlocation[0] - this.minX > 0) {
if ((post.Userlocation[1] - this.maxY) * post.Userlocation[1] - this.minY > 0) {
this.maxY = Math.max(this.maxY,post.Userlocation[1]);
this.minY = Math.min(this.minY, post.Userlocation[1]);
this.maxX = Math.max(this.maxX,post.Userlocation[0]);
this.minX = Math.min(this.minX, post.Userlocation[0]);
} else {
this.maxX = Math.max(this.maxX,post.Userlocation[0]);
this.minX = Math.min(this.minX, post.Userlocation[0]);
}
} else {
this.maxY = Math.max(this.maxY,post.Userlocation[1]);
this.minY = Math.min(this.minY, post.Userlocation[1]);
}
}
}
public boolean isUserHere(Tweet post) {
return (post.Userlocation[0] > this.minX)
&& (post.Userlocation[0] < this.maxX)
&& (post.Userlocation[1] > this.minY)
&& (post.Userlocation[1] < this.maxY);
}
public void updateRec2(Rectangle child,Rectangle parent) {
}
}