public class EMFDeviceContext extends java.lang.Object implements EMFOpCodes
The default scale is 1 device unit = 1/100 mm. It can be changed using setReferenceRatios(). To avoid the burden of encapsulating each integer value in an object, we have decided to use the following conventions:
In contrast with WMF, the order of coordinates in EMF is the usual one. X, then Y. (U means unsigned, S means signed, and the size is in bits).
EMR_ABORTPATH, EMR_ANGLEARC, EMR_ARC, EMR_ARCTO, EMR_BEGINPATH, EMR_BITBLT, EMR_CHORD, EMR_CLOSEFIGURE, EMR_CREATEBRUSHINDIRECT, EMR_CREATEDIBPATTERNBRUSHPT, EMR_CREATEMONOBRUSH, EMR_CREATEPALETTE, EMR_CREATEPEN, EMR_DELETEOBJECT, EMR_ELLIPSE, EMR_ENDPATH, EMR_EOF, EMR_EXCLUDECLIPRECT, EMR_EXTCREATEFONTINDIRECTW, EMR_EXTCREATEPEN, EMR_EXTFLOODFILL, EMR_EXTSELECTCLIPRGN, EMR_EXTTEXTOUTA, EMR_EXTTEXTOUTW, EMR_FILLPATH, EMR_FILLRGN, EMR_FLATTENPATH, EMR_FRAMERGN, EMR_GDICOMMENT, EMR_HEADER, EMR_INTERSECTCLIPRECT, EMR_INVERTRGN, EMR_LINETO, EMR_MASKBLT, EMR_MODIFYWORLDTRANSFORM, EMR_MOVETOEX, EMR_OFFSETCLIPRGN, EMR_PAINTRGN, EMR_PIE, EMR_PLGBLT, EMR_POLYBEZIER, EMR_POLYBEZIER16, EMR_POLYBEZIERTO, EMR_POLYBEZIERTO16, EMR_POLYDRAW, EMR_POLYDRAW16, EMR_POLYGON, EMR_POLYGON16, EMR_POLYLINE, EMR_POLYLINE16, EMR_POLYLINETO, EMR_POLYLINETO16, EMR_POLYPOLYGON, EMR_POLYPOLYGON16, EMR_POLYPOLYLINE, EMR_POLYPOLYLINE16, EMR_POLYTEXTOUTA, EMR_POLYTEXTOUTW, EMR_REALIZEPALETTE, EMR_RECTANGLE, EMR_RESIZEPALETTE, EMR_RESTOREDC, EMR_ROUNDRECT, EMR_SAVEDC, EMR_SCALEVIEWPORTEXTEX, EMR_SCALEWINDOWEXTEX, EMR_SELECTCLIPPATH, EMR_SELECTOBJECT, EMR_SELECTPALETTE, EMR_SETARCDIRECTION, EMR_SETBKCOLOR, EMR_SETBKMODE, EMR_SETBRUSHORGEX, EMR_SETCOLORADJUSTMENT, EMR_SETDIBITSTODEVICE, EMR_SETMAPMODE, EMR_SETMAPPERFLAGS, EMR_SETMETARGN, EMR_SETMITERLIMIT, EMR_SETPALETTEENTRIES, EMR_SETPIXELV, EMR_SETPOLYFILLMODE, EMR_SETROP2, EMR_SETSTRETCHBLTMODE, EMR_SETTEXTALIGN, EMR_SETTEXTCOLOR, EMR_SETVIEWPORTEXTEX, EMR_SETVIEWPORTORGEX, EMR_SETWINDOWEXTEX, EMR_SETWINDOWORGEX, EMR_SETWORLDTRANSFORM, EMR_STRETCHBLT, EMR_STRETCHDIBITS, EMR_STROKEANDFILLPATH, EMR_STROKEPATH, EMR_WIDENPATH| Constructor and Description |
|---|
EMFDeviceContext(RandomAccessStream stream,
java.awt.Dimension dims,
java.lang.String creator,
java.lang.String comment)
Create a device context.
|
EMFDeviceContext(RandomAccessStream stream,
long width,
long height,
java.lang.String creator,
java.lang.String comment)
Create a metafile in a RandomAccessStream, for instance a
RandomAccessByteArray or a RandomAccessFile.
|
| Modifier and Type | Method and Description |
|---|---|
void |
beginPath() |
void |
closeFigure() |
void |
closeMetafile() |
short |
createBrush(long hatch,
long colour,
long style)
Create a new brush and returns its number.
|
EMFPen |
createDrawPen(int penStyle,
short width,
long colour) |
EMFPen |
createDrawPen(short width,
long colour) |
EMFPen |
createFillPen(long colour) |
EMFPen |
createFillPen(short fillHatch,
long colour,
int fillStyle) |
short |
createPen(int penStyle,
int width,
long colour)
Create a pen and return its object id.
|
EMFPen |
createPenBrush(int penStyle,
short width,
long penColour,
short fillhatch,
long fillColour,
int fillStyle)
Generic function for building a Pen.
|
void |
deleteObject(int nobj) |
void |
deletePen(EMFPen pen) |
void |
endPath() |
void |
fillPath()
fill the last path.
|
void |
freePen(EMFPen pen) |
double |
getDevicePointSize() |
double |
getXScale()
Returns the length (in mm) of one horizontal device unit.
|
double |
getYScale()
Returns the length (in mm) of one vertical device unit.
|
void |
lineTo(EMFPoint point) |
void |
lineTo(long x,
long y) |
void |
moveToEx(EMFPoint point) |
void |
moveToEx(long x,
long y)
Moves the current point.
|
void |
polyBezierTo(EMFRectangle boundingBox,
EMFPoint[] controls)
Draws a Bezier curve.
|
void |
polyBezierTo16(EMFRectangle boundingBox,
EMFPoint[] controls)
Draws a Bezier curve.
|
void |
restoreDC() |
void |
saveDC() |
void |
selectObject(long nobj) |
void |
selectPen(EMFPen pen) |
void |
setBkColor(long color) |
void |
setBkMode(int bkMode)
Sets the background mode
|
void |
setDevicePointSize(double devicePointSize)
Sets the size of device point, in mm.
|
void |
setMapMode(long mapMode)
Sets the device coordinate system to use.
|
void |
setReferenceRatios(long dXpixels,
long dyPixels,
long dxMM,
long dyMM)
Sets the scale for this picture.
|
void |
setTextColor(int col) |
void |
setViewPortOrgEx(int x,
int y) |
void |
setWindowExt(int w,
int h)
Sets the reference window extension.
|
void |
setWindowExtEx(int w,
int h)
Defines window size in logical units.
|
void |
setWindowOrg(int x,
int y) |
void |
setWindowOrgEx(int x,
int y)
Sets window origin.
|
void |
strokePath(int minx,
int miny,
int maxx,
int maxy) |
public EMFDeviceContext(RandomAccessStream stream, java.awt.Dimension dims, java.lang.String creator, java.lang.String comment) throws java.io.IOException
stream - the stream where the data will be written.dims - size of the picture.creator - the software's name (may be null) (will default to "java" if
needed).comment - a free text comment (may be null)java.io.IOExceptionpublic EMFDeviceContext(RandomAccessStream stream, long width, long height, java.lang.String creator, java.lang.String comment) throws java.io.IOException
stream - width - : width in device pointsheight - : height in mmcreator - the software's name (may be null) (will default to "java" if
needed).comment - a free text comment (may be null)java.io.IOExceptionpublic void beginPath()
throws java.io.IOException
java.io.IOExceptionpublic void closeMetafile()
throws java.io.IOException
java.io.IOExceptionpublic void deleteObject(int nobj)
throws java.io.IOException
java.io.IOExceptionpublic void endPath()
throws java.io.IOException
java.io.IOExceptionpublic void fillPath()
throws java.io.IOException
java.io.IOExceptionpublic void lineTo(long x,
long y)
throws java.io.IOException
x - y - java.io.IOExceptionpublic void moveToEx(long x,
long y)
throws java.io.IOException
x - y - java.io.IOExceptionpublic void polyBezierTo(EMFRectangle boundingBox, EMFPoint[] controls) throws java.io.IOException
boundingBox - can be null, in which case it is computed.controls - java.io.IOExceptionpublic void polyBezierTo16(EMFRectangle boundingBox, EMFPoint[] controls) throws java.io.IOException
boundingBox - : can't be null.controls - java.io.IOExceptionpublic short createBrush(long hatch,
long colour,
long style)
throws java.io.IOException
hatch - (a hatch style from WMFConstants: HS_something.)colour - a 24bit RGB colour.style - (a brush style from WMFConstants: BS_something.)java.io.IOExceptionWMFConstantspublic short createPen(int penStyle,
int width,
long colour)
throws java.io.IOException
penStyle - a pen style (from WMFConstants)width - pen widthcolour - pen colour.java.io.IOExceptionpublic void setBkColor(long color)
throws java.io.IOException
java.io.IOExceptionpublic void strokePath(int minx,
int miny,
int maxx,
int maxy)
throws java.io.IOException
java.io.IOExceptionpublic void setMapMode(long mapMode)
throws java.io.IOException
mapMode - one of the MM codes from the WMFConstants interface.java.io.IOExceptionWMFConstantspublic void setReferenceRatios(long dXpixels,
long dyPixels,
long dxMM,
long dyMM)
The scales are expressed as two couples dXPixels/dxMM and dyPixel/dyMM. What's important is the corresponding ratio.
dXpixels - dyPixels - dxMM - dyMM - public double getXScale()
public double getYScale()
public void setDevicePointSize(double devicePointSize)
devicePointSize - the devicePointSize to setpublic double getDevicePointSize()
public void selectObject(long nobj)
throws java.io.IOException
java.io.IOExceptionpublic void closeFigure()
throws java.io.IOException
java.io.IOExceptionpublic void setWindowOrg(int x,
int y)
throws java.io.IOException
x - y - java.io.IOExceptionpublic void setWindowExt(int w,
int h)
throws java.io.IOException
w - h - java.io.IOExceptionpublic void setWindowOrgEx(int x,
int y)
throws java.io.IOException
x - y - java.io.IOExceptionpublic void setWindowExtEx(int w,
int h)
throws java.io.IOException
w - h - java.io.IOExceptionpublic void setBkMode(int bkMode)
throws java.io.IOException
bkMode - one of WMFConstants.TRANSPARENT or WMFConstants.OPAQUEjava.io.IOExceptionWMFConstantspublic void lineTo(EMFPoint point) throws java.io.IOException
java.io.IOExceptionpublic void moveToEx(EMFPoint point) throws java.io.IOException
java.io.IOExceptionpublic EMFPen createPenBrush(int penStyle, short width, long penColour, short fillhatch, long fillColour, int fillStyle) throws java.io.IOException
penStyle - : one of : one of PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT,
PS_DASHDOTDOT, PS_NULL, PS_INSIDEFRAME, PS_USERSTYLE,
PS_ALTERNATEwidth - : the pen's width, in 1/1440 of an inch.penColour - : the line colourfillhatch - : ignored if style is not hatched ; else : one of
HS_HORIZONTAL, HS_VERTICAL, HS_FDIAGONAL, HS_BDIAGONAL,
HS_CROSS, HS_DIAGCROSSfillColour - : the fill colour.fillStyle - one of BS_SOLID, BS_NULL or BS_HATCHED.java.io.IOExceptionpublic EMFPen createDrawPen(int penStyle, short width, long colour) throws java.io.IOException
java.io.IOExceptionpublic EMFPen createDrawPen(short width, long colour) throws java.io.IOException
java.io.IOExceptionpublic EMFPen createFillPen(short fillHatch, long colour, int fillStyle) throws java.io.IOException
java.io.IOExceptionpublic void deletePen(EMFPen pen) throws java.io.IOException
java.io.IOExceptionpublic void saveDC()
throws java.io.IOException
java.io.IOExceptionpublic void restoreDC()
throws java.io.IOException
java.io.IOExceptionpublic EMFPen createFillPen(long colour) throws java.io.IOException
java.io.IOExceptionpublic void selectPen(EMFPen pen) throws java.io.IOException
java.io.IOExceptionpublic void freePen(EMFPen pen) throws java.io.IOException
java.io.IOExceptionpublic void setViewPortOrgEx(int x,
int y)
throws java.io.IOException
java.io.IOExceptionpublic void setTextColor(int col)
throws java.io.IOException
java.io.IOException