}
}
}
protected void updateWidget() {
LocomotiveControlface locomotiveControl = AdHocRailway.getInstance()
.getLocomotiveControl();
if (myLocomotive == null)
return;
double speedInPercent = ((double) locomotiveControl
.getCurrentSpeed(myLocomotive))
/ ((double) myLocomotive.getLocomotiveType().getDrivingSteps());
if (speedInPercent > 0.9) {
speedBar.setForeground(new Color(255, 0, 0));
} else if (speedInPercent > 0.7) {
speedBar.setForeground(new Color(255, 255, 0));
} else {
speedBar.setForeground(new Color(0, 255, 0));
}
speedBar.setMinimum(0);
speedBar.setMaximum(myLocomotive.getLocomotiveType().getDrivingSteps());
speedBar.setValue(locomotiveControl.getCurrentSpeed(myLocomotive));
boolean functions[] = locomotiveControl.getFunctions(myLocomotive);
for (int i = 0; i < functions.length; i++) {
functionToggleButtons[i].setSelected(functions[i]);
}
switch (locomotiveControl.getDirection(myLocomotive)) {
case FORWARD:
directionButton.setIcon(createImageIcon("locomotives/forward.png"));
break;
case REVERSE:
directionButton.setIcon(createImageIcon("locomotives/back.png"));
break;
default:
directionButton.setIcon(createImageIcon("locomotives/forward.png"));
}
boolean locked = locomotiveControl.isLocked(myLocomotive);
lockButton.setSelected(locked);
if (locked) {
if (locomotiveControl.isLockedByMe(myLocomotive)) {
lockButton.setSelectedIcon(ImageTools
.createImageIcon("locomotives/locked_by_me.png"));
} else {
lockButton.setSelectedIcon(ImageTools