コード例 #1
0
ファイル: Stereotype.java プロジェクト: 51ttw/plantuml
 public Stereotype(
     String label,
     double radius,
     UFont circledFont,
     boolean automaticPackageStyle,
     IHtmlColorSet htmlColorSet) {
   if (label == null) {
     throw new IllegalArgumentException();
   }
   if (label.startsWith("<<") == false || label.endsWith(">>") == false) {
     throw new IllegalArgumentException(label);
   }
   this.automaticPackageStyle = automaticPackageStyle;
   this.radius = radius;
   this.circledFont = circledFont;
   final Matcher mCircleChar = circleChar.matcher(label);
   final Matcher mCircleSprite = circleSprite.matcher(label);
   if (mCircleSprite.find()) {
     if (StringUtils.isNotEmpty(mCircleSprite.group(3))) {
       this.label = "<<" + mCircleSprite.group(3) + ">>";
     } else {
       this.label = null;
     }
     final String colName = mCircleSprite.group(2);
     final HtmlColor col = htmlColorSet.getColorIfValid(colName);
     this.htmlColor = col == null ? HtmlColorUtils.BLACK : col;
     this.sprite = mCircleSprite.group(1);
     this.character = '\0';
   } else if (mCircleChar.find()) {
     if (StringUtils.isNotEmpty(mCircleChar.group(3))) {
       this.label = "<<" + mCircleChar.group(3) + ">>";
     } else {
       this.label = null;
     }
     final String colName = mCircleChar.group(2);
     this.htmlColor = htmlColorSet.getColorIfValid(colName);
     this.character = mCircleChar.group(1).charAt(0);
     this.sprite = null;
   } else {
     this.label = label;
     this.character = '\0';
     this.htmlColor = null;
     this.sprite = null;
   }
 }
コード例 #2
0
  public EntityImageBlock(
      IEntity entity, Rose rose, ISkinParam param, Collection<Link> links, FontParam titleParam) {
    this.entity = entity;
    this.param = param;
    this.rose = rose;
    this.links = links;

    if (StringUtils.isNotEmpty(entity.getDisplay2())) {
      this.name =
          TextBlockUtils.create(
              entity.getDisplay2(),
              new FontConfiguration(param.getFont(titleParam, null), HtmlColor.BLACK),
              HorizontalAlignement.CENTER,
              param);
    } else {
      this.name = null;
    }
  }
コード例 #3
0
  public CommandExecutionResult execute(List<String> lines) {
    StringUtils.trim(lines, false);
    final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());

    final IEntity entity1 = CommandLinkActivity.getEntity(getSystem(), line0, true);

    if (line0.get("STEREOTYPE", 0) != null) {
      entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
    }
    if (line0.get("BACKCOLOR", 0) != null) {
      entity1.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(line0.get("BACKCOLOR", 0)));
    }
    final StringBuilder sb = new StringBuilder();

    final String desc0 = line0.get("DESC", 0);
    Url urlActivity = null;
    if (StringUtils.isNotEmpty(desc0)) {
      final UrlBuilder urlBuilder =
          new UrlBuilder(getSystem().getSkinParam().getValue("topurl"), true);
      urlActivity = urlBuilder.getUrl(desc0);
      if (urlActivity == null) {
        sb.append(desc0);
        sb.append("\\n");
      }
    }
    for (int i = 1; i < lines.size() - 1; i++) {
      if (i == 1 && urlActivity == null) {
        final UrlBuilder urlBuilder =
            new UrlBuilder(getSystem().getSkinParam().getValue("topurl"), true);
        urlActivity = urlBuilder.getUrl(lines.get(i));
        if (urlActivity != null) {
          continue;
        }
      }
      sb.append(lines.get(i));
      if (i < lines.size() - 2) {
        sb.append("\\n");
      }
    }

    final List<String> lineLast =
        StringUtils.getSplit(Pattern.compile(getPatternEnd()), lines.get(lines.size() - 1));
    if (StringUtils.isNotEmpty(lineLast.get(0))) {
      if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
        sb.append("\\n");
      }
      sb.append(lineLast.get(0));
    }

    final String display = sb.toString();
    final Code code = Code.of(lineLast.get(1) == null ? display : lineLast.get(1));

    String partition = null;
    if (lineLast.get(3) != null) {
      partition = lineLast.get(3);
      partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
    }
    if (partition != null) {
      getSystem()
          .getOrCreateGroup(
              Code.of(partition),
              StringUtils.getWithNewlines(partition),
              null,
              GroupType.PACKAGE,
              null);
    }
    final IEntity entity2 =
        getSystem().createLeaf(code, StringUtils.getWithNewlines(display), LeafType.ACTIVITY);
    if (partition != null) {
      getSystem().endGroup();
    }
    if (urlActivity != null) {
      entity2.addUrl(urlActivity);
    }

    if (lineLast.get(2) != null) {
      entity2.setStereotype(new Stereotype(lineLast.get(2)));
    }
    if (lineLast.get(4) != null) {
      entity2.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(lineLast.get(4)));
    }

    if (entity1 == null || entity2 == null) {
      return CommandExecutionResult.error("No such entity");
    }

    final String arrow = StringUtils.manageArrowForCuca(line0.get("ARROW", 0));
    final int lenght = arrow.length() - 1;

    final String linkLabel = line0.get("BRACKET", 0);

    LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
    if (line0.get("ARROW", 0).contains(".")) {
      type = type.getDotted();
    }
    Link link = new Link(entity1, entity2, type, linkLabel, lenght);
    final Direction direction = StringUtils.getArrowDirection(line0.get("ARROW", 0));
    if (direction == Direction.LEFT || direction == Direction.UP) {
      link = link.getInv();
    }

    if (line0.get("URL", 0) != null) {
      final UrlBuilder urlBuilder =
          new UrlBuilder(getSystem().getSkinParam().getValue("topurl"), true);
      final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
      link.setUrl(urlLink);
    }

    getSystem().addLink(link);

    return CommandExecutionResult.ok();
  }