forked from PhilJay/MPAndroidChart
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCandleShadowBuffer.java
More file actions
35 lines (23 loc) · 819 Bytes
/
CandleShadowBuffer.java
File metadata and controls
35 lines (23 loc) · 819 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
package com.github.mikephil.charting.buffer;
import com.github.mikephil.charting.data.CandleEntry;
import java.util.List;
public class CandleShadowBuffer extends AbstractBuffer<CandleEntry> {
public CandleShadowBuffer(int size) {
super(size);
}
private void addShadow(float x1, float y1, float x2, float y2) {
buffer[index++] = x1;
buffer[index++] = y1;
buffer[index++] = x2;
buffer[index++] = y2;
}
@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);
addShadow(e.getXIndex(), e.getHigh() * phaseY, e.getXIndex(), e.getLow() * phaseY);
}
reset();
}
}