org.jfree.pixie.wmf
Class WmfFile

java.lang.Object
  extended by org.jfree.pixie.wmf.WmfFile
All Implemented Interfaces:
org.jfree.ui.Drawable, org.jfree.ui.ExtendedDrawable

public class WmfFile
extends java.lang.Object
implements org.jfree.ui.ExtendedDrawable

Parses and replays the WmfFile.


Field Summary
static int QUALITY_MAYBE
           
static int QUALITY_NO
           
static int QUALITY_YES
           
 
Constructor Summary
WmfFile(java.io.InputStream in, int imageX, int imageY)
          Initialize metafile for reading from filename.
WmfFile(java.lang.String input)
           
WmfFile(java.lang.String inName, int imageX, int imageY)
          Initialize metafile for reading from filename.
WmfFile(java.net.URL input)
           
WmfFile(java.net.URL input, int imageX, int imageY)
           
 
Method Summary
 void assertValid()
          Check class invariant.
 void deleteObject(int slot)
           
 void draw(java.awt.Graphics2D graphics, java.awt.geom.Rectangle2D bounds)
           
protected  int findFreeSlot()
          Return the next free slot from the objects table.
 MfLogBrush getBrushObject(int slot)
           
 MfDcState getCurrentState()
           
 java.awt.Graphics2D getGraphics2D()
           
 MfHeader getHeader()
          Return Placeable and Windows headers that were read earlier.
 java.awt.Dimension getImageSize()
           
 WmfObject getObject(int slot)
           
 MfPalette getPalette()
           
 MfLogPen getPenObject(int slot)
           
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the drawable.
 MfLogRegion getRegionObject(int slot)
           
 int getStateCount()
           
static int isMetafile(java.lang.String inName, java.io.InputStream in)
          Return true if the input is a metafile
 boolean isPreserveAspectRatio()
          Returns true, if this drawable will preserve an aspect ratio during the drawing.
static void main(java.lang.String[] args)
           
protected  void parseRecords()
          Read and interpret the body of the metafile.
 MfHeader readHeader()
          Read Placeable and Windows headers.
 MfRecord readNextRecord()
          Fetch a record.
 java.awt.image.BufferedImage replay()
           
 java.awt.image.BufferedImage replay(int imageX, int imageY)
           
 void resetStates()
           
 void restoreDCState(int stateCount)
          Restores a state.
 void saveDCState()
           
 void scalePercent(float percent)
          Scale the image to a certain percentage.
 void scalePercent(float percentX, float percentY)
          Scale the width and height of an image to a certain percentage.
 void scaleToFit(float fitWidth, float fitHeight)
           
 void storeObject(WmfObject o)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUALITY_NO

public static final int QUALITY_NO
See Also:
Constant Field Values

QUALITY_MAYBE

public static final int QUALITY_MAYBE
See Also:
Constant Field Values

QUALITY_YES

public static final int QUALITY_YES
See Also:
Constant Field Values
Constructor Detail

WmfFile

public WmfFile(java.net.URL input)
        throws java.io.IOException
Throws:
java.io.IOException

WmfFile

public WmfFile(java.lang.String input)
        throws java.io.IOException
Throws:
java.io.IOException

WmfFile

public WmfFile(java.net.URL input,
               int imageX,
               int imageY)
        throws java.io.IOException
Throws:
java.io.IOException

WmfFile

public WmfFile(java.lang.String inName,
               int imageX,
               int imageY)
        throws java.io.FileNotFoundException,
               java.io.IOException
Initialize metafile for reading from filename.

Throws:
java.io.FileNotFoundException
java.io.IOException

WmfFile

public WmfFile(java.io.InputStream in,
               int imageX,
               int imageY)
        throws java.io.FileNotFoundException,
               java.io.IOException
Initialize metafile for reading from filename.

Throws:
java.io.FileNotFoundException
java.io.IOException
Method Detail

getImageSize

public java.awt.Dimension getImageSize()

resetStates

public void resetStates()

getPalette

public MfPalette getPalette()

isMetafile

public static int isMetafile(java.lang.String inName,
                             java.io.InputStream in)
Return true if the input is a metafile


getHeader

public MfHeader getHeader()
Return Placeable and Windows headers that were read earlier.


getGraphics2D

public java.awt.Graphics2D getGraphics2D()

assertValid

public void assertValid()
Check class invariant.


readHeader

public MfHeader readHeader()
                    throws java.io.IOException
Read Placeable and Windows headers.

Throws:
java.io.IOException

readNextRecord

public MfRecord readNextRecord()
                        throws java.io.IOException
Fetch a record.

Throws:
java.io.IOException

parseRecords

protected void parseRecords()
                     throws java.io.IOException
Read and interpret the body of the metafile.

Throws:
java.io.IOException

scaleToFit

public void scaleToFit(float fitWidth,
                       float fitHeight)


scalePercent

public void scalePercent(float percent)
Scale the image to a certain percentage.

Parameters:
percent - the scaling percentage

scalePercent

public void scalePercent(float percentX,
                         float percentY)
Scale the width and height of an image to a certain percentage.

Parameters:
percentX - the scaling percentage of the width
percentY - the scaling percentage of the height

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getCurrentState

public MfDcState getCurrentState()

saveDCState

public void saveDCState()

getStateCount

public int getStateCount()

restoreDCState

public void restoreDCState(int stateCount)
Restores a state. The stateCount specifies the number of states to discard to find the correct one.

Parameters:
stateCount - the state count.

findFreeSlot

protected int findFreeSlot()
Return the next free slot from the objects table.


storeObject

public void storeObject(WmfObject o)

deleteObject

public void deleteObject(int slot)

getObject

public WmfObject getObject(int slot)

getBrushObject

public MfLogBrush getBrushObject(int slot)

getPenObject

public MfLogPen getPenObject(int slot)

getRegionObject

public MfLogRegion getRegionObject(int slot)

replay

public java.awt.image.BufferedImage replay()

replay

public java.awt.image.BufferedImage replay(int imageX,
                                           int imageY)

draw

public void draw(java.awt.Graphics2D graphics,
                 java.awt.geom.Rectangle2D bounds)
Specified by:
draw in interface org.jfree.ui.Drawable

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the drawable. If the drawable is aspect ratio aware, these bounds should be used to compute the preferred aspect ratio for this drawable.

Specified by:
getPreferredSize in interface org.jfree.ui.ExtendedDrawable
Returns:
the preferred size.

isPreserveAspectRatio

public boolean isPreserveAspectRatio()
Returns true, if this drawable will preserve an aspect ratio during the drawing.

Specified by:
isPreserveAspectRatio in interface org.jfree.ui.ExtendedDrawable
Returns:
true, if an aspect ratio is preserved, false otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object