use of com.androidplot.pie.SegmentFormatter in project i2p.i2p-bote by i2p.
the class NetworkInfoFragment method setupKademliaPeers.
private void setupKademliaPeers() {
DhtPeerStats dhtStats = I2PBote.getInstance().getDhtStats(new AndroidPeerStatsRenderer());
if (dhtStats != null) {
if (dhtStats.getData().size() == 0) {
Segment n = new Segment("", 100);
SegmentFormatter nf = new SegmentFormatter(getResources().getColor(android.R.color.darker_gray));
setupSegmentFormatter(nf);
mKademliaPie.addSeries(n, nf);
} else {
int reachable = 0;
for (DhtPeerStatsRow row : dhtStats.getData()) {
if (row.isReachable())
reachable += 1;
}
int unreachable = dhtStats.getData().size() - reachable;
mKademliaPeers.setText("" + dhtStats.getData().size());
if (reachable > 0) {
Segment r = new Segment(getString(R.string.reachable), reachable);
SegmentFormatter rf = new SegmentFormatter(getResources().getColor(R.color.green));
setupSegmentFormatter(rf);
mKademliaPie.addSeries(r, rf);
}
if (unreachable > 0) {
Segment u = new Segment(getString(R.string.unreachable), dhtStats.getData().size() - reachable);
SegmentFormatter uf = new SegmentFormatter(getResources().getColor(R.color.error_color));
setupSegmentFormatter(uf);
mKademliaPie.addSeries(u, uf);
}
}
}
mKademliaPie.getBorderPaint().setColor(Color.TRANSPARENT);
mKademliaPie.getBackgroundPaint().setColor(Color.TRANSPARENT);
}
use of com.androidplot.pie.SegmentFormatter in project i2p.i2p-bote by i2p.
the class NetworkInfoFragment method setupRelayPeers.
private void setupRelayPeers() {
Set<RelayPeer> relayPeers = I2PBote.getInstance().getRelayPeers();
mRelayPeers.setText("" + relayPeers.size());
if (relayPeers.size() == 0) {
Segment n = new Segment("", 100);
SegmentFormatter nf = new SegmentFormatter(getResources().getColor(android.R.color.darker_gray));
setupSegmentFormatter(nf);
mRelayPie.addSeries(n, nf);
} else {
int good = 0;
int untested = 0;
for (RelayPeer relayPeer : relayPeers) {
int reachability = relayPeer.getReachability();
if (reachability == 0)
untested += 1;
else if (reachability > 80)
good += 1;
}
int bad = relayPeers.size() - good - untested;
if (good > 0) {
Segment g = new Segment(getString(R.string.good), good);
SegmentFormatter gf = new SegmentFormatter(getResources().getColor(R.color.green));
setupSegmentFormatter(gf);
mRelayPie.addSeries(g, gf);
}
if (bad > 0) {
Segment b = new Segment(getString(R.string.unreliable), bad);
SegmentFormatter bf = new SegmentFormatter(getResources().getColor(R.color.red));
setupSegmentFormatter(bf);
mRelayPie.addSeries(b, bf);
}
if (untested > 0) {
Segment u = new Segment(getString(R.string.untested), untested);
SegmentFormatter uf = new SegmentFormatter(getResources().getColor(R.color.accent));
setupSegmentFormatter(uf);
mRelayPie.addSeries(u, uf);
}
}
mRelayPie.getBorderPaint().setColor(Color.TRANSPARENT);
mRelayPie.getBackgroundPaint().setColor(Color.TRANSPARENT);
}
Aggregations