|
|||||||||
| Home >> All >> com >> pjsofts >> eurobudget >> [ gui overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.pjsofts.eurobudget.gui
Class PrintableComponent

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.pjsofts.eurobudget.gui.PrintableComponent
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Pageable, java.awt.print.Printable, java.io.Serializable
- public class PrintableComponent
- extends javax.swing.JComponent
- implements java.awt.print.Printable, java.awt.print.Pageable
- extends javax.swing.JComponent
Basic Component that is able to print or preview another component. Receive an awt Component in parameters and prints it. Could be useed as a Printable or as a JComponent (to preview the printing)
| Nested Class Summary |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
private boolean |
autoFit
flag: make the component fit in page width if needed |
private int |
bufferH
same as |
private int |
bufferW
final width for buffer to be in page (same as buffer ) |
private java.awt.Component |
component
Initial awt component to render |
private int |
currentPage
current index of page to display (starting from 0 like Print API) |
private double |
fitRatio
fit ratio |
private boolean |
keepRatio
if component is resized; keep its ratio |
private int |
numberOfPages
last computed value for this |
private java.awt.print.PageFormat |
pageFormat
Page format to use |
private int |
pageHeight
|
private int |
pageWidth
width of the page on screen in pixel (could be different as the one in page format) due of zoom |
private int |
portionH
portion height, same as imageableHeight in one portion |
private double |
zoom
zoom value |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.print.Printable |
NO_SUCH_PAGE, PAGE_EXISTS |
| Fields inherited from interface java.awt.print.Pageable |
UNKNOWN_NUMBER_OF_PAGES |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
PrintableComponent(java.awt.Component component,
java.awt.print.PageFormat pf)
convenient constructor that take autofit value from preferences |
|
PrintableComponent(java.awt.Component component,
java.awt.print.PageFormat pf,
boolean autoFit)
|
|
| Method Summary | |
java.awt.Component |
getComponent()
Getter for property component. |
int |
getCurrentPage()
Getter for property currentPage. |
int |
getNumberOfPages()
Returns the number of pages in the set. |
java.awt.print.PageFormat |
getPageFormat()
Getter for property pageFormat. |
java.awt.print.PageFormat |
getPageFormat(int pageIndex)
Returns the PageFormat of the page specified by
pageIndex. |
java.awt.print.Printable |
getPrintable(int pageIndex)
Returns the Printable instance responsible for
rendering the page specified by pageIndex. |
double |
getZoom()
Getter for property zoom. |
boolean |
isAutoFit()
Getter for property autoFit. |
boolean |
isOpaque()
Returns true if this component is completely opaque. |
protected void |
paintComponent(java.awt.Graphics graph)
Invoked by Swing to draw components. |
int |
print(java.awt.Graphics graphics,
java.awt.print.PageFormat pf,
int pageIndex)
throws PrinterExceptionPrints the page at the specified index into the specified Graphics context in the specified format. |
void |
setAutoFit(boolean autoFit)
Setter for property autoFit. |
void |
setComponent(java.awt.Component component)
Setter for property component. |
void |
setCurrentPage(int currentPage)
Setter for property currentPage. |
void |
setPageFormat(java.awt.print.PageFormat pageFormat)
Setter for property pageFormat. |
void |
setZoom(double zoom)
Setter for property zoom. |
private void |
updateInternalData()
update current number of pages and cache of original component image. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
component
private java.awt.Component component
- Initial awt component to render
pageFormat
private java.awt.print.PageFormat pageFormat
- Page format to use
autoFit
private boolean autoFit
- flag: make the component fit in page width if needed
keepRatio
private boolean keepRatio
- if component is resized; keep its ratio
currentPage
private int currentPage
- current index of page to display (starting from 0 like Print API)
numberOfPages
private int numberOfPages
- last computed value for this
fitRatio
private double fitRatio
- fit ratio
zoom
private double zoom
- zoom value
bufferW
private int bufferW
- final width for buffer to be in page (same as buffer )
bufferH
private int bufferH
- same as
portionH
private int portionH
- portion height, same as imageableHeight in one portion
pageWidth
private int pageWidth
- width of the page on screen in pixel (could be different as the one in page format) due of zoom
pageHeight
private int pageHeight
| Constructor Detail |
PrintableComponent
public PrintableComponent(java.awt.Component component, java.awt.print.PageFormat pf, boolean autoFit)
PrintableComponent
public PrintableComponent(java.awt.Component component, java.awt.print.PageFormat pf)
- convenient constructor that take autofit value from preferences
| Method Detail |
public int print(java.awt.Graphics graphics, java.awt.print.PageFormat pf, int pageIndex)
- throws PrinterExceptionPrints the page at the specified index into the specified Graphics context in the specified format. A PrinterJob calls the Printable interface to request that a page be rendered into the context specified by graphics. The format of the page to be drawn is specified by pageFormat. The zero based index of the requested page is specified by pageIndex. If the requested page does not exist then this method returns NO_SUCH_PAGE; otherwise PAGE_EXISTS is returned. The Graphics class or subclass implements the PrinterGraphics interface to provide additional information. If the Printable object aborts the print job then it throws a PrinterException.
Parameters:
graphics - the context into which the page is drawn
pageFormat - the size and orientation of the page being drawn
pageIndex - the zero based index of the page to be drawn
Returns:
PAGE_EXISTS if the page is rendered successfully or NO_SUCH_PAGE if pageIndex specifies a non-existent page.
Throws:
PrinterException - thrown when the print job is terminated.
- Specified by:
printin interfacejava.awt.print.Printable
paintComponent
protected void paintComponent(java.awt.Graphics graph)
- Invoked by Swing to draw components.
updateInternalData
private void updateInternalData()
- update current number of pages and cache of original component image.
compute new size of component (width, height) to fit the page.
To call each time pageFormat or component changed.
getNumberOfPages
public int getNumberOfPages()
- Returns the number of pages in the set.
To enable advanced printing features,
it is recommended that
Pageableimplementations return the true number of pages rather than the UNKNOWN_NUMBER_OF_PAGES constant.- Specified by:
getNumberOfPagesin interfacejava.awt.print.Pageable
isOpaque
public boolean isOpaque()
- Returns true if this component is completely opaque.
An opaque component paints every pixel within its rectangular bounds. A non-opaque component paints only a subset of its pixels or none at all, allowing the pixels underneath it to "show through". Therefore, a component that does not fully paint its pixels provides a degree of transparency.
Subclasses that guarantee to always completely paint their contents should override this method and return true.
getPageFormat
public java.awt.print.PageFormat getPageFormat(int pageIndex) throws java.lang.IndexOutOfBoundsException
- Returns the
PageFormatof the page specified bypageIndex.- Specified by:
getPageFormatin interfacejava.awt.print.Pageable
getPrintable
public java.awt.print.Printable getPrintable(int pageIndex) throws java.lang.IndexOutOfBoundsException
- Returns the
Printableinstance responsible for rendering the page specified bypageIndex.- Specified by:
getPrintablein interfacejava.awt.print.Pageable
isAutoFit
public boolean isAutoFit()
- Getter for property autoFit.
setAutoFit
public void setAutoFit(boolean autoFit)
- Setter for property autoFit.
getPageFormat
public java.awt.print.PageFormat getPageFormat()
- Getter for property pageFormat.
setPageFormat
public void setPageFormat(java.awt.print.PageFormat pageFormat)
- Setter for property pageFormat.
getComponent
public java.awt.Component getComponent()
- Getter for property component.
setComponent
public void setComponent(java.awt.Component component)
- Setter for property component.
getCurrentPage
public int getCurrentPage()
- Getter for property currentPage.
setCurrentPage
public void setCurrentPage(int currentPage)
- Setter for property currentPage.
getZoom
public double getZoom()
- Getter for property zoom.
setZoom
public void setZoom(double zoom)
- Setter for property zoom.
|
|||||||||
| Home >> All >> com >> pjsofts >> eurobudget >> [ gui overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC