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
ConstructorsModifierConstructorDescriptionprotectedConstructor 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 TypeMethodDescriptionvoidaddRenderingHints(Map hints) See Graphics2D.voidclearRect(int x, int y, int width, int height) See Graphics2D.voidSee Graphics2D.voidclipRect(int x, int y, int width, int height) See Graphics2D.voidcopyArea(int x, int y, int width, int height, int dx, int dy) See Graphics2D.create()See Graphics2D.voiddispose()See Graphics2D.voidSee Graphics2D.voiddrawArc(int x, int y, int width, int height, int startAngle, int arcAngle) See Graphics2D.voiddrawGlyphVector(GlyphVector g, float x, float y) See Graphics2D.voiddrawImage(BufferedImage img, BufferedImageOp op, int x, int y) See Graphics2D.booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) See Graphics2D.booleandrawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) See Graphics2D.booleandrawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) See Graphics2D.booleandrawImage(Image img, int x, int y, int width, int height, ImageObserver observer) See Graphics2D.booleandrawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) See Graphics2D.booleandrawImage(Image img, int x, int y, ImageObserver observer) See Graphics2D.booleandrawImage(Image img, AffineTransform xform, ImageObserver obs) See Graphics2D.voiddrawLine(int x1, int y1, int x2, int y2) See Graphics2D.voiddrawOval(int x, int y, int width, int height) See Graphics2D.voiddrawPolygon(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.voiddrawPolyline(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.voiddrawRect(int x, int y, int width, int height) See Graphics2D.voiddrawRenderableImage(RenderableImage img, AffineTransform xform) See Graphics2D.voiddrawRenderedImage(RenderedImage img, AffineTransform xform) See Graphics2D.voiddrawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) See Graphics2D.voiddrawString(String s, float x, float y) See Graphics2D.voiddrawString(String str, int x, int y) See Graphics2D.voiddrawString(AttributedCharacterIterator iterator, float x, float y) See Graphics2D.voiddrawString(AttributedCharacterIterator iterator, int x, int y) See Graphics2D.voidSee Graphics2D.voidfillArc(int x, int y, int width, int height, int startAngle, int arcAngle) See Graphics2D.voidfillOval(int x, int y, int width, int height) See Graphics2D.voidfillPolygon(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.voidfillRect(int x, int y, int width, int height) See Graphics2D.voidfillRoundRect(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.doublegetFont()See Graphics2D.See Graphics2D.See Graphics2D.getPaint()See Graphics2D.See Graphics2D.See Graphics2D.See Graphics2D.See Graphics2D.booleanSee Graphics2D.booleanIndicates the use of the native GDI font drawing mechanism.booleanIndicates the use of the native GDI pen drawing mechanism.booleanIndicates the use of the native GDI pen width drawing.voidrotate(double theta) See Graphics2D.voidrotate(double theta, double x, double y) See Graphics2D.voidscale(double sx, double sy) See Graphics2D.voidsetBackground(Color color) See Graphics2D.voidsetClip(int x, int y, int width, int height) See Graphics2D.voidSets the clip attribute of the WMFGraphics2D objectvoidSee Graphics2D.voidsetComposite(Composite comp) See Graphics2D.voidsetFlatness(double flatness) Sets the number of polygons produced for drawing curved shapes.voidSee Graphics2D.voidsetGDIFontDrawing(boolean gdifontdrawing) Sets the use of the native GDI font drawing mechanism.voidsetGDIPenDrawing(boolean gdipendrawing) Sets the use of the native GDI pen drawing mechanism for java.awt.Shape outlines.voidsetGDIPenWidthDrawing(boolean gdipenwidthdrawing) Sets the use of width for the native GDI pen drawing (isGDIPenDrawing()must be true).voidSee Graphics2D.voidSee Graphics2D.voidsetRenderingHint(RenderingHints.Key key, Object hintValue) See Graphics2D.voidsetRenderingHints(Map hints) See Graphics2D.voidSee Graphics2D.voidSee Graphics2D.voidsetXORMode(Color color) See Graphics2D.voidshear(double shx, double shy) See Graphics2D.voidSee Graphics2D.voidtranslate(double tx, double ty) See Graphics2D.voidtranslate(int x, int y) See Graphics2D.Methods inherited from class java.awt.Graphics2D
draw3DRect, fill3DRectMethods 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 aWMFobject 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 aWMFobject 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:
getRenderingHintsin 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:
fillRoundRectin 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:
clipin classGraphics2D- Parameters:
s- Description of the Parameter- See Also:
-
setPaintMode
public void setPaintMode()See Graphics2D.- Specified by:
setPaintModein classGraphics- See Also:
-
hit
See Graphics2D.- Specified by:
hitin 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:
drawImagein 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:
getFontRenderContextin classGraphics2D- Returns:
- The fontRenderContext value
- See Also:
-
getDeviceConfiguration
See Graphics2D.- Specified by:
getDeviceConfigurationin classGraphics2D- Returns:
- The deviceConfiguration value
- See Also:
-
getColor
See Graphics2D. -
getComposite
See Graphics2D.- Specified by:
getCompositein classGraphics2D- Returns:
- The composite value
- See Also:
-
getPaint
See Graphics2D.- Specified by:
getPaintin classGraphics2D- Returns:
- The paint value
- See Also:
-
drawRenderedImage
See Graphics2D.- Specified by:
drawRenderedImagein 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:
setTransformin 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:
drawRoundRectin 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:
setBackgroundin 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:
getStrokein classGraphics2D- Returns:
- The stroke value
- See Also:
-
fillPolygon
public void fillPolygon(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.- Specified by:
fillPolygonin classGraphics- Parameters:
xpoints- Description of the Parameterypoints- Description of the Parameternpoints- Description of the Parameter- See Also:
-
setRenderingHint
See Graphics2D.- Specified by:
setRenderingHintin 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:
drawImagein 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:
setPaintin 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:
setStrokein classGraphics2D- Parameters:
s- The new stroke value- See Also:
-
drawPolygon
public void drawPolygon(int[] xpoints, int[] ypoints, int npoints) See Graphics2D.- Specified by:
drawPolygonin classGraphics- Parameters:
xpoints- Description of the Parameterypoints- Description of the Parameternpoints- Description of the Parameter- See Also:
-
drawString
See Graphics2D.- Specified by:
drawStringin 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:
drawPolylinein classGraphics- Parameters:
xpoints- Description of the Parameterypoints- Description of the Parameternpoints- Description of the Parameter- See Also:
-
drawString
See Graphics2D.- Specified by:
drawStringin 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:
drawRenderableImagein 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:
rotatein classGraphics2D- Parameters:
theta- Description of the Parameterx- Description of the Parametery- Description of the Parameter- See Also:
-
transform
See Graphics2D.- Specified by:
transformin 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:
getRenderingHintin classGraphics2D- Parameters:
key- Description of the Parameter- Returns:
- The renderingHint value
- See Also:
-
drawImage
See Graphics2D.- Specified by:
drawImagein 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:
setRenderingHintsin classGraphics2D- Parameters:
hints- The new renderingHints value- See Also:
-
translate
public void translate(int x, int y) See Graphics2D.- Specified by:
translatein classGraphics2D- Parameters:
x- Description of the Parametery- Description of the Parameter- See Also:
-
setXORMode
See Graphics2D.- Specified by:
setXORModein classGraphics- Parameters:
color- The new xORMode value- See Also:
-
getClipBounds
See Graphics2D.- Specified by:
getClipBoundsin classGraphics- Returns:
- The clipBounds value
- See Also:
-
drawString
See Graphics2D.- Specified by:
drawStringin classGraphics2D- Parameters:
iterator- Description of the Parameterx- Description of the Parametery- Description of the Parameter- See Also:
-
addRenderingHints
See Graphics2D.- Specified by:
addRenderingHintsin classGraphics2D- Parameters:
hints- The feature to be added to the RenderingHints attribute- See Also:
-
getBackground
See Graphics2D.- Specified by:
getBackgroundin classGraphics2D- Returns:
- The background value
- See Also:
-
translate
public void translate(double tx, double ty) See Graphics2D.- Specified by:
translatein classGraphics2D- Parameters:
tx- Description of the Parameterty- Description of the Parameter- See Also:
-
fill
See Graphics2D.- Specified by:
fillin classGraphics2D- Parameters:
s- Description of the Parameter- See Also:
-
getClip
See Graphics2D. -
drawImage
See Graphics2D. -
drawGlyphVector
See Graphics2D.- Specified by:
drawGlyphVectorin classGraphics2D- Parameters:
g- Description of the Parameterx- Description of the Parametery- Description of the Parameter- See Also:
-
setComposite
See Graphics2D.- Specified by:
setCompositein classGraphics2D- Parameters:
comp- The new composite value- See Also:
-
scale
public void scale(double sx, double sy) See Graphics2D.- Specified by:
scalein 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:
getFontMetricsin classGraphics- Parameters:
f- Description of the Parameter- Returns:
- The fontMetrics value
- See Also:
-
drawImage
See Graphics2D.- Specified by:
drawImagein 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:
rotatein classGraphics2D- Parameters:
theta- Description of the Parameter- See Also:
-
draw
See Graphics2D.- Specified by:
drawin classGraphics2D- Parameters:
s- Description of the Parameter- See Also:
-
drawString
See Graphics2D.- Specified by:
drawStringin 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:
drawImagein 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:
getTransformin classGraphics2D- Returns:
- The transform value
- See Also:
-
drawImage
See Graphics2D.- Specified by:
drawImagein 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:
shearin classGraphics2D- Parameters:
shx- Description of the Parametershy- Description of the Parameter- See Also:
-