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:

  1. Define/get the properties of a Line View report.
  2. 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.
  3. Produce an HTML table out of your data.
  4. Load and save .lmr files (lmr stands for Line Mode Report -- it is the standard format MERGe saves Line Mode reports in).
  5. Produce the NetRexx and Java code needed to reproduce the current report from others' code.
  6. Get information about the total number of pages a report will take.
  7. Get information about the maximum horizontal encumbrance (width) of a report.
  8. 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:

  1. Fields arrangement.
  2. Fields to print and fields to hide.
  3. Fonts and colors information, both for headers and for records.
  4. 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 Java and 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).
Returns:
java.lang.String

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.
Parameters:
iPage - int
iAlign - int

getAllProperties

 public LMProp getAllProperties()
Gets all of the properties for this Line Mode report.
Returns:
nrio.reports.LMProp

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.
Returns:
The fieldArrangement property value.
See Also:
setFieldArrangement
getAllProperties

getGraphicContext

 public Graphics getGraphicContext()
Returns the Graphics object used for the report.
Returns:
The graphicContext property value.
See Also:
setGraphicContext

getHeaderColor

 public Color getHeaderColor()
Gets the color used to paint the field names.
Returns:
The headerColor property value.
See Also:
setHeaderColor

getHeaderColorInvisible

 public boolean getHeaderColorInvisible()
Gets the visibility of the color used to paint the field names.
Returns:
The headerColorInvisible property value.
See Also:
setHeaderColorInvisible

getHeaderFill

 public Color getHeaderFill()
Gets the color used to paint the field names background.
Returns:
The headerFill property value.
See Also:
setHeaderFill

getHeaderFillInvisible

 public boolean getHeaderFillInvisible()
Gets the visibility of the background below field names.
Returns:
The headerFillInvisible property value.
See Also:
setHeaderFillInvisible

getHeaderFont

 public Font getHeaderFont()
Gets the font used to draw the field names.
Returns:
The headerFont property value.
See Also:
setHeaderFont

getHorHeaderLinesColor

 public Color getHorHeaderLinesColor()
Gets the color used to paint the horizontal lines surrounding field names.
Returns:
The horHeaderLinesColor property value.
See Also:
setHorHeaderLinesColor

getHorHeaderLinesColorInvisible

 public boolean getHorHeaderLinesColorInvisible()
Gets the visibility of the horizontal lines in the grid that surrounds the field names.
Returns:
The horHeaderLinesColorInvisible property value.
See Also:
setHorHeaderLinesColorInvisible

getHorRecordsLinesColor

 public Color getHorRecordsLinesColor()
Gets the color used to paint the horizontal lines surrounding records.
Returns:
The horRecordsLinesColor property value.
See Also:
setHorRecordsLinesColor

getHorRecordsLinesColorInvisible

 public boolean getHorRecordsLinesColorInvisible()
Gets the visibility of the horizontal lines in the grid that surrounds the records.
Returns:
The horRecordsLinesColorInvisible property value.
See Also:
setHorRecordsLinesColorInvisible

getJavaCode

 public String getJavaCode()
This method returns Java code that initializes a LineViewMockup object in order to replicate current report settings.
Returns:
java.lang.String

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.
Returns:
int
See Also:
setMaxHorEnc

getNetRexxCode

 public String getNetRexxCode()
This method returns NetRexx code that initializes a LineViewMockup object in order to replicate current report settings.
Returns:
java.lang.String

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.
Returns:
int

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.
Returns:
int

getPageLength

 public int getPageLength()
Gets the page length (in pixels).
Returns:
The pageLength property value.
See Also:
setPageLength

getRecordsColor

 public Color getRecordsColor()
Gets the color used to paint the record values.
Returns:
The recordsColor property value.
See Also:
setRecordsColor

getRecordsColorInvisible

 public boolean getRecordsColorInvisible()
Gets the color used to paint the record values.
Returns:
The recordsColorInvisible property value.
See Also:
setRecordsColorInvisible

getRecordsFill

 public Color getRecordsFill()
Gets the color used to paint the records background.
Returns:
The recordsFill property value.
See Also:
setRecordsFill

getRecordsFillInvisible

 public boolean getRecordsFillInvisible()
Gets the visibility of the records background.
Returns:
The recordsFillInvisible property value.
See Also:
setRecordsFillInvisible

getRecordsFont

 public Font getRecordsFont()
Gets the font used to draw the records values.
Returns:
The recordsFont property value.
See Also:
setRecordsFont

getVerHeaderLinesColor

 public Color getVerHeaderLinesColor()
Gets the color used to paint the vertical lines around field names.
Returns:
The verHeaderLinesColor property value.
See Also:
setVerHeaderLinesColor

getVerHeaderLinesColorInvisible

 public boolean getVerHeaderLinesColorInvisible()
Gets the visibility of the vertical lines in the grid that surrounds the field names.
Returns:
The verHeaderLinesColorInvisible property value.
See Also:
setVerHeaderLinesColorInvisible

getVerRecordsLinesColor

 public Color getVerRecordsLinesColor()
Gets the color used to paint the vertical lines around records.
Returns:
The verRecordsLinesColor property value.
See Also:
setVerRecordsLinesColor

getVerRecordsLinesColorInvisible

 public boolean getVerRecordsLinesColorInvisible()
Gets the visibility of the vertical lines in the grid that surrounds the records.
Returns:
The verRecordsLinesColorInvisible property value.
See Also:
setVerRecordsLinesColorInvisible

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.
Returns:
The xOffset property value.
See Also:
setXOffset

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.
Returns:
The yOffset property value.
See Also:
setYOffset

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)
Parameters:
fileName - java.lang.String

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)
Parameters:
fileName - java.lang.String

setAllProperties

 public void setAllProperties(LMProp props)
Sets all of the properties with a single method call.
Parameters:
props - nrio.reports.LMProp
See Also:
getAllProperties

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
Parameters:
iNewAlignment - int[]

See Also:

getAllProperties

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).
Parameters:
fieldArrangement - The new value for the property.
See Also:
getFieldArrangement
getAllProperties

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.
Parameters:
fieldLengths - java.lang.String[]

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[]
 
See Also:
getAllProperties

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.
Parameters:
bVisibles - boolean[]

See Also:

getAllProperties

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).
Parameters:
g - Graphics
See Also:
getGraphicContext

setHeaderColor

 public void setHeaderColor(Color headerColor)
Sets the color used to paint the field names.
Parameters:
headerColor - The new value for the property.
See Also:
getHeaderColor

setHeaderColorInvisible

 public void setHeaderColorInvisible(boolean headerColorInvisible)
Sets the visibility of the field names.
Parameters:
headerColorInvisible - The new value for the property.
See Also:
getHeaderColorInvisible

setHeaderFill

 public void setHeaderFill(Color headerFill)
Sets the color used to paint the field names background.
Parameters:
headerFill - The new value for the property.
See Also:
getHeaderFill

setHeaderFillInvisible

 public void setHeaderFillInvisible(boolean headerFillInvisible)
Sets the visibility of the field names background.
Parameters:
headerFillInvisible - The new value for the property.
See Also:
getHeaderFillInvisible

setHeaderFont

 public void setHeaderFont(Font headerFont)
Sets the font used to draw the field names.
Parameters:
headerFont - The new value for the property.
See Also:
getHeaderFont

setHorHeaderLinesColor

 public void setHorHeaderLinesColor(Color horHeaderLinesColor)
Sets the color used to paint the horizontal lines around field names.
Parameters:
horHeaderLinesColor - The new value for the property.
See Also:
getHorHeaderLinesColor

setHorHeaderLinesColorInvisible

 public void setHorHeaderLinesColorInvisible(boolean horHeaderLinesColorInvisible)
Sets the visibility of the horizontal lines in the grid that surrounds the field names.
Parameters:
horHeaderLinesColorInvisible - The new value for the property.
See Also:
getHorHeaderLinesColorInvisible

setHorRecordsLinesColor

 public void setHorRecordsLinesColor(Color horRecordsLinesColor)
Sets the color used to paint the horizontal lines around records.
Parameters:
horRecordsLinesColor - The new value for the property.
See Also:
getHorRecordsLinesColor

setHorRecordsLinesColorInvisible

 public void setHorRecordsLinesColorInvisible(boolean horRecordsLinesColorInvisible)
Sets the visibility of the horizontal lines in the grid that surrounds the records.
Parameters:
horRecordsLinesColorInvisible - The new value for the property.
See Also:
getHorRecordsLinesColorInvisible

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.
Returns:
void
See Also:
getMaxHorEnc

setPageLength

 public void setPageLength(int pageLength)
Sets the page length (in pixels).
Parameters:
pageLength - The new value for the property.
See Also:
getPageLength

setRecordsColor

 public void setRecordsColor(Color recordsColor)
Sets the color used to paint the records values.
Parameters:
recordsColor - The new value for the property.
See Also:
getRecordsColor

setRecordsColorInvisible

 public void setRecordsColorInvisible(boolean recordsColorInvisible)
Sets the visibility of records foreground. If records foreground is invisible, anything painted below it will be visible.
Parameters:
recordsColorInvisible - The new value for the property.
See Also:
getRecordsColorInvisible

setRecordsFill

 public void setRecordsFill(Color recordsFill)
Sets the color used to paint the records background.
Parameters:
recordsFill - The new value for the property.
See Also:
getRecordsFill

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).
Parameters:
recordsFillInvisible - The new value for the property.
See Also:
getRecordsFillInvisible

setRecordsFont

 public void setRecordsFont(Font recordsFont)
Sets the font used to draw the record values.
Parameters:
recordsFont - The new value for the property.
See Also:
getRecordsFont

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.
Parameters:
sVal - java.lang.String[][]

setVerHeaderLinesColor

 public void setVerHeaderLinesColor(Color verHeaderLinesColor)
Sets the color used to paint the vertical lines around the field names.
Parameters:
verHeaderLinesColor - The new value for the property.
See Also:
getVerHeaderLinesColor

setVerHeaderLinesColorInvisible

 public void setVerHeaderLinesColorInvisible(boolean verHeaderLinesColorInvisible)
Sets the visibility of the vertical lines in the grid that surrounds the field names.
Parameters:
verHeaderLinesColorInvisible - The new value for the property.
See Also:
getVerHeaderLinesColorInvisible

setVerRecordsLinesColor

 public void setVerRecordsLinesColor(Color verRecordsLinesColor)
Sets the color for vertical lines in the grid that surrounds the records.
Parameters:
verRecordsLinesColor - The new value for the property.
See Also:
getVerRecordsLinesColor

setVerRecordsLinesColorInvisible

 public void setVerRecordsLinesColorInvisible(boolean verRecordsLinesColorInvisible)
Sets the visibility of the vertical lines in the grid that surrounds the records.
Parameters:
verRecordsLinesColorInvisible - The new value for the property.
See Also:
getVerRecordsLinesColorInvisible

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.
Parameters:
The xOffset property value.
See Also:
getXOffset

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.
Parameters:
The yOffset property value.
See Also:
getYOffset

updateMockup

 public void updateMockup()
This method updates the Canvas (LineViewMockup is a Canvas) with a sample using current settings for fonts and colors.


Max Marsiglietti © 1997
Layout and artwork Andrea Resmini 1997