Ejemplo n.º 1
0
 private void setStatusButton(int priority, int state) {
   String tooltip = Resources.get("Standard Priority");
   ImageIcon icon = standardIcon;
   if (state == TrainModel.STATE_STOPPED) {
     icon = stoppedIcon;
     tooltip = Resources.get("Stopped");
   } else {
     switch (priority) {
       case TrainModel.PRIORITY_EXPRESS:
         icon = expressIcon;
         tooltip = Resources.get("Express Priority");
         break;
       case TrainModel.PRIORITY_NORMAL:
         icon = standardIcon;
         tooltip = Resources.get("Standard Priority");
         break;
       case TrainModel.PRIORITY_SLOW:
         icon = slowIcon;
         tooltip = Resources.get("Slow Priority");
         break;
       default:
         throw new IllegalStateException();
     }
   }
   statusJButton.setToolTipText(tooltip);
   statusJButton.setIcon(icon);
 }
Ejemplo n.º 2
0
  private void setStatusLabel(TrainModel trainModel) {
    if (trainModel == null) {
      statusJLabel.setIcon((Icon) null);
      statusJLabel.setToolTipText("");
      return;
    }

    switch (trainModel.getState()) {
      case TrainModel.STATE_RUNNABLE:
        if (trainModel.isBlocked()) {
          statusJLabel.setIcon(blockedIcon);
          statusJLabel.setToolTipText(Resources.get("Track blocked"));
        } else if (trainModel.getTrainMotionModel().isLost()) {
          statusJLabel.setIcon(noRouteIcon);
          statusJLabel.setToolTipText(Resources.get("No route to destination"));
        } else if (trainModel.getTrainMotionModel().isOutOfWater()) {
          statusJLabel.setIcon(outOfWaterIcon);
          statusJLabel.setToolTipText(Resources.get("No water"));
        } else {
          statusJLabel.setIcon((Icon) null);
          statusJLabel.setToolTipText("");
        }
        break;
      case TrainModel.STATE_LOADING:
        statusJLabel.setIcon(loadingIcon);
        statusJLabel.setToolTipText(Resources.get("Loading"));
        break;
      case TrainModel.STATE_UNLOADING:
        statusJLabel.setIcon(unloadingIcon);
        statusJLabel.setToolTipText(Resources.get("Unloading"));
        break;
      default:
        statusJLabel.setIcon((Icon) null);
        statusJLabel.setToolTipText("");
        break;
    }
  }