|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.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, its width is set to 1
(one pixel wide lines). The brush fill style is set to
WMF.BS_Solid, the brush hatch style to
WMF.HS_Horizontal. The font escapement is set to 0.
- See Also:
WMF
restoreState
public void restoreState()
- Restores internal WMFGraphics settings in WMF which have been
changed by copies (Graphics.create()) of this Graphics object.
setPenStyle
public void setPenStyle(int style)
- Sets the style of the pen, used to draw lines.
- Parameters:
style
- One of the WMF.PS_XXX constants.- See Also:
getPenStyle()
,
WMF
getPenStyle
public int getPenStyle()
- Returns the current style of the pen, used to draw lines.
- Returns:
- The current style.
- See Also:
setPenStyle(int)
setPenWidth
public void setPenWidth(int width)
- Sets the width of the pen, used to draw lines.
- Parameters:
width
- The new pen width (0 means always 1 pixel wide).- See Also:
getPenWidth()
getPenWidth
public int getPenWidth()
- Returns the current width of the pen, used to draw lines.
- Returns:
- The current width.
- See Also:
setPenWidth(int)
setBrushFillStyle
public void setBrushFillStyle(int style)
- Sets the fill style of the brush, used to fill shapes.
- Parameters:
style
- One of the WMF.BS_XXX constants.- See Also:
getBrushFillStyle()
,
WMF
getBrushFillStyle
public int getBrushFillStyle()
- Returns the current fill style of the brush, used to fill shapes.
- Returns:
- The current fill style.
- See Also:
setBrushFillStyle(int)
setBrushHatch
public void setBrushHatch(int hatch)
- Sets the hatch style of the brush, used to fill shapes.
- Parameters:
hatch
- One of the WMF.HS_XXX constants.- See Also:
getBrushHatch()
,
WMF
getBrushHatch
public int getBrushHatch()
- Returns the current hatch style of the brush, used to fill shapes.
- Returns:
- The current hatch style.
- See Also:
setBrushHatch(int)
setBrushPattern
public void setBrushPattern(java.awt.Image pattern)
- Sets the bitmap of the pattern brush, used to fill shapes.
There is no support for transparency.
- Parameters:
pattern
- The bitmap of the pattern. Must have at least 8x8 pixels.- See Also:
getBrushPattern()
,
WMF
getBrushPattern
public java.awt.Image getBrushPattern()
- Returns the bitmap of the pattern brush, used to fill shapes.
- Returns:
- The current bitmap.
- See Also:
setBrushPattern(java.awt.Image)
setFontEscapement
public void setFontEscapement(int escapement)
- Sets the escapement(rotation) of the font, used to draw text.
- Parameters:
escapement
- The new escapement (in tenth of degrees).- See Also:
getFontEscapement()
getFontEscapement
public int getFontEscapement()
- Returns the current escapement of the font, used to draw text.
- Returns:
- The current escapement.
- See Also:
setFontEscapement(int)
createWMFHandles
public void createWMFHandles()
- Creates and selects three GDI Objects:
a Pen, a Brush and a Font with the current styles and fore- and
background color.
- See Also:
WMF
setWMF
public void setWMF(WMF newwmf,
int width,
int height)
- Sets a new WMF object. It creates and selects three GDI Objects:
a Pen, a Brush and a Font with the current styles and fore- and
background color. Sets the standard evironment in the metafile.
- Parameters:
newwmf
- The new WMF object.- See Also:
getWMF()
,
WMF
getWMF
public WMF getWMF()
- Returns the current WMF object.
- Returns:
- The current WMF object.
- See Also:
setWMF(com.pietjonas.wmfwriter2d.WMF, int, int)
,
WMF
setGDIPen
public int setGDIPen()
- Creates and selects a new pen with the current pen style, width and
foreground color. Deletes the old pen.
- Returns:
- The GDI handle of the pen.
- See Also:
WMF
setGDIHollowBrush
public int setGDIHollowBrush()
- Creates and selects a new hollow brush with the current
foreground color. Deletes the old brush.
- Returns:
- The GDI handle of the brush.
- See Also:
WMF
setGDIFillBrush
public int setGDIFillBrush()
- Creates and selects a new fill brush with the current fill style,
hatch style, pattern and
foreground color. Deletes the old brush.
- Returns:
- The GDI handle of the brush.
- See Also:
WMF
setGDIFont
public int setGDIFont()
- Creates and selects a new font with the current Font and escapement.
Deletes the old font.
- Returns:
- The GDI handle of the font.
- See Also:
WMF
deleteGDIObjects
public void deleteGDIObjects()
- Deletes all created GDI objects. Should be the final method call
before writing the metafile to an OutputStream.
GDIPolyPolygon
public void GDIPolyPolygon(java.awt.Polygon[] polys)
- Executes the GDI polypolygon.
- Parameters:
polys
- Array of java.awt.Polygon- See Also:
WMF.polypolygon(java.awt.Polygon[])
clearRect
public void clearRect(int x,
int y,
int width,
int height)
- See Graphics.
- See Also:
Graphics
copyArea
public void copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
- Not supported.
- See Also:
Graphics
create
public java.awt.Graphics create()
- See Also:
Graphics
dispose
public void dispose()
- See Graphics.
- See Also:
Graphics
drawArc
public void drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
- See Graphics.
- See Also:
Graphics
drawImage
public boolean drawImage(java.awt.Image img,
int x,
int y,
java.awt.Color bgcolor,
java.awt.image.ImageObserver observer)
- See Graphics.
- See Also:
Graphics
drawImage
public boolean drawImage(java.awt.Image img,
int x,
int y,
java.awt.image.ImageObserver observer)
- See Graphics.
- See Also:
Graphics
drawImage
public 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.
- See Also:
Graphics
drawImage
public boolean drawImage(java.awt.Image img,
int x,
int y,
int width,
int height,
java.awt.image.ImageObserver observer)
- See Graphics.
- See Also:
Graphics
drawImage
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)
- See Graphics.
- See Also:
Graphics
drawImage
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)
- See Graphics.
- See Also:
Graphics
drawLine
public void drawLine(int x1,
int y1,
int x2,
int y2)
- See Graphics.
- See Also:
Graphics
drawOval
public void drawOval(int x,
int y,
int width,
int height)
- See Graphics.
- See Also:
Graphics
drawPolygon
public void drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
- See Graphics.
- See Also:
Graphics
drawPolyline
public void drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
- See Graphics.
- See Also:
Graphics
drawRect
public void drawRect(int x,
int y,
int width,
int height)
- See Graphics.
- See Also:
Graphics
drawRoundRect
public void drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
- See Graphics.
- See Also:
Graphics
drawString
public void drawString(java.lang.String str,
int x,
int y)
- See Graphics.
- See Also:
Graphics
drawString
public void drawString(java.text.AttributedCharacterIterator text,
int x,
int y)
- Not supported.
- See Also:
Graphics
fillArc
public void fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
- See Graphics.
- See Also:
Graphics
fillOval
public void fillOval(int x,
int y,
int width,
int height)
- See Graphics.
- See Also:
Graphics
fillPolygon
public void fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
- See Graphics.
- See Also:
Graphics
fillRect
public void fillRect(int x,
int y,
int width,
int height)
- See Graphics.
- See Also:
Graphics
fillRoundRect
public void fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
- See Graphics.
- See Also:
Graphics
clipRect
public void clipRect(int x,
int y,
int width,
int height)
- See Graphics.
- See Also:
Graphics
getClip
public java.awt.Shape getClip()
- See Graphics.
- See Also:
Graphics
getClipRect
public java.awt.Rectangle getClipRect()
- See Graphics.
- See Also:
Graphics
getClipBounds
public java.awt.Rectangle getClipBounds()
- See Graphics.
- See Also:
Graphics
setClip
public void setClip(int x,
int y,
int width,
int height)
- See Graphics
- See Also:
Graphics
setClip
public void setClip(java.awt.Shape clipshape)
- See Graphics
- See Also:
Graphics
getColor
public java.awt.Color getColor()
- See Graphics.
- See Also:
Graphics
getFont
public java.awt.Font getFont()
- See Graphics.
- See Also:
Graphics
getFontMetrics
public java.awt.FontMetrics getFontMetrics(java.awt.Font f)
- See Graphics.
- See Also:
Graphics
setColor
public void setColor(java.awt.Color newcolor)
- See Graphics.
- See Also:
Graphics
setFont
public void setFont(java.awt.Font newfont)
- See Graphics.
- See Also:
Graphics
setPaintMode
public void setPaintMode()
- Not supported.
- See Also:
Graphics
setXORMode
public void setXORMode(java.awt.Color c1)
- Not supported.
- See Also:
Graphics
translate
public void translate(int x,
int y)
- See Graphics.
- See Also:
Graphics
Package
Class
Tree
Deprecated
Index
Help
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD