Ejemplo n.º 1
0
 @Override
 protected CommandExecutionResult executeArg(List<String> arg) {
   final String code;
   final String display;
   if (arg.get(1) == null) {
     if (StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)).length() == 0) {
       code = "##" + UniqueSequence.getValue();
       display = null;
     } else {
       code = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
       display = code;
     }
   } else {
     display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
     code = arg.get(1);
   }
   final Group currentPackage = getSystem().getCurrentGroup();
   // if (getSystem().entityExist(code)) {
   // return CommandExecutionResult.error("Package cannot have the same
   // name as an existing class");
   // }
   final Group p =
       getSystem().getOrCreateGroup(code, display, null, GroupType.PACKAGE, currentPackage);
   p.setBold(true);
   final String color = arg.get(2);
   if (color != null) {
     p.setBackColor(HtmlColor.getColorIfValid(color));
   }
   return CommandExecutionResult.ok();
 }
 @Override
 protected CommandExecutionResult executeArg(List<String> arg) {
   final EntityType type = EntityType.CIRCLE_INTERFACE;
   final String code;
   final String display;
   if (arg.get(1) == null) {
     code = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
     display = code;
   } else {
     display = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0));
     code = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(1));
   }
   final String stereotype = arg.get(2);
   // final Entity entity = getSystem().createEntity(code, display, type);
   final Entity entity = (Entity) getSystem().getOrCreateEntity(code, type);
   entity.setDisplay2(display);
   if (stereotype != null) {
     entity.setStereotype(
         new Stereotype(
             stereotype,
             getSystem().getSkinParam().getCircledCharacterRadius(),
             getSystem().getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null)));
   }
   return CommandExecutionResult.ok();
 }
Ejemplo n.º 3
0
 private Direction getDirection(RegexResult arg) {
   if (arg.get("AR_TO_RIGHT", 2) != null) {
     return StringUtils.getQueueDirection(arg.get("AR_TO_RIGHT", 2));
   }
   if (arg.get("AR_TO_LEFT", 3) != null) {
     return StringUtils.getQueueDirection(arg.get("AR_TO_LEFT", 3)).getInv();
   }
   return null;
 }
Ejemplo n.º 4
0
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {

    final UClip clip = clipContainer.getClip();
    if (clip != null && clip.isInside(x, y) == false) {
      return;
    }

    final UText shape = (UText) ushape;
    final FontConfiguration fontConfiguration = shape.getFontConfiguration();
    final UFont font = fontConfiguration.getFont();
    String fontWeight = null;
    if (fontConfiguration.containsStyle(FontStyle.BOLD) || font.isBold()) {
      fontWeight = "bold";
    }
    String fontStyle = null;
    if (fontConfiguration.containsStyle(FontStyle.ITALIC) || font.isItalic()) {
      fontStyle = "italic";
    }
    String textDecoration = null;
    if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
      textDecoration = "underline";
    } else if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
      textDecoration = "line-through";
    }

    String backColor = null;
    if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
      backColor =
          StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getExtendedColor()));
    }

    svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor())));
    String text = shape.getText();
    if (text.startsWith(" ")) {
      final double space = stringBounder.calculateDimension(font, " ").getWidth();
      while (text.startsWith(" ")) {
        x += space;
        text = text.substring(1);
      }
    }
    text = StringUtils.trin(text);
    final Dimension2D dim = stringBounder.calculateDimension(font, text);
    svg.text(
        text,
        x,
        y,
        font.getFamily(UFontContext.SVG),
        font.getSize(),
        fontWeight,
        fontStyle,
        textDecoration,
        dim.getWidth(),
        fontConfiguration.getAttributes(),
        backColor);
  }
Ejemplo n.º 5
0
 private BlocLines addOneSingleLineManageEmbedded2(IteratorCounter2 it, BlocLines lines) {
   final CharSequence linetoBeAdded = it.next();
   lines = lines.add2(linetoBeAdded);
   if (StringUtils.trimNoTrace(linetoBeAdded).equals("{{")) {
     while (it.hasNext()) {
       final CharSequence s = it.next();
       lines = lines.add2(s);
       if (StringUtils.trimNoTrace(s).equals("}}")) {
         return lines;
       }
     }
   }
   return lines;
 }
Ejemplo n.º 6
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();
  }
Ejemplo n.º 7
0
 static ImgValign getValign(String html) {
   final Matcher m = valignPattern.matcher(html);
   if (m.find() == false) {
     return ImgValign.TOP;
   }
   return ImgValign.valueOf(StringUtils.goUpperCase(m.group(1)));
 }
Ejemplo n.º 8
0
  @Override
  protected CommandExecutionResult executeArg(List<String> arg) {
    final String code = arg.get(2);
    if (getSystem().participants().containsKey(code)) {
      getSystem().putParticipantInLast(code);
      return CommandExecutionResult.ok();
    }

    List<String> strings = null;
    if (arg.get(1) != null) {
      strings = StringUtils.getWithNewlines(arg.get(1));
    }

    final ParticipantType type = ParticipantType.valueOf(arg.get(0).toUpperCase());
    final Participant participant = getSystem().createNewParticipant(type, code, strings);

    final String stereotype = arg.get(3);

    if (stereotype != null) {
      participant.setStereotype(
          new Stereotype(
              stereotype,
              getSystem().getSkinParam().getCircledCharacterRadius(),
              getSystem().getSkinParam().getFont(FontParam.CIRCLED_CHARACTER, null)));
    }
    participant.setSpecificBackcolor(arg.get(4));

    return CommandExecutionResult.ok();
  }
Ejemplo n.º 9
0
  private CommandExecutionResult executeArgSpecial2(RegexResult arg) {
    final String clName1 = arg.get("COUPLE2", 0);
    final String clName2 = arg.get("COUPLE2", 1);
    if (getSystem().leafExist(clName1) == false) {
      return CommandExecutionResult.error("No class " + clName1);
    }
    if (getSystem().leafExist(clName2) == false) {
      return CommandExecutionResult.error("No class " + clName2);
    }

    final String ent1 =
        StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1));
    final IEntity cl1 = getSystem().getOrCreateClass(ent1);

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

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

    return CommandExecutionResult.ok();
  }
Ejemplo n.º 10
0
 public Url initUrl() {
   if (this.size() == 0) {
     return null;
   }
   final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
   return urlBuilder.getUrl(StringUtils.trin(this.get(0).toString()));
 }
Ejemplo n.º 11
0
 private String concat(final List<? extends CharSequence> strings) {
   final StringBuilder sb = new StringBuilder();
   for (CharSequence s : strings) {
     sb.append(StringUtils.trin(s));
   }
   return sb.toString();
 }
Ejemplo n.º 12
0
 @Override
 protected CommandExecutionResult executeArg(SequenceDiagram diagram, List<String> arg) {
   final LifeEventType type = LifeEventType.valueOf(StringUtils.goUpperCase(arg.get(0)));
   final Participant p =
       diagram.getOrCreateParticipant(
           StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(1)));
   final HtmlColor backColor =
       diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(2));
   final HtmlColor lineColor =
       diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get(3));
   final String error = diagram.activate(p, type, backColor, lineColor);
   if (error == null) {
     return CommandExecutionResult.ok();
   }
   return CommandExecutionResult.error(error);
 }
Ejemplo n.º 13
0
 @Override
 protected CommandExecutionResult executeArg(CucaDiagram diagram, List<String> arg) {
   final String s = StringUtils.goUpperCase(arg.get(0)).replace(' ', '_');
   ((SkinParam) diagram.getSkinParam()).setRankdir(Rankdir.valueOf(s));
   // diagram.setRankdir(Rankdir.valueOf(s));
   return CommandExecutionResult.ok();
 }
Ejemplo n.º 14
0
 private Direction getDirection(RegexResult arg) {
   final String arrowDirection = arg.get("ARROW_DIRECTION", 0);
   if (arrowDirection != null) {
     return StringUtils.getQueueDirection(arrowDirection);
   }
   return null;
 }
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) {
    final URectangle rect = (URectangle) ushape;

    double width = rect.getWidth();
    double height = rect.getHeight();

    final UClip clip = clipContainer.getClip();
    if (clip != null) {
      final Rectangle2D.Double r =
          clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
      x = r.x;
      y = r.y;
      width = r.width;
      height = r.height;
    }

    final double rx = rect.getRx();
    final double ry = rect.getRy();

    //		// Shadow
    //		if (rect.getDeltaShadow() != 0) {
    //			eps.epsRectangleShadow(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow());
    //		}

    final HtmlColor back = param.getBackcolor();
    if (back instanceof HtmlColorGradient) {
      //			eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
      //			eps.epsRectangle(x, y, width, height, rx / 2, ry / 2, (HtmlColorGradient) back, mapper);
    } else {
      final String color =
          param.getColor() == null
              ? null
              : StringUtils.getAsHtml(mapper.getMappedColor(param.getColor()));
      final String backcolor =
          param.getColor() == null
              ? null
              : StringUtils.getAsHtml(mapper.getMappedColor(param.getBackcolor()));

      html.setStrokeColor(color);
      html.setFillColor(backcolor);
      //			eps.setStrokeWidth("" + param.getStroke().getThickness(),
      // param.getStroke().getDashVisible(), param
      //					.getStroke().getDashSpace());
      html.htmlRectangle(x, y, width, height, rx / 2, ry / 2);
    }
  }
  private CommandExecutionResult executeInternal(
      RegexResult line0, AbstractEntityDiagram diagram, Url url, BlocLines lines) {

    final String pos = line0.get("POSITION", 0);

    final Code code = Code.of(line0.get("ENTITY", 0));
    final String member = line0.get("ENTITY", 1);
    if (code == null) {
      return CommandExecutionResult.error("Nothing to note to");
    }
    final IEntity cl1 = diagram.getOrCreateLeaf(code, null, null);
    final Position position =
        Position.valueOf(StringUtils.goUpperCase(pos))
            .withRankdir(diagram.getSkinParam().getRankdir());

    final Code codeTip = code.addSuffix("$$$" + position.name());
    IEntity tips = diagram.getLeafsget(codeTip);
    if (tips == null) {
      tips = diagram.getOrCreateLeaf(codeTip, LeafType.TIPS, null);
      final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible();
      final Link link;
      if (position == Position.RIGHT) {
        link = new Link(cl1, (IEntity) tips, type, Display.NULL, 1);
      } else {
        link = new Link((IEntity) tips, cl1, type, Display.NULL, 1);
      }
      diagram.addLink(link);
    }
    tips.putTip(member, lines.toDisplay());

    // final IEntity note = diagram.createLeaf(UniqueSequence.getCode("GMN"), Display.create(s),
    // LeafType.NOTE,
    // null);
    // note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
    // if (url != null) {
    // note.addUrl(url);
    // }
    //
    // final Position position = Position.valueOf(StringUtils.goUpperCase(pos)).withRankdir(
    // diagram.getSkinParam().getRankdir());
    // final Link link;
    //
    // final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed();
    // if (position == Position.RIGHT) {
    // link = new Link(cl1, note, type, null, 1);
    // link.setHorizontalSolitary(true);
    // } else if (position == Position.LEFT) {
    // link = new Link(note, cl1, type, null, 1);
    // link.setHorizontalSolitary(true);
    // } else if (position == Position.BOTTOM) {
    // link = new Link(cl1, note, type, null, 2);
    // } else if (position == Position.TOP) {
    // link = new Link(note, cl1, type, null, 2);
    // } else {
    // throw new IllegalArgumentException();
    // }
    // diagram.addLink(link);
    return CommandExecutionResult.ok();
  }
Ejemplo n.º 17
0
 public EntityImageUsecase(Entity entity) {
   super(entity);
   this.name =
       TextBlockUtils.create(
           StringUtils.getWithNewlines(entity.getDisplay()),
           new FontConfiguration(getFont14(), Color.BLACK),
           HorizontalAlignement.CENTER);
 }
Ejemplo n.º 18
0
 public Display removeUrlHiddenNewLineUrl() {
   final String full = UrlBuilder.purgeUrl(asStringWithHiddenNewLine());
   return new Display(
       StringUtils.splitHiddenNewLine(full),
       this.naturalHorizontalAlignment,
       this.isNull,
       this.defaultCreoleMode);
 }
Ejemplo n.º 19
0
 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;
   }
 }
Ejemplo n.º 20
0
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
    final URectangle rect = (URectangle) ushape;

    final double rx = rect.getRx();
    final double ry = rect.getRy();
    double width = rect.getWidth();
    double height = rect.getHeight();

    final UGradient gr = param.getGradient();
    if (gr == null) {
      final String color =
          param.getColor() == null
              ? "none"
              : StringUtils.getAsHtml(mapper.getMappedColor(param.getColor()));
      final String backcolor =
          param.getBackcolor() == null
              ? "none"
              : StringUtils.getAsHtml(mapper.getMappedColor(param.getBackcolor()));
      svg.setFillColor(backcolor);
      svg.setStrokeColor(color);
    } else {
      final String id =
          svg.createSvgGradient(
              StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
              StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())));
      svg.setFillColor("url(#" + id + ")");
      svg.setStrokeColor(null);
    }

    svg.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDasharraySvg());

    final UClip clip = clipContainer.getClip();
    if (clip != null) {
      final Rectangle2D.Double r =
          clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
      x = r.x;
      y = r.y;
      width = r.width;
      height = r.height;
    }

    svg.svgRectangle(x, y, width, height, rx / 2, ry / 2);
  }
Ejemplo n.º 21
0
 public String getLabel(boolean withGuillement) {
   assert label == null || label.length() > 0;
   if (isWithOOSymbol()) {
     return null;
   }
   if (withGuillement) {
     return StringUtils.manageGuillemetStrict(label);
   }
   return label;
 }
Ejemplo n.º 22
0
 public String asStringWithHiddenNewLine() {
   final StringBuilder sb = new StringBuilder();
   for (int i = 0; i < display.size(); i++) {
     sb.append(display.get(i));
     if (i < display.size() - 1) {
       sb.append(StringUtils.hiddenNewLine());
     }
   }
   return sb.toString();
 }
Ejemplo n.º 23
0
  @Override
  protected CommandExecutionResult executeArg(Map<String, RegexPartialMatch> arg2) {
    final IEntity entity1 = getEntity(getSystem(), arg2, true);
    if (entity1 == null) {
      return CommandExecutionResult.error("No such activity");
    }
    if (arg2.get("STEREOTYPE").get(0) != null) {
      entity1.setStereotype(new Stereotype(arg2.get("STEREOTYPE").get(0)));
    }
    if (arg2.get("BACKCOLOR").get(0) != null) {
      entity1.setSpecificBackcolor(arg2.get("BACKCOLOR").get(0));
    }

    final IEntity entity2 = getEntity(getSystem(), arg2, false);
    if (entity2 == null) {
      return CommandExecutionResult.error("No such activity");
    }
    if (arg2.get("BACKCOLOR2").get(0) != null) {
      entity2.setSpecificBackcolor(arg2.get("BACKCOLOR2").get(0));
    }
    if (arg2.get("STEREOTYPE2").get(0) != null) {
      entity2.setStereotype(new Stereotype(arg2.get("STEREOTYPE2").get(0)));
    }

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

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

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

    getSystem().addLink(link);

    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);
  }
Ejemplo n.º 25
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();
  }
Ejemplo n.º 26
0
  private CommandExecutionResult executePackageLink(RegexResult arg) {
    final String ent1 =
        StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1));
    final String ent2 =
        StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1));
    final IEntity cl1 = getSystem().getGroup(ent1);
    final IEntity cl2 = getSystem().getGroup(ent2);

    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 String labelLink = 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,
            getSystem().getLabeldistance(),
            getSystem().getLabelangle());
    // if (dir == Direction.LEFT || dir == Direction.UP) {
    // link = link.getInv();
    // }

    getSystem().resetPragmaLabel();
    addLink(link, arg.get("HEADER", 0));
    return CommandExecutionResult.ok();
  }
  public final CommandExecutionResult execute(List<String> lines) {

    final List<String> line0 = StringUtils.getSplit(getStartingPattern(), lines.get(0).trim());
    final String pos = line0.get(0);

    final IEntity activity = getSystem().getLastEntityConsulted();
    if (activity == null) {
      // activity = getSystem().getStart();
      return CommandExecutionResult.error("No activity defined");
    }

    final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
    //		final String s = StringUtils.getMergedLines(strings);

    final IEntity note =
        getSystem().createLeaf(UniqueSequence.getCode("GMN"), strings, LeafType.NOTE);
    note.setSpecificBackcolor(HtmlColorUtils.getColorIfValid(line0.get(1)));

    final Link link;

    final Position position =
        Position.valueOf(pos.toUpperCase()).withRankdir(getSystem().getRankdir());

    final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed();

    if (position == Position.RIGHT) {
      link = new Link(activity, note, type, null, 1);
    } else if (position == Position.LEFT) {
      link = new Link(note, activity, type, null, 1);
    } else if (position == Position.BOTTOM) {
      link = new Link(activity, note, type, null, 2);
    } else if (position == Position.TOP) {
      link = new Link(note, activity, type, null, 2);
    } else {
      throw new IllegalArgumentException();
    }
    getSystem().addLink(link);
    return CommandExecutionResult.ok();
  }
Ejemplo n.º 28
0
  public void draw(
      UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
    final UPath shape = (UPath) ushape;

    final String color =
        param.getColor() == null
            ? "none"
            : StringUtils.getAsHtml(mapper.getMappedColor(param.getColor()));
    final String backcolor =
        param.getBackcolor() == null
            ? "none"
            : StringUtils.getAsHtml(mapper.getMappedColor(param.getBackcolor()));

    //		// Shadow
    //		if (shape.getDeltaShadow() != 0) {
    //			double lastX = 0;
    //			double lastY = 0;
    //			for (USegment seg : shape) {
    //				final USegmentType type = seg.getSegmentType();
    //				final double coord[] = seg.getCoord();
    //				if (type == USegmentType.SEG_MOVETO) {
    //					lastX = x + coord[0];
    //					lastY = y + coord[1];
    //				} else if (type == USegmentType.SEG_LINETO) {
    //					svg.svgLineShadow(lastX, lastY, x + coord[0], y + coord[1], shape.getDeltaShadow());
    //					lastX = x + coord[0];
    //					lastY = y + coord[1];
    //				} else {
    //					throw new UnsupportedOperationException();
    //				}
    //			}
    //		}

    svg.setFillColor(backcolor);
    svg.setStrokeColor(color);
    svg.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDasharraySvg());

    svg.svgPath(x, y, shape, shape.getDeltaShadow());
  }
  public CommandExecutionResult execute(List<String> lines) {
    final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
    if (strings.size() > 0) {
      final List<CharSequence> n = StringUtils.manageEmbededDiagrams(strings);

      final Link link = getSystem().getLastStateLink();
      if (link == null) {
        return CommandExecutionResult.error("No link defined");
      }
      Position position = Position.BOTTOM;
      final Matcher m = getStartingPattern().matcher(lines.get(0));
      if (m.find()) {
        final String pos = m.group(1);
        if (pos != null) {
          position = Position.valueOf(pos.toUpperCase());
        }
      }

      link.addNote(n, position);
      return CommandExecutionResult.ok();
    }
    return CommandExecutionResult.error("No note defined");
  }
  private CommandExecutionResult executeInternal(
      SequenceDiagram system, final RegexResult line0, final List<String> in) {
    final AbstractMessage m = system.getLastMessage();
    if (m != null) {
      final NotePosition position = NotePosition.valueOf(line0.get("POSITION", 0).toUpperCase());
      List<CharSequence> strings = StringUtils.manageEmbededDiagrams(in);
      final Url url;
      if (strings.size() > 0) {
        url =
            StringUtils.extractUrl(
                system.getSkinParam().getValue("topurl"), strings.get(0).toString(), true);
      } else {
        url = null;
      }
      if (url != null) {
        strings = strings.subList(1, strings.size());
      }

      m.setNote(strings, position, line0.get("COLOR", 0), url);
    }

    return CommandExecutionResult.ok();
  }