org.freehep.graphicsio
Class AbstractVectorGraphicsIO

java.lang.Object
  extended by java.awt.Graphics
      extended by java.awt.Graphics2D
          extended by org.freehep.graphics2d.VectorGraphics
              extended by org.freehep.graphics2d.AbstractVectorGraphics
                  extended by org.freehep.graphicsio.VectorGraphicsIO
                      extended by org.freehep.graphicsio.AbstractVectorGraphicsIO
All Implemented Interfaces:
VectorGraphicsConstants
Direct Known Subclasses:
DummyGraphics2D, EMFGraphics2D, PDFGraphics2D, PSGraphics2D, SVGGraphics2D, SWFGraphics2D

public abstract class AbstractVectorGraphicsIO
extends VectorGraphicsIO

This class provides an abstract VectorGraphicsIO class for specific output drivers.

Version:
$Id: AbstractVectorGraphicsIO.java 12625 2007-06-08 21:43:44Z duns $
Author:
Charles Loomis, Mark Donszelmann, Steffen Greiffenberg

Field Summary
static java.lang.String CLIP
           
static java.lang.String EMIT_ERRORS
           
static java.lang.String EMIT_WARNINGS
           
static java.lang.String TEXT_AS_SHAPES
           
 
Fields inherited from interface org.freehep.graphics2d.VectorGraphicsConstants
NUMBER_OF_HORIZ_ALIGNMENTS, NUMBER_OF_SYMBOLS, NUMBER_OF_VERTICAL_ALIGNMENTS, SYMBOL_BOX, SYMBOL_CIRCLE, SYMBOL_CROSS, SYMBOL_DIAMOND, SYMBOL_DN_TRIANGLE, SYMBOL_HLINE, SYMBOL_PLUS, SYMBOL_STAR, SYMBOL_UP_TRIANGLE, SYMBOL_VLINE, TEXT_BASELINE, TEXT_BOTTOM, TEXT_CENTER, TEXT_LEFT, TEXT_RIGHT, TEXT_TOP
 
Constructor Summary
protected AbstractVectorGraphicsIO(AbstractVectorGraphicsIO graphics, boolean doRestoreOnDispose)
          Constructs a subgraphics context.
protected AbstractVectorGraphicsIO(java.awt.Component component, boolean doRestoreOnDispose)
          Constructs a Graphics context with the following graphics state: Paint: The color of the component.
protected AbstractVectorGraphicsIO(java.awt.Dimension size, boolean doRestoreOnDispose)
          Constructs a Graphics context with the following graphics state: Paint: black Font: Dailog, Plain, 12pt Stroke: Linewidth 1.0; No Dashing; Miter Join Style; Miter Limit 10; Square Endcaps; Transform: Identity Composite: AlphaComposite.SRC_OVER Clip: Rectangle(0, 0, size.width, size.height)
 
Method Summary
 void addRenderingHints(java.util.Map hints)
          Adds to table of rendering hints.
 void clearRect(double x, double y, double width, double height)
          Clears rectangle by painting it with the backgroundColor.
 void clip(java.awt.Shape s)
          Clips using given shape.
 void clipRect(double x, double y, double width, double height)
          Clips rectangle.
 void clipRect(int x, int y, int width, int height)
          Clips rectangle.
abstract  void closeStream()
          Called to close the stream you are writing to.
protected  java.awt.Shape createShape(double[] xPoints, double[] yPoints, int nPoints, boolean close)
          Creates a polyline/polygon shape from a set of points.
 void dispose()
          Disposes of the graphics context.
 void drawGlyphVector(java.awt.font.GlyphVector g, float x, float y)
          Use the transformation of the glyphvector and draw it
 void drawImage(java.awt.image.BufferedImage img, java.awt.image.BufferedImageOp op, int x, int y)
           
 boolean drawImage(java.awt.Image image, java.awt.geom.AffineTransform xform, java.awt.image.ImageObserver observer)
           
 boolean drawImage(java.awt.Image image, int x, int y, java.awt.Color bgColor, java.awt.image.ImageObserver observer)
           
 boolean drawImage(java.awt.Image image, int x, int y, java.awt.image.ImageObserver observer)
           
 boolean drawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.Color bgColor, java.awt.image.ImageObserver observer)
           
 boolean drawImage(java.awt.Image image, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
           
 boolean drawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgColor, java.awt.image.ImageObserver observer)
          Draw and resizes (transparent) image.
 boolean drawImage(java.awt.Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)
           
 void drawRenderableImage(java.awt.image.renderable.RenderableImage image, java.awt.geom.AffineTransform xform)
           
 void drawRenderedImage(java.awt.image.RenderedImage image, java.awt.geom.AffineTransform xform)
          Draws a rendered image using a transform.
 void drawString(java.text.AttributedCharacterIterator iterator, float x, float y)
           
 void drawString(java.lang.String string, double x, double y)
          Draws the string at (x, y).
 void endExport()
           
 java.awt.Shape getClip()
          Gets the current clip in form of a Shape (Rectangle).
 java.awt.Rectangle getClipBounds()
          Gets the current clip in form of a Rectangle.
 java.awt.Rectangle getClipBounds(java.awt.Rectangle r)
          Gets the current clip in form of a Rectangle.
 java.awt.Component getComponent()
           
 java.awt.Composite getComposite()
          Gets current composite.
 java.awt.FontMetrics getFontMetrics(java.awt.Font font)
          Deprecated.  
 java.awt.font.FontRenderContext getFontRenderContext()
          Gets the current font render context.
 java.lang.Object getRenderingHint(java.awt.RenderingHints.Key key)
          Gets a given rendering hint.
 java.awt.RenderingHints getRenderingHints()
          Gets a copy of the rendering hints.
 java.awt.Dimension getSize()
           
 java.awt.Stroke getStroke()
          Get the current stroke.
 java.awt.geom.AffineTransform getTransform()
          Get the current transform.
protected  void handleException(java.lang.Exception exception)
          Handles an exception which has been caught.
protected  void overLine(java.lang.String text, java.awt.Font font, float x, float y)
          Draws an overline for the text at (x, y).
 void printComment(java.lang.String comment)
           
protected  void resetClip(java.awt.Rectangle clip)
           
 void rotate(double theta)
          Rotate the current transform over the Z-axis.
 void scale(double sx, double sy)
          Scales the current transform.
 void setClip(double x, double y, double width, double height)
          Clips rectangle.
 void setClip(int x, int y, int width, int height)
          Clips rectangle.
 void setClip(java.awt.Shape s)
          Clips shape.
 void setColor(java.awt.Color color)
          Sets the current color and the current paint.
 void setComposite(java.awt.Composite composite)
          Sets current composite.
 void setFont(java.awt.Font font)
          Sets the current font.
 void setPaint(java.awt.Paint paint)
          Sets the current paint.
 void setRenderingHint(java.awt.RenderingHints.Key key, java.lang.Object hint)
          Sets a given rendering hint.
 void setRenderingHints(java.util.Map hints)
          Sets table of rendering hints.
 void setStroke(java.awt.Stroke stroke)
          Sets the current stroke.
 void setTransform(java.awt.geom.AffineTransform transform)
          Set the current transform.
 void shear(double shx, double shy)
          Shears the current transform.
 void startExport()
           
 void transform(java.awt.geom.AffineTransform transform)
          Transforms the current transform.
 void translate(double x, double y)
          Translates the current transform.
abstract  void writeBackground()
           
protected  void writeCap(int cap)
          Writes out the cap of the stroke.
protected abstract  void writeClip(java.awt.Shape shape)
          Write out Shape clip.
abstract  void writeComment(java.lang.String comment)
          Called to Write out a comment.
protected  void writeDash(double[] dash, double phase)
          Deprecated. use writeDash(float[], float)
protected  void writeDash(float[] dash, float phase)
          Writes out the dash of the stroke.
protected  void writeError(java.lang.Exception exception)
          Writes out an error, by default the stack trace is printed.
protected abstract  void writeFont(java.awt.Font font)
          Writes the font
protected abstract  void writeGraphicsRestore()
          Writes out the restore of a graphics context.
protected abstract  void writeGraphicsSave()
          Writes out the save of a graphics context for a later restore.
 void writeGraphicsState()
          Called to write the initial graphics state.
abstract  void writeHeader()
          Called to write the header part of the output.
protected abstract  void writeImage(java.awt.image.RenderedImage image, java.awt.geom.AffineTransform xform, java.awt.Color bkg)
           
protected  void writeJoin(int join)
          Writes out the join of the stroke.
protected  void writeMiterLimit(float limit)
          Writes out the miter limit of the stroke.
protected abstract  void writePaint(java.awt.Color color)
          Writes out paint as the given color.
protected abstract  void writePaint(java.awt.GradientPaint paint)
          Writes out paint as the given gradient.
protected abstract  void writePaint(java.awt.Paint paint)
          Writes out paint.
protected abstract  void writePaint(java.awt.TexturePaint paint)
          Writes out paint as the given texture.
protected abstract  void writeSetClip(java.awt.Shape shape)
          Write out Shape clip.
protected  void writeSetTransform(java.awt.geom.AffineTransform transform)
          Clears any existing transformation and sets the a new one.
protected abstract  void writeString(java.lang.String string, double x, double y)
           
protected  void writeStroke(java.awt.Stroke stroke)
          Writes the current stroke.
abstract  void writeTrailer()
          Called to write the trailing part of the output.
protected abstract  void writeTransform(java.awt.geom.AffineTransform transform)
          Writes out the transform as it needs to be concatenated to the internal transform of the output format.
protected  void writeWarning(java.lang.Exception exception)
          Writes out a warning, by default to System.err.
protected  void writeWarning(java.lang.String warning)
          Writes out a warning, by default to System.err.
protected  void writeWidth(float width)
          Writes out the width of the stroke.
 
Methods inherited from class org.freehep.graphicsio.VectorGraphicsIO
copyResourceTo, copyResourceTo
 
Methods inherited from class org.freehep.graphics2d.AbstractVectorGraphics
clearRect, createShape, drawArc, drawArc, drawLine, drawLine, drawOval, drawOval, drawPolygon, drawPolygon, drawPolyline, drawPolyline, drawRect, drawRect, drawRoundRect, drawRoundRect, drawString, drawString, drawString, drawString, drawString, drawString, drawString, drawString, drawSymbol, drawSymbol, drawSymbol, fillAndDraw, fillAndDrawSymbol, fillAndDrawSymbol, fillArc, fillArc, fillOval, fillOval, fillPolygon, fillPolygon, fillRect, fillRect, fillRoundRect, fillRoundRect, fillSymbol, fillSymbol, fillSymbol, getBackground, getColor, getColorMode, getCreator, getFont, getPaint, getPrintColor, getProperties, getProperty, getPropertyColor, getPropertyDimension, getPropertyDouble, getPropertyInsets, getPropertyInt, getPropertyRectangle, hit, initProperties, isDeviceIndependent, isProperty, rotate, setBackground, setColorMode, setCreator, setDeviceIndependent, setLineWidth, setLineWidth, setProperties, translate
 
Methods inherited from class org.freehep.graphics2d.VectorGraphics
copyArea, create, create, create, create, draw, fill, fill, getDeviceConfiguration, getSymbol, getTextAlignment, getXalignment, getYalignment, setPaintMode, setXORMode, toString
 
Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
 
Methods inherited from class java.awt.Graphics
drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipRect, getFontMetrics, hitClip
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMIT_WARNINGS

public static final java.lang.String EMIT_WARNINGS

TEXT_AS_SHAPES

public static final java.lang.String TEXT_AS_SHAPES

EMIT_ERRORS

public static final java.lang.String EMIT_ERRORS

CLIP

public static final java.lang.String CLIP
Constructor Detail

AbstractVectorGraphicsIO

protected AbstractVectorGraphicsIO(java.awt.Dimension size,
                                   boolean doRestoreOnDispose)
Constructs a Graphics context with the following graphics state:

Parameters:
size - rectangle specifying the bounds of the image
doRestoreOnDispose - true if writeGraphicsRestore() should be called when this graphics context is disposed of.

AbstractVectorGraphicsIO

protected AbstractVectorGraphicsIO(java.awt.Component component,
                                   boolean doRestoreOnDispose)
Constructs a Graphics context with the following graphics state:

Parameters:
component - to be used to initialize the values of the graphics state
doRestoreOnDispose - true if writeGraphicsRestore() should be called when this graphics context is disposed of.

AbstractVectorGraphicsIO

protected AbstractVectorGraphicsIO(AbstractVectorGraphicsIO graphics,
                                   boolean doRestoreOnDispose)
Constructs a subgraphics context.

Parameters:
graphics - context to clone from
doRestoreOnDispose - true if writeGraphicsRestore() should be called when this graphics context is disposed of.
Method Detail

getSize

public java.awt.Dimension getSize()
Specified by:
getSize in class VectorGraphicsIO

getComponent

public java.awt.Component getComponent()

startExport

public void startExport()
Specified by:
startExport in class VectorGraphics

endExport

public void endExport()
Specified by:
endExport in class VectorGraphics

writeHeader

public abstract void writeHeader()
                          throws java.io.IOException
Called to write the header part of the output.

Throws:
java.io.IOException

writeGraphicsState

public void writeGraphicsState()
                        throws java.io.IOException
Called to write the initial graphics state.

Throws:
java.io.IOException

writeBackground

public abstract void writeBackground()
                              throws java.io.IOException
Throws:
java.io.IOException

writeTrailer

public abstract void writeTrailer()
                           throws java.io.IOException
Called to write the trailing part of the output.

Throws:
java.io.IOException

closeStream

public abstract void closeStream()
                          throws java.io.IOException
Called to close the stream you are writing to.

Throws:
java.io.IOException

printComment

public void printComment(java.lang.String comment)
Specified by:
printComment in class VectorGraphicsIO

writeComment

public abstract void writeComment(java.lang.String comment)
                           throws java.io.IOException
Called to Write out a comment.

Parameters:
comment - to be written
Throws:
java.io.IOException

resetClip

protected void resetClip(java.awt.Rectangle clip)

dispose

public void dispose()
Disposes of the graphics context. If on creation restoreOnDispose was true, writeGraphicsRestore() will be called.

Specified by:
dispose in class VectorGraphics

writeGraphicsSave

protected abstract void writeGraphicsSave()
                                   throws java.io.IOException
Writes out the save of a graphics context for a later restore. Some implementations keep track of this by hand if the output format does not support it.

Throws:
java.io.IOException

writeGraphicsRestore

protected abstract void writeGraphicsRestore()
                                      throws java.io.IOException
Writes out the restore of a graphics context. Some implementations keep track of this by hand if the output format does not support it.

Throws:
java.io.IOException

drawImage

public boolean drawImage(java.awt.Image image,
                         int x,
                         int y,
                         java.awt.image.ImageObserver observer)
Specified by:
drawImage in class VectorGraphics

drawImage

public boolean drawImage(java.awt.Image image,
                         int x,
                         int y,
                         int width,
                         int height,
                         java.awt.image.ImageObserver observer)
Specified by:
drawImage in class VectorGraphics

drawImage

public boolean drawImage(java.awt.Image image,
                         int x,
                         int y,
                         int width,
                         int height,
                         java.awt.Color bgColor,
                         java.awt.image.ImageObserver observer)
Specified by:
drawImage in class VectorGraphics

drawImage

public boolean drawImage(java.awt.Image image,
                         int x,
                         int y,
                         java.awt.Color bgColor,
                         java.awt.image.ImageObserver observer)
Specified by:
drawImage in class VectorGraphics

drawImage

public boolean drawImage(java.awt.Image image,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         java.awt.image.ImageObserver observer)
Specified by:
drawImage in class VectorGraphics

drawImage

public boolean drawImage(java.awt.Image image,
                         java.awt.geom.AffineTransform xform,
                         java.awt.image.ImageObserver observer)
Specified by:
drawImage in class VectorGraphics

drawImage

public void drawImage(java.awt.image.BufferedImage img,
                      java.awt.image.BufferedImageOp op,
                      int x,
                      int y)
Specified by:
drawImage in class VectorGraphics

drawRenderableImage

public void drawRenderableImage(java.awt.image.renderable.RenderableImage image,
                                java.awt.geom.AffineTransform xform)
Specified by:
drawRenderableImage in class VectorGraphics

drawImage

public boolean drawImage(java.awt.Image image,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         java.awt.Color bgColor,
                         java.awt.image.ImageObserver observer)
Draw and resizes (transparent) image. Calls writeImage(...).

Specified by:
drawImage in class VectorGraphics
Parameters:
image - image to be drawn
dx1 - destination image bounds
dy1 - destination image bounds
dx2 - destination image bounds
dy2 - destination image bounds
sx1 - source image bounds
sy1 - source image bounds
sx2 - source image bounds
sy2 - source image bounds
bgColor - background color
observer - for updates if image still incomplete
Returns:
true if successful

drawRenderedImage

public void drawRenderedImage(java.awt.image.RenderedImage image,
                              java.awt.geom.AffineTransform xform)
Draws a rendered image using a transform.

Specified by:
drawRenderedImage in class VectorGraphics
Parameters:
image - to be drawn
xform - transform to be used on the image

writeImage

protected abstract void writeImage(java.awt.image.RenderedImage image,
                                   java.awt.geom.AffineTransform xform,
                                   java.awt.Color bkg)
                            throws java.io.IOException
Throws:
java.io.IOException

clearRect

public void clearRect(double x,
                      double y,
                      double width,
                      double height)
Clears rectangle by painting it with the backgroundColor.

Specified by:
clearRect in class VectorGraphics
Parameters:
x - rectangle to be cleared.
y - rectangle to be cleared.
width - rectangle to be cleared.
height - rectangle to be cleared.

drawString

public void drawString(java.lang.String string,
                       double x,
                       double y)
Draws the string at (x, y). If TEXT_AS_SHAPES is set drawGlyphVector(java.awt.font.GlyphVector, float, float) is used, otherwise writeString(String, double, double) for a more direct output of the string.

Specified by:
drawString in class VectorGraphics
Parameters:
string -
x -
y -

writeString

protected abstract void writeString(java.lang.String string,
                                    double x,
                                    double y)
                             throws java.io.IOException
Throws:
java.io.IOException

drawGlyphVector

public void drawGlyphVector(java.awt.font.GlyphVector g,
                            float x,
                            float y)
Use the transformation of the glyphvector and draw it

Specified by:
drawGlyphVector in class VectorGraphics
Parameters:
g -
x -
y -

drawString

public void drawString(java.text.AttributedCharacterIterator iterator,
                       float x,
                       float y)
Specified by:
drawString in class VectorGraphics

getTransform

public java.awt.geom.AffineTransform getTransform()
Get the current transform.

Specified by:
getTransform in class VectorGraphics
Returns:
current transform

setTransform

public void setTransform(java.awt.geom.AffineTransform transform)
Set the current transform. Calls writeSetTransform(Transform).

Specified by:
setTransform in class VectorGraphics
Parameters:
transform - to be set

transform

public void transform(java.awt.geom.AffineTransform transform)
Transforms the current transform. Calls writeTransform(Transform)

Specified by:
transform in class VectorGraphics
Parameters:
transform - to be applied

translate

public void translate(double x,
                      double y)
Translates the current transform. Calls writeTransform(Transform)

Specified by:
translate in class VectorGraphics
Parameters:
x - amount by which to translate
y - amount by which to translate

rotate

public void rotate(double theta)
Rotate the current transform over the Z-axis. Calls writeTransform(Transform). Rotating with a positive angle theta rotates points on the positive x axis toward the positive y axis.

Specified by:
rotate in class VectorGraphics
Parameters:
theta - radians over which to rotate

scale

public void scale(double sx,
                  double sy)
Scales the current transform. Calls writeTransform(Transform).

Specified by:
scale in class VectorGraphics
Parameters:
sx - amount used for scaling
sy - amount used for scaling

shear

public void shear(double shx,
                  double shy)
Shears the current transform. Calls writeTransform(Transform).

Specified by:
shear in class VectorGraphics
Parameters:
shx - amount for shearing
shy - amount for shearing

writeTransform

protected abstract void writeTransform(java.awt.geom.AffineTransform transform)
                                throws java.io.IOException
Writes out the transform as it needs to be concatenated to the internal transform of the output format. If there is no implementation of an internal transform, then this method needs to do nothing, BUT all coordinates need to be transformed by the currentTransform before being written out.

Parameters:
transform - to be written
Throws:
java.io.IOException

writeSetTransform

protected void writeSetTransform(java.awt.geom.AffineTransform transform)
                          throws java.io.IOException
Clears any existing transformation and sets the a new one. The default implementation calls writeTransform using the inverted affine transform to calculate it. s *

Parameters:
transform - to be written
Throws:
java.io.IOException

getClip

public java.awt.Shape getClip()
Gets the current clip in form of a Shape (Rectangle).

Specified by:
getClip in class VectorGraphics
Returns:
current clip

getClipBounds

public java.awt.Rectangle getClipBounds()
Gets the current clip in form of a Rectangle.

Specified by:
getClipBounds in class VectorGraphics
Returns:
current clip

getClipBounds

public java.awt.Rectangle getClipBounds(java.awt.Rectangle r)
Gets the current clip in form of a Rectangle.

Specified by:
getClipBounds in class VectorGraphics
Returns:
current clip

clipRect

public void clipRect(int x,
                     int y,
                     int width,
                     int height)
Clips rectangle. Calls clip(Rectangle).

Specified by:
clipRect in class VectorGraphics
Parameters:
x - rectangle for clipping
y - rectangle for clipping
width - rectangle for clipping
height - rectangle for clipping

clipRect

public void clipRect(double x,
                     double y,
                     double width,
                     double height)
Clips rectangle. Calls clip(Rectangle2D).

Specified by:
clipRect in class VectorGraphics
Parameters:
x - rectangle for clipping
y - rectangle for clipping
width - rectangle for clipping
height - rectangle for clipping

setClip

public void setClip(int x,
                    int y,
                    int width,
                    int height)
Clips rectangle. Calls clip(Rectangle).

Specified by:
setClip in class VectorGraphics
Parameters:
x - rectangle for clipping
y - rectangle for clipping
width - rectangle for clipping
height - rectangle for clipping

setClip

public void setClip(double x,
                    double y,
                    double width,
                    double height)
Clips rectangle. Calls clip(Rectangle2D).

Specified by:
setClip in class VectorGraphics
Parameters:
x - rectangle for clipping
y - rectangle for clipping
width - rectangle for clipping
height - rectangle for clipping

setClip

public void setClip(java.awt.Shape s)
Clips shape. Clears userClip and calls clip(Shape).

Specified by:
setClip in class VectorGraphics
Parameters:
s - used for clipping

clip

public void clip(java.awt.Shape s)
Clips using given shape. Dispatches to writeClip(Rectangle), writeClip(Rectangle2D) or writeClip(Shape).

Specified by:
clip in class VectorGraphics
Parameters:
s - used for clipping

writeClip

protected abstract void writeClip(java.awt.Shape shape)
                           throws java.io.IOException
Write out Shape clip.

Parameters:
shape - to be used for clipping
Throws:
java.io.IOException

writeSetClip

protected abstract void writeSetClip(java.awt.Shape shape)
                              throws java.io.IOException
Write out Shape clip.

Parameters:
shape - to be used for clipping
Throws:
java.io.IOException

getStroke

public java.awt.Stroke getStroke()
Get the current stroke.

Specified by:
getStroke in class VectorGraphics
Returns:
current stroke

setStroke

public void setStroke(java.awt.Stroke stroke)
Sets the current stroke. Calls writeStroke if stroke is unequal to the current stroke.

Specified by:
setStroke in class VectorGraphics
Parameters:
stroke - to be set

writeStroke

protected void writeStroke(java.awt.Stroke stroke)
                    throws java.io.IOException
Writes the current stroke. If stroke is an instance of BasicStroke it will call writeWidth, writeCap, writeJoin, writeMiterLimit and writeDash, if any were different than the current stroke.

Throws:
java.io.IOException

writeWidth

protected void writeWidth(float width)
                   throws java.io.IOException
Writes out the width of the stroke.

Parameters:
width - of the stroke
Throws:
java.io.IOException

writeCap

protected void writeCap(int cap)
                 throws java.io.IOException
Writes out the cap of the stroke.

Parameters:
cap - of the stroke
Throws:
java.io.IOException

writeJoin

protected void writeJoin(int join)
                  throws java.io.IOException
Writes out the join of the stroke.

Parameters:
join - of the stroke
Throws:
java.io.IOException

writeMiterLimit

protected void writeMiterLimit(float limit)
                        throws java.io.IOException
Writes out the miter limit of the stroke.

Parameters:
limit - miter limit of the stroke
Throws:
java.io.IOException

writeDash

protected void writeDash(float[] dash,
                         float phase)
                  throws java.io.IOException
Writes out the dash of the stroke.

Parameters:
dash - dash pattern, empty array is solid line
phase - of the dash pattern
Throws:
java.io.IOException

writeDash

protected void writeDash(double[] dash,
                         double phase)
                  throws java.io.IOException
Deprecated. use writeDash(float[], float)

Writes out the dash of the stroke.

Parameters:
dash - dash pattern, empty array is solid line
phase - of the dash pattern
Throws:
java.io.IOException

setColor

public void setColor(java.awt.Color color)
Description copied from class: AbstractVectorGraphics
Sets the current color and the current paint. Calls writePaint(Color).

Overrides:
setColor in class AbstractVectorGraphics
Parameters:
color - to be set

setPaint

public void setPaint(java.awt.Paint paint)
Sets the current paint. Dispatches to writePaint(Color), writePaint(GradientPaint), writePaint(TexturePaint paint) or writePaint(Paint). In the case paint is a Color the current color is also changed.

Overrides:
setPaint in class AbstractVectorGraphics
Parameters:
paint - to be set

writePaint

protected abstract void writePaint(java.awt.Color color)
                            throws java.io.IOException
Writes out paint as the given color.

Parameters:
color - to be written
Throws:
java.io.IOException

writePaint

protected abstract void writePaint(java.awt.GradientPaint paint)
                            throws java.io.IOException
Writes out paint as the given gradient.

Parameters:
paint - to be written
Throws:
java.io.IOException

writePaint

protected abstract void writePaint(java.awt.TexturePaint paint)
                            throws java.io.IOException
Writes out paint as the given texture.

Parameters:
paint - to be written
Throws:
java.io.IOException

writePaint

protected abstract void writePaint(java.awt.Paint paint)
                            throws java.io.IOException
Writes out paint.

Parameters:
paint - to be written
Throws:
java.io.IOException

getFontRenderContext

public java.awt.font.FontRenderContext getFontRenderContext()
Gets the current font render context. This returns an standard FontRenderContext with anti-aliasing and uses fractional metrics.

Specified by:
getFontRenderContext in class VectorGraphics
Returns:
current font render context

getFontMetrics

public java.awt.FontMetrics getFontMetrics(java.awt.Font font)
Deprecated. 

Gets the fontmetrics.

Specified by:
getFontMetrics in class VectorGraphics
Parameters:
font - to be used for retrieving fontmetrics
Returns:
fontmetrics for given font

getRenderingHints

public java.awt.RenderingHints getRenderingHints()
Gets a copy of the rendering hints.

Specified by:
getRenderingHints in class VectorGraphics
Returns:
clone of table of rendering hints.

addRenderingHints

public void addRenderingHints(java.util.Map hints)
Adds to table of rendering hints.

Specified by:
addRenderingHints in class VectorGraphics
Parameters:
hints - table to be added

setRenderingHints

public void setRenderingHints(java.util.Map hints)
Sets table of rendering hints.

Specified by:
setRenderingHints in class VectorGraphics
Parameters:
hints - table to be set

getRenderingHint

public java.lang.Object getRenderingHint(java.awt.RenderingHints.Key key)
Gets a given rendering hint.

Specified by:
getRenderingHint in class VectorGraphics
Parameters:
key - hint key
Returns:
hint associated to key

setRenderingHint

public void setRenderingHint(java.awt.RenderingHints.Key key,
                             java.lang.Object hint)
Sets a given rendering hint.

Specified by:
setRenderingHint in class VectorGraphics
Parameters:
key - hint key
hint - to be associated with key

setFont

public void setFont(java.awt.Font font)
Sets the current font.

Overrides:
setFont in class AbstractVectorGraphics
Parameters:
font - to be set

writeFont

protected abstract void writeFont(java.awt.Font font)
                           throws java.io.IOException
Writes the font

Parameters:
font - to be written
Throws:
java.io.IOException

getComposite

public java.awt.Composite getComposite()
Gets current composite.

Specified by:
getComposite in class VectorGraphics
Returns:
current composite

setComposite

public void setComposite(java.awt.Composite composite)
Sets current composite.

Specified by:
setComposite in class VectorGraphics
Parameters:
composite - to be set

handleException

protected void handleException(java.lang.Exception exception)
Handles an exception which has been caught. Dispatches exception to writeWarning for UnsupportedOperationExceptions and writeError for others

Parameters:
exception - to be handled

writeWarning

protected void writeWarning(java.lang.Exception exception)
Writes out a warning, by default to System.err.

Parameters:
exception - warning to be written

writeWarning

protected void writeWarning(java.lang.String warning)
Writes out a warning, by default to System.err.

Parameters:
warning - to be written

writeError

protected void writeError(java.lang.Exception exception)
Writes out an error, by default the stack trace is printed.

Parameters:
exception - error to be reported

createShape

protected java.awt.Shape createShape(double[] xPoints,
                                     double[] yPoints,
                                     int nPoints,
                                     boolean close)
Description copied from class: AbstractVectorGraphics
Creates a polyline/polygon shape from a set of points. Needs to be defined in subclass because its implementations could be device specific

Specified by:
createShape in class AbstractVectorGraphics
Parameters:
xPoints - X coordinates of the polyline.
yPoints - Y coordinates of the polyline.
nPoints - number of points of the polyline.
close - is shape closed

overLine

protected void overLine(java.lang.String text,
                        java.awt.Font font,
                        float x,
                        float y)
Draws an overline for the text at (x, y). The method is usesefull for drivers that do not support overlines by itself.

Parameters:
text - text for width calulation
font - font for width calulation
x - position of text
y - position of text


Copyright © 2000-2007 FreeHEP. All Rights Reserved.