Package rma.util.wmf

Class WMFGraphics2D

Direct Known Subclasses:
G2dWMFGraphics2D

public class WMFGraphics2D extends Graphics2D
A class for writing into Windows Metafiles with java.awt.Graphics2D methods.
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 Details

    • WMFGraphics2D

      public WMFGraphics2D(WMF wmf, int width, int height)
      Constructs a WMFGraphics2D object. Expects a WMF 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 into
      width - The width of the metafile extent
      height - The height of the metafile extent
      See Also:
    • WMFGraphics2D

      public WMFGraphics2D(WMF wmf, int width, int height, Color foreground, Color background)
      Constructs a WMFGraphics object. Expects a WMF 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 into
      width - The width of the metafile extent
      height - The height of the metafile extent
      foreground - The foreground color
      background - The background color
      See Also:
    • WMFGraphics2D

      protected WMFGraphics2D(WMFGraphics2D g)
      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

      public RenderingHints getRenderingHints()
      See Graphics2D.
      Specified by:
      getRenderingHints in class Graphics2D
      Returns:
      The renderingHints value
      See Also:
    • create

      public Graphics create()
      See Graphics2D.
      Specified by:
      create in class Graphics
      Returns:
      Description of the Return Value
      See Also:
    • getFont

      public Font getFont()
      See Graphics2D.
      Specified by:
      getFont in class Graphics
      Returns:
      The font value
      See Also:
    • fillRoundRect

      public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
      See Graphics2D.
      Specified by:
      fillRoundRect in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      arcWidth - Description of the Parameter
      arcHeight - Description of the Parameter
      See Also:
    • clip

      public void clip(Shape s)
      See Graphics2D.
      Specified by:
      clip in class Graphics2D
      Parameters:
      s - Description of the Parameter
      See Also:
    • setPaintMode

      public void setPaintMode()
      See Graphics2D.
      Specified by:
      setPaintMode in class Graphics
      See Also:
    • hit

      public boolean hit(Rectangle rect, Shape s, boolean onStroke)
      See Graphics2D.
      Specified by:
      hit in class Graphics2D
      Parameters:
      rect - Description of the Parameter
      s - Description of the Parameter
      onStroke - 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 class Graphics
      Parameters:
      img - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      bgcolor - Description of the Parameter
      observer - Description of the Parameter
      Returns:
      Description of the Return Value
      See Also:
    • getFontRenderContext

      public FontRenderContext getFontRenderContext()
      See Graphics2D.
      Specified by:
      getFontRenderContext in class Graphics2D
      Returns:
      The fontRenderContext value
      See Also:
    • getDeviceConfiguration

      public GraphicsConfiguration getDeviceConfiguration()
      See Graphics2D.
      Specified by:
      getDeviceConfiguration in class Graphics2D
      Returns:
      The deviceConfiguration value
      See Also:
    • getColor

      public Color getColor()
      See Graphics2D.
      Specified by:
      getColor in class Graphics
      Returns:
      The color value
      See Also:
    • getComposite

      public Composite getComposite()
      See Graphics2D.
      Specified by:
      getComposite in class Graphics2D
      Returns:
      The composite value
      See Also:
    • getPaint

      public Paint getPaint()
      See Graphics2D.
      Specified by:
      getPaint in class Graphics2D
      Returns:
      The paint value
      See Also:
    • drawRenderedImage

      public void drawRenderedImage(RenderedImage img, AffineTransform xform)
      See Graphics2D.
      Specified by:
      drawRenderedImage in class Graphics2D
      Parameters:
      img - Description of the Parameter
      xform - Description of the Parameter
      See Also:
    • setClip

      public void setClip(Shape clip)
      Sets the clip attribute of the WMFGraphics2D object
      Specified by:
      setClip in class Graphics
      Parameters:
      clip - The new clip value
    • setTransform

      public void setTransform(AffineTransform Tx)
      See Graphics2D.
      Specified by:
      setTransform in class Graphics2D
      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 class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      arcWidth - Description of the Parameter
      arcHeight - Description of the Parameter
      See Also:
    • drawArc

      public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
      See Graphics2D.
      Specified by:
      drawArc in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      startAngle - Description of the Parameter
      arcAngle - Description of the Parameter
      See Also:
    • setBackground

      public void setBackground(Color color)
      See Graphics2D.
      Specified by:
      setBackground in class Graphics2D
      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.
      Specified by:
      fillArc in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      startAngle - Description of the Parameter
      arcAngle - Description of the Parameter
      See Also:
    • getStroke

      public Stroke getStroke()
      See Graphics2D.
      Specified by:
      getStroke in class Graphics2D
      Returns:
      The stroke value
      See Also:
    • fillPolygon

      public void fillPolygon(int[] xpoints, int[] ypoints, int npoints)
      See Graphics2D.
      Specified by:
      fillPolygon in class Graphics
      Parameters:
      xpoints - Description of the Parameter
      ypoints - Description of the Parameter
      npoints - Description of the Parameter
      See Also:
    • setRenderingHint

      public void setRenderingHint(RenderingHints.Key key, Object hintValue)
      See Graphics2D.
      Specified by:
      setRenderingHint in class Graphics2D
      Parameters:
      key - The new renderingHint value
      hintValue - The new renderingHint value
      See Also:
    • clipRect

      public void clipRect(int x, int y, int width, int height)
      See Graphics2D.
      Specified by:
      clipRect in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - 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, Color bgcolor, ImageObserver observer)
      See Graphics2D.
      Specified by:
      drawImage in class Graphics
      Parameters:
      img - Description of the Parameter
      dx1 - Description of the Parameter
      dy1 - Description of the Parameter
      dx2 - Description of the Parameter
      dy2 - Description of the Parameter
      sx1 - Description of the Parameter
      sy1 - Description of the Parameter
      sx2 - Description of the Parameter
      sy2 - Description of the Parameter
      bgcolor - Description of the Parameter
      observer - 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.
      Specified by:
      drawOval in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      See Also:
    • setFont

      public void setFont(Font font)
      See Graphics2D.
      Specified by:
      setFont in class Graphics
      Parameters:
      font - The new font value
      See Also:
    • setPaint

      public void setPaint(Paint paint)
      See Graphics2D.
      Specified by:
      setPaint in class Graphics2D
      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.
      Specified by:
      copyArea in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      dx - Description of the Parameter
      dy - Description of the Parameter
      See Also:
    • setStroke

      public void setStroke(Stroke s)
      See Graphics2D.
      Specified by:
      setStroke in class Graphics2D
      Parameters:
      s - The new stroke value
      See Also:
    • drawPolygon

      public void drawPolygon(int[] xpoints, int[] ypoints, int npoints)
      See Graphics2D.
      Specified by:
      drawPolygon in class Graphics
      Parameters:
      xpoints - Description of the Parameter
      ypoints - Description of the Parameter
      npoints - Description of the Parameter
      See Also:
    • drawString

      public void drawString(AttributedCharacterIterator iterator, int x, int y)
      See Graphics2D.
      Specified by:
      drawString in class Graphics2D
      Parameters:
      iterator - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      See Also:
    • drawPolyline

      public void drawPolyline(int[] xpoints, int[] ypoints, int npoints)
      See Graphics2D.
      Specified by:
      drawPolyline in class Graphics
      Parameters:
      xpoints - Description of the Parameter
      ypoints - Description of the Parameter
      npoints - Description of the Parameter
      See Also:
    • drawString

      public void drawString(String str, int x, int y)
      See Graphics2D.
      Specified by:
      drawString in class Graphics2D
      Parameters:
      str - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      See Also:
    • drawLine

      public void drawLine(int x1, int y1, int x2, int y2)
      See Graphics2D.
      Specified by:
      drawLine in class Graphics
      Parameters:
      x1 - Description of the Parameter
      y1 - Description of the Parameter
      x2 - Description of the Parameter
      y2 - Description of the Parameter
      See Also:
    • drawRect

      public void drawRect(int x, int y, int width, int height)
      See Graphics2D.
      Overrides:
      drawRect in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      See Also:
    • dispose

      public void dispose()
      See Graphics2D.
      Specified by:
      dispose in class Graphics
      See Also:
    • setClip

      public void setClip(int x, int y, int width, int height)
      See Graphics2D.
      Specified by:
      setClip in class Graphics
      Parameters:
      x - The new clip value
      y - The new clip value
      width - The new clip value
      height - The new clip value
      See Also:
    • drawRenderableImage

      public void drawRenderableImage(RenderableImage img, AffineTransform xform)
      See Graphics2D.
      Specified by:
      drawRenderableImage in class Graphics2D
      Parameters:
      img - Description of the Parameter
      xform - Description of the Parameter
      See Also:
    • drawImage

      public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
      See Graphics2D.
      Specified by:
      drawImage in class Graphics
      Parameters:
      img - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      bgcolor - Description of the Parameter
      observer - Description of the Parameter
      Returns:
      Description of the Return Value
      See Also:
    • rotate

      public void rotate(double theta, double x, double y)
      See Graphics2D.
      Specified by:
      rotate in class Graphics2D
      Parameters:
      theta - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      See Also:
    • transform

      public void transform(AffineTransform Tx)
      See Graphics2D.
      Specified by:
      transform in class Graphics2D
      Parameters:
      Tx - Description of the Parameter
      See Also:
    • clearRect

      public void clearRect(int x, int y, int width, int height)
      See Graphics2D.
      Specified by:
      clearRect in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      See Also:
    • setColor

      public void setColor(Color c)
      See Graphics2D.
      Specified by:
      setColor in class Graphics
      Parameters:
      c - The new color value
      See Also:
    • getRenderingHint

      public Object getRenderingHint(RenderingHints.Key key)
      See Graphics2D.
      Specified by:
      getRenderingHint in class Graphics2D
      Parameters:
      key - Description of the Parameter
      Returns:
      The renderingHint value
      See Also:
    • drawImage

      public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
      See Graphics2D.
      Specified by:
      drawImage in class Graphics
      Parameters:
      img - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      observer - Description of the Parameter
      Returns:
      Description of the Return Value
      See Also:
    • setRenderingHints

      public void setRenderingHints(Map hints)
      See Graphics2D.
      Specified by:
      setRenderingHints in class Graphics2D
      Parameters:
      hints - The new renderingHints value
      See Also:
    • translate

      public void translate(int x, int y)
      See Graphics2D.
      Specified by:
      translate in class Graphics2D
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      See Also:
    • setXORMode

      public void setXORMode(Color color)
      See Graphics2D.
      Specified by:
      setXORMode in class Graphics
      Parameters:
      color - The new xORMode value
      See Also:
    • getClipBounds

      public Rectangle getClipBounds()
      See Graphics2D.
      Specified by:
      getClipBounds in class Graphics
      Returns:
      The clipBounds value
      See Also:
    • drawString

      public void drawString(AttributedCharacterIterator iterator, float x, float y)
      See Graphics2D.
      Specified by:
      drawString in class Graphics2D
      Parameters:
      iterator - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      See Also:
    • addRenderingHints

      public void addRenderingHints(Map hints)
      See Graphics2D.
      Specified by:
      addRenderingHints in class Graphics2D
      Parameters:
      hints - The feature to be added to the RenderingHints attribute
      See Also:
    • getBackground

      public Color getBackground()
      See Graphics2D.
      Specified by:
      getBackground in class Graphics2D
      Returns:
      The background value
      See Also:
    • translate

      public void translate(double tx, double ty)
      See Graphics2D.
      Specified by:
      translate in class Graphics2D
      Parameters:
      tx - Description of the Parameter
      ty - Description of the Parameter
      See Also:
    • fill

      public void fill(Shape s)
      See Graphics2D.
      Specified by:
      fill in class Graphics2D
      Parameters:
      s - Description of the Parameter
      See Also:
    • getClip

      public Shape getClip()
      See Graphics2D.
      Specified by:
      getClip in class Graphics
      Returns:
      The clip value
      See Also:
    • drawImage

      public boolean drawImage(Image img, int x, int y, ImageObserver observer)
      See Graphics2D.
      Specified by:
      drawImage in class Graphics
      Parameters:
      img - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      observer - Description of the Parameter
      Returns:
      Description of the Return Value
      See Also:
    • drawGlyphVector

      public void drawGlyphVector(GlyphVector g, float x, float y)
      See Graphics2D.
      Specified by:
      drawGlyphVector in class Graphics2D
      Parameters:
      g - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      See Also:
    • setComposite

      public void setComposite(Composite comp)
      See Graphics2D.
      Specified by:
      setComposite in class Graphics2D
      Parameters:
      comp - The new composite value
      See Also:
    • scale

      public void scale(double sx, double sy)
      See Graphics2D.
      Specified by:
      scale in class Graphics2D
      Parameters:
      sx - Description of the Parameter
      sy - Description of the Parameter
      See Also:
    • fillOval

      public void fillOval(int x, int y, int width, int height)
      See Graphics2D.
      Specified by:
      fillOval in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      See Also:
    • fillRect

      public void fillRect(int x, int y, int width, int height)
      See Graphics2D.
      Specified by:
      fillRect in class Graphics
      Parameters:
      x - Description of the Parameter
      y - Description of the Parameter
      width - Description of the Parameter
      height - Description of the Parameter
      See Also:
    • getFontMetrics

      public FontMetrics getFontMetrics(Font f)
      See Graphics2D.
      Specified by:
      getFontMetrics in class Graphics
      Parameters:
      f - Description of the Parameter
      Returns:
      The fontMetrics value
      See Also:
    • drawImage

      public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
      See Graphics2D.
      Specified by:
      drawImage in class Graphics2D
      Parameters:
      img - Description of the Parameter
      xform - Description of the Parameter
      obs - Description of the Parameter
      Returns:
      Description of the Return Value
      See Also:
    • rotate

      public void rotate(double theta)
      See Graphics2D.
      Specified by:
      rotate in class Graphics2D
      Parameters:
      theta - Description of the Parameter
      See Also:
    • draw

      public void draw(Shape s)
      See Graphics2D.
      Specified by:
      draw in class Graphics2D
      Parameters:
      s - Description of the Parameter
      See Also:
    • drawString

      public void drawString(String s, float x, float y)
      See Graphics2D.
      Specified by:
      drawString in class Graphics2D
      Parameters:
      s - Description of the Parameter
      x - Description of the Parameter
      y - 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 class Graphics
      Parameters:
      img - Description of the Parameter
      dx1 - Description of the Parameter
      dy1 - Description of the Parameter
      dx2 - Description of the Parameter
      dy2 - Description of the Parameter
      sx1 - Description of the Parameter
      sy1 - Description of the Parameter
      sx2 - Description of the Parameter
      sy2 - Description of the Parameter
      observer - Description of the Parameter
      Returns:
      Description of the Return Value
      See Also:
    • getTransform

      public AffineTransform getTransform()
      See Graphics2D.
      Specified by:
      getTransform in class Graphics2D
      Returns:
      The transform value
      See Also:
    • drawImage

      public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
      See Graphics2D.
      Specified by:
      drawImage in class Graphics2D
      Parameters:
      img - Description of the Parameter
      op - Description of the Parameter
      x - Description of the Parameter
      y - Description of the Parameter
      See Also:
    • shear

      public void shear(double shx, double shy)
      See Graphics2D.
      Specified by:
      shear in class Graphics2D
      Parameters:
      shx - Description of the Parameter
      shy - Description of the Parameter
      See Also: