APIdia Launch Partner
Top Description Fields Constructors Methods
sun.print

public Class GrayscaleProxyGraphics2D

extends ProxyGraphics2D
Class Inheritance
Imports
java.awt.Color, .GradientPaint, .Graphics, .Graphics2D, .Image, .LinearGradientPaint, .Paint, .RadialGradientPaint, .TexturePaint, java.awt.color.ColorSpace, java.awt.geom.AffineTransform, java.awt.image.BufferedImage, .BufferedImageOp, .ImageObserver, .RenderedImage, java.awt.print.PrinterJob

Proxy class to print with grayscale. Convert Colors, Paints and Images to the grayscale.

Field Summary

Inherited from sun.print.ProxyGraphics2D:
mGraphicsmPrinterJob

Constructor Summary

AccessConstructor and Description
public
GrayscaleProxyGraphics2D(Graphics2D graphics, PrinterJob printerJob)

The new ProxyGraphics2D will forward all graphics calls to 'graphics'.

Method Summary

Modifier and TypeMethod and Description
public boolean
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface.

public boolean
drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface.

public boolean
drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

public boolean
drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified image as is currently available.

public boolean
drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

public boolean
drawImage(Image img, int x, int y, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified image as is currently available.

public void
drawImage(BufferedImage img, BufferedImageOp op, int x, int y)

Overrides sun.print.ProxyGraphics2D.drawImage.

Draws a BufferedImage that is filtered with a BufferedImageOp.

public boolean
drawImage(Image img, AffineTransform xform, ImageObserver obs)

Overrides sun.print.ProxyGraphics2D.drawImage.

Draws an image, applying a transform from image space into user space before drawing.

public void
drawRenderedImage(RenderedImage img, AffineTransform xform)

Overrides sun.print.ProxyGraphics2D.drawRenderedImage.

Draws an image, applying a transform from image space into user space before drawing.

private Color

Returns:

grayscale color
getGrayscaleColor
(Color
color to transform to grayscale
color
)

Returns grayscale variant of the input Color

private BufferedImage

Returns:

grayscale BufferedImage
getGrayscaleImage
(Image
colored image
img
)

Converts Image to a grayscale

public void
setBackground(Color color)

Overrides sun.print.ProxyGraphics2D.setBackground.

Sets the background color in this context used for clearing a region.

public void
setColor(Color c)

Overrides sun.print.ProxyGraphics2D.setColor.

Sets this graphics context's current color to the specified color.

public void
setPaint(Paint paint)

Overrides sun.print.ProxyGraphics2D.setPaint.

Sets the Paint in the current graphics state.

Inherited from sun.print.ProxyGraphics2D:
addRenderingHintsclearRectclipclipRectcopyAreacreatedisposedrawdrawArcdrawGlyphVectordrawLinedrawOvaldrawPolygondrawPolylinedrawRenderableImagedrawRoundRectdrawStringdrawStringdrawStringdrawStringfillfillArcfillOvalfillPolygonfillRectfillRoundRectfinalizegetBackgroundgetClipgetClipBoundsgetColorgetCompositegetDelegategetDeviceConfigurationgetFontgetFontMetricsgetFontRenderContextgetPaintgetPrinterJobgetRenderingHintgetRenderingHintsgetStrokegetTransformhitrotaterotatescalesetClipsetClipsetCompositesetDelegatesetFontsetPaintModesetRenderingHintsetRenderingHintssetStrokesetTransformsetXORModesheartransformtranslatetranslate

Constructor Detail

GrayscaleProxyGraphics2Dback to summary
public GrayscaleProxyGraphics2D(Graphics2D graphics, PrinterJob printerJob)

The new ProxyGraphics2D will forward all graphics calls to 'graphics'.

Method Detail

drawImageback to summary
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Doc from sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface.

Transparent pixels are drawn in the specified background color. This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it, but possibly more efficient.

This method returns immediately in all cases, even if the image area to be drawn has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

This method always uses the unscaled version of the image to render the scaled rectangle and performs the required scaling on the fly. It does not use a cached, scaled version of the image for this operation. Scaling of the image from source to destination is performed such that the first coordinate of the source rectangle is mapped to the first coordinate of the destination rectangle, and the second source coordinate is mapped to the second destination coordinate. The subimage is scaled and flipped as needed to preserve those mappings.

Annotations
@Override
drawImageback to summary
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Doc from sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified area of the specified image as is currently available, scaling it on the fly to fit inside the specified area of the destination drawable surface. Transparent pixels do not affect whatever pixels are already there.

This method returns immediately in all cases, even if the image area to be drawn has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

This method always uses the unscaled version of the image to render the scaled rectangle and performs the required scaling on the fly. It does not use a cached, scaled version of the image for this operation. Scaling of the image from source to destination is performed such that the first coordinate of the source rectangle is mapped to the first coordinate of the destination rectangle, and the second source coordinate is mapped to the second destination coordinate. The subimage is scaled and flipped as needed to preserve those mappings.

Annotations
@Override
drawImageback to summary
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Doc from sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

The image is drawn inside the specified rectangle of this graphics context's coordinate space, and is scaled if necessary. Transparent pixels are drawn in the specified background color. This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it, but possibly more efficient.

This method returns immediately in all cases, even if the entire image has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

A scaled version of an image will not necessarily be available immediately just because an unscaled version of the image has been constructed for this output device. Each size of the image may be cached separately and generated from the original data in a separate image production sequence.

Annotations
@Override
drawImageback to summary
public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Doc from sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified image as is currently available. The image is drawn with its top-left corner at (x, y) in this graphics context's coordinate space. Transparent pixels are drawn in the specified background color.

This operation is equivalent to filling a rectangle of the width and height of the specified image with the given color and then drawing the image on top of it, but possibly more efficient.

This method returns immediately in all cases, even if the complete image has not yet been loaded, and it has not been dithered and converted for the current output device.

If the image has not yet been completely loaded, then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

Annotations
@Override
drawImageback to summary
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Doc from sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified image as has already been scaled to fit inside the specified rectangle.

The image is drawn inside the specified rectangle of this graphics context's coordinate space, and is scaled if necessary. Transparent pixels do not affect whatever pixels are already there.

This method returns immediately in all cases, even if the entire image has not yet been scaled, dithered, and converted for the current output device. If the current output representation is not yet complete, then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the image observer by calling its imageUpdate method.

A scaled version of an image will not necessarily be available immediately just because an unscaled version of the image has been constructed for this output device. Each size of the image may be cached separately and generated from the original data in a separate image production sequence.

Annotations
@Override
drawImageback to summary
public boolean drawImage(Image img, int x, int y, ImageObserver observer)

Overrides sun.print.ProxyGraphics2D.drawImage.

Doc from sun.print.ProxyGraphics2D.drawImage.

Draws as much of the specified image as is currently available. The image is drawn with its top-left corner at (x, y) in this graphics context's coordinate space. Transparent pixels in the image do not affect whatever pixels are already there.

This method returns immediately in all cases, even if the complete image has not yet been loaded, and it has not been dithered and converted for the current output device.

If the image has not yet been completely loaded, then drawImage returns false. As more of the image becomes available, the process that draws the image notifies the specified image observer.

Annotations
@Override
drawImageback to summary
public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)

Overrides sun.print.ProxyGraphics2D.drawImage.

Doc from sun.print.ProxyGraphics2D.drawImage.

Draws a BufferedImage that is filtered with a BufferedImageOp. The rendering attributes applied include the clip, transform and composite attributes. This is equivalent to:

img1 = op.filter(img, null);
drawImage(img1, new AffineTransform(1f,0f,0f,1f,x,y), null);
Annotations
@Override
drawImageback to summary
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)

Overrides sun.print.ProxyGraphics2D.drawImage.

Doc from sun.print.ProxyGraphics2D.drawImage.

Draws an image, applying a transform from image space into user space before drawing. The transformation from user space into device space is done with the current transform in the Graphics2D. The given transformation is applied to the image before the transform attribute in the Graphics2D state is applied. The rendering attributes applied include the clip, transform, and composite attributes. Note that the result is undefined, if the given transform is noninvertible.

Annotations
@Override
drawRenderedImageback to summary
public void drawRenderedImage(RenderedImage img, AffineTransform xform)

Overrides sun.print.ProxyGraphics2D.drawRenderedImage.

Doc from sun.print.ProxyGraphics2D.drawRenderedImage.

Draws an image, applying a transform from image space into user space before drawing. The transformation from user space into device space is done with the current transform in the Graphics2D. The given transformation is applied to the image before the transform attribute in the Graphics2D state is applied. The rendering attributes applied include the clip, transform, and composite attributes. Note that the result is undefined, if the given transform is noninvertible.

Annotations
@Override
getGrayscaleColorback to summary
private Color getGrayscaleColor(Color color)

Returns grayscale variant of the input Color

Parameters
color:Color

color to transform to grayscale

Returns:Color

grayscale color

getGrayscaleImageback to summary
private BufferedImage getGrayscaleImage(Image img)

Converts Image to a grayscale

Parameters
img:Image

colored image

Returns:BufferedImage

grayscale BufferedImage

setBackgroundback to summary
public void setBackground(Color color)

Overrides sun.print.ProxyGraphics2D.setBackground.

Doc from sun.print.ProxyGraphics2D.setBackground.

Sets the background color in this context used for clearing a region. When Graphics2D is constructed for a component, the background color is inherited from the component. Setting the background color in the Graphics2D context only affects the subsequent clearRect() calls and not the background color of the component. To change the background of the component, use appropriate methods of the component.

Annotations
@Override
setColorback to summary
public void setColor(Color c)

Overrides sun.print.ProxyGraphics2D.setColor.

Doc from sun.print.ProxyGraphics2D.setColor.

Sets this graphics context's current color to the specified color. All subsequent graphics operations using this graphics context use this specified color.

Annotations
@Override
setPaintback to summary
public void setPaint(Paint paint)

Overrides sun.print.ProxyGraphics2D.setPaint.

Doc from sun.print.ProxyGraphics2D.setPaint.

Sets the Paint in the current graphics state.

Annotations
@Override