securesmartcam / app / src / main / java / org / witness / obscuracam / video / ObscureRegion.java @ 41590feb
History | View | Annotate | Download (2.29 KB)
1 |
package org.witness.obscuracam.video; |
---|---|
2 |
|
3 |
import org.witness.obscuracam.ObscuraApp; |
4 |
|
5 |
import android.graphics.RectF; |
6 |
|
7 |
public class ObscureRegion { |
8 |
|
9 |
/*
|
10 |
* Thinking about whether or not a region should contain multiple start/end times
|
11 |
* realizing that doing this would make editing a real pita
|
12 |
* Of course, it would make displaying be a 1000x better though.
|
13 |
class PositionTime {
|
14 |
|
15 |
int sx = 0;
|
16 |
int sy = 0;
|
17 |
int ex = 0;
|
18 |
int ey = 0;
|
19 |
int startTime = 0;
|
20 |
int endTime = 0;
|
21 |
|
22 |
PositionTime(int _sx, int _sy, int _ex, int _ey, int _startTime, int _endTime) {
|
23 |
|
24 |
}
|
25 |
}
|
26 |
*/
|
27 |
|
28 |
public static final String LOGTAG = ObscuraApp.TAG; |
29 |
|
30 |
|
31 |
public static final float DEFAULT_X_SIZE = 150; |
32 |
public static final float DEFAULT_Y_SIZE = 150; |
33 |
|
34 |
public float sx = 0; |
35 |
public float sy = 0; |
36 |
|
37 |
public float ex = 0; |
38 |
public float ey = 0; |
39 |
|
40 |
public int timeStamp = 0; |
41 |
|
42 |
public RegionTrail regionTrail;
|
43 |
|
44 |
private RectF rectF;
|
45 |
|
46 |
public ObscureRegion(int _timeStamp, float _sx, float _sy, float _ex, float _ey) { |
47 |
|
48 |
timeStamp = _timeStamp; |
49 |
sx = _sx; |
50 |
sy = _sy; |
51 |
ex = _ex; |
52 |
ey = _ey; |
53 |
|
54 |
if (sx < 0) { |
55 |
sx = 0;
|
56 |
} else if (sy < 0) { |
57 |
sy = 0;
|
58 |
} |
59 |
|
60 |
|
61 |
} |
62 |
|
63 |
public ObscureRegion(int _startTime, float _sx, float _sy) { |
64 |
this(_startTime, _sx - DEFAULT_X_SIZE/2, _sy - DEFAULT_Y_SIZE/2, _sx + DEFAULT_X_SIZE/2, _sy + DEFAULT_Y_SIZE/2); |
65 |
} |
66 |
|
67 |
|
68 |
public void moveRegion(float _sx, float _sy) { |
69 |
moveRegion(_sx - DEFAULT_X_SIZE/2, _sy - DEFAULT_Y_SIZE/2, _sx + DEFAULT_X_SIZE/2, _sy + DEFAULT_Y_SIZE/2); |
70 |
} |
71 |
|
72 |
public void moveRegion(float _sx, float _sy, float _ex, float _ey) { |
73 |
sx = _sx; |
74 |
sy = _sy; |
75 |
ex = _ex; |
76 |
ey = _ey; |
77 |
|
78 |
rectF = null;
|
79 |
} |
80 |
|
81 |
public RectF getRectF() {
|
82 |
|
83 |
if (rectF == null) |
84 |
rectF = new RectF(sx, sy, ex, ey);
|
85 |
|
86 |
return rectF;
|
87 |
} |
88 |
|
89 |
public RectF getBounds() {
|
90 |
return getRectF();
|
91 |
} |
92 |
|
93 |
|
94 |
public String getStringData(float widthMod, float heightMod, int startTime, int duration, String currentMode) { |
95 |
//left, right, top, bottom
|
96 |
return "" + (float)startTime/(float)1000 + ',' + (float)(startTime+duration)/(float)1000 + ',' + (int)(sx*widthMod) + ',' + (int)(ex*widthMod) + ',' + (int)(sy*heightMod) + ',' + (int)(ey*heightMod) + ',' + currentMode; |
97 |
} |
98 |
|
99 |
public RegionTrail getRegionTrail() {
|
100 |
return regionTrail;
|
101 |
} |
102 |
|
103 |
public void setRegionTrail(RegionTrail regionTrail) { |
104 |
this.regionTrail = regionTrail;
|
105 |
} |
106 |
} |