| Method from sun.awt.windows.WPrinterJob Detail: |
protected native void abortDoc()
Call Window's AbortDoc routine to abort a
print job. |
protected void beginPath() {
beginPath(getPrintDC());
}
|
protected native void beginPath(long printDC)
Begin a Window's rendering path in the device
context printDC. |
protected void closeFigure() {
closeFigure(getPrintDC());
}
|
protected native void closeFigure(long printDC)
Close a subpath in a Window's rendering path in the device
context printDC. |
protected Graphics2D createPathGraphics(PeekGraphics peekGraphics,
PrinterJob printerJob,
Printable painter,
PageFormat pageFormat,
int pageIndex) {
WPathGraphics pathGraphics;
PeekMetrics metrics = peekGraphics.getMetrics();
/* If the application has drawn anything that
* out PathGraphics class can not handle then
* return a null PathGraphics. If the property
* to force the raster pipeline has been set then
* we also want to avoid the path (pdl) pipeline
* and return null.
*/
if (forcePDL == false && (forceRaster == true
|| metrics.hasNonSolidColors()
|| metrics.hasCompositing()
)) {
pathGraphics = null;
} else {
BufferedImage bufferedImage = new BufferedImage(8, 8,
BufferedImage.TYPE_INT_RGB);
Graphics2D bufferedGraphics = bufferedImage.createGraphics();
boolean canRedraw = peekGraphics.getAWTDrawingOnly() == false;
pathGraphics = new WPathGraphics(bufferedGraphics, printerJob,
painter, pageFormat, pageIndex,
canRedraw);
}
return pathGraphics;
}
Examine the metrics captured by the
PeekGraphics instance and
if capable of directly converting this
print job to the printer's control language
or the native OS's graphics primitives, then
return a PathGraphics to perform
that conversion. If there is not an object
capable of the conversion then return
null. Returning null
causes the print job to be rasterized. |
public PageFormat defaultPage(PageFormat page) {
PageFormat newPage = (PageFormat)page.clone();
getDefaultPage(newPage);
return newPage;
}
The passed in PageFormat will be copied and altered to describe
the default page size and orientation of the PrinterJob's
current printer.
Note: PageFormat.getPaper() returns a clone and getDefaultPage()
gets that clone so it won't overwrite the original paper. |
protected native void deviceEndPage(PageFormat format,
Printable painter,
int index)
End a page. This call's Window's EndPage
routine. |
protected native void deviceStartPage(PageFormat format,
Printable painter,
int index,
boolean paperChanged)
Begin a new page. This call's Window's
StartPage routine. |
protected void drawDIBImage(byte[] image,
float destX,
float destY,
float destWidth,
float destHeight,
float srcX,
float srcY,
float srcWidth,
float srcHeight,
IndexColorModel icm) {
int bitCount = 24;
byte[] bmiColors = null;
if (icm != null) {
bitCount = icm.getPixelSize();
bmiColors = new byte[(1< < bitCount)*4];
for (int i=0;i< icm.getMapSize(); i++) {
bmiColors[i*4+0]=(byte)(icm.getBlue(i)&0xff);
bmiColors[i*4+1]=(byte)(icm.getGreen(i)&0xff);
bmiColors[i*4+2]=(byte)(icm.getRed(i)&0xff);
}
}
drawDIBImage(getPrintDC(), image,
destX, destY,
destWidth, destHeight,
srcX, srcY,
srcWidth, srcHeight,
bitCount, bmiColors);
}
|
protected void drawImage3ByteBGR(byte[] image,
float destX,
float destY,
float destWidth,
float destHeight,
float srcX,
float srcY,
float srcWidth,
float srcHeight) {
drawDIBImage(getPrintDC(), image,
destX, destY,
destWidth, destHeight,
srcX, srcY,
srcWidth, srcHeight,
24, null);
}
Draw the 24 bit BGR image buffer represented by
image to the GDI device context
printDC. The image is drawn at
(destX, destY) in device coordinates.
The image is scaled into a square of size
specified by destWidth and
destHeight. The portion of the
source image copied into that square is specified
by srcX, srcY,
srcWidth, and srcHeight. |
protected native void endDoc()
Call Window's EndDoc routine to end a
print job. |
protected void endPage(PageFormat format,
Printable painter,
int index) {
deviceEndPage(format, painter, index);
}
|
protected void endPath() {
endPath(getPrintDC());
}
|
protected native void endPath(long printDC)
End a Window's rendering path in the device
context printDC. |
protected void fillPath() {
fillPath(getPrintDC());
}
|
protected native void fillPath(long printDC)
Fill a defined Window's rendering path in the device
context printDC. |
protected void fillRect(float x,
float y,
float width,
float height,
Color color) {
float[] rgb = color.getRGBColorComponents(null);
fillRect(getPrintDC(), x, y, width, height,
(int) (rgb[0] * MAX_WCOLOR),
(int) (rgb[1] * MAX_WCOLOR),
(int) (rgb[2] * MAX_WCOLOR));
}
|
protected native void fillRect(long printDC,
float x,
float y,
float width,
float height,
int red,
int green,
int blue)
Fill a rectangle specified by the coordinates using
specified brush. |
protected void frameRect(float x,
float y,
float width,
float height) {
frameRect(getPrintDC(), x, y, width, height);
}
|
protected native void frameRect(long printDC,
float x,
float y,
float width,
float height)
Draw a rectangle using specified brush. |
protected int getCollatedCopies() {
debug_println("driverDoesMultipleCopies="+driverDoesMultipleCopies
+" driverDoesCollation="+driverDoesCollation);
if (super.isCollated() && !driverDoesCollation) {
// we will do our own collation so we need to
// tell the printer to not collate
mAttCollate = 0;
mAttCopies = 1;
return getCopies();
}
return 1;
}
Returns how many times the entire book should
be printed by the PrintJob. If the printer
itself supports collation then this method
should return 1 indicating that the entire
book need only be printed once and the copies
will be collated and made in the printer. |
public Object getDisposerReferent() {
return disposerReferent;
}
|
protected int getGDIAdvance(String text) {
/* Don't leave handling of control chars to GDI. */
text = removeControlChars(text);
if (text.length() == 0) {
return 0;
}
return getGDIAdvance(getPrintDC(), text);
}
Get the advance of this text that GDI returns for the
font currently selected into the GDI device context for
this job. Note that the removed control characters are
interpreted as zero-width by JDK and we remove them for
rendering so also remove them for measurement so that
this measurement can be properly compared with JDK measurement. |
protected int getNoncollatedCopies() {
if (driverDoesMultipleCopies || super.isCollated()) {
return 1;
} else {
return getCopies();
}
}
Returns how many times each page in the book
should be consecutively printed by PrinterJob.
If the underlying Window's driver will
generate the copies, rather than having RasterPrinterJob
iterate over the number of copies, this method always returns
1. |
protected int getPenX() {
return getPenX(getPrintDC());
}
Return the x coordinate of the current pen
position in the print device context. |
protected native int getPenX(long printDC)
Return the x coordinate of the current pen
position in the device context
printDC. |
protected int getPenY() {
return getPenY(getPrintDC());
}
Return the y coordinate of the current pen
position in the print device context. |
protected native int getPenY(long printDC)
Return the y coordinate of the current pen
position in the device context
printDC. |
protected double getPhysicalPageHeight(Paper p) {
return mPageHeight;
}
|
protected double getPhysicalPageWidth(Paper p) {
return mPageWidth;
}
|
protected double getPhysicalPrintableHeight(Paper p) {
return mPrintHeight;
}
|
protected double getPhysicalPrintableWidth(Paper p) {
return mPrintWidth;
}
|
protected double getPhysicalPrintableX(Paper p) {
return mPrintPhysX;
}
|
protected double getPhysicalPrintableY(Paper p) {
return mPrintPhysY;
}
|
public PrintService getPrintService() {
if (myService == null) {
String printerName = getNativePrintService();
if (printerName != null) {
myService = Win32PrintServiceLookup.getWin32PrintLUS().
getPrintServiceByName(printerName);
// no need to call setNativePrintService as this name is
// currently set in native
if (myService != null) {
return myService;
}
}
myService = PrintServiceLookup.lookupDefaultPrintService();
if (myService != null) {
try {
setNativePrintService(myService.getName());
} catch (Exception e) {
myService = null;
}
}
}
return myService;
}
|
protected double getXRes() {
if (mAttXRes != 0) {
return mAttXRes;
} else {
return mPrintXRes;
}
}
|
protected double getYRes() {
if (mAttYRes != 0) {
return mAttYRes;
} else {
return mPrintYRes;
}
}
|
protected void glyphsOut(int[] glyphs,
float x,
float y,
float[] positions) {
/* TrueType glyph codes are 16 bit values, so can be packed
* in a unicode string, and that's how GDI expects them.
* A flag bit is set to indicate to GDI that these are glyphs,
* not characters. The positions array must always be non-null
* here for our purposes, although if not supplied, GDI should
* just use the default advances for the glyphs.
* Mask out upper 16 bits to remove any slot from a composite.
*/
char[] glyphCharArray = new char[glyphs.length];
for (int i=0;i< glyphs.length;i++) {
glyphCharArray[i] = (char)(glyphs[i] & 0xffff);
}
String glyphStr = new String(glyphCharArray);
textOut(getPrintDC(), glyphStr, glyphs.length, true, x, y, positions);
}
Draw the glyphs glyphs to the printer's
device context at the specified position. |
protected native void initPrinter()
|
protected boolean isCollated() {
return userRequestedCollation;
}
We don't (yet) provide API to support collation, and
when we do the logic here will require adjustment, but
this method is currently necessary to honour user-originated
collation requests - which can only originate from the print dialog.
REMIND: check if this can be deleted already. |
protected void lineTo(float x,
float y) {
lineTo(getPrintDC(), x, y);
}
|
protected native void lineTo(long printDC,
float x,
float y)
Draw a line from the current pen position to
(x,y) in the device context printDC. |
protected void moveTo(float x,
float y) {
moveTo(getPrintDC(), x, y);
}
|
protected native void moveTo(long printDC,
float x,
float y)
Move the Window's pen position to (x,y)
in the device context printDC. |
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
if (getPrintService() instanceof StreamPrintService) {
return super.pageDialog(page);
}
PageFormat pageClone = (PageFormat) page.clone();
boolean result = false;
/*
* Fix for 4507585: show the native modal dialog the same way printDialog() does so
* that it won't block event dispatching when called on EventDispatchThread.
*/
WPageDialog dialog = new WPageDialog((Frame)null, this,
pageClone, null);
dialog.setRetVal(false);
dialog.setVisible(true);
result = dialog.getRetVal();
dialog.dispose();
// myService = > current PrintService
if (result && (myService != null)) {
// It's possible that current printer is changed through
// the "Printer..." button so we query again from native.
String printerName = getNativePrintService();
if (!myService.getName().equals(printerName)) {
// native printer is different !
// we update the current PrintService
try {
setPrintService(Win32PrintServiceLookup.
getWin32PrintLUS().
getPrintServiceByName(printerName));
} catch (PrinterException e) {
}
}
// Update attributes, this will preserve the page settings.
// - same code as in RasterPrinterJob.java
updatePageAttributes(myService, pageClone);
return pageClone;
} else {
return page;
}
}
Display a dialog to the user allowing the modification of a
PageFormat instance.
The page argument is used to initialize controls
in the page setup dialog.
If the user cancels the dialog, then the method returns the
original page object unmodified.
If the user okays the dialog then the method returns a new
PageFormat object with the indicated changes.
In either case the original page object will
not be modified. |
protected void polyBezierTo(float control1x,
float control1y,
float control2x,
float control2y,
float endX,
float endY) {
polyBezierTo(getPrintDC(), control1x, control1y,
control2x, control2y,
endX, endY);
}
|
protected native void polyBezierTo(long printDC,
float control1x,
float control1y,
float control2x,
float control2y,
float endX,
float endY)
|
protected native void printBand(byte[] data,
int x,
int y,
int width,
int height)
Prints the contents of the array of ints, 'data'
to the current page. The band is placed at the
location (x, y) in device coordinates on the
page. The width and height of the band is
specified by the caller. |
public boolean printDialog() throws HeadlessException {
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
// current request attribute set should be reflected to the print dialog.
// If null, create new instance of HashPrintRequestAttributeSet.
if (attributes == null) {
attributes = new HashPrintRequestAttributeSet();
}
if (getPrintService() instanceof StreamPrintService) {
return super.printDialog(attributes);
}
if (noDefaultPrinter == true) {
return false;
} else {
return displayNativeDialog();
}
}
Presents the user a dialog for changing properties of the
print job interactively. |
protected String removeControlChars(String str) {
return super.removeControlChars(str);
}
Remove control characters. |
protected void selectClipPath() {
selectClipPath(getPrintDC());
}
Set the current path in the printer device's
context to be clipping path. |
protected native void selectClipPath(long printDC)
Select the device context's current path
to be the clipping path. |
protected void selectPen(float width,
Color color) {
float[] rgb = color.getRGBColorComponents(null);
selectPen(getPrintDC(), width,
(int) (rgb[0] * MAX_WCOLOR),
(int) (rgb[1] * MAX_WCOLOR),
(int) (rgb[2] * MAX_WCOLOR));
}
|
protected native void selectPen(long printDC,
float width,
int red,
int green,
int blue)
Create a solid brush using the RG & B colors and width.
Select this brush and delete the old one. |
protected void selectSolidBrush(Color color) {
/* We only need to select a brush if the color has changed.
*/
if (color.equals(mLastColor) == false) {
mLastColor = color;
float[] rgb = color.getRGBColorComponents(null);
selectSolidBrush(getPrintDC(),
(int) (rgb[0] * MAX_WCOLOR),
(int) (rgb[1] * MAX_WCOLOR),
(int) (rgb[2] * MAX_WCOLOR));
}
}
|
protected native void selectSolidBrush(long printDC,
int red,
int green,
int blue)
Create a Window's solid brush for the color specified
by (red, green, blue). Once the brush
is created, select it in the device
context printDC and free the old brush. |
protected boolean selectStylePen(int cap,
int join,
float width,
Color color) {
long endCap;
long lineJoin;
float[] rgb = color.getRGBColorComponents(null);
switch(cap) {
case BasicStroke.CAP_BUTT: endCap = PS_ENDCAP_FLAT; break;
case BasicStroke.CAP_ROUND: endCap = PS_ENDCAP_ROUND; break;
default:
case BasicStroke.CAP_SQUARE: endCap = PS_ENDCAP_SQUARE; break;
}
switch(join) {
case BasicStroke.JOIN_BEVEL:lineJoin = PS_JOIN_BEVEL; break;
default:
case BasicStroke.JOIN_MITER:lineJoin = PS_JOIN_MITER; break;
case BasicStroke.JOIN_ROUND:lineJoin = PS_JOIN_ROUND; break;
}
return (selectStylePen(getPrintDC(), endCap, lineJoin, width,
(int) (rgb[0] * MAX_WCOLOR),
(int) (rgb[1] * MAX_WCOLOR),
(int) (rgb[2] * MAX_WCOLOR)));
}
|
protected native boolean selectStylePen(long printDC,
long cap,
long join,
float width,
int red,
int green,
int blue)
Create a solid brush using the RG & B colors and specified
pen styles. Select this created brush and delete the old one. |
protected void setAttributes(PrintRequestAttributeSet attributes) throws PrinterException {
// initialize attribute values
initAttributeMembers();
super.setAttributes(attributes);
mAttCopies = getCopiesInt();
mDestination = destinationAttr;
if (attributes == null) {
return; // now always use attributes, so this shouldn't happen.
}
Attribute[] attrs = attributes.toArray();
for (int i=0; i< attrs.length; i++) {
Attribute attr = attrs[i];
try {
if (attr.getCategory() == Sides.class) {
setSidesAttrib(attr);
}
else if (attr.getCategory() == Chromaticity.class) {
setColorAttrib(attr);
}
else if (attr.getCategory() == PrinterResolution.class) {
setResolutionAttrib(attr);
}
else if (attr.getCategory() == PrintQuality.class) {
setQualityAttrib(attr);
}
else if (attr.getCategory() == SheetCollate.class) {
setCollateAttrib(attr);
} else if (attr.getCategory() == Media.class ||
attr.getCategory() == SunAlternateMedia.class) {
/* SunAlternateMedia is used if its a tray, and
* any Media that is specified is not a tray.
*/
if (attr.getCategory() == SunAlternateMedia.class) {
Media media = (Media)attributes.get(Media.class);
if (media == null ||
!(media instanceof MediaTray)) {
attr = ((SunAlternateMedia)attr).getMedia();
}
}
if (attr instanceof MediaSizeName) {
setWin32MediaAttrib(attr);
}
if (attr instanceof MediaTray) {
setMediaTrayAttrib(attr);
}
}
} catch (ClassCastException e) {
}
}
}
copy the attributes to the native print job
Note that this method, and hence the re-initialisation
of the GDI values is done on each entry to the print dialog since
an app could redisplay the print dialog for the same job and
1) the application may have changed attribute settings
2) the application may have changed the printer.
In the event that the user changes the printer using the
dialog, then it is up to GDI to report back all changed values. |
public void setCopies(int copies) {
super.setCopies(copies);
mAttCopies = copies;
setNativeCopies(copies);
}
Set the number of copies to be printed. |
protected boolean setFont(String family,
float size,
int style,
int rotation,
float awScale) {
boolean didSetFont = true;
if (!family.equals(mLastFontFamily) ||
size != mLastFontSize ||
style != mLastFontStyle ||
rotation != mLastRotation ||
awScale != mLastAwScale) {
didSetFont = setFont(getPrintDC(),
family,
size,
(style & Font.BOLD) != 0,
(style & Font.ITALIC) != 0,
rotation, awScale);
if (didSetFont) {
mLastFontFamily = family;
mLastFontSize = size;
mLastFontStyle = style;
mLastRotation = rotation;
mLastAwScale = awScale;
}
}
return didSetFont;
}
Set a GDI font capable of drawing the java Font
passed in. |
protected native boolean setFont(long printDC,
String familyName,
float fontSize,
boolean bold,
boolean italic,
int rotation,
float awScale)
Set a GDI font capable of drawing the java Font
passed in. |
public native void setNativeCopies(int copies)
|
protected void setPolyFillMode(int fillRule) {
setPolyFillMode(getPrintDC(), fillRule);
}
Set the current polgon fill rule into the printer device context.
The fillRule should
be one of the following Windows constants:
ALTERNATE or WINDING. |
protected native void setPolyFillMode(long printDC,
int fillRule)
Set the current polgon fill rule into the device context
printDC. The fillRule should
be one of the following Windows constants:
ALTERNATE or WINDING. |
public void setPrintService(PrintService service) throws PrinterException {
super.setPrintService(service);
if (service instanceof StreamPrintService) {
return;
}
driverDoesMultipleCopies = false;
driverDoesCollation = false;
setNativePrintService(service.getName());
}
Associate this PrinterJob with a new PrintService.
Throws PrinterException if the specified service
cannot support the Pageable and
Printable interfaces necessary to support 2D printing. |
protected void setTextColor(Color color) {
/* We only need to select a brush if the color has changed.
*/
if (color.equals(mLastTextColor) == false) {
mLastTextColor = color;
float[] rgb = color.getRGBColorComponents(null);
setTextColor(getPrintDC(),
(int) (rgb[0] * MAX_WCOLOR),
(int) (rgb[1] * MAX_WCOLOR),
(int) (rgb[2] * MAX_WCOLOR));
}
}
Set the GDI color for text drawing. |
protected native void setTextColor(long printDC,
int red,
int green,
int blue)
Set the GDI color for text drawing. |
protected void startDoc() throws PrinterException {
if (!_startDoc(mDestination, getJobName())) {
cancel();
}
}
|
protected void startPage(PageFormat format,
Printable painter,
int index,
boolean paperChanged) {
/* Invalidate any device state caches we are
* maintaining. Win95/98 resets the device
* context attributes to default values at
* the start of each page.
*/
invalidateCachedState();
deviceStartPage(format, painter, index, paperChanged);
}
|
protected void textOut(String str,
float x,
float y,
float[] positions) {
/* Don't leave handling of control chars to GDI.
* If control chars are removed, 'positions' isn't valid.
* This means the caller needs to be aware of this and remove
* control chars up front if supplying positions. Since the
* caller is tightly integrated here, that's acceptable.
*/
String text = removeControlChars(str);
assert (positions == null) || (text.length() == str.length());
if (text.length() == 0) {
return;
}
textOut(getPrintDC(), text, text.length(), false, x, y, positions);
}
Draw the string text to the printer's
device context at the specified position. |
protected native void textOut(long printDC,
String text,
int strlen,
boolean glyphs,
float x,
float y,
float[] positions)
Draw the string text into the device
context printDC at the specified
position. |
protected native void validatePaper(Paper origPaper,
Paper newPaper)
validate the paper size against the current printer. |