📄 tablewriter.java
字号:
* Return the current expression value.
* <P>
* The value depends (obviously) on the expression implementation.
*
* @return the value of the function.
*/
public Object getValue()
{
return this;
}
/**
* Gets the maximum width available for a root band during the layouting process.
*
* @return the maximum width for a root band.
*/
public float getMaxWidth()
{
return maxWidth;
}
/**
* Defines the maximum width available for a root band during the layouting process.
*
* @param width the maximum width for a root band.
*/
public void setMaxWidth(final float width)
{
maxWidth = width;
}
/**
* Perform the layout of a band. The height of the band is calculated according to the contents
* of the band. The width of the band will always span the complete printable width.
*
* @param band the band.
*
* @return the dimensions of the band.
*/
private Rectangle2D doLayout(final Band band)
{
// in this layouter the width of a band is always the full page width.
// the height is not limited ...
final float width = getMaxWidth();
final float height = Short.MAX_VALUE;
final Rectangle2D bounds = BandLayoutManagerUtil.doLayout(band,
getLayoutSupport(),
width,
height);
getCurrentEvent().getState().fireLayoutCompleteEvent(band, getCurrentEvent().getType());
return bounds;
}
/**
* Forwards the given band to the TableProducer. This will create the content
* and will add the TableCellData object to the grid.
*
* @see TableProducer#processBand
* @param bounds the bounds of the band, defines the position of the printed band within
* the sheet.
* @param band the band that should be printed.
*/
private void doPrint(final Rectangle2D bounds, final Band band)
{
// now print the band ...
producer.processBand(bounds, band);
getCursor().advance((float) bounds.getHeight());
// something was printed ...
producer.commit();
}
/**
* Ends the current page. Fires the PageFinished event.
*/
private void endPage()
{
if (inEndPage == true)
{
throw new IllegalStateException("Already in startPage or endPage");
}
inEndPage = true;
final ReportEvent currentEvent = getCurrentEvent();
final ReportState cEventState = getCurrentEvent().getState();
cEventState.firePageFinishedEvent();
cEventState.nextPage();
setCurrentEvent(currentEvent);
inEndPage = false;
}
/**
* Starts a new page. Fires the PageStarted event.
*/
public void startPage()
{
if (inEndPage == true)
{
throw new IllegalStateException("Already in startPage or endPage");
}
inEndPage = true;
final ReportEvent currentEvent = getCurrentEvent();
final ReportState cEventState = currentEvent.getState();
cEventState.firePageStartedEvent(currentEvent.getType());
setCurrentEvent(currentEvent);
inEndPage = false;
}
/**
* 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();
startPage();
delegate.reportStarted(event);
clearCurrentEvent();
}
/**
* Receives notification that the report has finished.
*
* @param event the event.
*/
public void reportFinished(final ReportEvent event)
{
setCurrentEvent(event);
delegate.reportFinished(event);
endPage();
producer.close();
clearCurrentEvent();
}
/**
* 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 ...
String sheetName = null;
if (getSheetNameFunction() != null)
{
sheetName = String.valueOf(getDataRow().get(getSheetNameFunction()));
}
producer.beginPage(sheetName);
delegate.pageStarted(event);
clearCurrentEvent();
}
/**
* Prints the page footer.
*
* @param event the event.
*/
public void pageFinished(final ReportEvent event)
{
setCurrentEvent(event);
delegate.pageFinished(event);
producer.endPage();
clearCurrentEvent();
}
/**
* Prints the group header for the current group.
*
* @param event the event.
*/
public void groupStarted(final ReportEvent event)
{
setCurrentEvent(event);
delegate.groupStarted(event);
clearCurrentEvent ();
}
/**
* Prints the group footer for the current group.
*
* @param event the event.
*/
public void groupFinished(final ReportEvent event)
{
setCurrentEvent(event);
delegate.groupFinished(event);
clearCurrentEvent ();
}
/**
* Clear the current event after the event was fully processed.
*/
private void clearCurrentEvent()
{
currentEvent = null;
}
/**
* Prints the itemband.
*
* @param event the event.
*/
public void itemsAdvanced(final ReportEvent event)
{
setCurrentEvent(event);
delegate.itemsAdvanced(event);
clearCurrentEvent();
}
/**
* 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);
delegate.itemsStarted(event);
clearCurrentEvent();
}
/**
* 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);
delegate.itemsFinished(event);
clearCurrentEvent();
}
/**
* 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)
{
if (producer == null)
{
throw new NullPointerException("Producer given must not be null.");
}
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("Assert: TableWriter function was not initialized properly");
}
}
public boolean isWatermarkSupported()
{
return false;
}
public boolean printWatermark(Band watermark) throws ReportProcessingException
{
throw new ReportProcessingException("Watermark printing is not supported for table targets.");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -