コード例 #1
0
ファイル: BoxLayout.java プロジェクト: sam-m888/opg
  public void drawNormalLines(
      OpgSession session,
      ChartMargins chart,
      PresetChartOptions options,
      StylingBox style,
      double x,
      double y,
      double width,
      double totalHeight,
      double textPos,
      Individual indi,
      LineLayout line,
      String dupLabel,
      boolean maleDescendant,
      Rectangle2D.Double boxCoords,
      String chartIndex) {
    double horizTextGap = style.textMargin;
    double linepos = 0.0;
    TextDirection direction = style.direction;
    if (direction == StylingBox.TextDirection.NORMAL) {
      linepos = y + (totalHeight / 2.0) - textPos;
      line.draw(
          session,
          chart,
          style,
          options,
          x + horizTextGap,
          linepos,
          width - (horizTextGap * 2),
          totalHeight,
          indi,
          dupLabel,
          maleDescendant,
          0,
          chartIndex,
          direction);

    } else if (direction == StylingBox.TextDirection.NINETY) {
      linepos = x + width - textPos;
      line.draw(
          session,
          chart,
          style,
          options,
          linepos,
          y + (totalHeight / 2.0) - horizTextGap,
          totalHeight - (horizTextGap * 2),
          width,
          indi,
          dupLabel,
          maleDescendant,
          0,
          chartIndex,
          direction);

    } else if (direction == StylingBox.TextDirection.ONE_EIGHTY) {
      linepos = y - (totalHeight / 2.0) + textPos;
      line.draw(
          session,
          chart,
          style,
          options,
          x + width - horizTextGap,
          linepos,
          width - (horizTextGap * 2),
          totalHeight,
          indi,
          dupLabel,
          maleDescendant,
          0,
          chartIndex,
          direction);
    } else {
      linepos = x + textPos;
      line.draw(
          session,
          chart,
          style,
          options,
          linepos,
          y - (totalHeight / 2.0) + horizTextGap,
          totalHeight - (horizTextGap * 2),
          width,
          indi,
          dupLabel,
          maleDescendant,
          0,
          chartIndex,
          direction);
    }
  }
コード例 #2
0
ファイル: BoxLayout.java プロジェクト: sam-m888/opg
  public void drawDescMarried(
      ChartMargins chart,
      StylingBox style,
      PresetChartOptions options,
      double x,
      double y,
      double width,
      double hgt,
      Individual indi,
      Individual husband,
      Individual wife,
      boolean drawBorder,
      boolean maleDescendant,
      Rectangle2D.Double boxCoords,
      int famCode,
      OpgSession session) {

    totalHeight = hgt;
    double lineWidth = (options.isBoxBorder() && drawBorder) ? style.borderlineWidth : 0;
    double xPos = x;

    if (options.isRoundedCorners())
      chart.addDrawCommand(
          new DrawCmdRoundRect(
              x,
              y - totalHeight / 2.0,
              width,
              totalHeight,
              lineWidth,
              style.cornerCurve,
              Color.BLACK,
              session.getBaseOptions().getDescScheme().getColor(indi.id),
              boxCoords));
    else
      chart.addDrawCommand(
          new DrawCmdFillRect(
              x,
              y - totalHeight / 2.0,
              width,
              totalHeight,
              lineWidth,
              Color.BLACK,
              session.getBaseOptions().getDescScheme().getColor(indi.id),
              boxCoords));

    if (parallelCouple) {
      if (style.direction == StylingBox.TextDirection.NORMAL
          || style.direction == StylingBox.TextDirection.ONE_EIGHTY) width = width / 2.0;
      else totalHeight = totalHeight / 2.0;
    }

    int positionMarker = 0;
    // Draw each line
    for (int i = 0; i < lines.size(); i++) {
      LineLayout line = lines.get(i);
      double textPos =
          (i < style.textPositions.size()
              ? style.textPositions.get(i)
              : style.textPositions.get(style.textPositions.size() - 1));
      drawNormalLines(
          session,
          chart,
          options,
          style,
          x,
          y,
          width,
          totalHeight,
          textPos,
          husband,
          line,
          "",
          maleDescendant,
          boxCoords,
          "");
      positionMarker++;
    }
    // Displays wedding information after the husband, if that's what's chosen
    if ((style.weddingDisplayType == StylingBox.WeddingPositions.HUSBAND_POSTFIX
            || (style.weddingDisplayType == StylingBox.WeddingPositions.DIRECT_DESCENDANT_POSTFIX
                && maleDescendant)
            || style.weddingDisplayType == StylingBox.WeddingPositions.BOTH_POSTFIX)
        && style.weddingLayout != null
        && !parallelCouple) {
      for (int i = 0; i < style.weddingLayout.lines.size(); i++) {
        LineLayout line = style.weddingLayout.lines.get(i);
        double textPos =
            (positionMarker < style.textPositions.size()
                ? style.textPositions.get(positionMarker)
                : style.textPositions.get(style.textPositions.size() - 1));

        drawMarriageLines(
            session,
            chart,
            options,
            style,
            x,
            y,
            width,
            totalHeight,
            textPos,
            indi,
            line,
            "",
            boxCoords,
            famCode);
        positionMarker++;
      }
    }
    if (parallelCouple) {
      if (style.direction == StylingBox.TextDirection.NORMAL
          || style.direction == StylingBox.TextDirection.ONE_EIGHTY) x += (width);
      else y += (totalHeight);

      positionMarker = 0;
    }
    for (int i = 0; i < lines.size(); i++) {
      LineLayout line = lines.get(i);
      double textPos =
          (positionMarker < style.textPositions.size()
              ? style.textPositions.get(positionMarker)
              : style.textPositions.get(style.textPositions.size() - 1));

      drawNormalLines(
          session,
          chart,
          options,
          style,
          x,
          y,
          width,
          totalHeight,
          textPos,
          wife,
          line,
          "",
          !maleDescendant,
          boxCoords,
          "");
      positionMarker++;
    }
    if ((style.weddingDisplayType == StylingBox.WeddingPositions.WIFE_POSTFIX
            || (style.weddingDisplayType == StylingBox.WeddingPositions.DIRECT_DESCENDANT_POSTFIX
                && !maleDescendant)
            || style.weddingDisplayType == StylingBox.WeddingPositions.BOTH_POSTFIX)
        && style.weddingLayout != null
        && !parallelCouple) {
      for (int i = 0; i < style.weddingLayout.lines.size(); i++) {
        LineLayout line = style.weddingLayout.lines.get(i);
        double textPos =
            (positionMarker < style.textPositions.size()
                ? style.textPositions.get(positionMarker)
                : style.textPositions.get(style.textPositions.size() - 1));

        drawMarriageLines(
            session,
            chart,
            options,
            style,
            x,
            y,
            width,
            totalHeight,
            textPos,
            indi,
            line,
            "",
            boxCoords,
            famCode);
        positionMarker++;
      }
    }
    if (parallelCouple) {
      for (int i = 0; i < style.weddingLayout.lines.size(); i++) {
        LineLayout line = style.weddingLayout.lines.get(i);
        double textPos =
            (positionMarker < style.textPositions.size()
                ? style.textPositions.get(positionMarker)
                : style.textPositions.get(style.textPositions.size() - 1));
        double offset =
            ((width * 2)
                    - line.getWidth(session, style.fontSize, options, indi, "", width, famCode))
                / 2.0;
        drawMarriageLines(
            session,
            chart,
            options,
            style,
            xPos + offset,
            y,
            (width * 2),
            totalHeight,
            textPos,
            indi,
            line,
            "",
            boxCoords,
            famCode);
        positionMarker++;
      }
    }
  }