com.aspose.metafiles
Class Metafile

java.lang.Object
  extended by com.aspose.metafiles.Metafile
All Implemented Interfaces:
java.awt.image.renderable.RenderableImage
Direct Known Subclasses:
EmfMetafile, WmfMetafile

public abstract class Metafile
extends java.lang.Object
implements java.awt.image.renderable.RenderableImage

Base class for both EMF and WMF metafile types.


Field Summary
 
Fields inherited from interface java.awt.image.renderable.RenderableImage
HINTS_OBSERVED
 
Method Summary
 java.awt.image.RenderedImage createDefaultRendering()
          Creates a RenderedImage with default size unless it exceeds MinPixelCount..MaxPixelCount range.
 java.awt.image.RenderedImage createScaledRendering(int w, int h, java.awt.RenderingHints hints)
          Creates a RenderedImage with the specified width and height.
abstract  java.awt.Rectangle getBounds()
          Returns the metafile's bounds.
abstract  MetafileComment[] getComments()
           
 java.awt.RenderingHints getDefaultRenderingHints()
          Returns metafile's default RenderingHints.
 EmbeddedBitmap[] getEmbeddedBitmaps()
          Returns an array containing copies of binary data of all embedded bitmaps.
 float getHeight()
          Returns the height of a metafile.
 int getMaxPixelCount()
          Returns a maximum number of pixels in the image, created by createDefaultRendering() method.
 int getMinPixelCount()
          Returns a minimum number of pixels in the image created by createDefaultRendering() method.
 float getMinX()
          Returns the minimum X coordinate of a metafile.
 float getMinY()
          Returns the minimum Y coordinate of a metafile.
 java.lang.Object getProperty(java.lang.String name)
          Required by RenderableImage interface.
 java.lang.String[] getPropertyNames()
          Required by RenderableImage interface.
 java.util.Vector getSources()
          Required by RenderableImage interface.
 TextOutOperation[] getTextOutOperations()
          Returns all TextOut Operations of a metafile.
 java.lang.String[] getTextStrings()
          Returns all strings from a metafile.
 float getWidth()
          Returns the width of a metafile.
 boolean isDynamic()
          Required by RenderableImage interface.
static Metafile LoadMetafile(java.io.InputStream stream)
          Reads a metafile from a stream.
static Metafile LoadMetafile(java.lang.String fileName)
          Reads a metafile from a file.
abstract  void playMetafile(java.awt.Graphics2D target)
          Plays a metafile without transform to the specified Graphics2D object.
abstract  void playMetafile(java.awt.Graphics2D target, java.awt.geom.AffineTransform trans)
          Plays a metafile to the specified Graphics2D object.
 void setDefaultRenderingHints(java.awt.RenderingHints rh)
          Replaces current metafile's default RenderingHints.
 void setMaxPixelCount(int value)
          Sets a maximum number of pixels in the image, created by createDefaultRendering() method.
 void setMinPixelCount(int value)
          Sets a minimum number of pixels in the image, created by createDefaultRendering() method.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.image.renderable.RenderableImage
createRendering
 

Method Detail

LoadMetafile

public static Metafile LoadMetafile(java.lang.String fileName)
                             throws MetafilesException,
                                    java.io.FileNotFoundException
Reads a metafile from a file.

Parameters:
fileName - - name of file to read
Returns:
Metafile object.
Throws:
MetafilesException
java.io.FileNotFoundException

LoadMetafile

public static Metafile LoadMetafile(java.io.InputStream stream)
                             throws MetafilesException
Reads a metafile from a stream.

Parameters:
stream - - stream to read
Returns:
Metafile object.
Throws:
MetafilesException

getBounds

public abstract java.awt.Rectangle getBounds()
Returns the metafile's bounds.
Note: this rectangle is not an image size. To get image size and position use getMinX(), getMinY(), getWidth() and getHeight().

Returns:
metafile's bounds.

playMetafile

public abstract void playMetafile(java.awt.Graphics2D target)
                           throws MetafilesException
Plays a metafile without transform to the specified Graphics2D object.

Parameters:
target - - Graphics2D object.
Throws:
MetafilesException

playMetafile

public abstract void playMetafile(java.awt.Graphics2D target,
                                  java.awt.geom.AffineTransform trans)
                           throws MetafilesException
Plays a metafile to the specified Graphics2D object.

Parameters:
target - - Graphics2D object.
trans - - coordinates transformation from metafile's coordinates to Graphics2D user space.
Throws:
MetafilesException

getSources

public java.util.Vector getSources()
Required by RenderableImage interface. Always returns null.

Specified by:
getSources in interface java.awt.image.renderable.RenderableImage

getMinX

public float getMinX()
Returns the minimum X coordinate of a metafile.

Specified by:
getMinX in interface java.awt.image.renderable.RenderableImage

getMinY

public float getMinY()
Returns the minimum Y coordinate of a metafile.

Specified by:
getMinY in interface java.awt.image.renderable.RenderableImage

getWidth

public float getWidth()
Returns the width of a metafile.

Specified by:
getWidth in interface java.awt.image.renderable.RenderableImage

getHeight

public float getHeight()
Returns the height of a metafile.

Specified by:
getHeight in interface java.awt.image.renderable.RenderableImage

isDynamic

public boolean isDynamic()
Required by RenderableImage interface. Always returns false.

Specified by:
isDynamic in interface java.awt.image.renderable.RenderableImage

getPropertyNames

public java.lang.String[] getPropertyNames()
Required by RenderableImage interface. Returns an empty array.

Specified by:
getPropertyNames in interface java.awt.image.renderable.RenderableImage

getProperty

public java.lang.Object getProperty(java.lang.String name)
Required by RenderableImage interface. Returns java.awt.Image.UndefinedProperty.

Specified by:
getProperty in interface java.awt.image.renderable.RenderableImage

createScaledRendering

public java.awt.image.RenderedImage createScaledRendering(int w,
                                                          int h,
                                                          java.awt.RenderingHints hints)
Creates a RenderedImage with the specified width and height.

Specified by:
createScaledRendering in interface java.awt.image.renderable.RenderableImage
Parameters:
w - - image width.
h - - image height.
hints - - RenderingHits used to draw and scale metafile.

createDefaultRendering

public java.awt.image.RenderedImage createDefaultRendering()
Creates a RenderedImage with default size unless it exceeds MinPixelCount..MaxPixelCount range. Unlike the other create*Rendering() functions, produced image's left and top coordinates are zeroes.

Specified by:
createDefaultRendering in interface java.awt.image.renderable.RenderableImage

setDefaultRenderingHints

public void setDefaultRenderingHints(java.awt.RenderingHints rh)
Replaces current metafile's default RenderingHints.

Note: default rendering hints used only by createRendering(), createDefaultRendering(), createScaledRendering() and methods, which use them. For example Graphics2D.DrawRenderableImage().

PlayMetafile() method uses RenderingHints of the specified Graphics2D object. When another RenderingHints object passed to createScaledRendering() or createRendering() via RenderContext object, function merges it with default RenderingHints. Caller's RenderingHints overrides metafile's default.

Parameters:
rh - - new default RenderingHints.

getDefaultRenderingHints

public java.awt.RenderingHints getDefaultRenderingHints()
Returns metafile's default RenderingHints.


getTextOutOperations

public TextOutOperation[] getTextOutOperations()
                                        throws MetafilesException
Returns all TextOut Operations of a metafile.

Throws:
MetafilesException

getTextStrings

public java.lang.String[] getTextStrings()
                                  throws MetafilesException
Returns all strings from a metafile.

Throws:
MetafilesException

getMinPixelCount

public int getMinPixelCount()
Returns a minimum number of pixels in the image created by createDefaultRendering() method. Image will be scaled in case it has smaller size. Default value is 0.


setMinPixelCount

public void setMinPixelCount(int value)
Sets a minimum number of pixels in the image, created by createDefaultRendering() method. Image will be scaled in case it has smaller size. Default value is 0.


getMaxPixelCount

public int getMaxPixelCount()
Returns a maximum number of pixels in the image, created by createDefaultRendering() method. Image will be scaled in case it has too large size. Default value is 10000000.


setMaxPixelCount

public void setMaxPixelCount(int value)
Sets a maximum number of pixels in the image, created by createDefaultRendering() method. Image will be scaled in case it has too large size. Default value is 10000000.


getComments

public abstract MetafileComment[] getComments()

getEmbeddedBitmaps

public EmbeddedBitmap[] getEmbeddedBitmaps()
Returns an array containing copies of binary data of all embedded bitmaps.