Пример #1
0
  public CellStyle(Writer styleWriter, JRExporterGridCell gridCell) {
    super(styleWriter);

    JRPrintElement element = gridCell.getElement();

    if (element != null && element.getModeValue() == ModeEnum.OPAQUE) {
      // fill = "solid";
      backcolor = JRColorUtil.getColorHexa(element.getBackcolor());
    } else {
      // fill = "none";
      if (gridCell.getBackcolor() != null) {
        backcolor = JRColorUtil.getColorHexa(gridCell.getBackcolor());
      }
    }

    RotationEnum rotation =
        element instanceof JRPrintText
            ? ((JRPrintText) element).getRotationValue()
            : RotationEnum.NONE;
    VerticalAlignEnum vAlign = VerticalAlignEnum.TOP;
    HorizontalAlignEnum hAlign = HorizontalAlignEnum.LEFT;

    JRAlignment alignment = element instanceof JRAlignment ? (JRAlignment) element : null;
    if (alignment != null) {
      vAlign = alignment.getVerticalAlignmentValue();
      hAlign = alignment.getHorizontalAlignmentValue();
    }

    horizontalAlignment = ParagraphStyle.getHorizontalAlignment(hAlign, vAlign, rotation);
    verticalAlignment = ParagraphStyle.getVerticalAlignment(hAlign, vAlign, rotation);

    setBox(gridCell.getBox());
  }
 public Color getCellBackcolor() {
   Color color;
   JRPrintElement element = getElement();
   if (element != null && element.getMode() == JRElement.MODE_OPAQUE) {
     color = element.getBackcolor();
   } else {
     color = backcolor;
   }
   return color;
 }