Beispiel #1
0
  @Override
  public void draw(DrawHandler drawHandler, DrawingInfo drawingInfo) {
    double width = drawingInfo.getSymmetricWidth(getFirstLifeline(), getLastLifeline(), tick);
    double height = getHeight(drawHandler, width);
    double topY =
        drawingInfo.getVerticalStart(tick) + (drawingInfo.getTickHeight(tick) - height) / 2;
    PointDouble topLeft =
        new PointDouble(
            drawingInfo.getHDrawingInfo(getFirstLifeline()).getSymmetricHorizontalStart(tick),
            topY);

    drawHandler.drawRectangle(topLeft.x, topLeft.y, width, height);
    PointDouble pentagonSize = PentagonDrawingHelper.draw(drawHandler, HEADER_TEXT, width, topLeft);
    TextSplitter.drawText(
        drawHandler,
        textLines,
        topLeft.x + pentagonSize.x + TEXT_X_PADDING,
        topLeft.y,
        width - (pentagonSize.x + TEXT_X_PADDING) * 2,
        height,
        AlignHorizontal.CENTER,
        AlignVertical.CENTER);

    for (Lifeline ll : coveredLifelines) {
      drawingInfo.getDrawingInfo(ll).addInterruptedArea(new Line1D(topLeft.y, topLeft.y + height));
    }
  }
  private void printAndUpdateIndex(
      DrawHandler drawer,
      RelationPointHandler relationPoints,
      PointDouble pointText,
      int index,
      String text,
      Set<Integer> usedIndexes) {
    drawer.print(text, pointText, AlignHorizontal.LEFT);

    // to make sure text is printed (and therefore withing relation-element-borders, resize relation
    // according to text
    relationPoints.setTextBox(
        index,
        new Rectangle(
            pointText.getX(),
            pointText.getY() - drawer.textHeightMax(),
            drawer.textWidth(text),
            drawer.textHeightMax()));
    usedIndexes.add(index);
  }
Beispiel #3
0
 @Override
 protected void drawCommonContent(DrawHandler drawer, PropertiesParserState state) {
   drawer.drawEllipse(0, 0, getRealSize().width, getRealSize().height);
   state.setStickingPolygonGenerator(stickingPolygonGenerator);
 }
  @Override
  public void parsingFinished(PropertiesParserState state, List<String> handledLines) {
    Map<String, Point> displacements =
        state.getOrInitFacetResponse(
            LineDescriptionPositionFacet.class, new HashMap<String, Point>());
    RelationPointHandler relationPoints = getRelationPoints(state);
    DrawHandler drawer = state.getDrawer();
    Set<Integer> usedIndexes = new HashSet<Integer>();

    List<String> middleLines = new ArrayList<String>();
    List<String> otherLines = new ArrayList<String>();

    for (String line : handledLines) {
      if (LineDescriptionEnum.forString(line) == LineDescriptionEnum.MESSAGE_MIDDLE) {
        middleLines.add(line);
      } else {
        otherLines.add(line);
      }
    }

    double halfMiddleBlockHeight =
        middleLines.size()
            * drawer.textHeightMaxWithSpace()
            / 2; // because vertical text blocks should be centered, the half of the total text
                 // block must be subtracted
    for (int i = 0; i < middleLines.size(); i++) {
      String line = LineDescriptionUtils.replaceArrowsWithUtf8Characters(middleLines.get(i));
      PointDouble pointText =
          LineDescriptionUtils.calcPosOfMiddleText(
              drawer, line, relationPoints.getMiddleLine(), i, halfMiddleBlockHeight);
      int index =
          LineDescriptionEnum.MESSAGE_MIDDLE.getIndex()
              + i; // middle index is increased by the amount of middle text lines
      printAndUpdateIndex(drawer, relationPoints, pointText, index, line, usedIndexes);
    }

    for (String line : otherLines) {
      LineDescriptionEnum enumVal = LineDescriptionEnum.forString(line);
      String[] split = line.split(KeyValueFacet.SEP, -1);
      String text = split[1];
      if (!text.isEmpty()) {
        PointDouble pointText =
            LineDescriptionUtils.calcPosOfEndText(drawer, text, relationPoints, enumVal);
        printAndUpdateIndex(
            drawer,
            relationPoints,
            pointText,
            enumVal.getIndex(),
            text,
            displacements.get(enumVal.getKey()),
            usedIndexes);
      }
    }

    // all unused textboxes must be reset to default size (to make sure the relation size is correct
    // even if LineDescriptionFacet is never called)
    relationPoints.resetTextBoxIndexesExcept(usedIndexes);
    relationPoints
        .resizeRectAndReposPoints(); // apply the (possible) changes now to make sure the following
                                     // facets use correct coordinates
  }