com.pietjonas.wmfwriter2d
Class WMF

java.lang.Object
  extended bycom.pietjonas.wmfwriter2d.WMF

public class WMF
extends java.lang.Object

A class for writing Windows metafiles. It encapsulats many Windows GDI commands useful in Windows metafiles. To create a Windows metafile you have to construct a WMF object:

     WMF wmf = new WMF(); 
and call the appropriate GDI commands:
     wmf.moveTo(0, 0);
     wmf.lineTo(10, 24);
     wmf.rectangle(10, 24, 100, 130);
     ...
     
or use a WMFGraphics object:
     WMFGraphics wmfg = new WMFGraphics(wmf, 400, 300);
     wmfg.drawLine(10, 10, 45, 34);
     wmfg.drawRect(0, 0, 400, 300);
     ...
     wmfg.deleteGDIObjects(); //not necessary but clean style
     
To write a standard Windows metafile to an OutputStream out use:
     wmf.writePlaceableWMF(out, 0, 0, 300, 200) 
which creates a metafile compatible with almost all Windows programs.
In Windows metafiles GDI Objects like Pens, Brushes and Fonts are stored in a handle table by createXXXIndirect. SelectObject selects one of the objects to draw something, while DeleteObject removes them from the table. All GDI objects are removed via DeleteObject at the end of the metafile by WMF by default.
Please consult the Windows SDK for the GDI commands and GDI constants.

WMF is compatible with JDK 1.0, JDK 1.1 and JDK 1.2

Version:
2.0
Author:
Dr. Piet Jonas (piet@jonas.com)
See Also:
WMFGraphics, WMFGraphics2D

Field Summary
static int ALTERNATE
           
static byte ANSI_CHARSET
           
static int BLACKNESS
           
static int BS_DIBPATTERN
           
static int BS_HATCHED
           
static int BS_HOLLOW
           
static int BS_NULL
           
static int BS_PATTERN
           
static int BS_SOLID
           
static byte CLIP_CHARACTER_PRECIS
           
static byte CLIP_DEFAULT_PRECIS
           
static byte CLIP_LH_ANGLES
           
static byte CLIP_MASK
           
static byte CLIP_STROKE_PRECIS
           
static byte CLIP_TT_ALWAYS
           
static byte DEFAULT_CHARSET
           
static byte DEFAULT_PITCH
           
static byte DEFAULT_QUALITY
           
static int DIB_PAL_COLORS
           
static int DIB_RGB_COLORS
           
static byte DRAFT_QUALITY
           
static int DSTINVERT
           
static int ETO_CLIPPED
           
static int ETO_OPAQUE
           
static byte FF_DECORATIVE
           
static byte FF_DONTCARE
           
static byte FF_MODERN
           
static byte FF_ROMAN
           
static byte FF_SCRIPT
           
static byte FF_SWISS
           
static byte FIXED_PITCH
           
static int FW_BLACK
           
static int FW_BOLD
           
static int FW_DONTCARE
           
static int FW_NORMAL
           
static int FW_THIN
           
static int HS_BDIAGONAL
           
static int HS_CROSS
           
static int HS_DIAGCROSS
           
static int HS_FDIAGONAL
           
static int HS_HORIZONTAL
           
static int HS_VERTICAL
           
static int MERGEPAINT
           
static int MM_ANISOTROPIC
           
static int MM_HIENGLISH
           
static int MM_HIMETRIC
           
static int MM_HITWIPS
           
static int MM_ISOTROPIC
           
static int MM_LOENGLISH
           
static int MM_LOMETRIC
           
static int MM_TEXT
           
static int NOTSRCCOPY
           
static int NOTSRCERASE
           
static byte OEM_CHARSET
           
static int OPAQUE
           
static byte OUT_CHARACTER_PRECIS
           
static byte OUT_DEFAULT_PRECIS
           
static byte OUT_DEVICE_PRECIS
           
static byte OUT_RASTER_PRECIS
           
static byte OUT_STRING_PRECIS
           
static byte OUT_STROKE_PRECIS
           
static byte OUT_TT_PRECIS
           
static int PATCOPY
           
static int PATINVERT
           
static int PATPAINT
           
static byte PROOF_QUALITY
           
static int PS_DASH
           
static int PS_DASHDOT
           
static int PS_DASHDOTDOT
           
static int PS_DOT
           
static int PS_INSIDEFRAME
           
static int PS_NULL
           
static int PS_SOLID
           
static int R2_BLACK
           
static int R2_COPYPEN
           
static int R2_MASKNOTPENNOT
           
static int R2_MASKPEN
           
static int R2_MASKPENNOT
           
static int R2_MERGENOTPEN
           
static int R2_MERGEPEN
           
static int R2_MERGEPENNOT
           
static int R2_NOP
           
static int R2_NOT
           
static int R2_NOTCOPYPEN
           
static int R2_NOTMASKPEN
           
static int R2_NOTMERGEPEN
           
static int R2_NOTXORPEN
           
static int R2_WHITE
           
static int R2_XORPEN
           
static byte SHIFTJIS_CHARSET
           
static int SRCAND
           
static int SRCCOPY
           
static int SRCERASE
           
static int SRCINVERT
           
static int SRCPAINT
           
static int STRETCH_ANDSCANS
           
static int STRETCH_DELETESCANS
           
static int STRETCH_ORSCANS
           
static byte SYMBOL_CHARSET
           
static int TA_BASELINE
           
static int TA_BOTTOM
           
static int TA_CENTER
           
static int TA_LEFT
           
static int TA_NOUPDATECP
           
static int TA_RIGHT
           
static int TA_TOP
           
static int TA_UPDATECP
           
static int TRANSPARENT
           
static byte VARIABLE_PITCH
           
static int WHITENESS
           
static int WINDING
           
 
Constructor Summary
WMF()
          constructs a WMF object.
 
Method Summary
protected  int addHandle()
          Add a new handle to the handle table with GDI objects .
 void arc(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
          See Windows SDK.
 void bitBlt(int dx, int dy, int dwidth, int dheight, int sx, int sy, int rop, int[] pix, int width, int height)
          See Windows SDK.
 void chord(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
          See Windows SDK.
 int createBrushIndirect(int style, java.awt.Color foreground, int hatch)
          See Windows SDK.
 int createFont(java.awt.Font font, int escapement, boolean underline, boolean strikeout)
          Convenience method to call createFontIndirect with a java.awt.Font.
 int createFontIndirect(int height, int width, int escapement, int orientation, int weight, boolean italic, boolean underline, boolean strikeout, byte charset, byte outprecision, byte clipprecision, byte quality, byte pitchandfamily, java.lang.String name)
          See Windows SDK.
 int createPatternBrush(int[] pix, int width, int height)
          See Windows SDK.
 int createPenIndirect(int style, int width, java.awt.Color foreground)
          See Windows SDK.
 void deleteObject(int index)
          See Windows SDK.
 void ellipse(int x1, int y1, int x2, int y2)
          See Windows SDK.
 void escape(int number, byte[] data)
          See Windows SDK.
 void extTextOut(int x, int y, int options, java.awt.Rectangle rect, java.lang.String str)
          See Windows SDK.
 void extTextOut(int x, int y, int options, java.awt.Rectangle rect, java.lang.String str, int[] dx)
          See Windows SDK.
 java.lang.String[][] getTranslateFontNames()
          Returns the current String replacement table.
 void intersectClipRect(int x1, int y1, int x2, int y2)
          See Windows SDK.
 void lineTo(int x, int y)
          See Windows SDK.
protected  void metaRecord(int id, int wordparams)
          Write the leading metafile record
 void moveTo(int x, int y)
          See Windows SDK.
 void offsetViewportOrg(int x, int y)
          See Windows SDK, should not be called in a metafile.
 void offsetWindowOrg(int x, int y)
          See Windows SDK.
 void patBlt(int x, int y, int width, int height, int rop)
          See Windows SDK.
 void pie(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
          See Windows SDK.
 void polygon(int[] xPoints, int[] yPoints, int nPoints)
          See Windows SDK.
 void polyline(int[] xPoints, int[] yPoints, int nPoints)
          See Windows SDK.
 void polypolygon(java.awt.Polygon[] polys)
          See Windows SDK.
 void rectangle(int x1, int y1, int x2, int y2)
          See Windows SDK.
 void roundRect(int x1, int y1, int x2, int y2, int x3, int y3)
          See Windows SDK.
 void scaleViewportExt(int xnum, int xdenom, int ynum, int ydenom)
          See Windows SDK, should not be called in a metafile.
 void scaleWindowExt(int xnum, int xdenom, int ynum, int ydenom)
          See Windows SDK.
 void selectObject(int index)
          See Windows SDK.
 void setBKColor(java.awt.Color bkcolor)
          See Windows SDK.
 void setBKMode(int mode)
          See Windows SDK.
 void setClipRgn()
          See Windows SDK.
 void setMapMode(int mode)
          See Windows SDK.
 void setPixel(int x, int y, java.awt.Color pixelcolor)
          See Windows SDK.
 void setPolyFillMode(int mode)
          See Windows SDK.
 void setROP2(int mode)
          See Windows SDK.
 void setStretchBltMode(int mode)
          See Windows SDK.
 void setTextAlign(int align)
          See Windows SDK.
 void setTextCharacterExtra(int charextra)
          See Windows SDK.
 void setTextColor(java.awt.Color textcolor)
          See Windows SDK.
 void setTextJustification(int breakextra, int breakcount)
          See Windows SDK.
 void setTranslateFontNames(java.lang.String[][] names)
          Sets the String replacement table for the font names.
 void setViewportExt(int width, int height)
          See Windows SDK, should not be called in a metafile.
 void setViewportOrg(int x, int y)
          See Windows SDK, should not be called in a metafile.
 void setWindowExt(int width, int height)
          See Windows SDK, should be called at the beginning of a metafile with the extend of the metafile.
 void setWindowOrg(int x, int y)
          See Windows SDK, should be called at the beginning of a metafile with the origin of the metafile.
 void stretchBlt(int dx, int dy, int dwidth, int dheight, int sx, int sy, int swidth, int sheight, int rop, int[] pix, int width, int height)
          See Windows SDK.
 void textOut(int x, int y, java.lang.String str)
          See Windows SDK.
 java.lang.String translateFontName(java.lang.String name)
          Replace a Java font name (e.g 'helvetica') by its Windows counterpart (e.g 'Arial').
protected  void writeBitmap(int[] tmppix, int width, int height)
          Write a 24 bit bitmap (TBitmapInfoHeader plus pixels) to the metafile
protected  void writeColor(java.awt.Color color)
          Write a TColorRef struct to the metafile
protected  void writeInteger(int value)
          Write an integer (four bytes) to the metafile
 void writePlaceableWMF(java.io.OutputStream out, int x, int y, int width, int height, int dpi)
          Write a placeable Windows metafile with the called GDI commands to the OutputStream out which is compatible with almost all Windows programs.
 void writeWMF(java.io.OutputStream out)
          Write a simple Windows metafile with the called GDI commands to the OutputStream out which is not recognized by a lot of Windows programs.
protected  void writeWord(int value)
          Write a word (two bytes) to the metafile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PS_SOLID

public static final int PS_SOLID
See Also:
Constant Field Values

PS_DASH

public static final int PS_DASH
See Also:
Constant Field Values

PS_DOT

public static final int PS_DOT
See Also:
Constant Field Values

PS_DASHDOT

public static final int PS_DASHDOT
See Also:
Constant Field Values

PS_DASHDOTDOT

public static final int PS_DASHDOTDOT
See Also:
Constant Field Values

PS_NULL

public static final int PS_NULL
See Also:
Constant Field Values

PS_INSIDEFRAME

public static final int PS_INSIDEFRAME
See Also:
Constant Field Values

BS_SOLID

public static final int BS_SOLID
See Also:
Constant Field Values

BS_HOLLOW

public static final int BS_HOLLOW
See Also:
Constant Field Values

BS_NULL

public static final int BS_NULL
See Also:
Constant Field Values

BS_HATCHED

public static final int BS_HATCHED
See Also:
Constant Field Values

BS_PATTERN

public static final int BS_PATTERN
See Also:
Constant Field Values

BS_DIBPATTERN

public static final int BS_DIBPATTERN
See Also:
Constant Field Values

HS_HORIZONTAL

public static final int HS_HORIZONTAL
See Also:
Constant Field Values

HS_VERTICAL

public static final int HS_VERTICAL
See Also:
Constant Field Values

HS_FDIAGONAL

public static final int HS_FDIAGONAL
See Also:
Constant Field Values

HS_BDIAGONAL

public static final int HS_BDIAGONAL
See Also:
Constant Field Values

HS_CROSS

public static final int HS_CROSS
See Also:
Constant Field Values

HS_DIAGCROSS

public static final int HS_DIAGCROSS
See Also:
Constant Field Values

DIB_RGB_COLORS

public static final int DIB_RGB_COLORS
See Also:
Constant Field Values

DIB_PAL_COLORS

public static final int DIB_PAL_COLORS
See Also:
Constant Field Values

FW_DONTCARE

public static final int FW_DONTCARE
See Also:
Constant Field Values

FW_THIN

public static final int FW_THIN
See Also:
Constant Field Values

FW_NORMAL

public static final int FW_NORMAL
See Also:
Constant Field Values

FW_BOLD

public static final int FW_BOLD
See Also:
Constant Field Values

FW_BLACK

public static final int FW_BLACK
See Also:
Constant Field Values

ANSI_CHARSET

public static final byte ANSI_CHARSET
See Also:
Constant Field Values

DEFAULT_CHARSET

public static final byte DEFAULT_CHARSET
See Also:
Constant Field Values

SYMBOL_CHARSET

public static final byte SYMBOL_CHARSET
See Also:
Constant Field Values

SHIFTJIS_CHARSET

public static final byte SHIFTJIS_CHARSET
See Also:
Constant Field Values

OEM_CHARSET

public static final byte OEM_CHARSET
See Also:
Constant Field Values

OUT_DEFAULT_PRECIS

public static final byte OUT_DEFAULT_PRECIS
See Also:
Constant Field Values

OUT_STRING_PRECIS

public static final byte OUT_STRING_PRECIS
See Also:
Constant Field Values

OUT_CHARACTER_PRECIS

public static final byte OUT_CHARACTER_PRECIS
See Also:
Constant Field Values

OUT_STROKE_PRECIS

public static final byte OUT_STROKE_PRECIS
See Also:
Constant Field Values

OUT_TT_PRECIS

public static final byte OUT_TT_PRECIS
See Also:
Constant Field Values

OUT_DEVICE_PRECIS

public static final byte OUT_DEVICE_PRECIS
See Also:
Constant Field Values

OUT_RASTER_PRECIS

public static final byte OUT_RASTER_PRECIS
See Also:
Constant Field Values

CLIP_DEFAULT_PRECIS

public static final byte CLIP_DEFAULT_PRECIS
See Also:
Constant Field Values

CLIP_CHARACTER_PRECIS

public static final byte CLIP_CHARACTER_PRECIS
See Also:
Constant Field Values

CLIP_STROKE_PRECIS

public static final byte CLIP_STROKE_PRECIS
See Also:
Constant Field Values

CLIP_MASK

public static final byte CLIP_MASK
See Also:
Constant Field Values

CLIP_LH_ANGLES

public static final byte CLIP_LH_ANGLES
See Also:
Constant Field Values

CLIP_TT_ALWAYS

public static final byte CLIP_TT_ALWAYS
See Also:
Constant Field Values

DEFAULT_QUALITY

public static final byte DEFAULT_QUALITY
See Also:
Constant Field Values

DRAFT_QUALITY

public static final byte DRAFT_QUALITY
See Also:
Constant Field Values

PROOF_QUALITY

public static final byte PROOF_QUALITY
See Also:
Constant Field Values

DEFAULT_PITCH

public static final byte DEFAULT_PITCH
See Also:
Constant Field Values

FIXED_PITCH

public static final byte FIXED_PITCH
See Also:
Constant Field Values

VARIABLE_PITCH

public static final byte VARIABLE_PITCH
See Also:
Constant Field Values

FF_DONTCARE

public static final byte FF_DONTCARE
See Also:
Constant Field Values

FF_ROMAN

public static final byte FF_ROMAN
See Also:
Constant Field Values

FF_SWISS

public static final byte FF_SWISS
See Also:
Constant Field Values

FF_MODERN

public static final byte FF_MODERN
See Also:
Constant Field Values

FF_SCRIPT

public static final byte FF_SCRIPT
See Also:
Constant Field Values

FF_DECORATIVE

public static final byte FF_DECORATIVE
See Also:
Constant Field Values

TRANSPARENT

public static final int TRANSPARENT
See Also:
Constant Field Values

OPAQUE

public static final int OPAQUE
See Also:
Constant Field Values

MM_TEXT

public static final int MM_TEXT
See Also:
Constant Field Values

MM_LOMETRIC

public static final int MM_LOMETRIC
See Also:
Constant Field Values

MM_HIMETRIC

public static final int MM_HIMETRIC
See Also:
Constant Field Values

MM_LOENGLISH

public static final int MM_LOENGLISH
See Also:
Constant Field Values

MM_HIENGLISH

public static final int MM_HIENGLISH
See Also:
Constant Field Values

MM_HITWIPS

public static final int MM_HITWIPS
See Also:
Constant Field Values

MM_ISOTROPIC

public static final int MM_ISOTROPIC
See Also:
Constant Field Values

MM_ANISOTROPIC

public static final int MM_ANISOTROPIC
See Also:
Constant Field Values

ALTERNATE

public static final int ALTERNATE
See Also:
Constant Field Values

WINDING

public static final int WINDING
See Also:
Constant Field Values

STRETCH_ANDSCANS

public static final int STRETCH_ANDSCANS
See Also:
Constant Field Values

STRETCH_ORSCANS

public static final int STRETCH_ORSCANS
See Also:
Constant Field Values

STRETCH_DELETESCANS

public static final int STRETCH_DELETESCANS
See Also:
Constant Field Values

TA_TOP

public static final int TA_TOP
See Also:
Constant Field Values

TA_BOTTOM

public static final int TA_BOTTOM
See Also:
Constant Field Values

TA_BASELINE

public static final int TA_BASELINE
See Also:
Constant Field Values

TA_LEFT

public static final int TA_LEFT
See Also:
Constant Field Values

TA_RIGHT

public static final int TA_RIGHT
See Also:
Constant Field Values

TA_CENTER

public static final int TA_CENTER
See Also:
Constant Field Values

TA_NOUPDATECP

public static final int TA_NOUPDATECP
See Also:
Constant Field Values

TA_UPDATECP

public static final int TA_UPDATECP
See Also:
Constant Field Values

R2_BLACK

public static final int R2_BLACK
See Also:
Constant Field Values

R2_NOTMERGEPEN

public static final int R2_NOTMERGEPEN
See Also:
Constant Field Values

R2_MASKNOTPENNOT

public static final int R2_MASKNOTPENNOT
See Also:
Constant Field Values

R2_NOTCOPYPEN

public static final int R2_NOTCOPYPEN
See Also:
Constant Field Values

R2_MASKPENNOT

public static final int R2_MASKPENNOT
See Also:
Constant Field Values

R2_NOT

public static final int R2_NOT
See Also:
Constant Field Values

R2_XORPEN

public static final int R2_XORPEN
See Also:
Constant Field Values

R2_NOTMASKPEN

public static final int R2_NOTMASKPEN
See Also:
Constant Field Values

R2_MASKPEN

public static final int R2_MASKPEN
See Also:
Constant Field Values

R2_NOTXORPEN

public static final int R2_NOTXORPEN
See Also:
Constant Field Values

R2_NOP

public static final int R2_NOP
See Also:
Constant Field Values

R2_MERGENOTPEN

public static final int R2_MERGENOTPEN
See Also:
Constant Field Values

R2_COPYPEN

public static final int R2_COPYPEN
See Also:
Constant Field Values

R2_MERGEPENNOT

public static final int R2_MERGEPENNOT
See Also:
Constant Field Values

R2_MERGEPEN

public static final int R2_MERGEPEN
See Also:
Constant Field Values

R2_WHITE

public static final int R2_WHITE
See Also:
Constant Field Values

ETO_OPAQUE

public static final int ETO_OPAQUE
See Also:
Constant Field Values

ETO_CLIPPED

public static final int ETO_CLIPPED
See Also:
Constant Field Values

BLACKNESS

public static final int BLACKNESS
See Also:
Constant Field Values

NOTSRCERASE

public static final int NOTSRCERASE
See Also:
Constant Field Values

NOTSRCCOPY

public static final int NOTSRCCOPY
See Also:
Constant Field Values

SRCERASE

public static final int SRCERASE
See Also:
Constant Field Values

DSTINVERT

public static final int DSTINVERT
See Also:
Constant Field Values

PATINVERT

public static final int PATINVERT
See Also:
Constant Field Values

SRCINVERT

public static final int SRCINVERT
See Also:
Constant Field Values

SRCAND

public static final int SRCAND
See Also:
Constant Field Values

MERGEPAINT

public static final int MERGEPAINT
See Also:
Constant Field Values

SRCCOPY

public static final int SRCCOPY
See Also:
Constant Field Values

SRCPAINT

public static final int SRCPAINT
See Also:
Constant Field Values

PATCOPY

public static final int PATCOPY
See Also:
Constant Field Values

PATPAINT

public static final int PATPAINT
See Also:
Constant Field Values

WHITENESS

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

WMF

public WMF()
constructs a WMF object.

Method Detail

metaRecord

protected void metaRecord(int id,
                          int wordparams)
Write the leading metafile record

Parameters:
id - the id of the metafile record
wordparams - the number of words (two bytes) of the parameters of therecord

writeWord

protected void writeWord(int value)
Write a word (two bytes) to the metafile

Parameters:
value - the word (in the lower two bytes)

writeInteger

protected void writeInteger(int value)
Write an integer (four bytes) to the metafile

Parameters:
value - the integer

writeColor

protected void writeColor(java.awt.Color color)
Write a TColorRef struct to the metafile

Parameters:
color - the Color

writeBitmap

protected void writeBitmap(int[] tmppix,
                           int width,
                           int height)
Write a 24 bit bitmap (TBitmapInfoHeader plus pixels) to the metafile

Parameters:
tmppix - the pixels as retrieved by java.awt.image.PixelGrabber
width - the width of the bitmap
height - the height of the bitmap

addHandle

protected int addHandle()
Add a new handle to the handle table with GDI objects . Used by the createXXXIndirect methods.

See Also:
selectObject(int), deleteObject(int), createPenIndirect(int, int, java.awt.Color), createBrushIndirect(int, java.awt.Color, int), createFontIndirect(int, int, int, int, int, boolean, boolean, boolean, byte, byte, byte, byte, byte, java.lang.String), createFont(java.awt.Font, int, boolean, boolean)

translateFontName

public java.lang.String translateFontName(java.lang.String name)
Replace a Java font name (e.g 'helvetica') by its Windows counterpart (e.g 'Arial'). Uses a String [][2] table with pairs of font names. If the Java font name can not be found in the table the return value is equal to name.

Parameters:
name - the Java font name
Returns:
the corresponding Windows fontname
See Also:
setTranslateFontNames(java.lang.String[][]), getTranslateFontNames()

setTranslateFontNames

public void setTranslateFontNames(java.lang.String[][] names)
Sets the String replacement table for the font names.

Parameters:
names - the String[][2] table with pairs of font names {Java font, Windows font}
See Also:
translateFontName(java.lang.String), getTranslateFontNames()

getTranslateFontNames

public java.lang.String[][] getTranslateFontNames()
Returns the current String replacement table.

Returns:
the String replacement table.
See Also:
translateFontName(java.lang.String), setTranslateFontNames(java.lang.String[][])

writePlaceableWMF

public void writePlaceableWMF(java.io.OutputStream out,
                              int x,
                              int y,
                              int width,
                              int height,
                              int dpi)
                       throws java.io.IOException
Write a placeable Windows metafile with the called GDI commands to the OutputStream out which is compatible with almost all Windows programs. All currently created GDI objects are deleted.

Parameters:
out - The OutputStream to write the metafile.
x - The x coordinate of the bounding rectangle.
y - The y coordinate of the bounding rectangle.
width - The width of the bounding rectangle.
height - The height of the bounding rectangle.
dpi - Specifies the number of metafile units to the inch.
Throws:
java.io.IOException
See Also:
writeWMF(java.io.OutputStream)

writeWMF

public void writeWMF(java.io.OutputStream out)
              throws java.io.IOException
Write a simple Windows metafile with the called GDI commands to the OutputStream out which is not recognized by a lot of Windows programs. All currently created GDI objects are deleted.

Parameters:
out - The OutputStream to write the metafile.
Throws:
java.io.IOException
See Also:
writePlaceableWMF(java.io.OutputStream, int, int, int, int, int)

selectObject

public void selectObject(int index)
See Windows SDK. Selects a GDI object from the handle table.

Parameters:
index - The index in the handle table
See Also:
deleteObject(int), createPenIndirect(int, int, java.awt.Color), createBrushIndirect(int, java.awt.Color, int), createFontIndirect(int, int, int, int, int, boolean, boolean, boolean, byte, byte, byte, byte, byte, java.lang.String), createFont(java.awt.Font, int, boolean, boolean)

deleteObject

public void deleteObject(int index)
See Windows SDK. Removes a GDI object from the handle table and deletes it.

Parameters:
index - The index in the handle table
See Also:
selectObject(int), createPenIndirect(int, int, java.awt.Color), createBrushIndirect(int, java.awt.Color, int), createFontIndirect(int, int, int, int, int, boolean, boolean, boolean, byte, byte, byte, byte, byte, java.lang.String), createFont(java.awt.Font, int, boolean, boolean)

createPenIndirect

public int createPenIndirect(int style,
                             int width,
                             java.awt.Color foreground)
See Windows SDK. Adds this GDI pen object to the next free place in the handle table.

Parameters:
style - Use a PS_XXX constant.
See Also:
selectObject(int), deleteObject(int)

createBrushIndirect

public int createBrushIndirect(int style,
                               java.awt.Color foreground,
                               int hatch)
See Windows SDK. Adds this GDI brush object to the next free place in the handle table.

Parameters:
style - Use a BS_XXX constant.
hatch - Use a HS_XXX constant.
See Also:
selectObject(int), deleteObject(int)

createPatternBrush

public int createPatternBrush(int[] pix,
                              int width,
                              int height)
See Windows SDK. Adds this GDI pattern brush object to the next free place in the handle table.

Parameters:
pix - The pixels of the pattern bitmap (from java.awt.image.PixelGrabber).
width - The width of the bitmap. Should be 8 at least.
height - The height of the bitmap. Should be 8 at least.
See Also:
selectObject(int), deleteObject(int)

createFont

public int createFont(java.awt.Font font,
                      int escapement,
                      boolean underline,
                      boolean strikeout)
Convenience method to call createFontIndirect with a java.awt.Font. Adds this GDI font object to the next free place in the handle table.

Parameters:
font - The Java Font object.
escapement - The drawing angle of the font (in tenth degrees).
underline - Whether to underline the font.
strikeout - Whether to strike the font out.
See Also:
createFontIndirect(int, int, int, int, int, boolean, boolean, boolean, byte, byte, byte, byte, byte, java.lang.String), selectObject(int), deleteObject(int)

createFontIndirect

public int createFontIndirect(int height,
                              int width,
                              int escapement,
                              int orientation,
                              int weight,
                              boolean italic,
                              boolean underline,
                              boolean strikeout,
                              byte charset,
                              byte outprecision,
                              byte clipprecision,
                              byte quality,
                              byte pitchandfamily,
                              java.lang.String name)
See Windows SDK. Adds this GDI font object to the next free place in the handle table.

Parameters:
height - The height of the font.
width - The width of the font (can be 0).
escapement - The drawing angle of the font (in tenth degrees).
orientation - Ignored.
weight - Use a FW_XXX constant.
italic - Whether to draw use an italic font.
underline - Whether to underline the font.
strikeout - Whether to strike the font out.
charset - Use a XXX_CHARSET constant.
outprecision - Use a OUT_XXX constant.
clipprecision - Use a CLIP_XXX constant.
quality - Use a XXX_QUALITY constant.
pitchandfamily - Use a combination of XXX_PITCH and FF_XXX constants.
name - The font name.
See Also:
createFont(java.awt.Font, int, boolean, boolean), selectObject(int), deleteObject(int)

setWindowOrg

public void setWindowOrg(int x,
                         int y)
See Windows SDK, should be called at the beginning of a metafile with the origin of the metafile.


setWindowExt

public void setWindowExt(int width,
                         int height)
See Windows SDK, should be called at the beginning of a metafile with the extend of the metafile.


offsetWindowOrg

public void offsetWindowOrg(int x,
                            int y)
See Windows SDK.


scaleWindowExt

public void scaleWindowExt(int xnum,
                           int xdenom,
                           int ynum,
                           int ydenom)
See Windows SDK.


setViewportOrg

public void setViewportOrg(int x,
                           int y)
See Windows SDK, should not be called in a metafile.


setViewportExt

public void setViewportExt(int width,
                           int height)
See Windows SDK, should not be called in a metafile.


offsetViewportOrg

public void offsetViewportOrg(int x,
                              int y)
See Windows SDK, should not be called in a metafile.


scaleViewportExt

public void scaleViewportExt(int xnum,
                             int xdenom,
                             int ynum,
                             int ydenom)
See Windows SDK, should not be called in a metafile.


setTextColor

public void setTextColor(java.awt.Color textcolor)
See Windows SDK.


setBKMode

public void setBKMode(int mode)
See Windows SDK.

Parameters:
mode - Use TRANSPARENT or OPAQUE.

setBKColor

public void setBKColor(java.awt.Color bkcolor)
See Windows SDK.


setMapMode

public void setMapMode(int mode)
See Windows SDK.

Parameters:
mode - Use a MM_XXX constant.

setPolyFillMode

public void setPolyFillMode(int mode)
See Windows SDK.

Parameters:
mode - Use ALTERNATE or WINDING.

setStretchBltMode

public void setStretchBltMode(int mode)
See Windows SDK.

Parameters:
mode - Use a STRETCH_XXX constant.

setTextAlign

public void setTextAlign(int align)
See Windows SDK.

Parameters:
align - Use a combination of TA_XXX constants.

setROP2

public void setROP2(int mode)
See Windows SDK.

Parameters:
mode - Use a R2_XXX constant.

setTextCharacterExtra

public void setTextCharacterExtra(int charextra)
See Windows SDK.


setTextJustification

public void setTextJustification(int breakextra,
                                 int breakcount)
See Windows SDK.


moveTo

public void moveTo(int x,
                   int y)
See Windows SDK.


lineTo

public void lineTo(int x,
                   int y)
See Windows SDK.


arc

public void arc(int x1,
                int y1,
                int x2,
                int y2,
                int x3,
                int y3,
                int x4,
                int y4)
See Windows SDK.


chord

public void chord(int x1,
                  int y1,
                  int x2,
                  int y2,
                  int x3,
                  int y3,
                  int x4,
                  int y4)
See Windows SDK.


pie

public void pie(int x1,
                int y1,
                int x2,
                int y2,
                int x3,
                int y3,
                int x4,
                int y4)
See Windows SDK.


rectangle

public void rectangle(int x1,
                      int y1,
                      int x2,
                      int y2)
See Windows SDK.


ellipse

public void ellipse(int x1,
                    int y1,
                    int x2,
                    int y2)
See Windows SDK.


roundRect

public void roundRect(int x1,
                      int y1,
                      int x2,
                      int y2,
                      int x3,
                      int y3)
See Windows SDK.


polygon

public void polygon(int[] xPoints,
                    int[] yPoints,
                    int nPoints)
See Windows SDK.


polypolygon

public void polypolygon(java.awt.Polygon[] polys)
See Windows SDK.


polyline

public void polyline(int[] xPoints,
                     int[] yPoints,
                     int nPoints)
See Windows SDK.


intersectClipRect

public void intersectClipRect(int x1,
                              int y1,
                              int x2,
                              int y2)
See Windows SDK.


setClipRgn

public void setClipRgn()
See Windows SDK. Selects a NIL region, therefore removes any clipping


textOut

public void textOut(int x,
                    int y,
                    java.lang.String str)
See Windows SDK.


extTextOut

public void extTextOut(int x,
                       int y,
                       int options,
                       java.awt.Rectangle rect,
                       java.lang.String str)
See Windows SDK.

Parameters:
options - Use a ETO_XXX constant.
rect - Bounding box. Is ignored, if options == 0

extTextOut

public void extTextOut(int x,
                       int y,
                       int options,
                       java.awt.Rectangle rect,
                       java.lang.String str,
                       int[] dx)
See Windows SDK.

Parameters:
options - Use a ETO_XXX constant.
rect - Bounding box. Is ignored, if options == 0
dx - Distance between character cells. Can be null. dx.length() >= str.length

escape

public void escape(int number,
                   byte[] data)
See Windows SDK.


setPixel

public void setPixel(int x,
                     int y,
                     java.awt.Color pixelcolor)
See Windows SDK.


stretchBlt

public void stretchBlt(int dx,
                       int dy,
                       int dwidth,
                       int dheight,
                       int sx,
                       int sy,
                       int swidth,
                       int sheight,
                       int rop,
                       int[] pix,
                       int width,
                       int height)
See Windows SDK.

Parameters:
dx - The destination rectangle
dy - The destination rectangle
dwidth - The destination rectangle
dheight - The destination rectangle
sx - The source rectangle
sy - The source rectangle
swidth - The source rectangle
sheight - The source rectangle
rop - Use a SRCXXX constant.
pix - The pixels of the source bitmap (from java.awt.image.PixelGrabber).
width - The width of the bitmap.
height - The height of the bitmap.

bitBlt

public void bitBlt(int dx,
                   int dy,
                   int dwidth,
                   int dheight,
                   int sx,
                   int sy,
                   int rop,
                   int[] pix,
                   int width,
                   int height)
See Windows SDK.

Parameters:
dx - The destination rectangle
dy - The destination rectangle
dwidth - The destination rectangle
dheight - The destination rectangle
sx - The source origin
sy - The source origin
rop - Use a SRCXXX constant.
pix - The pixels of the source bitmap (from java.awt.image.PixelGrabber).
width - The width of the bitmap.
height - The height of the bitmap.

patBlt

public void patBlt(int x,
                   int y,
                   int width,
                   int height,
                   int rop)
See Windows SDK.

Parameters:
x - The destination rectangle
y - The destination rectangle
width - The destination rectangle
height - The destination rectangle
rop - Use a PATXXX constant.