コード例 #1
0
ファイル: CellConfig.java プロジェクト: ahennr/mapfish-print
  protected void apply(PdfPCell cell, RenderingContext context, PJsonObject params) {
    if (paddingLeft != null) cell.setPaddingLeft(paddingLeft.floatValue());
    if (paddingRight != null) cell.setPaddingRight(paddingRight.floatValue());
    if (paddingTop != null) cell.setPaddingTop(paddingTop.floatValue());
    if (paddingBottom != null) cell.setPaddingBottom(paddingBottom.floatValue());

    if (borderWidthLeft != null) cell.setBorderWidthLeft(borderWidthLeft.floatValue());
    if (borderWidthRight != null) cell.setBorderWidthRight(borderWidthRight.floatValue());
    if (borderWidthTop != null) cell.setBorderWidthTop(borderWidthTop.floatValue());
    if (borderWidthBottom != null) cell.setBorderWidthBottom(borderWidthBottom.floatValue());

    if (getBorderColorLeftVal(context, params) != null)
      cell.setBorderColorLeft(getBorderColorLeftVal(context, params));
    if (getBorderColorRightVal(context, params) != null)
      cell.setBorderColorRight(getBorderColorRightVal(context, params));
    if (getBorderColorTopVal(context, params) != null)
      cell.setBorderColorTop(getBorderColorTopVal(context, params));
    if (getBorderColorBottomVal(context, params) != null)
      cell.setBorderColorBottom(getBorderColorBottomVal(context, params));

    if (getBackgroundColorVal(context, params) != null)
      cell.setBackgroundColor(getBackgroundColorVal(context, params));

    if (align != null) cell.setHorizontalAlignment(align.getCode());
    if (vertAlign != null) cell.setVerticalAlignment(vertAlign.getCode());
  }
コード例 #2
0
 /**
  * A helper method to create a PdfPCell. We can specify the content, font, horizontal alignment,
  * border (borderless, no bottom border, no right border, no top border, etc.
  *
  * @param content The text content to be displayed in the cell.
  * @param borderless boolean true if the cell should be borderless.
  * @param noBottom boolean true if the cell should have borderWidthBottom = 0.
  * @param noRight boolean true if the cell should have borderWidthRight = 0.
  * @param noTop boolean true if the cell should have borderWidthTop = 0.
  * @param horizontalAlignment The desired horizontal alignment for the cell.
  * @param font The font type to be used in the cell.
  * @return An instance of PdfPCell which content and attributes were set by the input parameters.
  */
 private PdfPCell createCell(
     String content,
     boolean borderless,
     boolean noBottom,
     boolean noRight,
     boolean noTop,
     int horizontalAlignment,
     Font font) {
   PdfPCell tableCell = new PdfPCell(new Paragraph(content, font));
   if (borderless) {
     tableCell.setBorder(0);
   }
   if (noBottom) {
     tableCell.setBorderWidthBottom(0);
   }
   if (noTop) {
     tableCell.setBorderWidthTop(0);
   }
   if (noRight) {
     tableCell.setBorderWidthRight(0);
   }
   tableCell.setHorizontalAlignment(horizontalAlignment);
   return tableCell;
 }
コード例 #3
0
ファイル: Cell.java プロジェクト: gthiruva/ilarkesto
 @Override
 public Element getITextElement() {
   PdfPCell cell = new PdfPCell();
   cell.setBorderColorTop(getBorderTopColor());
   cell.setBorderColorBottom(getBorderBottomColor());
   cell.setBorderColorLeft(getBorderLeftColor());
   cell.setBorderColorRight(getBorderRightColor());
   cell.setBorderWidthTop(APdfBuilder.mmToPoints(getBorderTopWidth()));
   cell.setBorderWidthBottom(APdfBuilder.mmToPoints(getBorderBottomWidth()));
   cell.setBorderWidthLeft(APdfBuilder.mmToPoints(getBorderLeftWidth()));
   cell.setBorderWidthRight(APdfBuilder.mmToPoints(getBorderRightWidth()));
   cell.setPadding(0);
   cell.setPaddingTop(APdfBuilder.mmToPoints(getPaddingTop()));
   cell.setPaddingBottom(APdfBuilder.mmToPoints(getPaddingBottom()));
   cell.setPaddingLeft(APdfBuilder.mmToPoints(getPaddingLeft()));
   cell.setPaddingRight(APdfBuilder.mmToPoints(getPaddingRight()));
   cell.setExtraParagraphSpace(0);
   cell.setIndent(0);
   cell.setUseBorderPadding(false);
   cell.setBackgroundColor(getBackgroundColor());
   cell.setColspan(getColspan());
   for (ItextElement element : elements) cell.addElement(element.getITextElement());
   return cell;
 }