Class WmfFile
- java.lang.Object
-
- org.pentaho.reporting.libraries.pixie.wmf.WmfFile
-
public class WmfFile extends Object
Parses and replays the WmfFile.
-
-
Field Summary
Fields Modifier and Type Field Description static int
QUALITY_MAYBE
static int
QUALITY_NO
static int
QUALITY_YES
-
Constructor Summary
Constructors Constructor Description WmfFile(InputStream in, int imageWidth, int imageHeight)
Initialize metafile for reading from the given input stream.WmfFile(String input)
Initialize metafile for reading from file.WmfFile(String inName, int imageWidth, int imageHeight)
Initialize metafile for reading from filename.WmfFile(URL input)
Initialize metafile for reading from an URL.WmfFile(URL input, int imageWidth, int imageHeight)
Initialize metafile for reading from an URL.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deleteObject(int slot)
void
draw(Graphics2D graphics, Rectangle2D bounds)
protected int
findFreeSlot()
Return the next free slot from the objects table.MfLogBrush
getBrushObject(int slot)
MfDcState
getCurrentState()
Graphics2D
getGraphics2D()
MfHeader
getHeader()
Return Placeable and Windows headers that were read earlier.Dimension
getImageSize()
WmfObject
getObject(int slot)
MfPalette
getPalette()
MfLogPen
getPenObject(int slot)
Dimension
getPreferredSize()
Returns the preferred size of the drawable.MfLogRegion
getRegionObject(int slot)
int
getStateCount()
boolean
isPreserveAspectRatio()
Returns true, if this drawable will preserve an aspect ratio during the drawing.static void
main(String[] args)
BufferedImage
replay()
BufferedImage
replay(int imageX, int imageY)
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)
Scales the WMF-image to the given width and height while preserving the aspect ration.void
storeObject(WmfObject o)
String
toString()
-
-
-
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(URL input) throws IOException
Initialize metafile for reading from an URL. Width and height will be computed automatically.- Parameters:
input
- the URL from where to read.- Throws:
IOException
- if any other error occured.
-
WmfFile
public WmfFile(String input) throws IOException
Initialize metafile for reading from file. Width and height will be computed automatically.- Parameters:
input
- the name of the file from where to read.- Throws:
IOException
- if any other error occured.
-
WmfFile
public WmfFile(URL input, int imageWidth, int imageHeight) throws IOException
Initialize metafile for reading from an URL.- Parameters:
imageWidth
- the target width of the image or -1 for automatic mode.imageHeight
- the target height of the image or -1 for automatic mode.input
- the URL from where to read.- Throws:
IOException
- if any other error occured.
-
WmfFile
public WmfFile(String inName, int imageWidth, int imageHeight) throws FileNotFoundException, IOException
Initialize metafile for reading from filename.- Parameters:
imageWidth
- the target width of the image or -1 for automatic mode.imageHeight
- the target height of the image or -1 for automatic mode.inName
- the file name from where to read.- Throws:
FileNotFoundException
- if the file was not found.IOException
- if any other error occured.
-
WmfFile
public WmfFile(InputStream in, int imageWidth, int imageHeight) throws IOException
Initialize metafile for reading from the given input stream.- Parameters:
imageWidth
- the target width of the image or -1 for automatic mode.imageHeight
- the target height of the image or -1 for automatic mode.in
- the stream from where to read.- Throws:
IOException
- if any other error occured.
-
-
Method Detail
-
getImageSize
public Dimension getImageSize()
-
getPalette
public MfPalette getPalette()
-
getHeader
public MfHeader getHeader()
Return Placeable and Windows headers that were read earlier.- Returns:
- the meta-file header.
-
getGraphics2D
public Graphics2D getGraphics2D()
-
scaleToFit
public void scaleToFit(float fitWidth, float fitHeight)
Scales the WMF-image to the given width and height while preserving the aspect ration.- Parameters:
fitWidth
- the target width.fitHeight
- the target height.
-
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 widthpercentY
- the scaling percentage of the height
-
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.- Returns:
- the next new free slot in the objects-registry
-
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 BufferedImage replay()
-
replay
public BufferedImage replay(int imageX, int imageY)
-
draw
public void draw(Graphics2D graphics, Rectangle2D bounds)
-
getPreferredSize
public 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.- Returns:
- the preferred size.
-
isPreserveAspectRatio
public boolean isPreserveAspectRatio()
Returns true, if this drawable will preserve an aspect ratio during the drawing.- Returns:
- true, if an aspect ratio is preserved, false otherwise.
-
-