fop 0.94 | |
Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
AbstractGraphics2D
org.apache.fop.svg.PDFGraphics2D
public class PDFGraphics2D
extends AbstractGraphics2D
org.apache.batik.ext.awt.g2d.AbstractGraphics2D
Field Summary | |
protected int |
|
protected String |
|
protected float |
|
protected StringWriter |
|
protected FontInfo |
|
protected PDFState |
|
protected int[] |
|
protected OutputStream |
|
protected Font |
|
protected String |
|
protected PDFDocument |
|
protected PDFResourceContext |
|
Constructor Summary | |
| |
| |
|
Method Summary | |
void |
|
void |
|
protected void |
|
protected boolean |
|
protected void |
|
protected boolean |
|
protected void |
|
void |
|
Graphics |
|
void |
|
protected void |
|
void |
|
boolean |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected AffineTransform |
|
StringBuffer |
|
GraphicsConfiguration |
|
java.awt.FontMetrics |
|
String |
|
protected void |
|
protected void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
protected void |
|
protected int baseLevel
The PDF graphics state level that this svg is being drawn into.
protected String currentFontName
the current (internal) font name
protected float currentFontSize
the current font size in millipoints
protected StringWriter currentStream
the current stream to add PDF commands to
protected int[] jpegCount
The count of JPEG images added to document so they recieve unique keys.
protected OutputStream outputStream
The output stream for the pdf document. If this is set then it can progressively output the pdf document objects to reduce memory. Especially with images.
protected Font ovFontState
The override font state used when drawing text and the font cannot be set using java fonts.
protected String pageRef
The PDF reference of the current page.
protected PDFResourceContext resourceContext
The current resource context for adding fonts, patterns etc.
protected PDFGraphics2D(boolean textAsShapes)
Create a new PDFGraphics2D.
- Parameters:
textAsShapes
- true if drawing text as shapes
public PDFGraphics2D(boolean textAsShapes, FontInfo fi, PDFDocument doc, PDFResourceContext page, String pref, String font, float size)
Create a new PDFGraphics2D with the given pdf document info. This is used to create a Graphics object for use inside an already existing document.
- Parameters:
textAsShapes
- if true then draw text as shapesfi
- the current font informationdoc
- the pdf document for creating pdf objectspage
- the current resource context or pagepref
- the PDF reference of the current pagefont
- the current font namesize
- the current font size
public PDFGraphics2D(PDFGraphics2D g)
This constructor supports the create method. This is not implemented properly.
- Parameters:
g
- the PDF graphics to make a copy of
public void addJpegImage(JpegImage jpeg, float x, float y, float width, float height)
Add a JPEG image directly to the PDF document. This is used by the PDFImageElementBridge to draw a JPEG directly into the pdf document rather than converting the image into a bitmap and increasing the size.
- Parameters:
jpeg
- the jpeg image to drawx
- the x positiony
- the y positionwidth
- the width to draw the imageheight
- the height to draw the image
public void addLink(Rectangle2D bounds, AffineTransform trans, String dest, int linkType)
This is a pdf specific method used to add a link to the pdf document.
- Parameters:
bounds
- the bounds of the link in user coordinatestrans
- the transform of the current drawing positiondest
- the PDF destinationlinkType
- the type of link, internal or external
protected void applyColor(Color col, boolean fill)
Apply the java Color to PDF. This converts the java colour to a PDF colour and sets it for the next drawing.
- Parameters:
col
- the java colourfill
- true if the colour will be used for filling
protected boolean applyPaint(Paint paint, boolean fill)
Apply the java paint to the PDF. This takes the java paint sets up the appropraite PDF commands for the drawing with that paint. Currently this supports the gradients and patterns from batik.
- Parameters:
paint
- the paint to convert to PDFfill
- true if the paint should be set for filling
- Returns:
- true if the paint is handled natively, false if the paint should be rasterized
protected void applyStroke(Stroke stroke)
Apply the stroke to the PDF. This takes the java stroke and outputs the appropriate settings to the PDF so that the stroke attributes are handled.
- Parameters:
stroke
- the java stroke
protected boolean applyUnknownPaint(Paint paint, Shape shape)
protected void checkTransparencyAllowed()
Checks whether the use of transparency is allowed.
public void copyArea(int x, int y, int width, int height, int dx, int dy)
Copies an area of the component by a distance specified bydx
anddy
. From the point specified byx
andy
, this method copies downwards and to the right. To copy an area of the component to the left or upwards, specify a negative value fordx
ordy
. If a portion of the source rectangle lies outside the bounds of the component, or is obscured by another window or component,copyArea
will be unable to copy the associated pixels. The area that is omitted can be refreshed by calling the component'spaint
method.
- Parameters:
x
- the x coordinate of the source rectangle.y
- the y coordinate of the source rectangle.width
- the width of the source rectangle.height
- the height of the source rectangle.dx
- the horizontal distance to copy the pixels.dy
- the vertical distance to copy the pixels.
public Graphics create()
Creates a newGraphics
object that is a copy of thisGraphics
object.
- Returns:
- a new graphics context that is a copy of this graphics context.
public void dispose()
Disposes of this graphics context and releases any system resources that it is using. AGraphics
object cannot be used afterdispose
has been called. When a Java program runs, a large number ofGraphics
objects can be created within a short time frame. Although the finalization process of the garbage collector also disposes of the same system resources, it is preferable to manually free the associated resources by calling this method rather than to rely on a finalization process which may not run to completion for a long period of time. Graphics objects which are provided as arguments to thepaint
andupdate
methods of components are automatically released by the system when those methods return. For efficiency, programmers should calldispose
when finished using aGraphics
object only if it was created directly from a component or anotherGraphics
object.
- See Also:
java.awt.Graphics.finalize
,java.awt.Component.paint
,java.awt.Component.update
,java.awt.Component.getGraphics
,java.awt.Graphics.create
protected void doDrawing(boolean fill, boolean stroke, boolean nonzero)
Do the PDF drawing command. This does the PDF drawing command according to fill stroke and winding rule.
- Parameters:
fill
- true if filling the pathstroke
- true if stroking the pathnonzero
- true if using the non-zero winding rule
public void draw(Shape s)
Strokes the outline of aShape
using the settings of the currentGraphics2D
context. The rendering attributes applied include theClip
,Transform
,Paint
,Composite
andStroke
attributes.
- Parameters:
s
- theShape
to be rendered
- See Also:
PDFGraphics2D
,PDFGraphics2D
,java.awt.Graphics.setColor
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
public boolean drawImage(Image img, int x, int y, ImageObserver observer)
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, thendrawImage
returnsfalse
. As more of the image becomes available, the process that draws the image notifies the specified image observer.
- Parameters:
img
- the specified image to be drawn.x
- the x coordinate.y
- the y coordinate.observer
- object to be notified as more of the image is converted.
- Returns:
- true if the image was drawn
- See Also:
java.awt.Image
,java.awt.image.ImageObserver
,java.awt.image.ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
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, thendrawImage
returnsfalse
. As more of the image becomes available, the process that draws the image notifies the image observer by calling itsimageUpdate
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.
- Parameters:
img
- the specified image to be drawn.x
- the x coordinate.y
- the y coordinate.width
- the width of the rectangle.height
- the height of the rectangle.observer
- object to be notified as more of the image is converted.
- Returns:
- true if the image was drawn
- See Also:
java.awt.Image
,java.awt.image.ImageObserver
,java.awt.image.ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)
public void drawRenderableImage(RenderableImage img, AffineTransform xform)
Renders aRenderableImage
, applying a transform from image space into user space before drawing. The transformation from user space into device space is done with the currentTransform
in theGraphics2D
. The specified transformation is applied to the image before the transform attribute in theGraphics2D
context is applied. The rendering attributes applied include theClip
,Transform
, andComposite
attributes. Note that no rendering is done if the specified transform is noninvertible. Rendering hints set on theGraphics2D
object might be used in rendering theRenderableImage
. If explicit control is required over specific hints recognized by a specificRenderableImage
, or if knowledge of which hints are used is required, then aRenderedImage
should be obtained directly from theRenderableImage
and rendered usingdrawRenderedImage
.
- Parameters:
img
- the image to be renderedxform
- the transformation from image space into user space
- See Also:
PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,drawRenderedImage(RenderedImage,AffineTransform)
public void drawRenderedImage(RenderedImage img, AffineTransform xform)
Renders aRenderedImage
, applying a transform from image space into user space before drawing. The transformation from user space into device space is done with the currentTransform
in theGraphics2D
. The specified transformation is applied to the image before the transform attribute in theGraphics2D
context is applied. The rendering attributes applied include theClip
,Transform
, andComposite
attributes. Note that no rendering is done if the specified transform is noninvertible.
- Parameters:
img
- the image to be renderedxform
- the transformation from image space into user space
- See Also:
PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
public void drawString(AttributedCharacterIterator iterator, float x, float y)
Renders the text of the specified iterator, using theGraphics2D
context's currentPaint
. The iterator must specify a font for each character. The baseline of the first character is at position (x, y) in the User Space. The rendering attributes applied include theClip
,Transform
,Paint
, andComposite
attributes. For characters in script systems such as Hebrew and Arabic, the glyphs can be rendered from right to left, in which case the coordinate supplied is the location of the leftmost character on the baseline.
- Parameters:
iterator
- the iterator whose text is to be renderedx
- the coordinate where the iterator's text is to be renderedy
- the coordinate where the iterator's text is to be rendered
- See Also:
PDFGraphics2D
,java.awt.Graphics.setColor
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
public void drawString(String s, float x, float y)
Renders the text specified by the specifiedString
, using the currentFont
andPaint
attributes in theGraphics2D
context. The baseline of the first character is at position (x, y) in the User Space. The rendering attributes applied include theClip
,Transform
,Paint
,Font
andComposite
attributes. For characters in script systems such as Hebrew and Arabic, the glyphs can be rendered from right to left, in which case the coordinate supplied is the location of the leftmost character on the baseline.
- Parameters:
s
- theString
to be renderedx
- the coordinate where theString
should be renderedy
- the coordinate where theString
should be rendered
- See Also:
PDFGraphics2D
,java.awt.Graphics.setColor
,java.awt.Graphics.setFont
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
public void fill(Shape s)
Fills the interior of aShape
using the settings of theGraphics2D
context. The rendering attributes applied include theClip
,Transform
,Paint
, andComposite
.
- Parameters:
s
- theShape
to be filled
- See Also:
PDFGraphics2D
,java.awt.Graphics.setColor
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
,PDFGraphics2D
protected AffineTransform getBaseTransform()
This is mainly used for shading patterns which use the document-global coordinate system instead of the local one.
- Returns:
- the transformation matrix that established the basic user space for this document
public StringBuffer getBuffer()
Get the string buffer from the currentStream, containing all the commands written into this Grpahics so far.
- Returns:
- the StringBuffer containing the PDF markup
public GraphicsConfiguration getDeviceConfiguration()
Returns the device configuration associated with thisGraphics2D
.
- Returns:
- the PDF graphics configuration
public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
Gets the font metrics for the specified font.
- Parameters:
f
- the specified font
- Returns:
- the font metrics for the specified font.
- See Also:
java.awt.Graphics.getFont
,java.awt.FontMetrics
,java.awt.Graphics.getFontMetrics()
public String getString()
Get the string containing all the commands written into this Grpahics.
- Returns:
- the string containing the PDF markup
protected void handleIOException(IOException ioe)
Central handler for IOExceptions for this class.
- Parameters:
ioe
- IOException to handle
protected void preparePainting()
This method is used by PDFDocumentGraphics2D to prepare a new page if necessary.
public void processPathIterator(PathIterator iter)
Processes a path iterator generating the necessary painting operations.
- Parameters:
iter
- PathIterator to process
public void setGraphicContext(GraphicContext c)
Set the Grpahics context.
- Parameters:
c
- the graphics context to use
public void setOutputStream(OutputStream os)
Set the output stream that this PDF document is being drawn to. This is so that it can progressively use the PDF document to output data such as images. This results in a significant saving on memory.
- Parameters:
os
- the output stream that is being used for the PDF document
public void setOverrideFontState(Font infont)
Set the override font state for drawing text. This is used by the PDF text painter so that it can temporarily set the font state when a java font cannot be used. The next drawString will use this font state.
- Parameters:
infont
- the font state to use
public void setPDFState(PDFState state)
Set the PDF state to use when starting to draw into the PDF graphics.
- Parameters:
state
- the PDF state
public void setXORMode(Color c1)
Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color. This specifies that logical pixel operations are performed in the XOR mode, which alternates pixels between the current color and a specified XOR color. When drawing operations are performed, pixels which are the current color are changed to the specified color, and vice versa. Pixels that are of colors other than those two colors are changed in an unpredictable but reversible manner; if the same figure is drawn twice, then all pixels are restored to their original values.
- Parameters:
c1
- the XOR alternation color
protected void writeClip(Shape s)
Set the clipping shape for future PDF drawing in the current graphics state. This sets creates and writes a clipping shape that will apply to future drawings in the current graphics state.
- Parameters:
s
- the clipping shape
fop 0.94 |