Package rma.util.wmf
Class WMFGraphics2D
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
rma.util.wmf.WMFGraphics2D
- Direct Known Subclasses:
G2dWMFGraphics2D
A class for writing into Windows Metafiles with java.awt.Graphics2D methods.
Usage is simple. Construct a WMFGraphics2D object with a WMF object
Usage is simple. Construct a WMFGraphics2D 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); ...Almost all features of the Java2D are supported. WMFGraphics2D is compatible with JDK 1.2 and above
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor for the WMFGraphics2D objectWMFGraphics2D
(WMF wmf, int width, int height) Constructs a WMFGraphics2D object.WMFGraphics2D
(WMF wmf, int width, int height, Color foreground, Color background) Constructs a WMFGraphics object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRenderingHints
(Map hints) See Graphics2D.void
clearRect
(int x, int y, int width, int height) See Graphics2D.void
See Graphics2D.void
clipRect
(int x, int y, int width, int height) See Graphics2D.void
copyArea
(int x, int y, int width, int height, int dx, int dy) See Graphics2D.create()
See Graphics2D.void
dispose()
See Graphics2D.void
See Graphics2D.void
drawArc
(int x, int y, int width, int height, int startAngle, int arcAngle) See Graphics2D.void
drawGlyphVector
(GlyphVector g, float x, float y) See Graphics2D.void
drawImage
(BufferedImage img, BufferedImageOp op, int x, int y) See Graphics2D.boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) See Graphics2D.boolean
drawImage
(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) See Graphics2D.boolean
drawImage
(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) See Graphics2D.boolean
drawImage
(Image img, int x, int y, int width, int height, ImageObserver observer) See Graphics2D.boolean
drawImage
(Image img, int x, int y, Color bgcolor, ImageObserver observer) See Graphics2D.boolean
drawImage
(Image img, int x, int y, ImageObserver observer) See Graphics2D.boolean
drawImage
(Image img, AffineTransform xform, ImageObserver obs) See Graphics2D.void
drawLine
(int x1, int y1, int x2, int y2) See Graphics2D.void
drawOval
(int x, int y, int width, int height) See Graphics2D.void
drawPolygon
(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.void
drawPolyline
(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.void
drawRect
(int x, int y, int width, int height) See Graphics2D.void
drawRenderableImage
(RenderableImage img, AffineTransform xform) See Graphics2D.void
drawRenderedImage
(RenderedImage img, AffineTransform xform) See Graphics2D.void
drawRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) See Graphics2D.void
drawString
(String s, float x, float y) See Graphics2D.void
drawString
(String str, int x, int y) See Graphics2D.void
drawString
(AttributedCharacterIterator iterator, float x, float y) See Graphics2D.void
drawString
(AttributedCharacterIterator iterator, int x, int y) See Graphics2D.void
See Graphics2D.void
fillArc
(int x, int y, int width, int height, int startAngle, int arcAngle) See Graphics2D.void
fillOval
(int x, int y, int width, int height) See Graphics2D.void
fillPolygon
(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.void
fillRect
(int x, int y, int width, int height) See Graphics2D.void
fillRoundRect
(int x, int y, int width, int height, int arcWidth, int arcHeight) See Graphics2D.See Graphics2D.getClip()
See Graphics2D.See Graphics2D.getColor()
See Graphics2D.See Graphics2D.See Graphics2D.double
getFont()
See Graphics2D.See Graphics2D.See Graphics2D.getPaint()
See Graphics2D.See Graphics2D.See Graphics2D.See Graphics2D.See Graphics2D.boolean
See Graphics2D.boolean
Indicates the use of the native GDI font drawing mechanism.boolean
Indicates the use of the native GDI pen drawing mechanism.boolean
Indicates the use of the native GDI pen width drawing.void
rotate
(double theta) See Graphics2D.void
rotate
(double theta, double x, double y) See Graphics2D.void
scale
(double sx, double sy) See Graphics2D.void
setBackground
(Color color) See Graphics2D.void
setClip
(int x, int y, int width, int height) See Graphics2D.void
Sets the clip attribute of the WMFGraphics2D objectvoid
See Graphics2D.void
setComposite
(Composite comp) See Graphics2D.void
setFlatness
(double flatness) Sets the number of polygons produced for drawing curved shapes.void
See Graphics2D.void
setGDIFontDrawing
(boolean gdifontdrawing) Sets the use of the native GDI font drawing mechanism.void
setGDIPenDrawing
(boolean gdipendrawing) Sets the use of the native GDI pen drawing mechanism for java.awt.Shape outlines.void
setGDIPenWidthDrawing
(boolean gdipenwidthdrawing) Sets the use of width for the native GDI pen drawing (isGDIPenDrawing()
must be true).void
See Graphics2D.void
See Graphics2D.void
setRenderingHint
(RenderingHints.Key key, Object hintValue) See Graphics2D.void
setRenderingHints
(Map hints) See Graphics2D.void
See Graphics2D.void
See Graphics2D.void
setXORMode
(Color color) See Graphics2D.void
shear
(double shx, double shy) See Graphics2D.void
See Graphics2D.void
translate
(double tx, double ty) See Graphics2D.void
translate
(int x, int y) See Graphics2D.Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRect
Methods inherited from class java.awt.Graphics
create, drawBytes, drawChars, drawPolygon, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
-
Constructor Details
-
WMFGraphics2D
Constructs a WMFGraphics2D object. Expects aWMF
object in which the Windows metafile commands are written and the extent the metafile will have.
It writes some GDI commands to the Windows Metafile to setup a standard environment (setWindowOrg, setWindowExt, setBKMode, ...
) It creates and selects three GDI Objects: a Pen, a Brush and a Font with black fore- and white background color.- Parameters:
wmf
- The WMF object to write the metafile intowidth
- The width of the metafile extentheight
- The height of the metafile extent- See Also:
-
WMFGraphics2D
Constructs a WMFGraphics object. Expects aWMF
object in which the Windows metafile commands are written and the extent the metafile will have.
It writes some GDI commands to the Windows Metafile to setup a standard environment (setWindowOrg, setWindowExt, setBKMode, ...
) It creates and selects three GDI Objects: a Pen, a Brush and a Font with the specified fore- and background color.- Parameters:
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 color- See Also:
-
WMFGraphics2D
Constructor for the WMFGraphics2D object- Parameters:
g
- Description of the Parameter
-
-
Method Details
-
setGDIFontDrawing
public void setGDIFontDrawing(boolean gdifontdrawing) Sets the use of the native GDI font drawing mechanism. GDI fonts are used if the current transformation is identity, the current java.awt.Paint is instance of java.awt.Color, the font transformation is identity, there is no clip. GDI fonts lead to smaller WMF, faster replay and better font quality but can produce slightly different appearence.- Parameters:
gdifontdrawing
- Whether to use GDI fonts
-
isGDIFontDrawing
public boolean isGDIFontDrawing()Indicates the use of the native GDI font drawing mechanism.- Returns:
- True if the GDI mechanism is used
-
setGDIPenDrawing
public void setGDIPenDrawing(boolean gdipendrawing) Sets the use of the native GDI pen drawing mechanism for java.awt.Shape outlines. GDI pens are used if the current java.awt.Stroke is instance of java.awt.BasicStroke with no or empty dash array, the current java.awt.Paint is instance of java.awt.Color. GDI pens lead to smaller WMF, faster replay and better drawing quality but can produce slightly different appearence (joins, end caps).- Parameters:
gdipendrawing
- Whether to use GDI pens- See Also:
-
isGDIPenDrawing
public boolean isGDIPenDrawing()Indicates the use of the native GDI pen drawing mechanism.- Returns:
- True if the GDI mechanism is used
-
setGDIPenWidthDrawing
public void setGDIPenWidthDrawing(boolean gdipenwidthdrawing) Sets the use of width for the native GDI pen drawing (isGDIPenDrawing()
must be true). GDI pens are used with the width indicated by the current java.awt.BasicStroke instance. If set to false, a GDI pen with width 0 is used plus line filling by the java.awt.Stroke object. GDI pens with native width lead to smaller WMF, faster replay and better drawing quality but can produce slightly different appearence (joins, end caps).- Parameters:
gdipenwidthdrawing
- Whether to use GDI pen width- See Also:
-
isGDIPenWidthDrawing
public boolean isGDIPenWidthDrawing()Indicates the use of the native GDI pen width drawing.- Returns:
- True if the GDI pen width is used
-
setFlatness
public void setFlatness(double flatness) Sets the number of polygons produced for drawing curved shapes. A smaller flatness parameter means a higher number of polygons which leads to better drawing quality but bigger WMF.- Parameters:
flatness
- The flatness parameter
-
getFlatness
public double getFlatness()- Returns:
- The current flatness parameter
-
getRenderingHints
See Graphics2D.- Specified by:
getRenderingHints
in classGraphics2D
- Returns:
- The renderingHints value
- See Also:
-
create
See Graphics2D. -
getFont
See Graphics2D. -
fillRoundRect
public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) See Graphics2D.- Specified by:
fillRoundRect
in classGraphics
- Parameters:
x
- Description of the Parametery
- Description of the Parameterwidth
- Description of the Parameterheight
- Description of the ParameterarcWidth
- Description of the ParameterarcHeight
- Description of the Parameter- See Also:
-
clip
See Graphics2D.- Specified by:
clip
in classGraphics2D
- Parameters:
s
- Description of the Parameter- See Also:
-
setPaintMode
public void setPaintMode()See Graphics2D.- Specified by:
setPaintMode
in classGraphics
- See Also:
-
hit
See Graphics2D.- Specified by:
hit
in classGraphics2D
- Parameters:
rect
- Description of the Parameters
- Description of the ParameteronStroke
- Description of the Parameter- Returns:
- Description of the Return Value
- See Also:
-
drawImage
public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) See Graphics2D.- Specified by:
drawImage
in classGraphics
- Parameters:
img
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameterwidth
- Description of the Parameterheight
- Description of the Parameterbgcolor
- Description of the Parameterobserver
- Description of the Parameter- Returns:
- Description of the Return Value
- See Also:
-
getFontRenderContext
See Graphics2D.- Specified by:
getFontRenderContext
in classGraphics2D
- Returns:
- The fontRenderContext value
- See Also:
-
getDeviceConfiguration
See Graphics2D.- Specified by:
getDeviceConfiguration
in classGraphics2D
- Returns:
- The deviceConfiguration value
- See Also:
-
getColor
See Graphics2D. -
getComposite
See Graphics2D.- Specified by:
getComposite
in classGraphics2D
- Returns:
- The composite value
- See Also:
-
getPaint
See Graphics2D.- Specified by:
getPaint
in classGraphics2D
- Returns:
- The paint value
- See Also:
-
drawRenderedImage
See Graphics2D.- Specified by:
drawRenderedImage
in classGraphics2D
- Parameters:
img
- Description of the Parameterxform
- Description of the Parameter- See Also:
-
setClip
Sets the clip attribute of the WMFGraphics2D object -
setTransform
See Graphics2D.- Specified by:
setTransform
in classGraphics2D
- Parameters:
Tx
- The new transform value- See Also:
-
drawRoundRect
public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) See Graphics2D.- Specified by:
drawRoundRect
in classGraphics
- Parameters:
x
- Description of the Parametery
- Description of the Parameterwidth
- Description of the Parameterheight
- Description of the ParameterarcWidth
- Description of the ParameterarcHeight
- Description of the Parameter- See Also:
-
drawArc
public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) See Graphics2D. -
setBackground
See Graphics2D.- Specified by:
setBackground
in classGraphics2D
- Parameters:
color
- The new background value- See Also:
-
fillArc
public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) See Graphics2D. -
getStroke
See Graphics2D.- Specified by:
getStroke
in classGraphics2D
- Returns:
- The stroke value
- See Also:
-
fillPolygon
public void fillPolygon(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.- Specified by:
fillPolygon
in classGraphics
- Parameters:
xpoints
- Description of the Parameterypoints
- Description of the Parameternpoints
- Description of the Parameter- See Also:
-
setRenderingHint
See Graphics2D.- Specified by:
setRenderingHint
in classGraphics2D
- Parameters:
key
- The new renderingHint valuehintValue
- The new renderingHint value- See Also:
-
clipRect
public void clipRect(int x, int y, int width, int height) See Graphics2D. -
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) See Graphics2D.- Specified by:
drawImage
in classGraphics
- Parameters:
img
- Description of the Parameterdx1
- Description of the Parameterdy1
- Description of the Parameterdx2
- Description of the Parameterdy2
- Description of the Parametersx1
- Description of the Parametersy1
- Description of the Parametersx2
- Description of the Parametersy2
- Description of the Parameterbgcolor
- Description of the Parameterobserver
- Description of the Parameter- Returns:
- Description of the Return Value
- See Also:
-
drawOval
public void drawOval(int x, int y, int width, int height) See Graphics2D. -
setFont
See Graphics2D. -
setPaint
See Graphics2D.- Specified by:
setPaint
in classGraphics2D
- Parameters:
paint
- The new paint value- See Also:
-
copyArea
public void copyArea(int x, int y, int width, int height, int dx, int dy) See Graphics2D. -
setStroke
See Graphics2D.- Specified by:
setStroke
in classGraphics2D
- Parameters:
s
- The new stroke value- See Also:
-
drawPolygon
public void drawPolygon(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.- Specified by:
drawPolygon
in classGraphics
- Parameters:
xpoints
- Description of the Parameterypoints
- Description of the Parameternpoints
- Description of the Parameter- See Also:
-
drawString
See Graphics2D.- Specified by:
drawString
in classGraphics2D
- Parameters:
iterator
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameter- See Also:
-
drawPolyline
public void drawPolyline(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.- Specified by:
drawPolyline
in classGraphics
- Parameters:
xpoints
- Description of the Parameterypoints
- Description of the Parameternpoints
- Description of the Parameter- See Also:
-
drawString
See Graphics2D.- Specified by:
drawString
in classGraphics2D
- Parameters:
str
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameter- See Also:
-
drawLine
public void drawLine(int x1, int y1, int x2, int y2) See Graphics2D. -
drawRect
public void drawRect(int x, int y, int width, int height) See Graphics2D. -
dispose
public void dispose()See Graphics2D. -
setClip
public void setClip(int x, int y, int width, int height) See Graphics2D. -
drawRenderableImage
See Graphics2D.- Specified by:
drawRenderableImage
in classGraphics2D
- Parameters:
img
- Description of the Parameterxform
- Description of the Parameter- See Also:
-
drawImage
See Graphics2D. -
rotate
public void rotate(double theta, double x, double y) See Graphics2D.- Specified by:
rotate
in classGraphics2D
- Parameters:
theta
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameter- See Also:
-
transform
See Graphics2D.- Specified by:
transform
in classGraphics2D
- Parameters:
Tx
- Description of the Parameter- See Also:
-
clearRect
public void clearRect(int x, int y, int width, int height) See Graphics2D. -
setColor
See Graphics2D. -
getRenderingHint
See Graphics2D.- Specified by:
getRenderingHint
in classGraphics2D
- Parameters:
key
- Description of the Parameter- Returns:
- The renderingHint value
- See Also:
-
drawImage
See Graphics2D.- Specified by:
drawImage
in classGraphics
- Parameters:
img
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameterwidth
- Description of the Parameterheight
- Description of the Parameterobserver
- Description of the Parameter- Returns:
- Description of the Return Value
- See Also:
-
setRenderingHints
See Graphics2D.- Specified by:
setRenderingHints
in classGraphics2D
- Parameters:
hints
- The new renderingHints value- See Also:
-
translate
public void translate(int x, int y) See Graphics2D.- Specified by:
translate
in classGraphics2D
- Parameters:
x
- Description of the Parametery
- Description of the Parameter- See Also:
-
setXORMode
See Graphics2D.- Specified by:
setXORMode
in classGraphics
- Parameters:
color
- The new xORMode value- See Also:
-
getClipBounds
See Graphics2D.- Specified by:
getClipBounds
in classGraphics
- Returns:
- The clipBounds value
- See Also:
-
drawString
See Graphics2D.- Specified by:
drawString
in classGraphics2D
- Parameters:
iterator
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameter- See Also:
-
addRenderingHints
See Graphics2D.- Specified by:
addRenderingHints
in classGraphics2D
- Parameters:
hints
- The feature to be added to the RenderingHints attribute- See Also:
-
getBackground
See Graphics2D.- Specified by:
getBackground
in classGraphics2D
- Returns:
- The background value
- See Also:
-
translate
public void translate(double tx, double ty) See Graphics2D.- Specified by:
translate
in classGraphics2D
- Parameters:
tx
- Description of the Parameterty
- Description of the Parameter- See Also:
-
fill
See Graphics2D.- Specified by:
fill
in classGraphics2D
- Parameters:
s
- Description of the Parameter- See Also:
-
getClip
See Graphics2D. -
drawImage
See Graphics2D. -
drawGlyphVector
See Graphics2D.- Specified by:
drawGlyphVector
in classGraphics2D
- Parameters:
g
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameter- See Also:
-
setComposite
See Graphics2D.- Specified by:
setComposite
in classGraphics2D
- Parameters:
comp
- The new composite value- See Also:
-
scale
public void scale(double sx, double sy) See Graphics2D.- Specified by:
scale
in classGraphics2D
- Parameters:
sx
- Description of the Parametersy
- Description of the Parameter- See Also:
-
fillOval
public void fillOval(int x, int y, int width, int height) See Graphics2D. -
fillRect
public void fillRect(int x, int y, int width, int height) See Graphics2D. -
getFontMetrics
See Graphics2D.- Specified by:
getFontMetrics
in classGraphics
- Parameters:
f
- Description of the Parameter- Returns:
- The fontMetrics value
- See Also:
-
drawImage
See Graphics2D.- Specified by:
drawImage
in classGraphics2D
- Parameters:
img
- Description of the Parameterxform
- Description of the Parameterobs
- Description of the Parameter- Returns:
- Description of the Return Value
- See Also:
-
rotate
public void rotate(double theta) See Graphics2D.- Specified by:
rotate
in classGraphics2D
- Parameters:
theta
- Description of the Parameter- See Also:
-
draw
See Graphics2D.- Specified by:
draw
in classGraphics2D
- Parameters:
s
- Description of the Parameter- See Also:
-
drawString
See Graphics2D.- Specified by:
drawString
in classGraphics2D
- Parameters:
s
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameter- See Also:
-
drawImage
public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) See Graphics2D.- Specified by:
drawImage
in classGraphics
- Parameters:
img
- Description of the Parameterdx1
- Description of the Parameterdy1
- Description of the Parameterdx2
- Description of the Parameterdy2
- Description of the Parametersx1
- Description of the Parametersy1
- Description of the Parametersx2
- Description of the Parametersy2
- Description of the Parameterobserver
- Description of the Parameter- Returns:
- Description of the Return Value
- See Also:
-
getTransform
See Graphics2D.- Specified by:
getTransform
in classGraphics2D
- Returns:
- The transform value
- See Also:
-
drawImage
See Graphics2D.- Specified by:
drawImage
in classGraphics2D
- Parameters:
img
- Description of the Parameterop
- Description of the Parameterx
- Description of the Parametery
- Description of the Parameter- See Also:
-
shear
public void shear(double shx, double shy) See Graphics2D.- Specified by:
shear
in classGraphics2D
- Parameters:
shx
- Description of the Parametershy
- Description of the Parameter- See Also:
-