Class PSGrBase

Direct Known Subclasses:
PSGr2

public abstract class PSGrBase extends Graphics2D
PSGr is a Graphics subclass that images to PostScript. (C) 1996 E.J. Friedman-Hill and Sandia National Labs
  • Field Details

    • DEBUG

      public static final boolean DEBUG
      See Also:
    • PAGEHEIGHT

      protected static final int PAGEHEIGHT
      See Also:
    • PAGEWIDTH

      protected static final int PAGEWIDTH
      See Also:
    • XOFFSET

      protected static final int XOFFSET
      See Also:
    • YOFFSET

      protected static final int YOFFSET
      See Also:
    • hd

      protected static final char[] hd
      hexadecimal digits
    • charsPerRow

      protected static final int charsPerRow
      number of chars in a full row of pixel data
      See Also:
    • os

      protected PrintWriter os
      Output stream where postscript goes
    • clr

      protected Color clr
      The current color
    • backClr

      protected Color backClr
      The background color of the current widget. It's up to the client software to set this correctly!
    • font

      protected Font font
      The current font
    • clippingRect

      protected Rectangle clippingRect
  • Constructor Details

    • PSGrBase

      public PSGrBase()
      Constructs a new PSGr Object that write to stdout. Unlike regular Graphics objects, PSGr contexts can be created directly.
    • PSGrBase

      public PSGrBase(Writer w)
      Constructs a new PSGr Object. Unlike regular Graphics objects, PSGr contexts can be created directly.
      Parameters:
      w - Output stream for PostScript output
    • PSGrBase

      public PSGrBase(Writer w, boolean emitProlog)
      Constructs a new PSGr Object. Unlike regular Graphics objects, PSGr contexts can be created directly.
      Parameters:
      w - Output stream for PostScript output
  • Method Details

    • create

      public Graphics create()
      Creates a new PSGr Object that is a copy of the original PSGr Object. Not implemented; throws RuntimeException
      Specified by:
      create in class Graphics
    • setOutput

      public void setOutput(Writer w)
      Change the Writer this context's output goes to.
    • translate

      public void translate(int x, int y)
      Translates the specified parameters into the origin of the graphics context. All subsequent operations on this graphics context will be relative to this origin.
      Specified by:
      translate in class Graphics2D
      Parameters:
      x - the x coordinate
      y - the y coordinate
      See Also:
    • scale

      public void scale(double x, double y)
      Scales the graphics context. All subsequent operations on this graphics context will be affected.
      Specified by:
      scale in class Graphics2D
      Parameters:
      x - the scaled x coordinate
      y - the scaled y coordinate
      See Also:
    • lineto

      protected void lineto(int x, int y)
    • moveto

      protected void moveto(int x, int y)
    • getColor

      public Color getColor()
      Gets the current color.
      Specified by:
      getColor in class Graphics
      See Also:
    • setBackground

      public void setBackground(Color c)
      Gets the current color.
      Specified by:
      setBackground in class Graphics2D
      See Also:
    • setColor

      public void setColor(Color c)
      Sets the current color to the specified color. All subsequent graphics operations will use this specified color.
      Specified by:
      setColor in class Graphics
      Parameters:
      c - the color to be set
      See Also:
    • setPaintMode

      public void setPaintMode()
      Sets the default paint mode to overwrite the destination with the current color. PostScript has only paint mode.
      Specified by:
      setPaintMode in class Graphics
    • setXORMode

      public void setXORMode(Color c1)
      Sets the paint mode to alternate between the current color and the new specified color. PostScript does not support XOR mode.
      Specified by:
      setXORMode in class Graphics
      Parameters:
      c1 - the second color
    • getFont

      public Font getFont()
      Gets the current font.
      Specified by:
      getFont in class Graphics
      See Also:
    • setFont

      public void setFont(Font f)
      Sets the font for all subsequent text-drawing operations.
      Specified by:
      setFont in class Graphics
      Parameters:
      f - the specified font
      See Also:
    • getFontMetrics

      public FontMetrics getFontMetrics()
      Gets the current font metrics.
      Overrides:
      getFontMetrics in class Graphics
      See Also:
    • getFontMetrics

      public FontMetrics getFontMetrics(Font f)
      Gets the current font metrics for the specified font.
      Specified by:
      getFontMetrics in class Graphics
      Parameters:
      f - the specified font
      See Also:
    • getClipRect

      @Deprecated public Rectangle getClipRect()
      Deprecated.
      Returns the bounding rectangle of the current clipping area.
      Overrides:
      getClipRect in class Graphics
      See Also:
    • getClip

      public Shape getClip()
      Returns the bounding rectangle of the current clipping area.
      Specified by:
      getClip in class Graphics
      See Also:
    • setClip

      public void setClip(Shape s)
      Sets the clipping region using the shape's bounding rectangle.
      Specified by:
      setClip in class Graphics
      Parameters:
      s - A shape to set the clipping rectangle to
    • getClipBounds

      public Rectangle getClipBounds()
      Returns the bounding rectangle of the current clipping area.
      Specified by:
      getClipBounds in class Graphics
      Returns:
      the bounding rectangle
      See Also:
    • setClip

      public void setClip(int x, int y, int width, int height)
      Clips to a rectangle. The resulting clipping area is the intersection of the current clipping area and the specified rectangle. Graphic operations have no effect outside of the clipping area.
      Specified by:
      setClip in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      See Also:
    • clipRect

      @Deprecated public void clipRect(int x, int y, int width, int height)
      Deprecated.
      Specified by:
      clipRect in class Graphics
    • copyArea

      public void copyArea(int x, int y, int width, int height, int dx, int dy)
      Copies an area of the screen.
      Specified by:
      copyArea in class Graphics
      Parameters:
      x - the x-coordinate of the source
      y - the y-coordinate of the source
      width - the width
      height - the height
      dx - the horizontal distance
      dy - the vertical distance Note: copyArea not supported by PostScript
    • drawLine

      public void drawLine(int x1, int y1, int x2, int y2)
      Draws a line between the coordinates (x1,y1) and (x2,y2). The line is drawn below and to the left of the logical coordinates.
      Specified by:
      drawLine in class Graphics
      Parameters:
      x1 - the first point's x coordinate
      y1 - the first point's y coordinate
      x2 - the second point's x coordinate
      y2 - the second point's y coordinate
    • doRect

      protected void doRect(int x, int y, int width, int height, boolean fill)
    • fillRect

      public void fillRect(int x, int y, int width, int height)
      Fills the specified rectangle with the current color.
      Specified by:
      fillRect in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      See Also:
    • drawRect

      public void drawRect(int x, int y, int width, int height)
      Draws the outline of the specified rectangle using the current color. Use drawRect(x, y, width-1, height-1) to draw the outline inside the specified rectangle.
      Overrides:
      drawRect in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      See Also:
    • clearRect

      public void clearRect(int x, int y, int width, int height)
      Clears the specified rectangle by filling it with the current background color of the current drawing surface. Which drawing surface it selects depends on how the graphics context was created.
      Specified by:
      clearRect in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      See Also:
    • doRoundRect

      protected void doRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight, boolean fill)
    • stroke

      protected void stroke(boolean fill)
    • arcTo

      protected void arcTo(int x1, int y1, int x2, int y2, int dim)
    • drawRoundRect

      public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
      Draws an outlined rounded corner rectangle using the current color.
      Specified by:
      drawRoundRect in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      arcWidth - the diameter of the arc
      arcHeight - the radius of the arc
      See Also:
    • fillRoundRect

      public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
      Draws a rounded rectangle filled in with the current color.
      Specified by:
      fillRoundRect in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      arcWidth - the diameter of the arc
      arcHeight - the radius of the arc
      See Also:
    • draw3DRect

      public void draw3DRect(int x, int y, int width, int height, boolean raised)
      Draws a highlighted 3-D rectangle.
      Overrides:
      draw3DRect in class Graphics2D
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      raised - a boolean that states whether the rectangle is raised or not
    • fill3DRect

      public void fill3DRect(int x, int y, int width, int height, boolean raised)
      Paints a highlighted 3-D rectangle using the current color.
      Overrides:
      fill3DRect in class Graphics2D
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      raised - a boolean that states whether the rectangle is raised or not
    • drawOval

      public void drawOval(int x, int y, int width, int height)
      Draws an oval inside the specified rectangle using the current color.
      Specified by:
      drawOval in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      See Also:
    • fillOval

      public void fillOval(int x, int y, int width, int height)
      Fills an oval inside the specified rectangle using the current color.
      Specified by:
      fillOval in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      See Also:
    • doArc

      protected void doArc(int x, int y, int width, int height, int startAngle, int arcAngle, boolean fill)
    • drawArc

      public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
      Draws an arc bounded by the specified rectangle from startAngle to endAngle. 0 degrees is at the 3-o'clock position.Positive arc angles indicate counter-clockwise rotations, negative arc angles are drawn clockwise.
      Specified by:
      drawArc in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      startAngle - the beginning angle
      arcAngle - the angle of the arc (relative to startAngle).
      See Also:
    • fillArc

      public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
      Fills an arc using the current color. This generates a pie shape.
      Specified by:
      fillArc in class Graphics
      Parameters:
      x - the x coordinate
      y - the y coordinate
      width - the width of the arc
      height - the height of the arc
      startAngle - the beginning angle
      arcAngle - the angle of the arc (relative to startAngle).
      See Also:
    • doPoly

      protected void doPoly(int[] xPoints, int[] yPoints, int nPoints, boolean fill, boolean close)
    • drawPolyline

      public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
      Draws a polygon defined by an array of x points and y points.
      Specified by:
      drawPolyline in class Graphics
      Parameters:
      xPoints - an array of x points
      yPoints - an array of y points
      nPoints - the total number of points
      See Also:
    • drawPolygon

      public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
      Draws a polygon defined by an array of x points and y points.
      Specified by:
      drawPolygon in class Graphics
      Parameters:
      xPoints - an array of x points
      yPoints - an array of y points
      nPoints - the total number of points
      See Also:
    • drawPolygon

      public void drawPolygon(Polygon p)
      Draws a polygon defined by the specified point.
      Overrides:
      drawPolygon in class Graphics
      Parameters:
      p - the specified polygon
      See Also:
    • fillPolygon

      public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
      Fills a polygon with the current color.
      Specified by:
      fillPolygon in class Graphics
      Parameters:
      xPoints - an array of x points
      yPoints - an array of y points
      nPoints - the total number of points
      See Also:
    • fillPolygon

      public void fillPolygon(Polygon p)
      Fills the specified polygon with the current color.
      Overrides:
      fillPolygon in class Graphics
      Parameters:
      p - the polygon
      See Also:
    • drawString

      public void drawString(String str, int x, int y)
      Draws the specified String using the current font and color. The x,y position is the starting point of the baseline of the String.
      Specified by:
      drawString in class Graphics2D
      Parameters:
      str - the String to be drawn
      x - the x coordinate
      y - the y coordinate
      See Also:
    • drawChars

      public void drawChars(char[] data, int offset, int length, int x, int y)
      Draws the specified characters using the current font and color.
      Overrides:
      drawChars in class Graphics
      Parameters:
      data - the array of characters to be drawn
      offset - the start offset in the data
      length - the number of characters to be drawn
      x - the x coordinate
      y - the y coordinate
      See Also:
    • drawBytes

      public void drawBytes(byte[] data, int offset, int length, int x, int y)
      Draws the specified bytes using the current font and color.
      Overrides:
      drawBytes in class Graphics
      Parameters:
      data - the data to be drawn
      offset - the start offset in the data
      length - the number of bytes that are drawn
      x - the x coordinate
      y - the y coordinate
      See Also:
    • doImage

      protected boolean doImage(Image img, int x, int y, int width, int height, int sx, int sy, int sw, int sh, ImageObserver observer, Color bgcolor)
    • drawImage

      public boolean drawImage(Image img, int x, int y, ImageObserver observer)
      Draws the specified image at the specified coordinate (x, y). If the image is incomplete the image observer will be notified later.
      Specified by:
      drawImage in class Graphics
      Parameters:
      img - the specified image to be drawn
      x - the x coordinate
      y - the y coordinate
      observer - notifies if the image is complete or not
      See Also:
    • drawImage

      public boolean drawImage(Image img, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, ImageObserver observer)
      Warning this is not yet supported
      Specified by:
      drawImage in class Graphics
    • drawImage

      public boolean drawImage(Image img, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, Color c, ImageObserver observer)
      Warning this is not yet supported
      Specified by:
      drawImage in class Graphics
    • drawImage

      public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
      Draws the specified image inside the specified rectangle. The image is scaled if necessary. If the image is incomplete the image observer will be notified later.
      Specified by:
      drawImage in class Graphics
      Parameters:
      img - the specified image to be drawn
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      observer - notifies if the image is complete or not
      See Also:
    • drawImage

      public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
      Draws the specified image at the specified coordinate (x, y). If the image is incomplete the image observer will be notified later.
      Specified by:
      drawImage in class Graphics
      Parameters:
      img - the specified image to be drawn
      x - the x coordinate
      y - the y coordinate
      bgcolor - the background color
      observer - notifies if the image is complete or not
      See Also:
    • drawImage

      public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
      Draws the specified image inside the specified rectangle. The image is scaled if necessary. If the image is incomplete the image observer will be notified later.
      Specified by:
      drawImage in class Graphics
      Parameters:
      img - the specified image to be drawn
      x - the x coordinate
      y - the y coordinate
      width - the width of the rectangle
      height - the height of the rectangle
      bgcolor - the background color
      observer - notifies if the image is complete or not
      See Also:
    • dispose

      public void dispose()
      Disposes of this graphics context. The Graphics context cannot be used after being disposed of.
      Specified by:
      dispose in class Graphics
      See Also:
    • finalize

      public void finalize()
      Disposes of this graphics context once it is no longer referenced.
      Overrides:
      finalize in class Graphics
      See Also:
    • toString

      public String toString()
      Returns a String object representing this Graphic's value.
      Overrides:
      toString in class Graphics
    • transformY

      protected int transformY(int y)
      Flip Y coords so Postscript looks like Java
    • emitProlog

      protected void emitProlog()
      Top of every PS file
    • emitColorImageProlog

      protected void emitColorImageProlog(int xdim)
    • gsave

      public void gsave()
    • grestore

      public void grestore()
    • emitThis

      public void emitThis(String s)
    • diagnostic

      protected void diagnostic(String s)
    • setdash

      protected void setdash(float[] dashstyle, float dashphase)
    • rotate

      public void rotate(double theta)
      Specified by:
      rotate in class Graphics2D
    • rotate

      public void rotate(double theta, double x, double y)
      Specified by:
      rotate in class Graphics2D
    • getComposite

      public Composite getComposite()
      Specified by:
      getComposite in class Graphics2D
    • drawString

      public void drawString(String s, float x, float y)
      Specified by:
      drawString in class Graphics2D
    • drawRenderableImage

      public void drawRenderableImage(RenderableImage image, AffineTransform xform)
      Specified by:
      drawRenderableImage in class Graphics2D
    • drawRenderedImage

      public void drawRenderedImage(RenderedImage img, AffineTransform xform)
      Specified by:
      drawRenderedImage in class Graphics2D
    • addRenderingHints

      public void addRenderingHints(Map map)
      Specified by:
      addRenderingHints in class Graphics2D
    • getRenderingHint

      public Object getRenderingHint(RenderingHints.Key key)
      Specified by:
      getRenderingHint in class Graphics2D
    • getRenderingHints

      public RenderingHints getRenderingHints()
      Specified by:
      getRenderingHints in class Graphics2D
    • setRenderingHint

      public void setRenderingHint(RenderingHints.Key kintKey, Object hintValue)
      Specified by:
      setRenderingHint in class Graphics2D
    • setRenderingHints

      public void setRenderingHints(Map hints)
      Specified by:
      setRenderingHints in class Graphics2D
    • getPaint

      public Paint getPaint()
      Specified by:
      getPaint in class Graphics2D
    • hit

      public boolean hit(Rectangle r, Shape s, boolean b)
      Specified by:
      hit in class Graphics2D
    • drawGlyphVector

      public void drawGlyphVector(GlyphVector vec, float x, float y)
      Specified by:
      drawGlyphVector in class Graphics2D
    • setComposite

      public void setComposite(Composite c)
      Specified by:
      setComposite in class Graphics2D
    • draw

      public void draw(Shape s)
      Specified by:
      draw in class Graphics2D
    • drawImage

      public void drawImage(BufferedImage image, BufferedImageOp op, int x, int y)
      Specified by:
      drawImage in class Graphics2D
    • drawImage

      public boolean drawImage(Image image, AffineTransform xform, ImageObserver observer)
      Specified by:
      drawImage in class Graphics2D
    • shear

      public void shear(double shx, double shy)
      Specified by:
      shear in class Graphics2D
    • clip

      public void clip(Shape s)
      Specified by:
      clip in class Graphics2D
    • fill

      public void fill(Shape s)
      Specified by:
      fill in class Graphics2D
    • transform

      public void transform(AffineTransform xform)
      Specified by:
      transform in class Graphics2D
    • drawString

      public void drawString(AttributedCharacterIterator iterator, float x, float y)
      Specified by:
      drawString in class Graphics2D
    • getTransform

      public AffineTransform getTransform()
      Specified by:
      getTransform in class Graphics2D
    • setTransform

      public void setTransform(AffineTransform xform)
      Specified by:
      setTransform in class Graphics2D
    • getBackground

      public Color getBackground()
      Specified by:
      getBackground in class Graphics2D
    • getDeviceConfiguration

      public GraphicsConfiguration getDeviceConfiguration()
      Specified by:
      getDeviceConfiguration in class Graphics2D
    • getFontRenderContext

      public FontRenderContext getFontRenderContext()
      Specified by:
      getFontRenderContext in class Graphics2D
    • setPaint

      public void setPaint(Paint paint)
      Specified by:
      setPaint in class Graphics2D
    • translate

      public void translate(double x, double y)
      Specified by:
      translate in class Graphics2D
    • getStroke

      public Stroke getStroke()
      Specified by:
      getStroke in class Graphics2D
    • setStroke

      public void setStroke(Stroke stroke)
      Specified by:
      setStroke in class Graphics2D