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

net.sf.dynamicreports.report.builder.column.ComponentColumnBuilder 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.DRColumn;
import net.sf.dynamicreports.report.base.component.DRComponent;
import net.sf.dynamicreports.report.base.component.DRDimensionComponent;
import net.sf.dynamicreports.report.builder.component.ComponentBuilder;
import net.sf.dynamicreports.report.constant.ComponentDimensionType;
import net.sf.dynamicreports.report.constant.Constants;
import net.sf.dynamicreports.report.definition.component.DRIDimensionComponent;
import net.sf.dynamicreports.report.exception.DRReportException;

/**
 * It is used to display custom components (e.g. images or complex content) in columns.
 *
 * @author Ricardo Mariaca ([email protected])
 */
public class ComponentColumnBuilder extends ColumnBuilder> {
	private static final long serialVersionUID = Constants.SERIAL_VERSION_UID;

	protected ComponentColumnBuilder(ComponentBuilder component) {
		super(new DRColumn(component.getComponent()));
	}

  /**
   * 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 ComponentColumnBuilder setWidth(Integer width) {
		getDimensionComponent().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 ComponentColumnBuilder setFixedWidth(Integer width) {
		getDimensionComponent().setWidth(width);
		getDimensionComponent().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 ComponentColumnBuilder setMinWidth(Integer width) {
		getDimensionComponent().setWidth(width);
		getDimensionComponent().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 ComponentColumnBuilder setHeight(Integer height) {
		getDimensionComponent().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 ComponentColumnBuilder setFixedHeight(Integer height) {
		getDimensionComponent().setHeight(height);
		getDimensionComponent().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 ComponentColumnBuilder setMinHeight(Integer height) {
		getDimensionComponent().setHeight(height);
		getDimensionComponent().setHeightType(ComponentDimensionType.EXPAND);
		return this;
	}

	private DRDimensionComponent getDimensionComponent() {
		if (!(getObject().getComponent() instanceof DRIDimensionComponent)) {
			throw new DRReportException("Column component" + getObject().getComponent().getClass().getName() + "is not a dimension component.");
		}
		return (DRDimensionComponent) getObject().getComponent();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy