org.foray.graphic.batik
Class PSGraphics2D

java.lang.Object
  extended by java.awt.Graphics
      extended by java.awt.Graphics2D
          extended by org.apache.xmlgraphics.java2d.AbstractGraphics2D
              extended by org.foray.graphic.batik.PSGraphics2D
All Implemented Interfaces:
Cloneable

public class PSGraphics2D
extends org.apache.xmlgraphics.java2d.AbstractGraphics2D

Implementation of AbstractGraphics2D suitable for integration with Batik for purposes of converting SVG to PostScript.


Field Summary
 
Fields inherited from class org.apache.xmlgraphics.java2d.AbstractGraphics2D
gc, inPossibleRecursion, textAsShapes
 
Constructor Summary
PSGraphics2D(boolean textAsShapes, CharacterOutputStream out, org.apache.commons.logging.Log logger)
          Create a new PDFGraphics2D with the given pdf document info.
PSGraphics2D(PSGraphics2D g, org.apache.commons.logging.Log logger)
          Constructor supporting the create() method.
 
Method Summary
protected  void applyPaint(Paint paint, boolean fill)
          Apply the paint to this graphic.
protected  void applyStroke(Stroke stroke)
          Draw the graphic using a specified Stroke.
 void copyArea(int x, int y, int width, int height, int dx, int dy)
           
 Graphics create()
           
 void dispose()
           
protected  void doDrawing(boolean fill, boolean stroke, boolean nonzero)
          Write the command to the renderer.
 void draw(Shape s)
           
 boolean drawImage(Image img, int x, int y, ImageObserver observer)
           
 boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
           
 void drawRenderableImage(RenderableImage img, AffineTransform xform)
           
 void drawRenderedImage(RenderedImage img, AffineTransform xform)
           
 void drawString(AttributedCharacterIterator iterator, float x, float y)
           
 void drawString(String s, float x, float y)
           
 void fill(Shape s)
           
 GraphicsConfiguration getDeviceConfiguration()
           
 FontMetrics getFontMetrics(Font f)
           
 void setGraphicContext(org.apache.xmlgraphics.java2d.GraphicContext c)
          Sets the graphic context.
 void setXORMode(Color c1)
           
protected  void writeClip(Shape s)
          Creates code to clip along a given shape.
 
Methods inherited from class org.apache.xmlgraphics.java2d.AbstractGraphics2D
addRenderingHints, clearRect, clip, clipRect, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, drawString, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, getBackground, getClip, getClipBounds, getColor, getComposite, getFont, getFontRenderContext, getGraphicContext, getPaint, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, rotate, rotate, scale, setBackground, setClip, setClip, setColor, setComposite, setFont, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setTransform, shear, transform, translate, translate
 
Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
 
Methods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PSGraphics2D

public PSGraphics2D(boolean textAsShapes,
                    CharacterOutputStream out,
                    org.apache.commons.logging.Log logger)
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 - Indicates whether text should be treated as text (false), or whether it should be converted to its paths (true).
out - The output stream to which the content should be written.
logger - The logger.

PSGraphics2D

public PSGraphics2D(PSGraphics2D g,
                    org.apache.commons.logging.Log logger)
Constructor supporting the create() method.

Parameters:
g - The wrapped graphic.
logger - The logger.
Method Detail

setGraphicContext

public void setGraphicContext(org.apache.xmlgraphics.java2d.GraphicContext c)
Sets the graphic context.

Parameters:
c - The new graphic context.

create

public Graphics create()
Specified by:
create in class Graphics

drawImage

public boolean drawImage(Image img,
                         int x,
                         int y,
                         ImageObserver observer)
Specified by:
drawImage in class Graphics

drawImage

public boolean drawImage(Image img,
                         int x,
                         int y,
                         int width,
                         int height,
                         ImageObserver observer)
Specified by:
drawImage in class Graphics

dispose

public void dispose()
Specified by:
dispose in class Graphics

draw

public void draw(Shape s)
Specified by:
draw in class Graphics2D

writeClip

protected void writeClip(Shape s)
                  throws IOException
Creates code to clip along a given shape.

Parameters:
s - The shape upon which the clip should be created.
Throws:
IOException - For I/O errors writing the content.

applyPaint

protected void applyPaint(Paint paint,
                          boolean fill)
Apply the paint to this graphic.

Parameters:
paint - The paint to use.
fill - Indicates whether the paint is for fill (true) or stroke (false).

applyStroke

protected void applyStroke(Stroke stroke)
                    throws IOException
Draw the graphic using a specified Stroke.

Parameters:
stroke - The stroke to use for drawing.
Throws:
IOException - For I/O errors writing the content.

drawRenderedImage

public void drawRenderedImage(RenderedImage img,
                              AffineTransform xform)
Specified by:
drawRenderedImage in class Graphics2D

drawRenderableImage

public void drawRenderableImage(RenderableImage img,
                                AffineTransform xform)
Specified by:
drawRenderableImage in class Graphics2D

drawString

public void drawString(String s,
                       float x,
                       float y)
Specified by:
drawString in class Graphics2D

drawString

public void drawString(AttributedCharacterIterator iterator,
                       float x,
                       float y)
Overrides:
drawString in class org.apache.xmlgraphics.java2d.AbstractGraphics2D

fill

public void fill(Shape s)
Specified by:
fill in class Graphics2D

doDrawing

protected void doDrawing(boolean fill,
                         boolean stroke,
                         boolean nonzero)
                  throws IOException
Write the command to the renderer.

Parameters:
fill - Set to true if filling.
stroke - Set to true if stroking.
nonzero - Set to true to use the nonzero winding number rule.
Throws:
IOException - For IO errors on output.

getDeviceConfiguration

public GraphicsConfiguration getDeviceConfiguration()
Specified by:
getDeviceConfiguration in class Graphics2D

getFontMetrics

public FontMetrics getFontMetrics(Font f)
Specified by:
getFontMetrics in class Graphics

setXORMode

public void setXORMode(Color c1)
Specified by:
setXORMode in class Graphics

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Specified by:
copyArea in class Graphics


Copyright © 2017. All rights reserved.