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

📄 jfreereport.java

📁 Java的Web报表库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
   *
   * @return the report footer (never <code>null</code>).
   */
  public ReportFooter getReportFooter()
  {
    return reportFooter;
  }

  /**
   * Sets the page header.
   *
   * @param header  the page header (<code>null</code> not permitted).
   */
  public void setPageHeader(final PageHeader header)
  {
    if (header == null)
    {
      throw new NullPointerException("JFreeReport.setPageHeader(...) : null not permitted.");
    }

    this.pageHeader.unregisterStyleSheetCollection(getStyleSheetCollection());
    this.pageHeader = header;
    this.pageHeader.registerStyleSheetCollection(getStyleSheetCollection());
  }

  /**
   * Returns the page header.
   *
   * @return the page header (never <code>null</code>).
   */
  public PageHeader getPageHeader()
  {
    return pageHeader;
  }

  /**
   * Sets the page footer.
   *
   * @param footer  the page footer (<code>null</code> not permitted).
   */
  public void setPageFooter(final PageFooter footer)
  {
    if (footer == null)
    {
      throw new NullPointerException("JFreeReport.setPageFooter(...) : null not permitted.");
    }

    this.pageFooter.unregisterStyleSheetCollection(getStyleSheetCollection());
    this.pageFooter = footer;
    this.pageFooter.registerStyleSheetCollection(getStyleSheetCollection());
  }

  /**
   * Returns the page footer.
   *
   * @return the page footer (never <code>null</code>).
   */
  public PageFooter getPageFooter()
  {
    return pageFooter;
  }

  /**
   * Sets the item band for the report.
   *
   * @param band  the new item band (<code>null</code> not permitted).
   */
  public void setItemBand(final ItemBand band)
  {
    if (band == null)
    {
      throw new NullPointerException("JFreeReport.setItemBand(...) : null not permitted.");
    }

    this.itemBand.unregisterStyleSheetCollection(getStyleSheetCollection());
    this.itemBand = band;
    this.itemBand.registerStyleSheetCollection(getStyleSheetCollection());
  }

  /**
   * Returns the report's item band.
   *
   * @return the item band (never <code>null</code>).
   */
  public ItemBand getItemBand()
  {
    return this.itemBand;
  }

  /**
   * Adds a group to the report.
   *
   * @param group  the group.
   */
  public void addGroup(final Group group)
  {
    groups.add(group);
  }

  /**
   * Sets the groups for this report. If no list (null) or an
   * empty list is given, an default group is created. This default
   * group contains no elements and starts at the first record of the
   * data and ends on the last record.
   *
   * @param groupList  the list of groups.
   */
  public void setGroups(final GroupList groupList)
  {
    if (groupList == null)
    {
      throw new NullPointerException("GroupList must not be null");
    }

    this.groups.clear();
    final Iterator it = groupList.iterator();
    while (it.hasNext())
    {
      addGroup((Group) it.next());
    }
    checkGroups();
  }

  /**
   * Verifies the group list and adds the default group to the list if necessary.
   */
  protected void checkGroups()
  {
    // if this was an empty group, fix it by adding an default group
    if (groups.size() == 0)
    {
      final Group defaultGroup = new Group();
      defaultGroup.setName("default");
      addGroup(defaultGroup);
    }
  }

  /**
   * Returns a clone of the list of groups for the report.
   *
   * @return the group list.
   */
  public GroupList getGroups()
  {
    return (GroupList) this.groups.clone();
  }

  /**
   * Returns the number of groups in this report.
   * <P>
   * Every report has at least one group defined.
   *
   * @return the group count.
   */
  public int getGroupCount()
  {
    return groups.size();
  }

  /**
   * Returns the group at the specified index or null, if there is no such group.
   *
   * @param count  the group index.
   *
   * @return the requested group.
   *
   * @throws IllegalArgumentException if the count is negative.
   * @throws IndexOutOfBoundsException if the count is greater than the number of defined groups.
   */
  public Group getGroup(final int count)
  {
    if (count < 0)
    {
      throw new IllegalArgumentException("GroupCount must not be negative");
    }

    if (count >= groups.size())
    {
      throw new IndexOutOfBoundsException("No such group defined. " + count + " vs. "
          + groups.size());
    }

    return groups.get(count);
  }

  /**
   * Adds a function to the report's collection of functions.
   *
   * @param function  the function.
   *
   * @throws FunctionInitializeException if any of the functions cannot be initialized.
   */
  public void addExpression(final Expression function) throws FunctionInitializeException
  {
    expressions.add(function);
  }

  /**
   * Adds a function to the report's collection of functions.
   *
   * @param function  the function.
   *
   * @throws FunctionInitializeException if any of the functions cannot be initialized.
   */
  public void addFunction(final Function function) throws FunctionInitializeException
  {
    this.functions.add(function);
  }

  /**
   * Returns the report's collection of functions.
   *
   * @return the function collection.
   */
  public ExpressionCollection getFunctions()
  {
    return this.functions;
  }

  /**
   * Sets the function collection.
   *
   * @param functions  the collection of functions.
   */
  public void setFunctions(final ExpressionCollection functions)
  {
    if (functions == null)
    {
      throw new NullPointerException("JFreeReport.setFunctions(...) : null not permitted.");
    }
    else
    {
      this.functions = functions;
    }
  }

  /**
   * Returns the default page format.
   *
   * @return the page format.
   */
  public PageFormat getDefaultPageFormat()
  {
    return defaultPageFormat;
  }

  /**
   * Defines the default page format for this report. The default is a hint
   * to define at least one suitable format. If no format is defined the system's default
   * page format is used.
   *
   * @param format  the default format (<code>null</code> permitted).
   */
  public void setDefaultPageFormat(PageFormat format)
  {
    if (format == null)
    {
      format = PrinterJob.getPrinterJob().defaultPage();
    }
    defaultPageFormat = format;
  }

  /**
   * Sets the data for the report.
   * <P>
   * Reports are generated from a {@link TableModel} (as used by Swing's
   * {@link javax.swing.JTable}). If you don't want to give data to the report, use an empty
   * {@link TableModel} instead of <code>null</code>.
   *
   * @param data  the data for the report (<code>null</code> not permitted).
   */
  public void setData(final TableModel data)
  {
    if (data == null)
    {
      throw new NullPointerException("JFreeReport.setData(...) : null not permitted.");
    }
    this.data = data;
  }

  /**
   * Returns the current data for this report.
   *
   * @return the data in form of a table model.
   */
  public TableModel getData()
  {
    return data;
  }

  /**
   * Clones the report.
   *
   * @return the clone.
   *
   * @throws CloneNotSupportedException this should never happen.
   */
  public Object clone() throws CloneNotSupportedException
  {
    final JFreeReport report = (JFreeReport) super.clone();
    report.data = data; // data is defined to be immutable, so don't clone the thing
    report.defaultPageFormat = (PageFormat) defaultPageFormat.clone();
    report.groups = (GroupList) groups.clone();
    report.itemBand = (ItemBand) itemBand.clone();
    report.pageFooter = (PageFooter) pageFooter.clone();
    report.pageHeader = (PageHeader) pageHeader.clone();
    report.properties = (ReportProperties) properties.clone();
    report.reportFooter = (ReportFooter) reportFooter.clone();
    report.reportHeader = (ReportHeader) reportHeader.clone();
    report.functions = (ExpressionCollection) functions.clone();
    report.expressions = (ExpressionCollection) expressions.clone();
    report.styleSheetCollection = (StyleSheetCollection) styleSheetCollection.clone();
    report.groups.updateStyleSheetCollection(report.styleSheetCollection);
    report.itemBand.updateStyleSheetCollection(report.styleSheetCollection);
    report.reportFooter.updateStyleSheetCollection(report.styleSheetCollection);
    report.reportHeader.updateStyleSheetCollection(report.styleSheetCollection);
    report.pageFooter.updateStyleSheetCollection(report.styleSheetCollection);
    report.pageHeader.updateStyleSheetCollection(report.styleSheetCollection);
    return report;
  }

  /**
   * Returns information about the JFreeReport class library.
   *
   * @return the information.
   */
  public static final JFreeReportInfo getInfo()
  {
    if (JFreeReport.info == null)
    {
      JFreeReport.info = new JFreeReportInfo();
    }
    return JFreeReport.info;
  }

  /**
   * Returns the expressions for the report.
   *
   * @return the expressions.
   */
  public ExpressionCollection getExpressions()
  {
    return expressions;
  }

  /**
   * Sets the expressions for the report.
   *
   * @param expressions  the expressions (<code>null</code> not permitted).
   */
  public void setExpressions(final ExpressionCollection expressions)
  {
    if (expressions == null)
    {
      throw new NullPointerException("JFreeReport.setExpressions(...) : null not permitted.");
    }
    this.expressions = expressions;
  }

  /**
   * Returns the report configuration.
   * <p>
   * The report configuration is automatically set up when the report is first created, and uses
   * the global JFreeReport configuration as its parent.
   *
   * @return the report configuration.
   */
  public ReportConfiguration getReportConfiguration()
  {
    return reportConfiguration;
  }

  /**
   * deserizalize the report and restore the pageformat.
   *
   * @param out the objectoutput stream
   * @throws IOException if errors occur
   */
  private void writeObject(final ObjectOutputStream out)
      throws IOException
  {
    out.defaultWriteObject();
    SerializerHelper.getInstance().writeObject(defaultPageFormat, out);
  }

  /**
   * resolve the pageformat, as PageFormat is not serializable.
   *
   * @param in  the input stream.
   *
   * @throws IOException if there is an IO problem.
   * @throws ClassNotFoundException if there is a class problem.
   */
  private void readObject(final ObjectInputStream in)
      throws IOException, ClassNotFoundException
  {
    in.defaultReadObject();
    defaultPageFormat = (PageFormat) SerializerHelper.getInstance().readObject(in);
  }

  /**
   * Returns the stylesheet collection of this report. The stylesheet collection
   * is fixed for the report and all elements of the report. When a band or
   * group is added to the report it will get registered with this stylesheet
   * collection and cannot be used in an different report.
   *
   * @return the stylesheet collection of the report, never null.
   */
  public StyleSheetCollection getStyleSheetCollection()
  {
    return styleSheetCollection;
  }
}

⌨️ 快捷键说明

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