static EntityType getTypeIfExisting(ActivityDiagram system, String code) {
   if (system.entityExist(code)) {
     final IEntity ent = system.entities().get(code);
     if (ent.getType() == EntityType.BRANCH) {
       return EntityType.BRANCH;
     }
   }
   return EntityType.ACTIVITY;
 }
  public void drawU(
      UGraphic ug,
      double xTheoricalPosition,
      double yTheoricalPosition,
      double marginWidth,
      double marginHeight) {
    final Dimension2D dim = getDimension(ug.getStringBounder());

    final double widthTotal = dim.getWidth() + 2 * marginWidth;
    final double heightTotal = dim.getHeight() + 2 * marginHeight;
    final URectangle rect = new URectangle(widthTotal, heightTotal);

    // if (entity.getParent() == null) {
    if (entity.getType() != EntityType.GROUP) {
      ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.classBackground));
      ug.getParam().setColor(rose.getHtmlColor(param, ColorParam.classBorder));
      ug.draw(xTheoricalPosition - marginWidth, yTheoricalPosition - marginHeight, rect);
      // name.drawU(ug, xTheoricalPosition + margin, yTheoricalPosition + margin);
      name.drawU(ug, xTheoricalPosition + 0, yTheoricalPosition + 0);
    } else {
      // final Frame frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()),
      // Color.BLACK, param
      // .getFont(FontParam.CLASS), rose.getHtmlColor(param, ColorParam.classBorder).getColor());
      final Frame frame = new Frame(entity.getDisplay2(), param);

      ug.getParam().setBackcolor(rose.getHtmlColor(param, ColorParam.background));
      ug.getParam().setColor(null);
      ug.draw(xTheoricalPosition - marginWidth, yTheoricalPosition - marginWidth, rect);

      final double oldX = ug.getTranslateX();
      final double oldY = ug.getTranslateY();
      ug.translate(xTheoricalPosition - marginWidth, yTheoricalPosition - marginHeight);
      frame.drawU(ug, new Area(new Dimension2DDouble(widthTotal, heightTotal)), null);
      // ug.translate(-xTheoricalPosition + marginWidth,
      // -yTheoricalPosition + marginHeight);
      ug.setTranslate(oldX, oldY);

      // playField.drawInternal(UGraphicUtils.translate(ug, xTheoricalPosition + margin,
      // yTheoricalPosition +
      // margin
      // + frame.getPreferredHeight(ug.getStringBounder())));
      playField.drawInternal(
          UGraphicUtils.translate(
              ug,
              xTheoricalPosition + 0,
              yTheoricalPosition + 0 + frame.getPreferredHeight(ug.getStringBounder())));
    }
  }
  private void initPlayField(StringBounder stringBounder) {
    if (playField != null || entity.getParent() == null || entity.getType() != EntityType.GROUP) {
      return;
    }
    this.playField = new PlayField(param);
    final Collection<IEntity> entities = new ArrayList<IEntity>();
    for (IEntity ent : entity.getParent().entities().values()) {
      // entities.add(EntityUtils.withNoParent(ent));
      entities.add(ent);
    }
    playField.initInternal(entities, links, stringBounder);

    // this.frame = new Frame(StringUtils.getWithNewlines(entity.getDisplay()), Color.BLACK, param
    // .getFont(FontParam.CLASS), rose.getHtmlColor(param, ColorParam.classBorder).getColor());
    this.frame = new Frame(entity.getDisplay2(), param);
  }