All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.dynamicreports.report.builder.column.BooleanColumnBuilder Maven / Gradle / Ivy

Go to download

DynamicReports is an open source Java reporting library based on JasperReports. It allows to create dynamic report designs and it doesn't need a visual report designer. You can very quickly create reports and produce documents that can be displayed, printed or exported into many popular formats such as PDF, Excel, Word and others.

There is a newer version: 6.20.1
Show newest version
/**
 * DynamicReports - Free Java reporting library for creating reports dynamically
 *
 * Copyright (C) 2010 - 2016 Ricardo Mariaca
 * http://www.dynamicreports.org
 *
 * This file is part of DynamicReports.
 *
 * DynamicReports is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * DynamicReports is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with DynamicReports. If not, see .
 */

package net.sf.dynamicreports.report.builder.column;

import net.sf.dynamicreports.report.base.column.DRBooleanColumn;
import net.sf.dynamicreports.report.base.component.DRBooleanField;
import net.sf.dynamicreports.report.builder.FieldBuilder;
import net.sf.dynamicreports.report.constant.BooleanComponentType;
import net.sf.dynamicreports.report.constant.ComponentDimensionType;
import net.sf.dynamicreports.report.constant.Constants;
import net.sf.dynamicreports.report.constant.HorizontalAlignment;
import net.sf.dynamicreports.report.constant.HorizontalImageAlignment;
import net.sf.dynamicreports.report.constant.HorizontalTextAlignment;
import net.sf.dynamicreports.report.definition.expression.DRIExpression;

import org.apache.commons.lang3.Validate;

/**
 * It shows a boolean value either as a text or as an image.
 *
 * @author Ricardo Mariaca ([email protected])
 */
@SuppressWarnings("deprecation")
public class BooleanColumnBuilder extends ColumnBuilder {
	private static final long serialVersionUID = Constants.SERIAL_VERSION_UID;

	protected BooleanColumnBuilder(FieldBuilder field) {
		super(new DRBooleanColumn(new DRBooleanField()));
		Validate.notNull(field, "field must not be null");
		getComponent().setValueExpression(field.getField());
	}

	protected BooleanColumnBuilder(DRIExpression valueExpression) {
		super(new DRBooleanColumn(new DRBooleanField()));
		getComponent().setValueExpression(valueExpression);
	}

  /**
   * Sets the preferred width of a column.
   * @see net.sf.dynamicreports.report.builder.Units
   *
   * @param width the column preferred width >= 0
   * @exception IllegalArgumentException if width is < 0
   * @return a column builder
   */
	public BooleanColumnBuilder setWidth(Integer width) {
		getComponent().setWidth(width);
		return this;
	}

  /**
   * Sets the fixed width of a column.
   * @see net.sf.dynamicreports.report.builder.Units
   *
   * @param width the column fixed width >= 0
   * @exception IllegalArgumentException if width is < 0
   * @return a column builder
   */
	public BooleanColumnBuilder setFixedWidth(Integer width) {
		getComponent().setWidth(width);
		getComponent().setWidthType(ComponentDimensionType.FIXED);
		return this;
	}

  /**
   * Sets the minimum width of a column.
   * @see net.sf.dynamicreports.report.builder.Units
   *
   * @param width the column minimum width >= 0
   * @exception IllegalArgumentException if width is < 0
   * @return a column builder
   */
	public BooleanColumnBuilder setMinWidth(Integer width) {
		getComponent().setWidth(width);
		getComponent().setWidthType(ComponentDimensionType.EXPAND);
		return this;
	}

  /**
   * Sets the preferred height of a column.
   * @see net.sf.dynamicreports.report.builder.Units
   *
   * @param height the column preferred height >= 0
   * @exception IllegalArgumentException if height is < 0
   * @return a column builder
   */
	public BooleanColumnBuilder setHeight(Integer height) {
		getComponent().setHeight(height);
		return this;
	}

  /**
   * Sets the fixed height of a column.
   * @see net.sf.dynamicreports.report.builder.Units
   *
   * @param height the column fixed height >= 0
   * @exception IllegalArgumentException if height is < 0
   * @return a column builder
   */
	public BooleanColumnBuilder setFixedHeight(Integer height) {
		getComponent().setHeight(height);
		getComponent().setHeightType(ComponentDimensionType.FIXED);
		return this;
	}

  /**
   * Sets the minimum height of a column.
   * @see net.sf.dynamicreports.report.builder.Units
   *
   * @param height the column minimum height >= 0
   * @exception IllegalArgumentException if height is < 0
   * @return a column builder
   */
	public BooleanColumnBuilder setMinHeight(Integer height) {
		getComponent().setHeight(height);
		getComponent().setHeightType(ComponentDimensionType.EXPAND);
		return this;
	}

	/**
	 * Sets the boolean presentation type.
* BooleanComponentType.TEXT_* - shows a text value
* BooleanComponentType.IMAGE_* - shows an image * * @param booleanComponentType the component type * @return a column builder */ public BooleanColumnBuilder setComponentType(BooleanComponentType booleanComponentType) { getComponent().setComponentType(booleanComponentType); return this; } public BooleanColumnBuilder setEmptyWhenNullValue(Boolean emptyWhenNullValue) { getComponent().setEmptyWhenNullValue(emptyWhenNullValue); return this; } /** * Sets the boolean image dimension. Has effect only when the boolean value is presented as an image. * * @param width the image width * @param height the image height * @return a column builder */ public BooleanColumnBuilder setImageDimension(Integer width, Integer height) { getComponent().setImageWidth(width); getComponent().setImageHeight(height); return this; } /** * Sets the boolean image width. Has effect only when the boolean value is presented as an image. * * @param width the image width * @return a column builder */ public BooleanColumnBuilder setImageWidth(Integer width) { getComponent().setImageWidth(width); return this; } /** * Sets the boolean image height. Has effect only when the boolean value is presented as an image. * * @param height the image height * @return a column builder */ public BooleanColumnBuilder setImageHeight(Integer height) { getComponent().setImageHeight(height); return this; } /** * Sets the column value horizontal alignment. * * @param horizontalAlignment * @return a column builder * * @deprecated use setHorizontalImageAlignment instead */ @Deprecated public BooleanColumnBuilder setHorizontalAlignment(HorizontalAlignment horizontalAlignment) { if (horizontalAlignment != null) { getComponent().setHorizontalImageAlignment(HorizontalImageAlignment.valueOf(horizontalAlignment.name())); } else { getComponent().setHorizontalImageAlignment(null); } return this; } /** * Sets the column value horizontal image alignment. * * @param horizontalImageAlignment * @return a column builder */ public BooleanColumnBuilder setHorizontalImageAlignment(HorizontalImageAlignment horizontalImageAlignment) { getComponent().setHorizontalImageAlignment(horizontalImageAlignment); return this; } /** * Sets the column value horizontal text alignment. * * @param horizontalTextAlignment * @return a column builder */ public BooleanColumnBuilder setHorizontalTextAlignment(HorizontalTextAlignment horizontalTextAlignment) { getComponent().setHorizontalTextAlignment(horizontalTextAlignment); return this; } @Override protected DRBooleanField getComponent() { return (DRBooleanField) getObject().getComponent(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy