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

📄 tablewriter.java

📁 Java的Web报表库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }

    final float y = getCursor().getY();
    // don't save the state if the current page is currently being finished
    // or restarted; PageHeader and PageFooter are printed out of order and
    // do not influence the reporting state

    final Rectangle2D bounds = doLayout(b);
    bounds.setRect(0, y, bounds.getWidth(), bounds.getHeight());
    doPrint(bounds, b);

    if (!isInEndPage() && (isPageEmpty == false)
        && b.getStyle().getBooleanStyleProperty(BandStyleSheet.PAGEBREAK_AFTER) == true)
    {
      endPage();
      startPage();
    }
  }

  /**
   * The dependency level defines the level of execution for this function. Higher dependency
   * functions are executed before lower dependency functions. For ordinary functions and
   * expressions, the range for dependencies is defined to start from 0 (lowest dependency
   * possible to 2^31 (upper limit of int).
   * <p>
   * PageLayouter functions override the default behaviour an place them self at depency level -1,
   * an so before any userdefined function.
   *
   * @return the level.
   */
  public int getDependencyLevel()
  {
    return depLevel;
  }

  /**
   * Overrides the depency level. Should be lower than any other function depency.
   * @param deplevel the new depency level.
   */
  public void setDependencyLevel(final int deplevel)
  {
    this.depLevel = deplevel;
  }

  /**
   * Receives notification that the report has started.
   *
   * @param event  the event.
   */
  public void reportStarted(final ReportEvent event)
  {
    setCurrentEvent(event);

    producer.open();
    currentEffectiveGroupIndex = -1;
    startPage();
    print(event.getReport().getReportHeader());
  }

  /**
   * Receives notification that the report has finished.
   *
   * @param event  the event.
   */
  public void reportFinished(final ReportEvent event)
  {
    isLastPageBreak = true;
    setCurrentEvent(event);
    currentEffectiveGroupIndex -= 1;
    print(event.getReport().getReportFooter());
    endPage();
    producer.close();
  }

  /**
   * Retrieves the resources for this PreviewFrame. If the resources are not initialized,
   * they get loaded on the first call to this method.
   *
   * @return this frames ResourceBundle.
   */
  public ResourceBundle getResources()
  {
    if (resources == null)
    {
      resources = ResourceBundle.getBundle(BASE_RESOURCE_CLASS);
    }
    return resources;
  }

  /**
   * Prints the PageHeader and all repeating group headers.
   *
   * @param event  the event.
   */
  public void pageStarted(final ReportEvent event)
  {
    setCurrentEvent(event);
    // a new page has started, so reset the cursor ...
    setCursor(new TableWriterCursor());

    String sheetName = null;
    if (getSheetNameFunction() != null)
    {
      sheetName = String.valueOf(getDataRow().get(getSheetNameFunction()));
    }
    producer.beginPage(sheetName);

    final Band b = event.getReport().getPageHeader();
    if (event.getState().getCurrentPage() == 1)
    {
      if (b.getStyle().getBooleanStyleProperty(BandStyleSheet.DISPLAY_ON_FIRSTPAGE) == true)
      {
        print(b);
      }
    }
    else if (isLastPageBreak)
    {
      if (b.getStyle().getBooleanStyleProperty(BandStyleSheet.DISPLAY_ON_LASTPAGE) == true)
      {
        print(b);
      }
    }
    else
    {
      print(b);
    }

    /**
     * Repeating group header are printed on the top of every page, in reverse order.
     */
    for (int gidx = 0; gidx < currentEffectiveGroupIndex; gidx++)
    {
      final Group g = event.getReport().getGroup(gidx);
      if (g.getHeader().getStyle().getBooleanStyleProperty(BandStyleSheet.REPEAT_HEADER))
      {
        print(g.getHeader());
      }
    }
  }

  /**
   * Prints the page footer.
   *
   * @param event  the event.
   */
  public void pageFinished(final ReportEvent event)
  {
    setCurrentEvent(event);
    final Band b = event.getReport().getPageFooter();
    if (event.getState().getCurrentPage() == 1)
    {
      if (b.getStyle().getBooleanStyleProperty(BandStyleSheet.DISPLAY_ON_FIRSTPAGE) == true)
      {
        print(b);
      }
    }
    else if (isLastPageBreak)
    {
      if (b.getStyle().getBooleanStyleProperty(BandStyleSheet.DISPLAY_ON_LASTPAGE) == true)
      {
        print(b);
      }
    }
    else
    {
      print(b);
    }

    producer.endPage();
  }

  /**
   * Prints the group header for the current group.
   *
   * @param event  the event.
   */
  public void groupStarted(final ReportEvent event)
  {
    setCurrentEvent(event);
    currentEffectiveGroupIndex += 1;
    final int gidx = event.getState().getCurrentGroupIndex();
    final Group g = event.getReport().getGroup(gidx);
    final Band b = g.getHeader();
    print(b);
  }

  /**
   * Prints the group footer for the current group.
   *
   * @param event  the event.
   */
  public void groupFinished(final ReportEvent event)
  {
    setCurrentEvent(event);
    currentEffectiveGroupIndex -= 1;
    final int gidx = event.getState().getCurrentGroupIndex();
    final Group g = event.getReport().getGroup(gidx);
    final Band b = g.getFooter();
    print(b);
  }

  /**
   * Prints the itemband.
   *
   * @param event  the event.
   */
  public void itemsAdvanced(final ReportEvent event)
  {
    setCurrentEvent(event);
    print(event.getReport().getItemBand());
  }

  /**
   * Handles the start of the item processing.
   * <P>
   * The next events will be itemsAdvanced events until the itemsFinished event is raised.
   *
   * @param event The event.
   */
  public void itemsStarted(final ReportEvent event)
  {
    setCurrentEvent(event);
    currentEffectiveGroupIndex += 1;
  }

  /**
   * Handles the end of the item processing.
   * <P>
   * The itemBand is finished, the report starts to close open groups.
   *
   * @param event The event.
   */
  public void itemsFinished(final ReportEvent event)
  {
    // this event does nothing
    setCurrentEvent(event);
    currentEffectiveGroupIndex -= 1;
  }

  /**
   * Returns the current event, which has been updated at the start of every
   * ReportListener method.
   *
   * @return the current event.
   */
  public ReportEvent getCurrentEvent()
  {
    return currentEvent;
  }

  /**
   * Defines the current event, which must be updated at the start of every
   * ReportListener method.
   *
   * @param currentEvent the current event.
   */
  public void setCurrentEvent(final ReportEvent currentEvent)
  {
    this.currentEvent = currentEvent;
  }

  /**
   * Gets the TableProducer.
   *
   * @return the table producer that should be used to create the TableCellData.
   */
  public TableProducer getProducer()
  {
    return producer;
  }

  /**
   * Sets the TableProducer, that should be used to create the TableCellData.
   *
   * @param producer the table producer that should be used to create the TableCellData.
   */
  public void setProducer(final TableProducer producer)
  {
    this.producer = producer;
  }

  /**
   * Receives notification that a page was canceled by the ReportProcessor.
   * This method is called, when a page was removed from the report after
   * it was generated.
   *
   * @param event The event.
   */
  public void pageCanceled(final ReportEvent event)
  {
    // we are fairly sure, that our table report processor does not invoke this
    // method
  }

  /**
   * Receives notification that report generation initializes the current run.
   * <P>
   * The event carries a ReportState.Started state.  Use this to initialize the report.
   *
   * @param event The event.
   */
  public void reportInitialized(final ReportEvent event)
  {
    if (getMaxWidth() == 0)
    {
      throw new IllegalStateException("TableWriter function was not initialized properly");
    }
  }
}

⌨️ 快捷键说明

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