fllogosm
 Main
 User's Guide
 Developer's Guide
 Admin's Guide
 FAQ
 License Info
 Feedback
 Page Preview

Class nrio.reports.FMPreviewPanel


java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----nrio.reports.FMPreviewPanel


 

public class FMPreviewPanel extends Canvas

FMPreviewPanel is a Canvas that shows a preview of a form view report, with several useful utilities, like being able to print report pages (instead of directly using FormViewPagePrinter), incorporating page layout printing and previewing or finally having a built-in zoom feature. This bean should be used as a high-level, all-in-one printing facility for form view reports.

In FMPreviewPanel you have two different entities whose settings need to be set: the page (and its layout, as defined in the nrio.reports.PageLayout bean) represents the actual page to be printed, while forms are panels designed with theVFD (Visual Form Designer). Usually you will have several forms for each page (eg. 2 columns by 4 rows).

How do you use this object? Here follows a simple Java method that creates a Frame, draws a page on screen, and then prints it on paper (a PrintJob object correctly initialized must be passed to this method in order for it to work).

Note: myFormString, myRecVal, myRecStr, myPSettings in this listing are to be substituted with objects containing meaningful values.

private void printFormPage(int page, PrintJob myPrintJob) {
        Frame f = new Frame("printing..");

        f.setBounds(0, 0, 600, 400);
        f.setLayout(new BorderLayout());
       

        if (myPrintJob != null) {
                Graphics g;
                FMPreviewPanel fmp = new FMPreviewPanel();
                f.setVisible(true);
                f.add(fmp, "Center");
                fmp.setFormBackground(Color.black);
                fmp.setFormForeground(Color.white);
                fmp.setFormHorCopies(0);
                fmp.setFormVerCopies(0);
                fmp.setFormSize(new Dimension(640, 400));
                fmp.setFormInit(myFormString);
                fmp.setTopLeftMargin(new Point(30, 30));
                fmp.setBottomRightMargin(new Point(30, 30);
                fmp.setPSettings(myPSettings);
                fmp.setPSize(new Dimension(2000, 1000));
                fmp.setSRecVal(myRecVal);
                fmp.setSRecordStr(myRecStr);
                fmp.setPagePrinter(new FormViewPagePrinter());
                fmp.setCurrentPage(page);
                fmp.setZoomLevel(100);
                fmp.repaint();
                f.validate();
                g = myPrintJob.getGraphics();
                fmp.print(g);
                g.dispose();
                f.dispose();
        }
}


FMPreviewPanel()
        FMPreviewPanel constructor.

getBottomRightMargin()
        Gets the bottom right margin for the printable area of the page, in pixels.
getCurrentPage()
        Gets the current page to be printed.
getFormBackground()
        Gets the form background color.
getFormForeground()
        Gets the form foreground color.
getFormHorCopies()
        Gets the number of forms to be printed in a page (in the horizontal direction).
getFormInit()
        Gets the form init string.
getFormSize()
        Gets the form size.
getFormVerCopies()
        Gets the number of forms to be printed in a page (in the vertical direction).
getPagePrinter()
        Gets the currently in use FormViewPagePrinter object.
getPSettings()
        Gets the page settings that will be used to draw a page layout.
getPSize()
        Gets the page size.
getSRecordStr()
        Gets the database fields structure.
getSRecVal()
        Gets the currently set records.
getTopLeftMargin()
        Gets the top left margin for the printable area of the page, in pixels.
getZoomLevel()
        Gets the currently set zoom level.
paint(Graphics)
        Paints the current page with the current settings.
print(Graphics)
        Prints the current page with the current settings. Use this method instead of paint if you are going to print on paper your reports.
setBottomRightMargin(Point)
        Sets the bottom right margin for the printable area of the page, in pixels.
setCurrentPage(int)
        Sets the page to be printed.
setFormBackground(Color)
        Sets the form background color.
setFormForeground(Color)
        Sets the form foreground color.
setFormHorCopies(int)
        Sets the number of forms to be printed in a page (in the horizontal direction).
setFormInit(String)
        Sets the form init string.
setFormSize(Dimension)
        Sets the form size.
setFormVerCopies(int)
        Sets the number of forms to be printed in a page (in the vertical direction).
setPagePrinter(FormViewPagePrinter)
        Sets the currently in use FormViewPagePrinter object.
setPSettings(PageSettings)
        Sets the page settings that will be used to draw a page layout.
setPSize(Dimension)
        Sets the page size.
setSRecordStr(String[][])
        Sets the database fields structure.
setSRecVal(String[][])
        Sets the records to be printed.
setTopLeftMargin(Point)
        Sets the top left margin for the printable area of the page, in pixels.
setZoomLevel(int)
        Sets the zoom level.

 

FMPreviewPanel


 public FMPreviewPanel()
 


        FMPreviewPanel constructor.

getBottomRightMargin


 public Point getBottomRightMargin()
 


        Gets the bottom right margin for the printable area of the page, in pixels. This measure is considered to be relative to the bottom right margin of the document (eg. [10, 15] means 10 pixels from the right of the document and 15 from the bottom).
       

    Returns:
                    The bottomRightMargin property value. See Also:
                    setBottomRightMargin

getCurrentPage


 public int getCurrentPage()
 


        Gets the current number of page to be printed. The first page is marked as 1 (one).
       

    Returns:
                    The currentPage property value. See Also:
                    setCurrentPage

getFormBackground


 public Color getFormBackground()
 


        Gets the form background color. This is not the background color for the page, but rather the background color for the single forms to be printed in the page (therefore you can have blue forms on a violet page, if you got the toner).
       

    Returns:
                    The formBackground property value. See Also:
                    setFormBackground

getFormForeground


 public Color getFormForeground()
 


        Gets the form foreground color. This is not the foreground color for the page, but rather the foreground color for the single forms to be printed in the page (therefore you can have pink forms on a yellow page, if your aesthetics can forgive you).

    Returns:
                    The formForeground property value. See Also:
                    setFormForeground

getFormHorCopies


 public int getFormHorCopies()
 


        Gets the number of forms to be printed in a page (in the horizontal direction). If you get 0 (zero) as the return value for this method, it means that an optimal number of forms (as many as they will fit into a page) will be drawn.
       

    Returns:
                    The formHorCopies property value. See Also:
                    setFormHorCopies

getFormInit


 public String getFormInit()
 


        Gets the form init string. The form init string is not human readable, it's just what the VFD produces and saves into .mfr files.

    Returns:
                    The formInit property value. See Also:
                    setFormInit

getFormSize


 public Dimension getFormSize()
 


        Gets the form size (in pixels). Warning: this is not the page size.
       

    Returns:
                    The formSize property value. See Also:
                    setFormSize

getFormVerCopies


 public int getFormVerCopies()
 


        Gets the number of forms to be printed in a page (in the vertical direction). If you get 0 (zero) as the return value for this method, it means that an optimal number of forms (as many as they will fit into a page) will be drawn.
       

    Returns:
                    The formVerCopies property value. See Also:
                    setFormVerCopies

getPagePrinter


 public FormViewPagePrinter getPagePrinter()
 


        Gets the currently in use FormViewPagePrinter object. You can directly set properties for this object, or let the paint and print methods do this for you (as long as you have correctly set all of the related properties in this object, of course).
       

    Returns:
                    nrio.reports.FormViewPagePrinter

getPSettings


 public PageSettings getPSettings()
 


        Gets the page settings that will be used to draw a page layout (this is not related to forms, only to the layout of the page, eg background color for the page, watermark, page header and footer, etc).
       

    Returns:
                    The pSettings property value. See Also:
                    setPSettings

getPSize


 public Dimension getPSize()
 


        Gets the page size (in pixels). This includes header and footer (basically the whole page size is returned).
       

    Returns:
                    The pSize property value. See Also:
                    setPSize

getSRecordStr


 public String[][] getSRecordStr()
 


        Gets the database fields structure, exactly as it would be returned by RXDbase or MaxBase dbinfo method.
       

    Returns:
                    java.lang.String[][]

getSRecVal


 public String[][] getSRecVal()
 


        Gets the currently set records, exactly as they were returned by RXDbase or MaxBase loadrecwithfilter method..
       

    Returns:
                    java.lang.String[][]

getTopLeftMargin


 public Point getTopLeftMargin()
 


        Gets the top left margin for the printable area of the page, in pixels. This measure is considered to be relative to the bottom right margin of the document (eg. [10, 15] means 10 pixels from the left of the document and 15 from the top).
       

    Returns:
                    The topLeftMargin property value. See Also:
                    setTopLeftMargin

getZoomLevel


 public int getZoomLevel()
 


        Gets the currently set zoom level. Warning: zoom level only affects the paint(Graphics) method, not print(Graphics).
       

    Returns:
                    int

paint


 public void paint(Graphics g)
 


        Paints the current page, with the current settings, on the specified Graphics object. Should be used to draw on screen representations of yout forms, although the FMPreviewPanel object can do this already (advice: if you need to do a preview of your reports, just put this object into a Frame with some controls to let the user modify page number, zoom level, etc).
       

    Parameters:
                    g - java.awt.Graphics Overrides:
                    paint in class Canvas

print


 public void print(Graphics g)
 


        Prints the current page, with the current settings, on the specified Graphics object. Use this method instead of paint if you are going to print on paper your reports. Warning: zoom settings will be ignored while printing the form.
       

    Parameters:
                    g - java.awt.Graphics Overrides:
                    print in class Component

setBottomRightMargin


 public void setBottomRightMargin(Point bottomRightMargin)
 


        Sets the bottom right margin for the printable area of the page, in pixels. This measure is considered to be relative to the bottom right margin of the document (eg. [10, 15] means 10 pixels from the right of the document and 15 from the bottom).

    Parameters:
                    bottomRightMargin - The new value for the property. See Also:
                    getBottomRightMargin

setCurrentPage


 public void setCurrentPage(int page)
 


        Sets the current number of page to be printed. The first page is marked as 1 (one).
       

    Parameters:
                    page - the new value for this property. See Also:
                    setCurrentPage

setFormBackground


 public void setFormBackground(Color formBackground)
 


        Sets the form background color. This is not the background color for the page, but rather the background color for the single forms to be printed in the page (therefore you can have blue forms on a violet page, if you got the toner).

    Parameters:
                    formBackground - The new value for the property. See Also:
                    getFormBackground

setFormForeground


 public void setFormForeground(Color formForeground)
 


        Sets the form foreground color. This is not the foreground color for the page, but rather the foreground color for the single forms to be printed in the page (therefore you can have pink forms on a yellow page, if your aesthetics can forgive you).

    Parameters:
                    formForeground - The new value for the property. See Also:
                    getFormForeground

setFormHorCopies


 public void setFormHorCopies(int formHorCopies)
 


        Sets the number of forms to be printed in a page (in the horizontal direction). If you get 0 (zero) as the return value for this method, it means that an optimal number of forms (as many as they will fit into a page) will be drawn.

    Parameters:
                    formHorCopies - The new value for the property. See Also:
                    getFormHorCopies

setFormInit


 public void setFormInit(String formInit)
 


        Sets the form init string. The form init string is not human readable, it's just what the VFD produces and saves into .mfr files.

    Parameters:
                    formInit - The new value for the property. See Also:
                    getFormInit

setFormSize


 public void setFormSize(Dimension formSize)
 


        Sets the form size (in pixels). Warning: this is not the page size.

    Parameters:
                    formSize - The new value for the property. See Also:
                    getFormSize

setFormVerCopies


 public void setFormVerCopies(int formVerCopies)
 


        Sets the number of forms to be printed in a page (in the vertical direction). If you get 0 (zero) as the return value for this method, it means that an optimal number of forms (as many as they will fit into a page) will be drawn.

    Parameters:
                    formVerCopies - The new value for the property. See Also:
                    getFormVerCopies

setPagePrinter


 public void setPagePrinter(FormViewPagePrinter newValue)
 


        Sets the currently in use FormViewPagePrinter object. You can directly set properties for this object, or let the paint and print methods do this for you (as long as you have correctly set all of the related properties in this object, of course).

    Parameters:
                    newValue - nrio.reports.FormViewPagePrinter

setPSettings


 public void setPSettings(PageSettings pSettings)
 


        Sets the page settings that will be used to draw a page layout (this is not related to forms, only to the layout of the page, eg background color for the page, watermark, page header and footer, etc).

    Parameters:
                    pSettings - The new value for the property. See Also:
                    getPSettings

setPSize


 public void setPSize(Dimension pSize)
 


        Sets the page size (in pixels). This includes header and footer (basically the whole page size).

    Parameters:
                    pSize - The new value for the property. See Also:
                    getPSize

setSRecordStr


 public void setSRecordStr(String newValue[][])
 


       

    Sets the database fields structure, exactly as it would be returned by RXDbase or MaxBase dbinfo method.Parameters:
                    newValue - java.lang.String[][]

setSRecVal


 public void setSRecVal(String newValue[][])
 


        Sets the currently set records, exactly as they were returned by RXDbase or MaxBase loadrecwithfilter method.

    Parameters:
                    newValue - java.lang.String[][]

setTopLeftMargin


 public void setTopLeftMargin(Point topLeftMargin)
 


        Sets the top left margin for the printable area of the page, in pixels. This measure is considered to be relative to the bottom right margin of the document (eg. [10, 15] means 10 pixels from the left of the document and 15 from the top).

    Parameters:
                    topLeftMargin - The new value for the property. See Also:
                    getTopLeftMargin

setZoomLevel


 public void setZoomLevel(int newValue)
 


        Sets the currently set zoom level. Warning: zoom level only affects the paint(Graphics) method, not print(Graphics).

    Parameters:
                    newValue - int

 Page Layout  Line View  Form View