public Color[] getColorOf(Mote mote) {
if (mote.getState() == Mote.State.DEAD)
return new Color[]{Color.RED};
Battery battery = mote.getInterfaces().getBattery();
if (battery == null) {
return new Color[]{Color.BLUE};
}
if (battery.hasInfiniteEnergy()) {
return new Color[]{Color.BLUE};
}
double currentEnergy = battery.getCurrentEnergy();
if (currentEnergy < 0.0) {
return new Color[]{Color.RED};
}
int grayValue = (int) (255 * (currentEnergy / battery.getInitialEnergy()));
return new Color[]{new Color(grayValue, grayValue, grayValue)};
}