using new energy interface

This commit is contained in:
fros4943 2008-10-28 15:36:25 +00:00
parent 6e9e29f758
commit ee655cf8c4

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: VisBattery.java,v 1.4 2007/01/09 09:49:24 fros4943 Exp $
* $Id: VisBattery.java,v 1.5 2008/10/28 15:36:25 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -93,8 +93,9 @@ public class VisBattery extends Visualizer2D {
}
public Color[] getColorOf(Mote mote) {
if (mote.getState() == Mote.State.DEAD)
if (mote.getState() == Mote.State.DEAD) {
return new Color[]{Color.RED};
}
Battery battery = mote.getInterfaces().getBattery();
if (battery == null) {
@ -105,13 +106,13 @@ public class VisBattery extends Visualizer2D {
return new Color[]{Color.BLUE};
}
double currentEnergy = battery.getCurrentEnergy();
double currentEnergy = battery.getEnergyLeftRatio();
if (currentEnergy < 0.0) {
return new Color[]{Color.RED};
}
int grayValue = (int) (255 * (currentEnergy / battery.getInitialEnergy()));
int grayValue = (int) (255 * currentEnergy);
return new Color[]{new Color(grayValue, grayValue, grayValue)};
}