org.freehep.graphicsio
Class ImageGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
org.freehep.graphics2d.VectorGraphics
org.freehep.graphics2d.AbstractVectorGraphics
org.freehep.graphics2d.PixelGraphics2D
org.freehep.graphicsio.ImageGraphics2D
- All Implemented Interfaces:
- VectorGraphicsConstants
- Direct Known Subclasses:
- GIFGraphics2D
public class ImageGraphics2D
- extends PixelGraphics2D
Generic class for generating bitmap outputs from an image.
- Version:
- $Id: ImageGraphics2D.java 10273 2007-01-09 19:01:32Z duns $
- Author:
- Mark Donszelmann
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 |
Method Summary |
static boolean |
canWriteTransparent(java.lang.String format)
|
static boolean |
canWriteUncompressed(java.lang.String format)
|
void |
closeStream()
|
java.awt.Graphics |
create()
|
java.awt.Graphics |
create(double x,
double y,
double width,
double height)
|
static java.awt.image.BufferedImage |
createBufferedImage(java.lang.String format,
int width,
int height)
creates an empty image |
void |
endExport()
|
static java.awt.image.BufferedImage |
generateThumbnail(java.awt.Component component,
java.awt.Dimension size)
|
static java.util.Properties |
getDefaultProperties(java.lang.String format)
|
static java.util.SortedSet |
getImageWriters(java.util.Iterator iterator)
|
static javax.imageio.ImageWriter |
getPreferredImageWriter(java.lang.String format)
|
static javax.imageio.ImageWriter |
getPreferredImageWriterForMIMEType(java.lang.String mimeType)
|
static org.freehep.util.UserProperties |
getRAWProperties(java.awt.Color bkg,
java.lang.String code)
|
protected void |
handleException(java.lang.Exception exception)
Handles an exception which has been caught. |
static java.awt.image.BufferedImage |
readImage(java.lang.String format,
java.io.InputStream is)
|
void |
setProperties(java.util.Properties newProperties)
|
void |
startExport()
|
static byte[] |
toByteArray(java.awt.image.RenderedImage image,
java.lang.String format,
java.lang.String encoding,
java.util.Properties props)
Converts a given image to byte[] |
protected void |
write()
|
static void |
writeImage(java.awt.Image image,
java.lang.String format,
java.util.Properties properties,
java.io.OutputStream os)
|
static void |
writeImage(java.awt.image.RenderedImage image,
java.lang.String format,
java.util.Properties properties,
java.io.OutputStream os)
|
Methods inherited from class org.freehep.graphics2d.PixelGraphics2D |
addRenderingHints, clearRect, clearRect, clip, clipRect, clipRect, copyArea, createShape, dispose, draw, drawArc, drawGlyphVector, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawImage, drawLine, drawOval, drawPolygon, drawPolygon, drawPolyline, drawRect, drawRenderableImage, drawRenderedImage, drawString, drawString, drawString, drawString, drawString, drawSymbol, fill, fillAndDrawSymbol, fillArc, fillOval, fillPolygon, fillPolygon, fillRect, fillSymbol, getClip, getClipBounds, getClipBounds, getComposite, getDeviceConfiguration, getFontMetrics, getFontRenderContext, getRenderingHint, getRenderingHints, getStroke, getTransform, hit, isDisplayLocal, isDisplayX11, printComment, rotate, rotate, scale, setBackground, setClip, setClip, setClip, setColor, setComposite, setFont, setHostGraphics, setLineWidth, setPaint, setPaintMode, setRenderingHint, setRenderingHints, setStroke, setTransform, setXORMode, shear, toString, transform, translate, translate |
Methods inherited from class org.freehep.graphics2d.AbstractVectorGraphics |
createShape, drawArc, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawRoundRect, drawString, drawString, drawString, drawString, drawString, drawSymbol, drawSymbol, fillAndDraw, fillAndDrawSymbol, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, fillRoundRect, fillSymbol, fillSymbol, getBackground, getColor, getColorMode, getCreator, getFont, getPaint, getPrintColor, getProperties, getProperty, getPropertyColor, getPropertyDimension, getPropertyDouble, getPropertyInsets, getPropertyInt, getPropertyRectangle, initProperties, isDeviceIndependent, isProperty, setColorMode, setCreator, setDeviceIndependent, setLineWidth |
Methods inherited from class java.awt.Graphics2D |
draw3DRect, fill3DRect |
Methods inherited from class java.awt.Graphics |
drawBytes, drawChars, finalize, getClipRect, getFontMetrics, hitClip |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
rootKey
public static final java.lang.String rootKey
- See Also:
- Constant Field Values
TRANSPARENT
public static final java.lang.String TRANSPARENT
- See Also:
- Constant Field Values
BACKGROUND
public static final java.lang.String BACKGROUND
- See Also:
- Constant Field Values
BACKGROUND_COLOR
public static final java.lang.String BACKGROUND_COLOR
- See Also:
- Constant Field Values
ANTIALIAS
public static final java.lang.String ANTIALIAS
- See Also:
- Constant Field Values
ANTIALIAS_TEXT
public static final java.lang.String ANTIALIAS_TEXT
- See Also:
- Constant Field Values
PROGRESSIVE
public static final java.lang.String PROGRESSIVE
- See Also:
- Constant Field Values
COMPRESS
public static final java.lang.String COMPRESS
- See Also:
- Constant Field Values
COMPRESS_MODE
public static final java.lang.String COMPRESS_MODE
- See Also:
- Constant Field Values
COMPRESS_DESCRIPTION
public static final java.lang.String COMPRESS_DESCRIPTION
- See Also:
- Constant Field Values
COMPRESS_QUALITY
public static final java.lang.String COMPRESS_QUALITY
- See Also:
- Constant Field Values
os
protected java.io.OutputStream os
image
protected java.awt.image.BufferedImage image
format
protected java.lang.String format
component
protected java.awt.Component component
ImageGraphics2D
public ImageGraphics2D(java.io.File file,
java.awt.Dimension size,
java.lang.String format)
throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
ImageGraphics2D
public ImageGraphics2D(java.io.File file,
java.awt.Component component,
java.lang.String format)
throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
ImageGraphics2D
public ImageGraphics2D(java.io.OutputStream os,
java.awt.Dimension size,
java.lang.String format)
ImageGraphics2D
public ImageGraphics2D(java.io.OutputStream os,
java.awt.Component component,
java.lang.String format)
ImageGraphics2D
protected ImageGraphics2D(ImageGraphics2D graphics)
getDefaultProperties
public static java.util.Properties getDefaultProperties(java.lang.String format)
setProperties
public void setProperties(java.util.Properties newProperties)
- Overrides:
setProperties
in class AbstractVectorGraphics
create
public java.awt.Graphics create()
- Overrides:
create
in class PixelGraphics2D
create
public java.awt.Graphics create(double x,
double y,
double width,
double height)
- Overrides:
create
in class PixelGraphics2D
startExport
public void startExport()
- Overrides:
startExport
in class PixelGraphics2D
endExport
public void endExport()
- Overrides:
endExport
in class PixelGraphics2D
write
protected void write()
throws java.io.IOException
- Throws:
java.io.IOException
closeStream
public void closeStream()
throws java.io.IOException
- Throws:
java.io.IOException
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
createBufferedImage
public static java.awt.image.BufferedImage createBufferedImage(java.lang.String format,
int width,
int height)
- creates an empty image
- Parameters:
format
- e.g. ImageConstants.BMP
or {ImageConstants#PNG}width
- image widthheight
- image height
- Returns:
- offscreen buffered image
generateThumbnail
public static java.awt.image.BufferedImage generateThumbnail(java.awt.Component component,
java.awt.Dimension size)
writeImage
public static void writeImage(java.awt.Image image,
java.lang.String format,
java.util.Properties properties,
java.io.OutputStream os)
throws java.io.IOException
- Throws:
java.io.IOException
writeImage
public static void writeImage(java.awt.image.RenderedImage image,
java.lang.String format,
java.util.Properties properties,
java.io.OutputStream os)
throws java.io.IOException
- Throws:
java.io.IOException
getPreferredImageWriter
public static javax.imageio.ImageWriter getPreferredImageWriter(java.lang.String format)
getPreferredImageWriterForMIMEType
public static javax.imageio.ImageWriter getPreferredImageWriterForMIMEType(java.lang.String mimeType)
getImageWriters
public static java.util.SortedSet getImageWriters(java.util.Iterator iterator)
readImage
public static java.awt.image.BufferedImage readImage(java.lang.String format,
java.io.InputStream is)
throws java.io.IOException
- Throws:
java.io.IOException
canWriteUncompressed
public static boolean canWriteUncompressed(java.lang.String format)
canWriteTransparent
public static boolean canWriteTransparent(java.lang.String format)
getRAWProperties
public static org.freehep.util.UserProperties getRAWProperties(java.awt.Color bkg,
java.lang.String code)
- Parameters:
bkg
- Background color for the imagecode
- Color encoding, e.g. ImageConstants.COLOR_MODEL_RGB
- Returns:
- Properties used to create a RAW image
toByteArray
public static byte[] toByteArray(java.awt.image.RenderedImage image,
java.lang.String format,
java.lang.String encoding,
java.util.Properties props)
throws java.io.IOException
- Converts a given image to byte[]
- Parameters:
image
- Image to convertformat
- e.g. ImageConstants.JPG
, ImageConstants#PNG, {@link ImageConstants#RAW}props
- Properties for writing, e.g. RawImageWriteParam.BACKGROUND
encoding
- ImageConstants.ENCODING_ASCII85
, ImageConstants.ENCODING_FLATE
or null
- Returns:
- bytes representing the image
- Throws:
java.io.IOException
- thrown by writeImage(java.awt.image.RenderedImage, String, java.util.Properties, java.io.OutputStream)
Copyright © 2000-2007 FreeHEP. All Rights Reserved.