Example #1
0
    @Override
    public void iwMenuItemSelected(SelectionEvent selectionEvent) {
      hideEvolvingMenu();
      EvolutionTypeIWMenuItem menuItem = (EvolutionTypeIWMenuItem) selectionEvent.getSource();
      Morph selectedMorph =
          UIModel.getUiModel().getSelectionModel().getSelectedMorphs().values().iterator().next();
      Evolving transformBehavior = new Evolving(selectedMorph, menuItem.getEvolutionType());
      selectedMorph.getActivationIsolatedBehaviorList().add(transformBehavior);

      // Remove iwselections
      UIModel.getUiModel().getSelectionModel().removeAllIWMenuItemsFromSelection();
    }
Example #2
0
  /** Shows the menu items for evolution mecanism. */
  private void showEvolvingMenu() {
    IWMenu inWorldMenu = new IWMenu();
    Morph m =
        UIModel.getUiModel().getSelectionModel().getSelectedMorphs().values().iterator().next();
    for (EvolutionType type : m.getClass().getAnnotation(MorphInfo.class).possibleEvolutions()) {
      EvolutionTypeIWMenuItem menuItem = new EvolutionTypeIWMenuItem(type);
      inWorldMenu.getMenuItems().put(menuItem.getId(), menuItem);
    }
    UIModel.getUiModel().setCurrentInWorldMenu(inWorldMenu);
    UIModel.getUiModel().setUiState(UIState.EVOLVING);

    inWorldMenuListener = new MenuListener();
    UIModel.getUiModel().getSelectionModel().addSelectionListener(inWorldMenuListener);
  }