Package org.pentaho.reporting.engine.classic.core.layout.model.table.columns

Source Code of org.pentaho.reporting.engine.classic.core.layout.model.table.columns.TableColumn

/*!
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This program 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.
*
* Copyright (c) 2002-2013 Pentaho Corporation..  All rights reserved.
*/

package org.pentaho.reporting.engine.classic.core.layout.model.table.columns;


import org.pentaho.reporting.engine.classic.core.layout.model.Border;
import org.pentaho.reporting.engine.classic.core.layout.model.RenderLength;
import org.pentaho.reporting.engine.classic.core.util.LongList;

/**
* A column definition. A column has an effective definedWidth, which
* corresponds with the computed definedWidth of the content. If that
* definedWidth gets greater than the initial definedWidth (the definedWidth
* that has been computed by the table at the beginning of the rendering), we
* entered the auto-mode.
*
* Once a column has been explicitly marked as validated, any attempt to
* redefine the computed sizes must fail. (This makes sure that the table
* stays in sync and does not get disordered if its rendered incrementally.)
*
* A column is constrained by three metrics:
*
* The Minimum ChunkSize defines the smallest non-breakable content item in
* the column. A column will always consume at least this space. (This is zero,
* if the column has overflow enabled.)
*
* The Maximum Box-Width is the size the content would consume, if there is
* infinite space available. Manual linebreaks are taken into account, but not
* automatic ones.
*
* If the column explicitly defines a width, the preferred size indicates that.
* If no preferred width is defined, the preferred size will be zero.
*
* @author Thomas Morgner
*/
public class TableColumn
{
  private Border border;
  private RenderLength definedWidth;

  private long effectiveSize;
  private LongList cachedSize;

  private boolean autoGenerated;
  private boolean validated;

  public TableColumn(final Border border,
                     final RenderLength definedWidth,
                     final boolean autoGenerated)
  {
    if (border == null)
    {
      throw new NullPointerException();
    }
    if (definedWidth == null)
    {
      throw new NullPointerException();
    }

    this.definedWidth = definedWidth;
    this.border = border;
    this.autoGenerated = autoGenerated;
    this.cachedSize = new LongList(10);
  }

  public RenderLength getDefinedWidth()
  {
    return definedWidth;
  }

  public Border getBorder()
  {
    return border;
  }

  public long getEffectiveSize()
  {
    return effectiveSize;
  }

  public void setEffectiveSize(final long effectiveSize)
  {
    this.effectiveSize = effectiveSize;
  }

  public boolean isValidated()
  {
    return validated;
  }

  public void setValidated(final boolean validated)
  {
    this.validated = validated;
  }

  public boolean isAutoGenerated()
  {
    return autoGenerated;
  }

  public void setCachedSize(final int colSpan, final long size)
  {
    final int idx = colSpan - 1;
    if (getCachedSize(colSpan) < size)
    {
      cachedSize.set(idx, size);
    }
  }

  public long getCachedSize(final int colspan)
  {
    final int idx = colspan - 1;
    if (idx < cachedSize.size())
    {
      return cachedSize.get(idx);
    }
    return 0;
  }

  public int getMaxColspan()
  {
    return cachedSize.size();
  }

  public String toString()
  {
    final StringBuilder sb = new StringBuilder();
    sb.append("TableColumn");
    sb.append("{validated=").append(validated);
    sb.append(", autoGenerated=").append(autoGenerated);
    sb.append(", effectiveSize=").append(effectiveSize);
    sb.append(", definedWidth=").append(definedWidth);
    sb.append(", border=").append(border);
    sb.append(", cachedSize=").append(cachedSize);
    sb.append('}');
    return sb.toString();
  }
}
TOP

Related Classes of org.pentaho.reporting.engine.classic.core.layout.model.table.columns.TableColumn

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.