LineViewMockup is a Java Bean that subclasses java.awt.Canvas, implementing all of the MERGe Line View Reports features.
In the following diagram you can see the role of LineViewMockup in the reports drawing process:
What is the relationship between LineViewMockup and PageLayout? I have tried to make each one independent from the other, so you can benefit from greater flexibility (you can easily replace one of the two steps of the process of printing -- drawing the page layout and drawing the actual data --with your own code). This comes with a price, of course: you have to setup and call methods for two distinct objects but, as you will see, this is no rocket science. Everything has been thought to be as intuitive as possible.
The icon for this JavaBean is the following:
It allows you to do the following things:
- Define/get the properties of a Line View report.
- Draw the report in a Graphics object, on a per page basis. This means that you can both print on paper and on screen your reports.
- Produce an HTML table out of your data.
- Load and save .lmr files (lmr stands for Line Mode Report -- it is the standard format MERGe saves Line Mode reports in).
- Produce the NetRexx and Java code needed to reproduce the current report from others' code.
- Get information about the total number of pages a report will take.
- Get information about the maximum horizontal encumbrance (width) of a report.
- Show on screen a mockup of the report, because after all this is a Canvas. (Incidentally, this was the original reason for this class name)
You are not forced to use MaxBase databases for your reports, in fact you must pass the actual records information to a LineViewMockup object yourself, and thus they can come from any source you like. Moreover, you can set the following parameters for a given report:
- Fields arrangement.
- Fields to print and fields to hide.
- Fonts and colors information, both for headers and for records.
- Fields alignment.
The best way to code a report is to get a skeleton for it from MERGe, then add your own code (if needed), for further customization. However, here follows the complete listing of the LineViewMockup methods.
Use in IBM VisualAge for Javaand Symantec Visual Café: just create an instance of this bean inside a frame (if you want to exploit the fact that LineViewMockup draws a preview of the report in its Graphics space), or use it as a non-visual object (to draw and print into other Graphics objects).
Use of the LineViewMockup class with plain Jdk: import nrio.reports.LineViewMockup; Is required in your Java source file.
Constructor
LineViewMockup() Constructor
Methods
drawLineModeHTMLReport() Returns an HTML table using current report parameters. drawLineModeReport(int, int) Draws page "iPage" of the Line Mode report using current report parameters. getAllProperties() Gets all of the properties for this Line Mode report. getFieldArrangement() Gets the fieldArrangement property (java.lang.String[]) value. getGraphicContext() Returns the Graphics object used for the report. getHeaderColor() Gets the color used to paint the field names. getHeaderColorInvisible() Gets the visibility of the color used to paint the field names. getHeaderFill() Gets the color used to paint the field names background. getHeaderFillInvisible() Gets the visibility of the background below field names. getHeaderFont() Gets the font used to draw the field names. getHorHeaderLinesColor() Gets the color used to paint the horizontal lines surrounding field names getHorHeaderLinesColorInvisible() Gets the visibility of the horizontal lines in the grid that surrounds the field names. getHorRecordsLinesColor() Gets the color used to paint the horizontal lines surrounding records. getHorRecordsLinesColorInvisible() Gets the visibility of the horizontal lines in the grid that surrounds the records. getJavaCode() This method returns Java code that initializes a LineViewMockup object in order to replicate current report settings. getMaxHorEnc() This method returns the maximum width in pixels of the report. getNetRexxCode() This method returns NetRexx code that initializes a LineViewMockup object in order to replicate current report settings. getNumberOfPages() Returns the number of pages that this report will occupy. getNumberOfPages(int) Returns the number of pages that this report will occupy given a page height in pixels. getPageLength() Gets the page length (in pixels). getRecordsColor() Gets the color used to paint the record values. getRecordsColorInvisible() Gets the color used to paint the record values. getRecordsFill() Gets the color used to paint the records background. getRecordsFillInvisible() Gets the visibility of the records background. getRecordsFont() Gets the font used to draw the records values. getVerHeaderLinesColor() Gets the color used to paint the vertical lines around field names. getVerHeaderLinesColorInvisible() Gets the visibility of the vertical lines in the grid that surrounds the field names. getVerRecordsLinesColor() Gets the color used to paint the vertical lines around records. getVerRecordsLinesColorInvisible() Gets the visibility of the vertical lines in the grid that surrounds the records. getXOffset() Gets the left margin for the report. getYOffset() Gets the top margin for the report. loadProperties(String) Initializes the LineViewMockup object according to the fileName file. resetMockupDefaults() Reset color and font information to the default ones. saveProperties(String) Saves the LineViewMockup object on the fileName file. setAllProperties(LMProp) Sets all of the properties with a single method call. setFieldAlignment(int[]) Sets alignment for each field (even those not displayed). setFieldArrangement(String[]) Sets the fieldArrangement property (java.lang.String[]) value. setFieldLength(int[]) Sets maximum length (in characters) for each field (even those not displayed). setFieldName(String[]) Sets field names for each field (even those not displayed). setFieldVisible(boolean[]) Sets visibility for each field (even those not displayed). setGraphicContext(Graphics g) Sets the Graphics object used for the report. setHeaderColor(Color) Sets the color used to paint the field names. setHeaderColorInvisible(boolean) Sets the visibility of the field names. setHeaderFill(Color) Sets the color used to paint the field names background. setHeaderFillInvisible(boolean) Sets the visibility of the field names background. setHeaderFont(Font) Sets the font used to draw the field names. setHorHeaderLinesColor(Color) Sets the color used to paint the horizontal lines around field names. setHorHeaderLinesColorInvisible(boolean) Sets the visibility of the horizontal lines in the grid that surrounds the field names. setHorRecordsLinesColor(Color) Sets the color used to paint the horizontal lines around records. setHorRecordsLinesColorInvisible(boolean) Sets the visibility of the horizontal lines in the grid that surrounds the records. setMaxHorEnc() Sets the maximum width in pixels of the report. setPageLength(int) Sets the page length (in pixels). setRecordsColor(Color) Sets the color used to paint the records values. setRecordsColorInvisible(boolean) Sets the visibility of records foreground. If records foreground is invisible, anything painted below it will be visible. setRecordsFill(Color) Sets the color used to paint the records background. setRecordsFillInvisible(boolean) Sets the visibility of the background in the grid that surrounds the records (if the background is invisible, anything painted below it will be visible). setRecordsFont(Font) Sets the font used to draw the record values. setRecordValue(String[][]) Sets information about actual values to be printed. setVerHeaderLinesColor(Color) Sets the color used to paint the vertical lines around the field names. setVerHeaderLinesColorInvisible(boolean) Sets the visibility of the vertical lines in the grid that surrounds the field names. setVerRecordsLinesColor(Color) Sets the color for vertical lines in the grid that surrounds the records. setVerRecordsLinesColorInvisible(boolean) Sets the visibility of the vertical lines in the grid that surrounds the records. setXOffset() Sets the left margin for the report. setYOffset() Sets the top margin for the report. updateMockup() This method updates the Canvas (LineViewMockup is a Canvas) with a sample using current settings for fonts and colors.
Constructor
LineViewMockup
public LineViewMockup()
Constructor
Methods
drawLineModeHTMLReport
public String drawLineModeHTMLReport()
Returns a String representing an HTML table (using current report parameters).
drawLineModeReport
public synchronized void drawLineModeReport(int iPage, int iAlign)
Draws page "iPage" of the Line Mode report on the current graphic context (see getGraphicContext and setGraphicContext), which must be already correctly initialized when you call drawLineModeReport, using current report parameters. iAlign represents the alignment of the printed records, and can be one of the following: 0 (right aligned), 1 (left aligned), 2 (centered). Note: if you decide to use right-alignment or centered alignment, you'll need to call setMaxHorEnc before calling drawLineModeReport.
getAllProperties
public LMProp getAllProperties()
Gets all of the properties for this Line Mode report.
The LMProp object is a class which only has a constructor, LMProp(), and a a bunch of properties (that you can get or set):
Color hBack (Header Background color) Color hFore (Header Foreground color) Color hVL (Header Vertical Lines color) Color hHL (Header Horizontal Lines color) Color rBack (Records Background color) Color rFore (Records Foreground color) Color rVL (Records Vertical Lines color) Color rHL (Records Horizontal Lines color) boolean hForeInvisible (is Header Foreground invisible?) boolean hBackInvisible boolean hHLInvisible boolean hVLInvisible boolean rForeInvisible boolean rBackInvisible boolean rHLInvisible boolean rVLInvisible Font hFont (Header Font) Font rFont (Records Font) String dbName (Name of the local DB -- must include full path info but no .dat extension. This is facultative, if you don't use RXDBase for your data) String sortIndex (The name of the field on which records should be ordered. Facultative) boolean bAscending (Should the records be ordered in ascending or descending order? Facultative) String query (Query to be executed on the MaxBase DB. Facultative) String[] fNames (Field names: given that the fields are N, this has an N+1 size, with the [0]-th elementh representing the array size NOT COUNTING the [0]-th element.) String[] fLength (Fields length: given that the fields are N, this has an N+1 size, with the [0]-th elementh representing the array size NOT COUNTING the [0]-th element.) int[] fAlignment (Fields alignment: given that the fields are N, this has an N+1 size; every item can be 0 - left alignment, 1 - right alignment, 2 - center alignment.) boolean[] fPrintable (Fields printability: given that the fields are N, this has an N+1 size; if the X-th item is TRUE, then that field will be printed.) String[] fArrangement (Fields alignment: given that the fields are N, this is N sized; thus this is the only property whose meaningful data starts from 0 -- this property is a list of fields names: the fields will be printed in this order. Note: you must include even the fields that will not be printed).
getFieldArrangement
public String[] getFieldArrangement()
Gets the fieldArrangement property (java.lang.String[]) value. The array contains field names, ordered as they must be plotted.
getGraphicContext
public Graphics getGraphicContext()
Returns the Graphics object used for the report.
getHeaderColor
public Color getHeaderColor()
Gets the color used to paint the field names.
getHeaderColorInvisible
public boolean getHeaderColorInvisible()
Gets the visibility of the color used to paint the field names.
getHeaderFill
public Color getHeaderFill()
Gets the color used to paint the field names background.
getHeaderFillInvisible
public boolean getHeaderFillInvisible()
Gets the visibility of the background below field names.
getHeaderFont
public Font getHeaderFont()
Gets the font used to draw the field names.
getHorHeaderLinesColor
public Color getHorHeaderLinesColor()
Gets the color used to paint the horizontal lines surrounding field names.
getHorHeaderLinesColorInvisible
public boolean getHorHeaderLinesColorInvisible()
Gets the visibility of the horizontal lines in the grid that surrounds the field names.
getHorRecordsLinesColor
public Color getHorRecordsLinesColor()
Gets the color used to paint the horizontal lines surrounding records.
getHorRecordsLinesColorInvisible
public boolean getHorRecordsLinesColorInvisible()
Gets the visibility of the horizontal lines in the grid that surrounds the records.
getJavaCode
public String getJavaCode()
This method returns Java code that initializes a LineViewMockup object in order to replicate current report settings.
getMaxHorEnc
public int getMaxHorEnc()
this method returns the maximum width in pixels of the report (the actual data that's going to be written). Warning: this is not the real width, but only a teorical value, basing on font width. Please notice also that you must have correctly initialized the graphic context by calling setGraphicContext before making use of this method.
getNetRexxCode
public String getNetRexxCode()
This method returns NetRexx code that initializes a LineViewMockup object in order to replicate current report settings.
getNumberOfPages
public int getNumberOfPages()
Returns the number of pages that this report will occupy; the number is calculated using currently in use page length. Please notice that you must have correctly initialized the graphic context by calling setGraphicContext before making use of this method.
getNumberOfPages
public int getNumberOfPages(int pageHeightInPixels)
Returns the number of pages that this report will occupy given a page height in pixels. Please notice that you must have correctly initialized the graphic context by calling setGraphicContext before making use of this method.
getPageLength
public int getPageLength()
Gets the page length (in pixels).
getRecordsColor
public Color getRecordsColor()
Gets the color used to paint the record values.
getRecordsColorInvisible
public boolean getRecordsColorInvisible()
Gets the color used to paint the record values.
getRecordsFill
public Color getRecordsFill()
Gets the color used to paint the records background.
getRecordsFillInvisible
public boolean getRecordsFillInvisible()
Gets the visibility of the records background.
getRecordsFont
public Font getRecordsFont()
Gets the font used to draw the records values.
getVerHeaderLinesColor
public Color getVerHeaderLinesColor()
Gets the color used to paint the vertical lines around field names.
getVerHeaderLinesColorInvisible
public boolean getVerHeaderLinesColorInvisible()
Gets the visibility of the vertical lines in the grid that surrounds the field names.
getVerRecordsLinesColor
public Color getVerRecordsLinesColor()
Gets the color used to paint the vertical lines around records.
getVerRecordsLinesColorInvisible
public boolean getVerRecordsLinesColorInvisible()
Gets the visibility of the vertical lines in the grid that surrounds the records.
getXOffset
public int getXOffset()
Gets the left margin for the report, in pixels. Note: this value is always considered relative to the actual page dimension, not to a PageLayout instance (that may or may not be present). Therefore "15 pixels" means 15 pixels from the left margin of the page.
getYOffset
public int getYOffset()
Gets the top margin for the report, in pixels. Note: this value is always considered relative to the actual page dimension, not to a PageLayout instance (that may or may not be present). Therefore "15 pixels" means 15 pixels from the top margin of the page.
loadProperties
public void loadProperties(String fileName)
Initializes the LineViewMockup object according to the fileName file. (which must be a valid Line Mode Report -- .lmr -- file)
resetMockupDefaults
public void resetMockupDefaults()
Reset color and font information to the default ones.
saveProperties
public void saveProperties(String fileName)
Saves the LineViewMockup object on the fileName file. (which will then be a valid Line Mode Report file)
setAllProperties
public void setAllProperties(LMProp props)
Sets all of the properties with a single method call.
setFieldAlignment
public void setFieldAlignment(int iNewAlignment[])
Sets alignment for each field (even those not displayed). The values must be provided in an array, starting from element 1 up to element (number of fields). 0 = left, 1 = right, 2 = center
setFieldArrangement
public void setFieldArrangement(String fieldArrangement[])
Sets the fieldArrangement property (java.lang.String[]) value. The array contains field names, ordered as they must be plotted. The values must be provided in an array, starting from element 0 up to element (number of fields - 1).
setFieldLength
public void setFieldLength(int fieldLengths[])
Sets maximum length (in characters) for each field (even those not displayed). fieldLengths[0] must contain the number of fields, fieldLengths[1] to fieldLengths[fieldLengths[0]] must contain the actual length info.
setFieldName
public void setFieldName(String fieldNames[])
Sets field names for each field (even those not displayed). fieldNames[0] must contain the number of fields, fieldNames[1] to fieldNames[fieldNames[0]] must contain the actual names.
Parameters: fieldNames - java.lang.String[]
setFieldVisible
public void setFieldVisible(boolean bVisibles[])
Sets visibility for each field (even those not displayed). The values must be provided in an array, starting from element 1 up to element (number of fields). Not visible == not to be displayed.
setGraphicContext
public void setGraphicContext(Graphics g)
Sets the Graphics object used for the report. This method needs to be called before any other method that may need information about the graphic context is called. Currently, you need to call it before you call one of the following: drawLineModeReport,getMaxHorEnc, getNumberOfPages, getNumberOfPages(int).
setHeaderColor
public void setHeaderColor(Color headerColor)
Sets the color used to paint the field names.
setHeaderColorInvisible
public void setHeaderColorInvisible(boolean headerColorInvisible)
Sets the visibility of the field names.
setHeaderFill
public void setHeaderFill(Color headerFill)
Sets the color used to paint the field names background.
setHeaderFillInvisible
public void setHeaderFillInvisible(boolean headerFillInvisible)
Sets the visibility of the field names background.
setHeaderFont
public void setHeaderFont(Font headerFont)
Sets the font used to draw the field names.
setHorHeaderLinesColor
public void setHorHeaderLinesColor(Color horHeaderLinesColor)
Sets the color used to paint the horizontal lines around field names.
setHorHeaderLinesColorInvisible
public void setHorHeaderLinesColorInvisible(boolean horHeaderLinesColorInvisible)
Sets the visibility of the horizontal lines in the grid that surrounds the field names.
setHorRecordsLinesColor
public void setHorRecordsLinesColor(Color horRecordsLinesColor)
Sets the color used to paint the horizontal lines around records.
setHorRecordsLinesColorInvisible
public void setHorRecordsLinesColorInvisible(boolean horRecordsLinesColorInvisible)
Sets the visibility of the horizontal lines in the grid that surrounds the records.
setMaxHorEnc
public void getMaxHorEnc(int horenc)
This method sets the maximum width of the report. Every field that would cause the report to exceed this length (in pixels) will not be printed.
setPageLength
public void setPageLength(int pageLength)
Sets the page length (in pixels).
setRecordsColor
public void setRecordsColor(Color recordsColor)
Sets the color used to paint the records values.
setRecordsColorInvisible
public void setRecordsColorInvisible(boolean recordsColorInvisible)
Sets the visibility of records foreground. If records foreground is invisible, anything painted below it will be visible.
setRecordsFill
public void setRecordsFill(Color recordsFill)
Sets the color used to paint the records background.
setRecordsFillInvisible
public void setRecordsFillInvisible(boolean recordsFillInvisible)
Sets the visibility of the background in the grid that surrounds the records (if the background is invisible, anything painted below it will be visible).
setRecordsFont
public void setRecordsFont(Font recordsFont)
Sets the font used to draw the record values.
setRecordValue
public void setRecordValue(String sVal[][])
Sets records information. The double array must be built this way: element [i][j] contains record j, field i, while element [0][1] must contain the total number of records to be printed.You must include record information also for those fields which won't be printed.
setVerHeaderLinesColor
public void setVerHeaderLinesColor(Color verHeaderLinesColor)
Sets the color used to paint the vertical lines around the field names.
setVerHeaderLinesColorInvisible
public void setVerHeaderLinesColorInvisible(boolean verHeaderLinesColorInvisible)
Sets the visibility of the vertical lines in the grid that surrounds the field names.
setVerRecordsLinesColor
public void setVerRecordsLinesColor(Color verRecordsLinesColor)
Sets the color for vertical lines in the grid that surrounds the records.
setVerRecordsLinesColorInvisible
public void setVerRecordsLinesColorInvisible(boolean verRecordsLinesColorInvisible)
Sets the visibility of the vertical lines in the grid that surrounds the records.
setXOffset
public setXOffset(int xOffset)
Sets the left margin for the report. Note: this value is always considered relative to the actual page dimension, not to a PageLayout instance (that may or may not be present). Therefore "15 pixels" means 15 pixels from the left margin of the page.
setYOffset
public setYOffset(int yOffset)
Sets the top margin for the report. Note: this value is always considered relative to the actual page dimension, not to a PageLayout instance (that may or may not be present). Therefore "15 pixels" means 15 pixels from the top margin of the page.
updateMockup
public void updateMockup()
This method updates the Canvas (LineViewMockup is a Canvas) with a sample using current settings for fonts and colors.
|