public class Metafile extends java.lang.Object implements PdfProvider
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
currFontName
Current font name (default is 'Courier New').
|
private int |
currPageNum
The number of the current page.
|
private java.lang.String |
currZoomType
Current zoom type name (default is whole page.
|
private double |
diPageHeight
Current page height in device independent units.
|
private double |
diPageWidth
Current page width in device independent units.
|
private static double |
EDGE_LINE_X_SHIFT
If X coord is on the lefd edge (0.0), the value must be increased.
|
private double |
extraRowDistance
Extra vertical distance between two sequential rows of the text.
|
private int |
fillColor
Background color for filled rectangles.
|
private boolean |
firstPageCreated
Flag to indicate the first page already created.
|
private static java.lang.String |
FONT_NAME_DEFAULT
Font name default value for metafile.
|
private static int |
FONT_SIZE_DEFAULT
Font size default value for metafile.
|
private float |
fontSize
Current font size (default is 12).
|
private double |
fontSizeMetric
Current font size in metric units (default is 12).
|
private double |
footerHeight
Footer reserverd size value.
|
static int |
IMAGE_ALIGN_BOTTOM
Bottom image alignment.
|
static int |
IMAGE_ALIGN_CENTER
Center image alignment.
|
static int |
IMAGE_ALIGN_LEFT
Left image alignment.
|
static int |
IMAGE_ALIGN_RIGHT
Right image alignment.
|
static int |
IMAGE_ALIGN_TOP
Top image alignment.
|
private int |
imageAlignHorizCurr
Current horizontal image alignment.
|
private int |
imageAlignVertCurr
Current vertical image alignment.
|
private boolean |
isBold
Flag indicating if the font is currently bold or not.
|
private boolean |
isItalic
Flag indicating if the font is currently italic or not.
|
private boolean |
isUnderline
Flag indicating if the font is currently underlined or not.
|
private double |
leftMargin
Left margin value.
|
private int |
lineColor
Line color for lines, rectangles and border of the filled rectangles.
|
private net.sf.jasperreports.engine.type.LineStyleEnum |
lineStyle
Current line style value.
|
private int |
lineWidth
Current line thickness value.
|
private int |
maxPageNum
The number of the maximum page.
|
private static double |
OBJ_Y_SHIFT
Constant vertical shift for object.
|
private java.util.List<XprObjBase> |
objects
The objects for the current page.
|
private java.util.List<XprObjText> |
pageNumberTextObj
Page number texts.
|
private java.util.List<XprPageOptions> |
pageOptions
New page specific options.
|
private int |
pageOrientation
Current page orientation.
|
private java.util.List<java.util.List<XprObjBase>> |
pages
The Z-ordered list of the objects recognized inside current file entity, paginated.
|
private static double |
pdf2MfDpi
Optional scaling from PDF coord to metafile.
|
private java.lang.String |
pdfDir
Temporary directory to store the intermediate files.
|
private static double |
pixPerColMf
To convert columns to metafile pixels
|
private boolean |
recordingStopped
Flag indicating there are possibly records to commit.
|
private boolean |
showFooter
Flag indicating if the footer will be shown or not.
|
static int |
TEXT_ALIGN_BASELINE
Baseline text alignment.
|
static int |
TEXT_ALIGN_BOTTOM
Bottom text alignment.
|
static int |
TEXT_ALIGN_CENTER
Center text alignment.
|
static int |
TEXT_ALIGN_LEFT
Left text alignment.
|
static int |
TEXT_ALIGN_RIGHT
Right text alignment.
|
static int |
TEXT_ALIGN_TOP
Top text alignment.
|
private int |
textAlignHorizCurr
Current horizontal text alignment.
|
private int |
textAlignVertCurr
Current vertical text alignment.
|
private int |
textColor
Foreground color for text.
|
private double |
topMargin
Top margin value.
|
private static double |
VERT_LINE_Y_SHIFT
Vertical lines should be shifted with this value.
|
private double |
xCurr
Current X value in new entity.
|
private double |
xPageNum
Current X value for page number text.
|
private double |
yCurr
Current Y value in new entity.
|
private double |
yPageNum
Current Y value for page number text.
|
private static java.lang.String |
ZOOM_TYPE_DEFAULT
Zoom type default value for metafile.
|
Constructor and Description |
---|
Metafile()
Default metafile object constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
addTextObject(java.lang.String textToAdd,
double xText,
double yText)
Internal method to construct and add new text object.
|
void |
drawFilledRect(double left,
double top,
double right,
double bottom)
Draws the rectangle between left-top point and right-bottom with current line and fill
attributes.
|
void |
drawImage(java.lang.String option,
double x,
double y,
double width,
double height,
java.lang.String filename,
decimal imgWidth,
decimal imgHeight)
Draws the image.
|
void |
drawImagePart(double x,
double y,
int widthPix,
int heightPix,
double maxWidth,
java.lang.String filename)
Draws the part of the image.
|
void |
drawLine(double left,
double top,
double right,
double bottom)
Draws the line from left-top point to right-bottom with current line attributes.
|
void |
drawRect(double left,
double top,
double right,
double bottom)
Draws the framed rectangle between left-top point and right-bottom with current line
attributes.
|
void |
drawText(java.lang.String text)
Draws the text at current position.
|
void |
drawTextAndSetX(double x,
java.lang.String text)
Draws the text at current position.
|
void |
drawTextAtX(double x,
java.lang.String text,
java.lang.String align)
Draws the text at the given X position and current Y position and given alignment.
|
void |
drawTextBetween(double left,
double right,
java.lang.String text,
java.lang.String align)
Draws the text between left and right X positions and current Y position with given
alignment.
|
void |
getFont(character fontName)
Gets the current font value.
|
double |
getFontHeight()
Gets the current font height value.
|
void |
getFontHeight(decimal fontHeight)
Gets the current font height value.
|
void |
getFreeSpaceDown(decimal freeSpaceDown)
Gets the free space below the current Y position.
|
void |
getFreeSpaceRight(decimal freeSpaceRight)
Gets the free space to the right the current X position.
|
private net.sf.jasperreports.engine.type.LineStyleEnum |
getLineType(java.lang.String lineType)
Converts line style string into JasperReports compatible line type.
|
java.util.List<XprObjBase> |
getObjectsInPage(int pageNum)
Getting internal object list from XPR object for particular page.
|
void |
getPageHeight(decimal pageHeight)
Gets the current page height.
|
int |
getPageHeight(int pageNum)
Getting the page height for given page numbers.
|
void |
getPageNumber(integer pageNum)
Gets the current page number.
|
void |
getPageWidth(decimal pageWidth)
Gets the current page width.
|
int |
getPageWidth(int pageNum)
Getting the page width for given page numbers.
|
double |
getTextWidth(java.lang.String textToMeasure)
Gets the given text width value.
|
void |
getTextWidth(java.lang.String textToMeasure,
decimal textWidth)
Gets the given text width value.
|
double |
getTextWidth(java.lang.String textToMeasure,
float customFontSize,
boolean bold,
boolean italic)
Gets the given text width value.
|
java.lang.String |
getTmpDirectory()
Gets optionally set temporary directory to store generated PDF temporary files.
|
int |
getTotalPageNumbers()
Getting total number of pages in document.
|
void |
getXY(decimal x,
decimal y)
Gets the new current position for cursor.
|
void |
getZoomFactor(character zoomType)
Gets the current zoom factor value.
|
void |
initialize(double footerTextHeight,
java.lang.String tmpDir,
integer ok)
General metafile subsystem init procedure.
|
boolean |
isUnderline()
Gets flag meaning underlined text should be currently used.
|
void |
resetPage(java.lang.String mode,
int newMaxPageNum)
Sets new value for current/maximum page number.
|
void |
resetTextStyle()
Resets new value for text style to be off.
|
void |
setFillColor(int rgbColor)
Sets new current color value to be used in fill based primitives.
|
void |
setFont(java.lang.String fontName)
Sets new value for current font.
|
void |
setFontHeight(float fontHeight)
Sets the current font height value.
|
void |
setImageAlign(java.lang.String horizAlign,
java.lang.String vertAlign)
Sets new values for image alignment.
|
void |
setInterleaving(double extraYSpace)
Sets the extra vertical space between two sequential rows.
|
void |
setLeftMargin(double leftMargin)
Sets the new value for document's left margin.
|
void |
setLineAttributes(java.lang.String style,
double thickness,
int redColor,
int greenColor,
int blueColor)
Sets new values for line attributes.
|
void |
setLineColor(int rgbColor)
Sets new current color value to be used in line based primitives.
|
void |
setLineStyle(java.lang.String style,
double thickness)
Sets new values for line attributes.
|
void |
setPageNumber(int newPageNum)
Sets new value for current page number.
|
void |
setPageNumberPosition(double x,
double y)
Sets the new current position for page number.
|
void |
setPageNumberText(java.lang.String text,
int pgNumberNdx)
Sets new value for current page number text.
|
private void |
setPageOptions()
Set up options for new current document page.
|
void |
setPageOrientation(java.lang.String mode)
Sets new value for current page orientation.
|
void |
setTextAlignment(java.lang.String horizAlign,
java.lang.String vertAlign)
Sets new values for text alignment.
|
void |
setTextColor(int rgbColor)
Sets new current color value to be used in text primitives.
|
void |
setTextStyle(java.lang.String style)
Sets new value for text style.
|
void |
setXY(double x,
double y)
Sets the new current position for cursor.
|
void |
setZoomFactor(java.lang.String zoomType)
Sets new value for current zoom factor.
|
void |
showPageFooter(boolean show)
Sets to show page footer or not.
|
void |
startNewPage()
Starts the new page construction for the document that is currently processing.
|
void |
startNewTextLine()
Starts new line of the text.
|
void |
stopRecording()
Stops all operation for the current metafile and commit remaining objects to the current page.
|
private void |
updatePageOptions()
Update options for new current document page.
|
public static final int IMAGE_ALIGN_LEFT
public static final int IMAGE_ALIGN_CENTER
public static final int IMAGE_ALIGN_RIGHT
public static final int IMAGE_ALIGN_TOP
public static final int IMAGE_ALIGN_BOTTOM
public static final int TEXT_ALIGN_LEFT
public static final int TEXT_ALIGN_RIGHT
public static final int TEXT_ALIGN_CENTER
public static final int TEXT_ALIGN_TOP
public static final int TEXT_ALIGN_BASELINE
public static final int TEXT_ALIGN_BOTTOM
private static final int FONT_SIZE_DEFAULT
private static final java.lang.String FONT_NAME_DEFAULT
private static final java.lang.String ZOOM_TYPE_DEFAULT
private static final double pdf2MfDpi
private static final double pixPerColMf
private static final double OBJ_Y_SHIFT
private static final double EDGE_LINE_X_SHIFT
private static final double VERT_LINE_Y_SHIFT
private java.util.List<java.util.List<XprObjBase>> pages
private java.util.List<XprPageOptions> pageOptions
private java.util.List<XprObjBase> objects
private int currPageNum
private int maxPageNum
private int pageOrientation
private java.lang.String currFontName
private java.lang.String currZoomType
private float fontSize
private double fontSizeMetric
private boolean isBold
private boolean isItalic
private boolean isUnderline
private int textColor
private int lineColor
private int fillColor
private double xPageNum
private double yPageNum
private java.util.List<XprObjText> pageNumberTextObj
private double leftMargin
private double topMargin
private double footerHeight
private double extraRowDistance
private double diPageWidth
private double diPageHeight
private double xCurr
private double yCurr
private int lineWidth
private int textAlignHorizCurr
private int textAlignVertCurr
private int imageAlignHorizCurr
private int imageAlignVertCurr
private boolean showFooter
private net.sf.jasperreports.engine.type.LineStyleEnum lineStyle
private boolean recordingStopped
private java.lang.String pdfDir
private boolean firstPageCreated
public void setTextAlignment(java.lang.String horizAlign, java.lang.String vertAlign)
horizAlign
- The new String value for horizontal text alignment. The valid alignment values:
"left", "center", "right".vertAlign
- The new String value for vertical text alignment. The valid alignment values:
"top", "baseline", "bottom".public void setTextColor(int rgbColor)
rgbColor
- The new 32-bit color value packed in int value.public void setTextStyle(java.lang.String style)
style
- The new String value for the current text style. The valid style values:
"italic", "underline", "bold", "no-italic", "no-underline", "no-bold".public boolean isUnderline()
TRUE
if text underlined, FALSE
otherwise.public void startNewPage()
public void setFont(java.lang.String fontName)
fontName
- The new String value for the current font name. Can be "default" for default
font to use.public void resetTextStyle()
public void getFont(character fontName)
fontName
- The value for the font name currently in use.public void setZoomFactor(java.lang.String zoomType)
zoomType
- The new String value for the current zoom type.public void getZoomFactor(character zoomType)
zoomType
- The value for the zoom type currently in use.public void getFontHeight(decimal fontHeight)
fontHeight
- The currently used font height value in metric units.public double getFontHeight()
public void setFontHeight(float fontHeight)
fontHeight
- The font height value in pics to use.public void getTextWidth(java.lang.String textToMeasure, decimal textWidth)
textToMeasure
- The text to calculate width.textWidth
- The width of the text in metric units.public double getTextWidth(java.lang.String textToMeasure)
textToMeasure
- The text to calculate width.public double getTextWidth(java.lang.String textToMeasure, float customFontSize, boolean bold, boolean italic)
textToMeasure
- The text to calculate width.customFontSize
- The optional font size to use instead of current one.bold
- The bold font in use to measure text.italic
- The italic font in use to measure text.public void setXY(double x, double y)
x
- The new X position.y
- The new Y position.public void getXY(decimal x, decimal y)
x
- The returned X position.y
- The returned Y position.public void setLeftMargin(double leftMargin)
leftMargin
- The new left margin value.public void startNewTextLine()
public void setInterleaving(double extraYSpace)
extraYSpace
- The new extra Y distance between rows.public void getFreeSpaceDown(decimal freeSpaceDown)
freeSpaceDown
- The remaining vertical free space on the current page.public void getFreeSpaceRight(decimal freeSpaceRight)
freeSpaceRight
- The remaining horizontal free space on the current line(page).public void drawText(java.lang.String text)
text
- The new text to draw at current position.public void drawTextAndSetX(double x, java.lang.String text)
x
- The X position to set after text drawing in device independent units.text
- The new text to draw at current position.public void drawTextAtX(double x, java.lang.String text, java.lang.String align)
x
- The X position for text to draw in device independent units.text
- The new text to draw at the given position.align
- The alignment value, either left or right.public void drawTextBetween(double left, double right, java.lang.String text, java.lang.String align)
left
- The left X position for text to draw in device independent units.right
- The right X position for text to draw in device independent units.text
- The new text to fit and draw in the given positions.align
- The alignment value, either left or right.public void setLineAttributes(java.lang.String style, double thickness, int redColor, int greenColor, int blueColor)
style
- The new String value for the current line style. The valid style values:
"solid", "dash", "dot", "dashdot", "dashdotdot", "null", "insideframe".thickness
- The thick of the line in device independent units.redColor
- The new red part of the color value.greenColor
- The new green part of the color value.blueColor
- The new blue part of the color value.public void setLineColor(int rgbColor)
rgbColor
- The new 32-bit color value packed in int value.public void setLineStyle(java.lang.String style, double thickness)
style
- The new String value for the current line style. The valid style values:
"solid", "dash", "dot", "dashdot", "dashdotdot", "null", "insideframe".thickness
- The thick of the line in device independent units.public void setFillColor(int rgbColor)
rgbColor
- The new 32-bit color value packed in int value.public void drawLine(double left, double top, double right, double bottom)
left
- The left X position of the line start.top
- The top Y position of the line start.right
- The right X position of the line start.bottom
- The bottom Y position of the line start.public void drawRect(double left, double top, double right, double bottom)
left
- The left X position of the rectangle.top
- The top Y position of the rectangle.right
- The right X position of the rectangle.bottom
- The bottom Y position of the rectangle.public void drawFilledRect(double left, double top, double right, double bottom)
left
- The left X position of the rectangle.top
- The top Y position of the rectangle.right
- The right X position of the rectangle.bottom
- The bottom Y position of the rectangle.public void setImageAlign(java.lang.String horizAlign, java.lang.String vertAlign)
horizAlign
- The new String value for horizontal text alignment. The valid alignment values:
"left", "center", "right".vertAlign
- The new String value for vertical text alignment. The valid alignment values:
"top", "baseline", "bottom".public void drawImage(java.lang.String option, double x, double y, double width, double height, java.lang.String filename, decimal imgWidth, decimal imgHeight)
option
- The image painting option for example "origratio=yes".x
- The image X position.y
- The image Y position.width
- The image width in metric units.height
- The image height in metric units.filename
- The name of the file to use as image.imgWidth
- The final painted image width in metric units(return value).imgHeight
- The final painted image height in metric units(return value).public void drawImagePart(double x, double y, int widthPix, int heightPix, double maxWidth, java.lang.String filename)
x
- The image X position.y
- The image Y position.widthPix
- The image width in pixels.heightPix
- The image height in pixels.maxWidth
- The image maximum right border not to exceed.filename
- The name of the file to use as image.public void setPageOrientation(java.lang.String mode)
mode
- The new String value for page orientation. The valid alignment values:
"standard", "portrait", "landscape".public void getPageWidth(decimal pageWidth)
pageWidth
- The current page width value in device independent units.public void getPageHeight(decimal pageHeight)
pageHeight
- The current page height value in device independent units.public void resetPage(java.lang.String mode, int newMaxPageNum)
mode
- The new String value for page mode. The valid alignment values: "append", "new".newMaxPageNum
- The integer max page number value.public void getPageNumber(integer pageNum)
pageNum
- The current integer page number value.public void setPageNumber(int newPageNum)
newPageNum
- The integer page number value.public void setPageNumberPosition(double x, double y)
x
- The new X position for page nummber.y
- The new Y position for page nummber.public void setPageNumberText(java.lang.String text, int pgNumberNdx)
text
- The new text for page number.pgNumberNdx
- The 1-based index of new text for page number.public void showPageFooter(boolean show)
show
- The TRUE
value means show footer, FALSE
means no footer.public void initialize(double footerTextHeight, java.lang.String tmpDir, integer ok)
footerTextHeight
- The height of the footed text in device independent units.tmpDir
- The temporary directory to use.ok
- The return value, meaning success init or not.public void stopRecording()
public java.lang.String getTmpDirectory()
private net.sf.jasperreports.engine.type.LineStyleEnum getLineType(java.lang.String lineType)
lineType
- The line type lower cased string.private void setPageOptions()
private void updatePageOptions()
private void addTextObject(java.lang.String textToAdd, double xText, double yText)
textToAdd
- The line of the text to be added..xText
- The X text position.yText
- The Y text position.public java.util.List<XprObjBase> getObjectsInPage(int pageNum)
getObjectsInPage
in interface PdfProvider
pageNum
- 0 based page number for objects to get.public int getTotalPageNumbers()
getTotalPageNumbers
in interface PdfProvider
public int getPageWidth(int pageNum)
getPageWidth
in interface PdfProvider
pageNum
- 0 based page number for option to get.public int getPageHeight(int pageNum)
getPageHeight
in interface PdfProvider
pageNum
- 0 based page number for option to get.