예제 #1
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;
 }
예제 #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;
 }
  @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();
  }
  @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);
  }