|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Graphics com.pietjonas.wmfwriter2d.WMFGraphics
A class for writing into Windows Metafiles with standard
java.awt.Graphics methods. Additional methods for using GDI specialities
like different line and fill styles and rotated fonts are provided.
Usage is simple. Construct a WMFGraphics object with a WMF object
wmf
and the metafile extent:
WMFGraphics wmfg = new WMFGraphics(wmf, 400, 300);Use the standard java.awt.Graphics methods to draw:
... wmfg.drawLine(0, 0, 400, 300); wmfg.drawOval(100, 100, 200, 100); ...You can even use GDI specialities:
... wmfg.setPenStyle(WMF.PS_DOT); wmfg.setPenWidth(5); wmfg.drawLine(400, 0, 0, 300); wmfg.setBrushFillStyle(WMF.BS_HATCHED); wmfg.setBrushHatch(WMF.HS_CROSS); wmfg.fillOval(150, 100, 100, 100); wmfg.reset(); //set back to standard AWT settings ...Finish your drawings with the delete of the GDI objects used by the WMFGraphics objects:
wmfg.deleteGDIObjects()This is not really necessary because the WMF object deletes them automatically but clean style.
WMFGraphics2D
,
WMF
Constructor Summary | |
WMFGraphics(WMF wmf,
int width,
int height)
Constructs a WMFGraphics object. |
|
WMFGraphics(WMF wmf,
int width,
int height,
java.awt.Color foreground,
java.awt.Color background)
Constructs a WMFGraphics object. |
Method Summary | |
void |
clearRect(int x,
int y,
int width,
int height)
See Graphics. |
void |
clipRect(int x,
int y,
int width,
int height)
See Graphics. |
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Not supported. |
java.awt.Graphics |
create()
|
void |
createWMFHandles()
Creates and selects three GDI Objects: a Pen, a Brush and a Font with the current styles and fore- and background color. |
void |
deleteGDIObjects()
Deletes all created GDI objects. |
void |
dispose()
See Graphics. |
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
See Graphics. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
See Graphics. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
java.awt.image.ImageObserver observer)
See Graphics. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
See Graphics. |
boolean |
drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver observer)
See Graphics. |
boolean |
drawImage(java.awt.Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
See Graphics. |
boolean |
drawImage(java.awt.Image img,
int dx1,
int dy1,
int dx2,
int dy2,
int sx1,
int sy1,
int sx2,
int sy2,
java.awt.image.ImageObserver observer)
See Graphics. |
void |
drawLine(int x1,
int y1,
int x2,
int y2)
See Graphics. |
void |
drawOval(int x,
int y,
int width,
int height)
See Graphics. |
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
See Graphics. |
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
See Graphics. |
void |
drawRect(int x,
int y,
int width,
int height)
See Graphics. |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
See Graphics. |
void |
drawString(java.text.AttributedCharacterIterator text,
int x,
int y)
Not supported. |
void |
drawString(java.lang.String str,
int x,
int y)
See Graphics. |
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
See Graphics. |
void |
fillOval(int x,
int y,
int width,
int height)
See Graphics. |
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
See Graphics. |
void |
fillRect(int x,
int y,
int width,
int height)
See Graphics. |
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
See Graphics. |
void |
GDIPolyPolygon(java.awt.Polygon[] polys)
Executes the GDI polypolygon. |
int |
getBrushFillStyle()
Returns the current fill style of the brush, used to fill shapes. |
int |
getBrushHatch()
Returns the current hatch style of the brush, used to fill shapes. |
java.awt.Image |
getBrushPattern()
Returns the bitmap of the pattern brush, used to fill shapes. |
java.awt.Shape |
getClip()
See Graphics. |
java.awt.Rectangle |
getClipBounds()
See Graphics. |
java.awt.Rectangle |
getClipRect()
See Graphics. |
java.awt.Color |
getColor()
See Graphics. |
java.awt.Font |
getFont()
See Graphics. |
int |
getFontEscapement()
Returns the current escapement of the font, used to draw text. |
java.awt.FontMetrics |
getFontMetrics(java.awt.Font f)
See Graphics. |
int |
getPenStyle()
Returns the current style of the pen, used to draw lines. |
int |
getPenWidth()
Returns the current width of the pen, used to draw lines. |
WMF |
getWMF()
Returns the current WMF object. |
void |
reset()
Resets WMFGraphics to its standard Java AWT behavior. |
void |
restoreState()
Restores internal WMFGraphics settings in WMF which have been changed by copies (Graphics.create()) of this Graphics object. |
void |
setBrushFillStyle(int style)
Sets the fill style of the brush, used to fill shapes. |
void |
setBrushHatch(int hatch)
Sets the hatch style of the brush, used to fill shapes. |
void |
setBrushPattern(java.awt.Image pattern)
Sets the bitmap of the pattern brush, used to fill shapes. |
void |
setClip(int x,
int y,
int width,
int height)
See Graphics |
void |
setClip(java.awt.Shape clipshape)
See Graphics |
void |
setColor(java.awt.Color newcolor)
See Graphics. |
void |
setFont(java.awt.Font newfont)
See Graphics. |
void |
setFontEscapement(int escapement)
Sets the escapement(rotation) of the font, used to draw text. |
int |
setGDIFillBrush()
Creates and selects a new fill brush with the current fill style, hatch style, pattern and foreground color. |
int |
setGDIFont()
Creates and selects a new font with the current Font and escapement. |
int |
setGDIHollowBrush()
Creates and selects a new hollow brush with the current foreground color. |
int |
setGDIPen()
Creates and selects a new pen with the current pen style, width and foreground color. |
void |
setPaintMode()
Not supported. |
void |
setPenStyle(int style)
Sets the style of the pen, used to draw lines. |
void |
setPenWidth(int width)
Sets the width of the pen, used to draw lines. |
void |
setWMF(WMF newwmf,
int width,
int height)
Sets a new WMF object. |
void |
setXORMode(java.awt.Color c1)
Not supported. |
void |
translate(int x,
int y)
See Graphics. |
Methods inherited from class java.awt.Graphics |
create, draw3DRect, drawBytes, drawChars, drawPolygon, fill3DRect, fillPolygon, finalize, getClipBounds, getFontMetrics, hitClip, toString |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public WMFGraphics(WMF wmf, int width, int height)
WMF
object in which the Windows metafile commands
are written and the extent the metafile will have. setWindowOrg, setWindowExt, setBKMode, ...
)
It creates and selects three GDI Objects: a Pen, a Brush and a Font
with black fore- and white background color.
wmf
- The WMF object to write the metafile intowidth
- The width of the metafile extentheight
- The height of the metafile extentWMF
public WMFGraphics(WMF wmf, int width, int height, java.awt.Color foreground, java.awt.Color background)
WMF
object in which the Windows metafile commands
are written and the extent the metafile will have. setWindowOrg, setWindowExt, setBKMode, ...
)
It creates and selects three GDI Objects: a Pen, a Brush and a Font
with the specified fore- and background color.
wmf
- The WMF object to write the metafile intowidth
- The width of the metafile extentheight
- The height of the metafile extentforeground
- The foreground colorbackground
- The background colorWMF
Method Detail |
public void reset()
WMF.PS_Solid/code>, its width is set to 1
(one pixel wide lines). The brush fill style is set to
WMF.BS_Solid/code>, the brush hatch style to
WMF.HS_Horizontal/code>. The font escapement is set to 0.
- See Also:
WMF
public void restoreState()
public void setPenStyle(int style)
style
- One of the WMF.PS_XXX constants.getPenStyle()
,
WMF
public int getPenStyle()
setPenStyle(int)
public void setPenWidth(int width)
width
- The new pen width (0 means always 1 pixel wide).getPenWidth()
public int getPenWidth()
setPenWidth(int)
public void setBrushFillStyle(int style)
style
- One of the WMF.BS_XXX constants.getBrushFillStyle()
,
WMF
public int getBrushFillStyle()
setBrushFillStyle(int)
public void setBrushHatch(int hatch)
hatch
- One of the WMF.HS_XXX constants.getBrushHatch()
,
WMF
public int getBrushHatch()
setBrushHatch(int)
public void setBrushPattern(java.awt.Image pattern)
pattern
- The bitmap of the pattern. Must have at least 8x8 pixels.getBrushPattern()
,
WMF
public java.awt.Image getBrushPattern()
setBrushPattern(java.awt.Image)
public void setFontEscapement(int escapement)
escapement
- The new escapement (in tenth of degrees).getFontEscapement()
public int getFontEscapement()
setFontEscapement(int)
public void createWMFHandles()
WMF
public void setWMF(WMF newwmf, int width, int height)
newwmf
- The new WMF object.getWMF()
,
WMF
public WMF getWMF()
setWMF(com.pietjonas.wmfwriter2d.WMF, int, int)
,
WMF
public int setGDIPen()
WMF
public int setGDIHollowBrush()
WMF
public int setGDIFillBrush()
WMF
public int setGDIFont()
WMF
public void deleteGDIObjects()
public void GDIPolyPolygon(java.awt.Polygon[] polys)
polys
- Array of java.awt.PolygonWMF.polypolygon(java.awt.Polygon[])
public void clearRect(int x, int y, int width, int height)
Graphics
public void copyArea(int x, int y, int width, int height, int dx, int dy)
Graphics
public java.awt.Graphics create()
Graphics
public void dispose()
Graphics
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Graphics
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
Graphics
public boolean drawImage(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)
Graphics
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
Graphics
public boolean drawImage(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)
Graphics
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)
Graphics
public boolean drawImage(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)
Graphics
public void drawLine(int x1, int y1, int x2, int y2)
Graphics
public void drawOval(int x, int y, int width, int height)
Graphics
public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
Graphics
public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
Graphics
public void drawRect(int x, int y, int width, int height)
Graphics
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Graphics
public void drawString(java.lang.String str, int x, int y)
Graphics
public void drawString(java.text.AttributedCharacterIterator text, int x, int y)
Graphics
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Graphics
public void fillOval(int x, int y, int width, int height)
Graphics
public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
Graphics
public void fillRect(int x, int y, int width, int height)
Graphics
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Graphics
public void clipRect(int x, int y, int width, int height)
Graphics
public java.awt.Shape getClip()
Graphics
public java.awt.Rectangle getClipRect()
Graphics
public java.awt.Rectangle getClipBounds()
Graphics
public void setClip(int x, int y, int width, int height)
Graphics
public void setClip(java.awt.Shape clipshape)
Graphics
public java.awt.Color getColor()
Graphics
public java.awt.Font getFont()
Graphics
public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
Graphics
public void setColor(java.awt.Color newcolor)
Graphics
public void setFont(java.awt.Font newfont)
Graphics
public void setPaintMode()
Graphics
public void setXORMode(java.awt.Color c1)
Graphics
public void translate(int x, int y)
Graphics
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |