コード例 #1
0
  public ComponentRoseReference(
      FontConfiguration font,
      SymbolContext symbolContext,
      FontConfiguration header,
      Display stringsToDisplay,
      HorizontalAlignment position,
      ISkinSimple spriteContainer,
      HtmlColor background) {
    super(
        stringsToDisplay.subList(1, stringsToDisplay.size()),
        font,
        HorizontalAlignment.LEFT,
        4,
        4,
        4,
        spriteContainer,
        0,
        false,
        null,
        null);
    this.position = position;
    this.symbolContext = symbolContext;
    this.background = background;

    this.textHeader =
        stringsToDisplay.subList(0, 1).create(header, HorizontalAlignment.LEFT, spriteContainer);
  }
コード例 #2
0
 private Display getLabelOfMessage(MessageExo message) {
   if (message.getMessageNumber() == null) {
     return message.getLabel();
   }
   Display result = Display.empty();
   result = result.add(new MessageNumber(message.getMessageNumber()));
   result = result.addAll(message.getLabel());
   return result;
 }
コード例 #3
0
 protected final TextBlock getTextBlock(Display display) {
   if (Display.isNull(display)) {
     return null;
   }
   final ISkinParam skinParam = getSkinParam();
   final UFont font = skinParam.getFont(FontParam.ACTIVITY_ARROW, null, false);
   final HtmlColor color = rose.getFontColor(skinParam, FontParam.ACTIVITY_ARROW);
   final FontConfiguration fontConfiguration =
       new FontConfiguration(
           font, color, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
   return display.create(
       fontConfiguration, HorizontalAlignment.LEFT, this, CreoleMode.SIMPLE_LINE);
 }
コード例 #4
0
ファイル: TimeScale.java プロジェクト: vamsirajendra/plantuml
  public void draw(UGraphic ug, final double x, double y) {
    final StringBounder stringBounder = ug.getStringBounder();
    final double monthHeight = getMonthHeight(stringBounder);
    final double caseWidth = getCaseWidth(stringBounder);
    final double caseHeight = getCaseHeight(stringBounder);
    final int nb = getNbCase();

    ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
    ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, monthHeight));
    final Instant end = project.getEnd();

    Month printed = null;

    double curx = x;
    for (Instant cur = project.getStart();
        cur.compareTo(end) <= 0;
        cur = cur.next(project.getDayClose())) {
      final Day d = cur.getDay();
      if (printed == null || d.getMonth() != printed) {
        ug.apply(new UTranslate(curx, y)).draw(new ULine(0, monthHeight));
        printed = d.getMonth();
        final TextBlock b =
            Display.create(printed.name())
                .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
        final Dimension2D dim = b.calculateDimension(stringBounder);
        b.drawU(ug.apply(new UTranslate(curx, (y + (monthHeight - dim.getHeight()) / 2))));
      }
      curx += caseWidth;
    }

    curx = x;
    y += monthHeight;
    ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, caseHeight));

    for (Instant cur = project.getStart();
        cur.compareTo(end) <= 0;
        cur = cur.next(project.getDayClose())) {
      final Day d = cur.getDay();
      final TextBlock b =
          Display.create("" + d.getNumDay())
              .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
      final Dimension2D dim = b.calculateDimension(stringBounder);
      b.drawU(
          ug.apply(
              new UTranslate(
                  (curx + (caseWidth - dim.getWidth()) / 2),
                  (y + (caseHeight - dim.getHeight()) / 2))));
      curx += caseWidth;
      ug.apply(new UTranslate(curx, y)).draw(new ULine(0, caseHeight));
    }
  }
コード例 #5
0
  @Override
  protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
    final HtmlColor color =
        diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));

    String test = arg.get("TEST", 0);
    if (test.length() == 0) {
      test = null;
    }
    diagram.startIf(
        Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color);

    return CommandExecutionResult.ok();
  }
コード例 #6
0
ファイル: Display.java プロジェクト: mar9000/plantuml
 public Display removeEmptyColumns() {
   if (firstColumnRemovable() == false) {
     return this;
   }
   final Display result = new Display(this);
   do {
     for (int i = 0; i < result.size(); i++) {
       final CharSequence s = result.get(i);
       if (s.length() > 0) {
         result.display.set(i, s.toString().substring(1));
       }
     }
   } while (result.firstColumnRemovable());
   return result;
 }
コード例 #7
0
  private CommandExecutionResult executeArgSpecial2(
      AbstractClassOrObjectDiagram diagram, RegexResult arg) {
    final Code clName1 = Code.of(arg.get("COUPLE2", 0));
    final Code clName2 = Code.of(arg.get("COUPLE2", 1));
    if (diagram.leafExist(clName1) == false) {
      return CommandExecutionResult.error("No class " + clName1);
    }
    if (diagram.leafExist(clName2) == false) {
      return CommandExecutionResult.error("No class " + clName2);
    }

    final Code ent1 =
        Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1)));
    final IEntity cl1 = diagram.getOrCreateLeaf(ent1, null, null);

    final LinkType linkType = getLinkType(arg);
    final Display label = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
    // final int length = getQueueLength(arg);
    // final String weight = arg.get("HEADER").get(0);

    final boolean result = diagram.associationClass(2, clName1, clName2, cl1, linkType, label);
    if (result == false) {
      return CommandExecutionResult.error("Cannot have more than 2 assocications");
    }

    return CommandExecutionResult.ok();
  }
コード例 #8
0
  public EntityImageUseCase(ILeaf entity, ISkinParam skinParam) {
    super(entity, skinParam);
    final Stereotype stereotype = entity.getStereotype();

    final TextBlock tmp =
        new BodyEnhanced(
            entity.getDisplay(),
            FontParam.USECASE,
            skinParam,
            HorizontalAlignment.CENTER,
            stereotype,
            true,
            false);

    if (stereotype == null || stereotype.getLabel() == null) {
      this.desc = tmp;
    } else {
      final TextBlock stereo =
          TextBlockUtils.create(
              Display.getWithNewlines(stereotype.getLabel()),
              new FontConfiguration(
                  SkinParamUtils.getFont(getSkinParam(), FontParam.ACTOR_STEREOTYPE, stereotype),
                  SkinParamUtils.getFontColor(getSkinParam(), FontParam.ACTOR_STEREOTYPE, null),
                  getSkinParam().getHyperlinkColor()),
              HorizontalAlignment.CENTER,
              skinParam);
      this.desc = TextBlockUtils.mergeTB(stereo, tmp, HorizontalAlignment.CENTER);
    }
    this.url = entity.getUrl99();
  }
コード例 #9
0
  private TextBlockBackcolored addTitle(TextBlockBackcolored original) {
    final Display title = diagram.getTitle();
    if (Display.isNull(title)) {
      return original;
    }
    final TextBlock text =
        title.create(
            new FontConfiguration(
                getFont(FontParam.TITLE),
                getFontColor(FontParam.TITLE, null),
                diagram.getSkinParam().getHyperlinkColor(),
                diagram.getSkinParam().useUnderlineForHyperlink()),
            HorizontalAlignment.CENTER,
            diagram.getSkinParam());

    return DecorateEntityImage.addTop(original, text, HorizontalAlignment.CENTER);
  }
コード例 #10
0
ファイル: AbstractPSystem.java プロジェクト: Zir0-93/plantuml
 public DisplayPositionned getTitle() {
   if (source == null) {
     return new DisplayPositionned(
         Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
   }
   return new DisplayPositionned(
       source.getTitle(), HorizontalAlignment.CENTER, VerticalAlignment.TOP);
 }
コード例 #11
0
ファイル: CommandHeader.java プロジェクト: mar9000/plantuml
 @Override
 protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
   final String align = arg.get(0);
   if (align != null) {
     diagram.setHeaderAlignment(HorizontalAlignment.valueOf(align.toUpperCase()));
   }
   diagram.setHeader(Display.getWithNewlines(arg.get(1)));
   return CommandExecutionResult.ok();
 }
コード例 #12
0
  private TextBlockBackcolored addLegend(TextBlockBackcolored original) {
    final Display legend = diagram.getLegend();
    if (Display.isNull(legend)) {
      return original;
    }
    final TextBlock text = EntityImageLegend.create(legend, diagram.getSkinParam());

    return DecorateEntityImage.add(
        original, text, diagram.getLegendAlignment(), diagram.getLegendVerticalAlignment());
  }
コード例 #13
0
 private void manage(UGraphic ug, double x, double y, int n, String last, double pendingX) {
   final double width = n * dayWidth - pendingX;
   ug.apply(new UTranslate(x + pendingX, y)).draw(new URectangle(width, getHeight()));
   final TextBlock b =
       Display.create(last)
           .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
   final Dimension2D dimText = b.calculateDimension(ug.getStringBounder());
   final double diffX = width - dimText.getWidth();
   final double diffY = getHeight() - dimText.getHeight();
   b.drawU(ug.apply(new UTranslate((x + pendingX + diffX / 2), (y + diffY / 2))));
 }
コード例 #14
0
  @Override
  public CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
    lines = lines.trim(false);
    final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
    final RegexResult lineLast = getPatternEnd2().matcher(lines.getLast499().toString());

    // System.err.println("line0=" + line0);
    // System.err.println("linesLast=" + lineLast);

    //
    // final HtmlColor color =
    // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));

    final String test = line0.get("TEST1", 0);
    Display testDisplay = Display.getWithNewlines(test);
    for (CharSequence s : lines.subExtract(1, 1)) {
      testDisplay = testDisplay.add(s);
    }
    final String trailTest = lineLast.get("TEST1", 0);
    if (StringUtils.isEmpty(trailTest) == false) {
      testDisplay = testDisplay.add(trailTest);
    }

    Display yes = Display.NULL; // Display.getWithNewlines("arg.getLazzy(\"WHEN\", 0)");
    final Display out = Display.NULL; // Display.getWithNewlines("arg.getLazzy(\"OUT\", 0)");
    final HtmlColor linkColor =
        null; // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR",
    // 0));
    final Display linkLabel = Display.NULL; // Display.getWithNewlines("arg.get(\"LABEL\", 0)");
    final List<Display> splitted =
        testDisplay.splitMultiline(
            MyPattern.cmpile("\\)[%s]*(is|equals?)[%s]*\\(", Pattern.CASE_INSENSITIVE));
    if (splitted.size() == 2) {
      testDisplay = splitted.get(0);
      yes = splitted.get(1);
    }

    return diagram.repeatWhile(testDisplay, yes, out, linkLabel, linkColor);
  }
コード例 #15
0
ファイル: GanttDiagram2.java プロジェクト: 51ttw/plantuml
	private Row getMainRow() {
		final List<Task> tasks = project.getTasks();
		final List<Row> rows = new ArrayList<Row>();
		for (Task t : tasks) {
			final String text = t.getCode();
			final TextBlock label = Display.create(text).create(fontConfig, HorizontalAlignment.LEFT,
					new SpriteContainerEmpty());
			rows.add(new RowSimple((Day) t.getStart(), (Day) t.getEnd(), HtmlColorUtils.BLACK, TextBlockUtils
					.withMargin(label, 3, 3)));
		}
		final Row row = RowUtils.merge(rows);
		return row;
	}
コード例 #16
0
  @Override
  public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
    StringUtils.trim(lines, false);
    final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
    final List<String> lineLast =
        StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.get(lines.size() - 1));

    final HtmlColor color = HtmlColorUtils.getColorIfValid(line0.get("COLOR", 0));

    final String test = line0.get("TEST", 0);
    Display testDisplay = Display.getWithNewlines(test);
    for (int i = 1; i < lines.size() - 1; i++) {
      testDisplay = testDisplay.add(lines.get(i));
    }
    final String trailTest = lineLast.get(0);
    if (StringUtils.isEmpty(trailTest) == false) {
      testDisplay = testDisplay.add(trailTest);
    }

    diagram.startIf(testDisplay, Display.getWithNewlines(lineLast.get(1)), color);
    return CommandExecutionResult.ok();
  }
コード例 #17
0
  public void draw(UGraphic ug, double x, double y) {

    final StringBounder stringBounder = ug.getStringBounder();

    ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
    ug.apply(new UTranslate(x, y))
        .draw(new URectangle(getWidth(stringBounder), getHeight(stringBounder)));

    for (Item it : project.getValidItems()) {
      final TextBlock b =
          Display.create("" + it.getCode())
              .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
      final Dimension2D dim = b.calculateDimension(stringBounder);
      b.drawU(ug.apply(new UTranslate(x, y)));
      y += dim.getHeight();
      ug.apply(new UTranslate(x, y)).draw(new ULine(getWidth(stringBounder), 0));
    }
  }
コード例 #18
0
 private static Display breakLines(
     Display texts,
     FontConfiguration fontConfiguration,
     SpriteContainer spriteContainer,
     double maxWidth) {
   if (texts.size() != 1) {
     return texts;
   }
   final CharSequence s = texts.get(0);
   Display result = Display.empty();
   final int nb = s.length() / 2;
   result = result.add(s.subSequence(0, nb));
   result = result.add(s.subSequence(nb + 1, s.length()));
   return result;
 }
コード例 #19
0
  private TextBlockBackcolored addHeaderAndFooter(TextBlockBackcolored original) {
    final Display footer = diagram.getFooter();
    final Display header = diagram.getHeader();
    if (Display.isNull(footer) && Display.isNull(header)) {
      return original;
    }
    final TextBlock textFooter =
        Display.isNull(footer)
            ? null
            : footer.create(
                new FontConfiguration(
                    getFont(FontParam.FOOTER),
                    getFontColor(FontParam.FOOTER, null),
                    diagram.getSkinParam().getHyperlinkColor(),
                    diagram.getSkinParam().useUnderlineForHyperlink()),
                diagram.getFooterAlignment(),
                diagram.getSkinParam());
    final TextBlock textHeader =
        Display.isNull(header)
            ? null
            : header.create(
                new FontConfiguration(
                    getFont(FontParam.HEADER),
                    getFontColor(FontParam.HEADER, null),
                    diagram.getSkinParam().getHyperlinkColor(),
                    diagram.getSkinParam().useUnderlineForHyperlink()),
                diagram.getHeaderAlignment(),
                diagram.getSkinParam());

    return new DecorateEntityImage(
        original,
        textHeader,
        diagram.getHeaderAlignment(),
        textFooter,
        diagram.getFooterAlignment());
  }
コード例 #20
0
ファイル: PSystemCreole.java プロジェクト: thetric/plantuml
  public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat)
      throws IOException {
    final Display display = Display.create(lines);
    final UFont font = new UFont("Serif", Font.PLAIN, 14);
    final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font);
    final Sheet sheet =
        new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, null, CreoleMode.FULL)
            .createSheet(display);
    final SheetBlock1 sheetBlock = new SheetBlock1(sheet, 0, 0);

    final ImageBuilder builder =
        new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 0, 0, null, false);
    builder.setUDrawable(sheetBlock);
    return builder.writeImageTOBEMOVED(fileFormat, os);

    // final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock);
    // final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1, dim, null,
    // false);
    // // sheetBlock.drawU(ug.apply(new UTranslate(0, 10)));
    // sheetBlock.drawU(ug);
    // ug.writeImageTOBEMOVED(os, null, 96);
    // return new ImageDataSimple(dim);
  }
コード例 #21
0
ファイル: Display.java プロジェクト: 51ttw/plantuml
 private static List<CharSequence> manageEmbededDiagrams2(
     final Collection<? extends CharSequence> strings) {
   final List<CharSequence> result = new ArrayList<CharSequence>();
   final Iterator<? extends CharSequence> it = strings.iterator();
   while (it.hasNext()) {
     CharSequence s = it.next();
     if (s != null && StringUtils.trin(s.toString()).equals("{{")) {
       final List<CharSequence> other = new ArrayList<CharSequence>();
       other.add("@startuml");
       while (it.hasNext()) {
         final CharSequence s2 = it.next();
         if (s2 != null && StringUtils.trin(s2.toString()).equals("}}")) {
           break;
         }
         other.add(s2);
       }
       other.add("@enduml");
       s = new EmbededDiagram(Display.create(other));
     }
     result.add(s);
   }
   return result;
 }
コード例 #22
0
ファイル: GrayComponent.java プロジェクト: mar9000/plantuml
  @Override
  protected void drawInternalU(UGraphic ug, Area area) {
    final StringBounder stringBounder = ug.getStringBounder();
    ug =
        ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY))
            .apply(new UChangeColor(HtmlColorUtils.BLACK));
    ug.draw(new URectangle(getPreferredWidth(stringBounder), getPreferredHeight(stringBounder)));

    final String n = type.name();
    final int split = 9;
    final List<String> strings = new ArrayList<String>();
    for (int i = 0; i < n.length(); i += split) {
      strings.add(n.substring(i, Math.min(i + split, n.length())));
    }

    final TextBlock textBlock =
        TextBlockUtils.create(
            Display.create(strings),
            new FontConfiguration(NORMAL, HtmlColorUtils.BLACK, HtmlColorUtils.BLUE),
            HorizontalAlignment.LEFT,
            new SpriteContainerEmpty());
    textBlock.drawU(ug);
  }
コード例 #23
0
  private CommandExecutionResult executePackageLink(
      AbstractClassOrObjectDiagram diagram, RegexResult arg) {
    final IEntity cl1 =
        diagram.getGroup(
            Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1))));
    final IEntity cl2 =
        diagram.getGroup(
            Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1))));

    final LinkType linkType = getLinkType(arg);
    final Direction dir = getDirection(arg);
    final int queue;
    if (dir == Direction.LEFT || dir == Direction.RIGHT) {
      queue = 1;
    } else {
      queue = getQueueLength(arg);
    }

    final Display labelLink = Display.getWithNewlines(arg.get("LABEL_LINK", 0));
    final String firstLabel = arg.get("FIRST_LABEL", 0);
    final String secondLabel = arg.get("SECOND_LABEL", 0);
    final Link link =
        new Link(
            cl1,
            cl2,
            linkType,
            labelLink,
            queue,
            firstLabel,
            secondLabel,
            diagram.getLabeldistance(),
            diagram.getLabelangle());

    diagram.resetPragmaLabel();
    addLink(diagram, link, arg.get("HEADER", 0));
    return CommandExecutionResult.ok();
  }
コード例 #24
0
  @Override
  protected CommandExecutionResult executeArg(StateDiagram diagram, RegexResult arg) {
    final String ent1 = arg.get("ENT1", 0);
    final String ent2 = arg.get("ENT2", 0);

    final IEntity cl1 = getEntityStart(diagram, ent1);
    if (cl1 == null) {
      return CommandExecutionResult.error(
          "The state "
              + ent1
              + " has been created in a concurrent state : it cannot be used here.");
    }
    final IEntity cl2 = getEntityEnd(diagram, ent2);
    if (cl2 == null) {
      return CommandExecutionResult.error(
          "The state "
              + ent2
              + " has been created in a concurrent state : it cannot be used here.");
    }

    if (arg.get("ENT1", 1) != null) {
      cl1.setStereotype(new Stereotype(arg.get("ENT1", 1)));
    }
    if (arg.get("ENT1", 2) != null) {
      cl1.setSpecificColorTOBEREMOVED(
          ColorType.BACK,
          diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("ENT1", 2)));
    }
    if (arg.get("ENT2", 1) != null) {
      cl2.setStereotype(new Stereotype(arg.get("ENT2", 1)));
    }
    if (arg.get("ENT2", 2) != null) {
      cl2.setSpecificColorTOBEREMOVED(
          ColorType.BACK,
          diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("ENT2", 2)));
    }

    String queue = arg.get("ARROW_BODY1", 0) + arg.get("ARROW_BODY2", 0);
    final Direction dir = getDirection(arg);

    if (dir == Direction.LEFT || dir == Direction.RIGHT) {
      queue = "-";
    }

    final int lenght = queue.length();

    final boolean crossStart = arg.get("ARROW_CROSS_START", 0) != null;
    final boolean circleEnd = arg.get("ARROW_CIRCLE_END", 0) != null;
    final LinkType linkType =
        new LinkType(
            circleEnd ? LinkDecor.ARROW_AND_CIRCLE : LinkDecor.ARROW,
            crossStart ? LinkDecor.CIRCLE_CROSS : LinkDecor.NONE);

    Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(arg.get("LABEL", 0)), lenght);
    if (dir == Direction.LEFT || dir == Direction.UP) {
      link = link.getInv();
    }
    CommandLinkClass.applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
    diagram.addLink(link);

    return CommandExecutionResult.ok();
  }
コード例 #25
0
ファイル: CommandTitle.java プロジェクト: 51ttw/plantuml
 @Override
 protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
   diagram.setTitle(Display.getWithNewlines(arg.get(0)));
   return CommandExecutionResult.ok();
 }
コード例 #26
0
 public Display getTitle() {
   if (source == null) {
     return Display.empty();
   }
   return source.getTitle();
 }
コード例 #27
0
  @Override
  protected CommandExecutionResult executeArg(
      AbstractClassOrObjectDiagram diagram, RegexResult arg) {
    Code ent1 = Code.of(arg.get("ENT1", 1));
    Code ent2 = Code.of(arg.get("ENT2", 1));
    if (ent1 == null) {
      return executeArgSpecial1(diagram, arg);
    }
    if (ent2 == null) {
      return executeArgSpecial2(diagram, arg);
    }
    ent1 = ent1.eventuallyRemoveStartingAndEndingDoubleQuote();
    ent2 = ent2.eventuallyRemoveStartingAndEndingDoubleQuote();
    if (diagram.isGroup(ent1) && diagram.isGroup(ent2)) {
      return executePackageLink(diagram, arg);
    }

    final IEntity cl1 =
        diagram.isGroup(ent1)
            ? diagram.getGroup(
                Code.of(
                    StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1))))
            : diagram.getOrCreateLeaf(ent1, null, null);
    final IEntity cl2 =
        diagram.isGroup(ent2)
            ? diagram.getGroup(
                Code.of(
                    StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1))))
            : diagram.getOrCreateLeaf(ent2, null, null);

    if (arg.get("ENT1", 0) != null) {
      final LeafType type = LeafType.getLeafType(arg.get("ENT1", 0));
      if (type != LeafType.OBJECT) {
        ((ILeaf) cl1).muteToType(type, null);
      }
    }
    if (arg.get("ENT2", 0) != null) {
      final LeafType type = LeafType.getLeafType(arg.get("ENT2", 0));
      if (type != LeafType.OBJECT) {
        ((ILeaf) cl2).muteToType(type, null);
      }
    }
    if (arg.get("ENT1", 2) != null) {
      cl1.setStereotype(
          new Stereotype(
              arg.get("ENT1", 2),
              diagram.getSkinParam().getCircledCharacterRadius(),
              diagram.getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null)));
    }
    if (arg.get("ENT2", 2) != null) {
      cl2.setStereotype(
          new Stereotype(
              arg.get("ENT2", 2),
              diagram.getSkinParam().getCircledCharacterRadius(),
              diagram.getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null)));
    }

    final LinkType linkType = getLinkType(arg);
    final Direction dir = getDirection(arg);
    final int queue;
    if (dir == Direction.LEFT || dir == Direction.RIGHT) {
      queue = 1;
    } else {
      queue = getQueueLength(arg);
    }

    String firstLabel = arg.get("FIRST_LABEL", 0);
    String secondLabel = arg.get("SECOND_LABEL", 0);

    String labelLink = null;

    if (arg.get("LABEL_LINK", 0) != null) {
      labelLink = arg.get("LABEL_LINK", 0);
      if (firstLabel == null && secondLabel == null) {
        final Pattern p1 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)[%g]([^%g]+)[%g]$");
        final Matcher m1 = p1.matcher(labelLink);
        if (m1.matches()) {
          firstLabel = m1.group(1);
          labelLink =
              StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m1.group(2).trim()).trim();
          secondLabel = m1.group(3);
        } else {
          final Pattern p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
          final Matcher m2 = p2.matcher(labelLink);
          if (m2.matches()) {
            firstLabel = m2.group(1);
            labelLink =
                StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m2.group(2).trim()).trim();
            secondLabel = null;
          } else {
            final Pattern p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
            final Matcher m3 = p3.matcher(labelLink);
            if (m3.matches()) {
              firstLabel = null;
              labelLink =
                  StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m3.group(1).trim())
                      .trim();
              secondLabel = m3.group(2);
            }
          }
        }
      }
      labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink);
    }

    LinkArrow linkArrow = LinkArrow.NONE;
    if ("<".equals(labelLink)) {
      linkArrow = LinkArrow.BACKWARD;
      labelLink = null;
    } else if (">".equals(labelLink)) {
      linkArrow = LinkArrow.DIRECT_NORMAL;
      labelLink = null;
    } else if (labelLink != null && labelLink.startsWith("< ")) {
      linkArrow = LinkArrow.BACKWARD;
      labelLink = labelLink.substring(2).trim();
    } else if (labelLink != null && labelLink.startsWith("> ")) {
      linkArrow = LinkArrow.DIRECT_NORMAL;
      labelLink = labelLink.substring(2).trim();
    } else if (labelLink != null && labelLink.endsWith(" >")) {
      linkArrow = LinkArrow.DIRECT_NORMAL;
      labelLink = labelLink.substring(0, labelLink.length() - 2).trim();
    } else if (labelLink != null && labelLink.endsWith(" <")) {
      linkArrow = LinkArrow.BACKWARD;
      labelLink = labelLink.substring(0, labelLink.length() - 2).trim();
    }

    Link link =
        new Link(
            cl1,
            cl2,
            linkType,
            Display.getWithNewlines(labelLink),
            queue,
            firstLabel,
            secondLabel,
            diagram.getLabeldistance(),
            diagram.getLabelangle());

    if (dir == Direction.LEFT || dir == Direction.UP) {
      link = link.getInv();
    }
    link.setLinkArrow(linkArrow);
    applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);

    addLink(diagram, link, arg.get("HEADER", 0));

    return CommandExecutionResult.ok();
  }
コード例 #28
0
ファイル: CommandDivider.java プロジェクト: mar9000/plantuml
 @Override
 protected CommandExecutionResult executeArg(SequenceDiagram sequenceDiagram, List<String> arg) {
   final Display strings = Display.getWithNewlines(arg.get(0));
   sequenceDiagram.divider(strings);
   return CommandExecutionResult.ok();
 }