forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCandleBodyBuffer.java
More file actions
41 lines (27 loc) · 1009 Bytes
/
CandleBodyBuffer.java
File metadata and controls
41 lines (27 loc) · 1009 Bytes
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
package com.github.mikephil.charting.buffer;
import com.github.mikephil.charting.data.CandleEntry;
import java.util.List;
public class CandleBodyBuffer extends AbstractBuffer<CandleEntry> {
private float mBodySpace = 0f;
public CandleBodyBuffer(int size) {
super(size);
}
public void setBodySpace(float bodySpace) {
this.mBodySpace = bodySpace;
}
private void addBody(float left, float top, float right, float bottom) {
buffer[index++] = left;
buffer[index++] = top;
buffer[index++] = right;
buffer[index++] = bottom;
}
@Override
public void feed(List<CandleEntry> entries) {
int size = (int)Math.ceil((mTo - mFrom) * phaseX + mFrom);
for (int i = mFrom; i < size; i++) {
CandleEntry e = entries.get(i);
addBody(e.getXIndex() - 0.5f + mBodySpace, e.getClose() * phaseY, e.getXIndex() + 0.5f - mBodySpace, e.getOpen() * phaseY);
}
reset();
}
}