FreeHEP API
Version current

org.freehep.graphicsio
Class AbstractVectorGraphicsIO

java.lang.Object
  extended byjava.awt.Graphics
      extended byjava.awt.Graphics2D
          extended byorg.freehep.graphics2d.VectorGraphics
              extended byorg.freehep.graphics2d.AbstractVectorGraphics
                  extended byorg.freehep.graphicsio.VectorGraphicsIO
                      extended byorg.freehep.graphicsio.AbstractVectorGraphicsIO
All Implemented Interfaces:
VectorGraphicsConstants
Direct Known Subclasses:
CGMGraphics2D, DummyGraphics2D, EMFGraphics2D, LatexGraphics2D, 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,v 1.20 2005/08/27 19:44:16 duns Exp $
Author:
Charles Loomis, Mark Donszelmann
Source Code:
AbstractVectorGraphicsIO.java

Field Summary
static String EMIT_ERRORS
           
static String EMIT_WARNINGS
           
 
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(Component component, boolean doRestoreOnDispose)
          Constructs a Graphics context with the following graphics state: Paint: The color of the component.
protected AbstractVectorGraphicsIO(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(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(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  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(GlyphVector g, float x, float y)
           
 void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
           
 boolean drawImage(Image image, AffineTransform xform, ImageObserver observer)
           
 boolean drawImage(Image image, int x, int y, Color bgColor, ImageObserver observer)
           
 boolean drawImage(Image image, int x, int y, ImageObserver observer)
           
 boolean drawImage(Image image, int x, int y, int width, int height, Color bgColor, ImageObserver observer)
           
 boolean drawImage(Image image, int x, int y, int width, int height, ImageObserver observer)
           
 boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgColor, ImageObserver observer)
          Draw and resizes (transparent) image.
 boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
           
 void drawRenderableImage(RenderableImage image, AffineTransform xform)
           
 void drawRenderedImage(RenderedImage image, AffineTransform xform)
          Draws a rendered image using a transform.
 void drawString(AttributedCharacterIterator iterator, float x, float y)
           
 void drawString(String string, double x, double y)
          Draws a string.
 void drawString(String str, double x, double y, int horizontal, int vertical, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor)
          Draws a string with a lot of parameters.
 void drawString(TagString str, double x, double y, int horizontal, int vertical, boolean framed, Color frameColor, double frameWidth, boolean banner, Color bannerColor)
          Draws a TagString with a lot of parameters.
 void endExport()
           
 Shape getClip()
          Gets the current clip in form of a Shape (Rectangle).
 Rectangle getClipBounds()
          Gets the current clip in form of a Rectangle.
 Rectangle getClipBounds(Rectangle r)
          Gets the current clip in form of a Rectangle.
 Component getComponent()
           
 Composite getComposite()
          Gets current composite.
 FontMetrics getFontMetrics(Font font)
          Gets the fontmetrics.
 FontRenderContext getFontRenderContext()
          Gets the current font render context.
 Object getRenderingHint(RenderingHints.Key key)
          Gets a given rendering hint.
 RenderingHints getRenderingHints()
          Gets a copy of the rendering hints.
 Dimension getSize()
           
 Stroke getStroke()
          Get the current stroke.
 AffineTransform getTransform()
          Get the current transform.
protected  void handleException(Exception exception)
          Handles an exception which has been caught.
 void printComment(String comment)
           
protected  void resetClip(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(Shape shape)
          Clips shape.
 void setColor(Color color)
          Sets the current color and the current paint.
 void setComposite(Composite composite)
          Sets current composite.
 void setPaint(Paint paint)
          Sets the current paint.
 void setRenderingHint(RenderingHints.Key key, Object hint)
          Sets a given rendering hint.
 void setRenderingHints(Map hints)
          Sets table of rendering hints.
 void setStroke(Stroke stroke)
          Sets the current stroke.
 void setTransform(AffineTransform transform)
          Set the current transform.
 void shear(double shx, double shy)
          Shears the current transform.
 void startExport()
           
 void transform(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  void writeClip(Rectangle rectangle)
          Write out Rectangle clip.
protected abstract  void writeClip(Rectangle2D rectangle)
          Write out Rectangle2D clip.
protected abstract  void writeClip(Shape shape)
          Write out Shape clip.
abstract  void writeComment(String comment)
          Called to Write out a comment.
protected  void writeDash(double[] dash, double phase)
          Writes out the dash of the stroke.
protected  void writeError(Exception exception)
          Writes out an error, by default the stack trace is printed.
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(RenderedImage image, AffineTransform xform, 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(Color color)
          Writes out paint as the given color.
protected abstract  void writePaint(GradientPaint paint)
          Writes out paint as the given gradient.
protected abstract  void writePaint(Paint paint)
          Writes out paint.
protected abstract  void writePaint(TexturePaint paint)
          Writes out paint as the given texture.
protected  void writeSetClip(Shape shape)
          Called to set a clip, no intersection made.
protected abstract  void writeString(String string, double x, double y)
           
protected  void writeStroke(Stroke stroke)
          Writes the current stroke.
abstract  void writeTrailer()
          Called to write the trailing part of the output.
protected abstract  void writeTransform(AffineTransform transform)
          Writes out the transform as it needs to be concatenated to the internal transform of the output format.
protected  void writeWarning(Exception exception)
          Writes out a warning, by default to System.err.
protected  void writeWarning(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, 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, initProperties, isDeviceIndependent, isProperty, rotate, setBackground, setColorMode, setCreator, setDeviceIndependent, setFont, setLineWidth, setLineWidth, setProperties, translate
 
Methods inherited from class org.freehep.graphics2d.VectorGraphics
copyArea, create, create, create, create, draw, fill, getDeviceConfiguration, getSymbol, getTextAlignment, getXalignment, getYalignment, hit, 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 String EMIT_WARNINGS

EMIT_ERRORS

public static final String EMIT_ERRORS
Constructor Detail

AbstractVectorGraphicsIO

protected AbstractVectorGraphicsIO(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(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 Dimension getSize()
Specified by:
getSize in class VectorGraphicsIO

getComponent

public 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 IOException
Called to write the header part of the output.

Throws:
IOException

writeGraphicsState

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

Throws:
IOException

writeBackground

public abstract void writeBackground()
                              throws IOException
Throws:
IOException

writeTrailer

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

Throws:
IOException

closeStream

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

Throws:
IOException

printComment

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

writeComment

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

Parameters:
comment - to be written
Throws:
IOException

resetClip

protected void resetClip(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 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:
IOException

writeGraphicsRestore

protected abstract void writeGraphicsRestore()
                                      throws 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:
IOException

drawImage

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

drawImage

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

drawImage

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

drawImage

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

drawImage

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

drawImage

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

drawImage

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

drawRenderableImage

public void drawRenderableImage(RenderableImage image,
                                AffineTransform xform)
Specified by:
drawRenderableImage in class VectorGraphics

drawImage

public boolean drawImage(Image image,
                         int dx1,
                         int dy1,
                         int dx2,
                         int dy2,
                         int sx1,
                         int sy1,
                         int sx2,
                         int sy2,
                         Color bgColor,
                         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(RenderedImage image,
                              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(RenderedImage image,
                                   AffineTransform xform,
                                   Color bkg)
                            throws IOException
Throws:
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(String string,
                       double x,
                       double y)
Description copied from class: VectorGraphics
Draws a string.

Specified by:
drawString in class VectorGraphics

drawString

public void drawString(String str,
                       double x,
                       double y,
                       int horizontal,
                       int vertical,
                       boolean framed,
                       Color frameColor,
                       double frameWidth,
                       boolean banner,
                       Color bannerColor)
Description copied from class: VectorGraphics
Draws a string with a lot of parameters.

Specified by:
drawString in class VectorGraphics
Parameters:
str - text to be drawn
x - coordinate to draw string
y - coordinate to draw string
horizontal - alignment of the text
vertical - alignment of the text
framed - true if text is surrounded by a frame
frameColor - color of the frame
frameWidth - witdh of the frame
banner - true if the frame is filled by a banner
bannerColor - color of the banner

drawString

public void drawString(TagString str,
                       double x,
                       double y,
                       int horizontal,
                       int vertical,
                       boolean framed,
                       Color frameColor,
                       double frameWidth,
                       boolean banner,
                       Color bannerColor)
Description copied from class: VectorGraphics
Draws a TagString with a lot of parameters.

Specified by:
drawString in class VectorGraphics
Parameters:
str - Tagged text to be drawn
x - coordinate to draw string
y - coordinate to draw string
horizontal - alignment of the text
vertical - alignment of the text
framed - true if text is surrounded by a frame
frameColor - color of the frame
frameWidth - witdh of the frame
banner - true if the frame is filled by a banner
bannerColor - color of the banner

writeString

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

drawGlyphVector

public void drawGlyphVector(GlyphVector g,
                            float x,
                            float y)
Specified by:
drawGlyphVector in class VectorGraphics

drawString

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

getTransform

public AffineTransform getTransform()
Get the current transform.

Specified by:
getTransform in class VectorGraphics
Returns:
current transform

setTransform

public void setTransform(AffineTransform transform)
Set the current transform. Since most output formats do not implement this functionality, the inverse transform of the currentTransform is calculated and multiplied by the transform to be set. The result is then forwarded by a call to writeTransform(Transform).

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

transform

public void transform(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(AffineTransform transform)
                                throws 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:
IOException

getClip

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

Specified by:
getClip in class VectorGraphics
Returns:
current clip

getClipBounds

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

Specified by:
getClipBounds in class VectorGraphics
Returns:
current clip

getClipBounds

public Rectangle getClipBounds(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(Shape shape)
Clips shape. Sets the userClip to shape and calls clip(Shape).

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

writeSetClip

protected void writeSetClip(Shape shape)
                     throws IOException
Called to set a clip, no intersection made. Calls clip(shape).

Throws:
IOException

clip

public void clip(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 void writeClip(Rectangle rectangle)
                  throws IOException
Write out Rectangle clip. Calls writeClip(Rectangle2D).

Parameters:
rectangle - to be used for clipping
Throws:
IOException

writeClip

protected abstract void writeClip(Rectangle2D rectangle)
                           throws IOException
Write out Rectangle2D clip.

Parameters:
rectangle - to be used for clipping
Throws:
IOException

writeClip

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

Parameters:
shape - to be used for clipping
Throws:
IOException

getStroke

public Stroke getStroke()
Get the current stroke.

Specified by:
getStroke in class VectorGraphics
Returns:
current stroke

setStroke

public void setStroke(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(Stroke stroke)
                    throws 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:
IOException

writeWidth

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

Parameters:
width - of the stroke
Throws:
IOException

writeCap

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

Parameters:
cap - of the stroke
Throws:
IOException

writeJoin

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

Parameters:
join - of the stroke
Throws:
IOException

writeMiterLimit

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

Parameters:
limit - miter limit of the stroke
Throws:
IOException

writeDash

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

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

setColor

public void setColor(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(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
Returns:
current paint

writePaint

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

Parameters:
color - to be written
Throws:
IOException

writePaint

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

Parameters:
paint - to be written
Throws:
IOException

writePaint

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

Parameters:
paint - to be written
Throws:
IOException

writePaint

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

Parameters:
paint - to be written
Throws:
IOException

getFontRenderContext

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

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

getFontMetrics

public FontMetrics getFontMetrics(Font font)
Gets the fontmetrics.

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

getRenderingHints

public 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(Map hints)
Adds to table of rendering hints.

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

setRenderingHints

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

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

getRenderingHint

public Object getRenderingHint(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(RenderingHints.Key key,
                             Object hint)
Sets a given rendering hint.

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

getComposite

public Composite getComposite()
Gets current composite.

Specified by:
getComposite in class VectorGraphics
Returns:
current composite

setComposite

public void setComposite(Composite composite)
Sets current composite.

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

handleException

protected void handleException(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(Exception exception)
Writes out a warning, by default to System.err.

Parameters:
exception - warning to be written

writeWarning

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

Parameters:
warning - to be written

writeError

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

Parameters:
exception - error to be reported

createShape

protected 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

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.