⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 logicalpageimpl.java

📁 swing编写的库存管理程序。毕业设计类
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**
 * ========================================
 * JFreeReport : a free Java report library
 * ========================================
 *
 * Project Info:  http://www.jfree.org/jfreereport/index.html
 * Project Lead:  Thomas Morgner;
 *
 * (C) Copyright 2000-2003, by Simba Management Limited and Contributors.
 *
 * This library 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 2.1 of the License, or (at your option) any later version.
 *
 * This library 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 this
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * --------------------
 * LogicalPageImpl.java
 * --------------------
 * (C)opyright 2002, 2003, by Thomas Morgner and Contributors.
 *
 * Original Author:  Thomas Morgner;
 * Contributor(s):   David Gilbert (for Simba Management Limited);
 *
 * $Id: LogicalPageImpl.java,v 1.9.2.1 2003/12/21 23:28:45 taqua Exp $
 *
 * Changes
 * -------
 * 02-Dec-2002 : Initial version
 * 04-Dec-2002 : Added Javadocs (DG);
 * 14-Jan-2003 : BugFix: SubBands were not spooled ...
 * 29-Jan-2003 : LogicalPage is closed by default, need explicit open call
 * 01-Feb-2003 : BugFix: SubBand layouting was not translated correctly
 * 07-Feb-2003 : Added explict OperationFactory support
 */

package org.jfree.report.modules.output.pageable.base.physicals;

import java.awt.geom.Rectangle2D;
import java.awt.print.PageFormat;

import org.jfree.report.Band;
import org.jfree.report.Element;
import org.jfree.report.content.Content;
import org.jfree.report.content.ContentCreationException;
import org.jfree.report.content.ContentFactory;
import org.jfree.report.modules.output.pageable.base.LogicalPage;
import org.jfree.report.modules.output.pageable.base.OutputTarget;
import org.jfree.report.modules.output.pageable.base.OutputTargetException;
import org.jfree.report.modules.output.pageable.base.Spool;
import org.jfree.report.modules.output.pageable.base.operations.DrawableOperationModule;
import org.jfree.report.modules.output.pageable.base.operations.ImageOperationModule;
import org.jfree.report.modules.output.pageable.base.operations.OperationFactory;
import org.jfree.report.modules.output.pageable.base.operations.PhysicalOperation;
import org.jfree.report.modules.output.pageable.base.operations.ShapeOperationModule;
import org.jfree.report.modules.output.pageable.base.operations.TextOperationModule;
import org.jfree.report.style.ElementStyleSheet;
import org.jfree.report.util.ElementLayoutInformation;
import org.jfree.report.util.Log;
import org.jfree.report.util.ReportConfiguration;

/**
 * A simple logical page implementation. Does work with a single physical page
 * and is not yet able to distribute its contents.
 *
 * @author Thomas Morgner
 */
public strictfp class LogicalPageImpl implements LogicalPage
{
  /** The output target. */
  private OutputTarget outputTarget;

  /** An array of physical pages. */
  private final PhysicalPage[] physicalPage;

  /** The physical page width. */
  private final int physicalPageWidth;

  /** The logical page format. */
  private PageFormat pageFormat;

  /** The physical page format. */
  private PageFormat physicalPageFormat;

  /** A flag that indicates whether or not the logical page is closed. */
  private boolean closed;

  /** The operation factory. */
  private final OperationFactory operationFactory;

  /**
   * A flag that indicates whether or not to add comments to the generated
   * physical operations. This is a usefull debugging option, but you won't have
   * fun with it elsewhere.
   */
  private final boolean addOperationComments;

  /**
   * Creates a new logical page, where the physical page format is equal to the
   * logical page format.
   *
   * @param format  the page format.
   */
  public LogicalPageImpl(final PageFormat format)
  {
    this(format, format);
  }

  /**
   * Creates a new logical page.  This creates a set of physical pages to receive
   * the content generated by the logical page.
   *
   * @param log  the logical page format.
   * @param phys  the physical page format.
   */
  public LogicalPageImpl(final PageFormat log, final PageFormat phys)
  {
    addOperationComments = ReportConfiguration.getGlobalConfig().isPrintOperationComment();
    closed = true; // logical page is closed by default ..
    operationFactory = createOperationFactory();

    setPageFormat(log);
    setPhysicalPageFormat(phys);

    int x = (int) (log.getImageableWidth() / phys.getImageableWidth());
    if (x * phys.getImageableWidth() < log.getImageableWidth())
    {
      x += 1;
    }

    int y = (int) (log.getImageableHeight() / phys.getImageableHeight());
    if (y * phys.getImageableHeight() < log.getImageableHeight())
    {
      y += 1;
    }
    physicalPage = new PhysicalPage[x * y];
    physicalPageWidth = y;
    for (int i = 0; i < physicalPage.length; i++)
    {
      physicalPage[i] = new PhysicalPage(phys,
          new Rectangle2D.Float(0, 0,
              (float) phys.getImageableWidth(),
              (float) phys.getImageableHeight()));
    }
  }

  /**
   * Gets the local instance of the operations factory. The operation factory is
   * responsible for converting content into basic operations, which can be executed
   * on the OutputTarget.
   *
   * @return the local operation factory.
   */
  public OperationFactory getOperationFactory()
  {
    return operationFactory;
  }

  /**
   * Initializes the operations factory. The operation factory is responsible for
   * converting content into basic operations, which can be executed on the OutputTarget.
   *
   * @return the local operation factory.
   */
  protected OperationFactory createOperationFactory()
  {
    final OperationFactory operationFactory = new OperationFactory();
    operationFactory.registerModule(new TextOperationModule());
    operationFactory.registerModule(new ImageOperationModule());
    operationFactory.registerModule(new ShapeOperationModule());
    operationFactory.registerModule(new DrawableOperationModule());
    return operationFactory;
  }

  /**
   * Returns the physical page at a particular row and column of the PageGrid.
   * The logical page can be split into multiple physical pages to display content
   * that would not fit on a single page.
   *
   * @param x the X-Coordinate in the page grid.
   * @param y the Y-Coordinate in the page grid.
   *
   * @return the physical page.
   */
  public PhysicalPage getPhysicalPage(final int x, final int y)
  {
    return physicalPage[y * physicalPageWidth + x];
  }

  /**
   * Defines the OutputTarget that is used to finally print the content.
   *
   * @param ot the outputTarget, must not be null
   * @throws NullPointerException if the given OutputTarget is null
   */
  public void setOutputTarget(final OutputTarget ot)
  {
    if (ot == null)
    {
      throw new NullPointerException();
    }
    this.outputTarget = ot;
  }

  /**
   * Returns the OutputTarget used to display the contents of this logical page.
   *
   * @return the defined OutputTarget
   */
  public OutputTarget getOutputTarget()
  {
    return outputTarget;
  }

  /**
   * Returns the logical page format.
   *
   * @return the page format.
   */
  public PageFormat getPageFormat()
  {
    return pageFormat;
  }

  /**
   * Sets the logical page format.
   *
   * @param format  the page format (null not permitted).
   */
  public void setPageFormat(final PageFormat format)
  {
    if (format == null)
    {
      throw new NullPointerException();
    }
    this.pageFormat = format;
  }

  /**
   * Returns the physical page format.
   *
   * @return the page format.
   */
  public PageFormat getPhysicalPageFormat()
  {
    return physicalPageFormat;
  }

  /**
   * Sets the physical page format.
   *
   * @param format  the page format.
   */
  public void setPhysicalPageFormat(final PageFormat format)
  {
    if (format == null)
    {
      throw new NullPointerException();
    }
    this.physicalPageFormat = format;
  }

  /**
   * Add all elements from the band to this logical page. The content is also distributed
   * over the assigned physical pages.
   *
   * @param bounds where to add the band. The bands were calculated by the PageLayouter
   * @param band the band which will be added to the page
   * @throws OutputTargetException if the band addition failed
   */
  public void addBand(final Rectangle2D bounds, final Band band) throws OutputTargetException
  {
    final Spool operations = spoolBand(bounds, band);
    if (operations.isEmpty())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -