Package ptolemy.plot

Class EPSGraphics


  • public class EPSGraphics
    extends java.awt.Graphics
    Graphics class supporting EPS export from plots. If this is used from within an applet, then the output goes to the standard output. Unfortunately, with standard browsers, this is not useful. With MS Internet Explorer, standard output is not available. With Netscape Navigator, standard output is available in the Java console, but is limited to fewer lines than what is usually generated. Thus, we recommend using this within Sun's appletviewer, and redirecting its standard output to a file.
    Since:
    Ptolemy II 0.2
    Version:
    $Id$
    Author:
    Edward A. Lee
    Pt.AcceptedRating:
    Yellow (cxh)
    Pt.ProposedRating:
    Yellow (cxh)
    • Constructor Summary

      Constructors 
      Constructor Description
      EPSGraphics​(java.io.OutputStream out, int width, int height)
      Constructor for a graphics object that writes encapsulated PostScript to the specified output stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearRect​(int x, int y, int width, int height)  
      void clipRect​(int x, int y, int width, int height)  
      void copyArea​(int x, int y, int width, int height, int dx, int dy)  
      java.awt.Graphics create()  
      void dispose()  
      void drawArc​(int x, int y, int width, int height, int startAngle, int arcAngle)  
      boolean drawImage​(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)  
      boolean drawImage​(java.awt.Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, java.awt.image.ImageObserver observer)  
      boolean drawImage​(java.awt.Image img, int x, int y, int width, int height, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)  
      boolean drawImage​(java.awt.Image img, int x, int y, int width, int height, java.awt.image.ImageObserver observer)  
      boolean drawImage​(java.awt.Image img, int x, int y, java.awt.Color bgcolor, java.awt.image.ImageObserver observer)  
      boolean drawImage​(java.awt.Image img, int x, int y, java.awt.image.ImageObserver observer)  
      void drawLine​(int x1, int y1, int x2, int y2)
      Draw a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system.
      void drawOval​(int x, int y, int width, int height)
      Draw an oval bounded by the specified rectangle with the current color.
      void drawPolygon​(int[] xPoints, int[] yPoints, int nPoints)
      Draw a closed polygon defined by arrays of x and y coordinates.
      void drawPolyline​(int[] xPoints, int[] yPoints, int nPoints)  
      void drawRect​(int x, int y, int width, int height)  
      void drawRoundRect​(int x, int y, int width, int height, int arcWidth, int arcHeight)  
      void drawString​(java.lang.String str, int x, int y)
      Draw a string.
      void drawString​(java.text.AttributedCharacterIterator iterator, int x, int y)  
      void fillArc​(int x, int y, int width, int height, int startAngle, int arcAngle)  
      void fillOval​(int x, int y, int width, int height)
      Fill an oval bounded by the specified rectangle with the current color.
      void fillPolygon​(int[] xPoints, int[] yPoints, int nPoints)
      Draw a filled polygon defined by arrays of x and y coordinates.
      void fillRect​(int x, int y, int width, int height)
      Fill the specified rectangle and draw a thin outline around it.
      void fillRoundRect​(int x, int y, int width, int height, int arcWidth, int arcHeight)  
      java.awt.Shape getClip()  
      java.awt.Rectangle getClipBounds()  
      java.awt.Color getColor()
      Get the current color.
      java.awt.Font getFont()  
      java.awt.FontMetrics getFontMetrics​(java.awt.Font f)  
      void setClip​(int x, int y, int width, int height)  
      void setClip​(java.awt.Shape clip)  
      void setColor​(java.awt.Color c)
      Set the current color.
      void setFont​(java.awt.Font font)  
      void setPaintMode()  
      void setXORMode​(java.awt.Color c1)  
      void showpage()
      Issue the PostScript showpage command, then write and flush the output.
      void translate​(int x, int y)  
      • Methods inherited from class java.awt.Graphics

        create, draw3DRect, drawBytes, drawChars, drawPolygon, fill3DRect, fillPolygon, finalize, getClipBounds, getClipRect, getFontMetrics, hitClip, toString
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • EPSGraphics

        public EPSGraphics​(java.io.OutputStream out,
                           int width,
                           int height)
        Constructor for a graphics object that writes encapsulated PostScript to the specified output stream. If the out argument is null, then it writes to standard output (it would write it to the clipboard, but as of this writing, writing to the clipboard does not work in Java).
        Parameters:
        out - The stream to write to, or null to write to standard out.
        width - The width of the plot graphic, in units of 1/72 inch.
        height - The height of the plot graphic, in units of 1/72 inch.
    • Method Detail

      • clearRect

        public void clearRect​(int x,
                              int y,
                              int width,
                              int height)
        Specified by:
        clearRect in class java.awt.Graphics
      • clipRect

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

        public void copyArea​(int x,
                             int y,
                             int width,
                             int height,
                             int dx,
                             int dy)
        Specified by:
        copyArea in class java.awt.Graphics
      • create

        public java.awt.Graphics create()
        Specified by:
        create in class java.awt.Graphics
      • dispose

        public void dispose()
        Specified by:
        dispose in class java.awt.Graphics
      • drawArc

        public void drawArc​(int x,
                            int y,
                            int width,
                            int height,
                            int startAngle,
                            int arcAngle)
        Specified by:
        drawArc in class java.awt.Graphics
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int x,
                                 int y,
                                 java.awt.image.ImageObserver observer)
        Specified by:
        drawImage in class java.awt.Graphics
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int x,
                                 int y,
                                 int width,
                                 int height,
                                 java.awt.image.ImageObserver observer)
        Specified by:
        drawImage in class java.awt.Graphics
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int x,
                                 int y,
                                 java.awt.Color bgcolor,
                                 java.awt.image.ImageObserver observer)
        Specified by:
        drawImage in class java.awt.Graphics
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int x,
                                 int y,
                                 int width,
                                 int height,
                                 java.awt.Color bgcolor,
                                 java.awt.image.ImageObserver observer)
        Specified by:
        drawImage in class java.awt.Graphics
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int dx1,
                                 int dy1,
                                 int dx2,
                                 int dy2,
                                 int sx1,
                                 int sy1,
                                 int sx2,
                                 int sy2,
                                 java.awt.image.ImageObserver observer)
        Specified by:
        drawImage in class java.awt.Graphics
      • drawImage

        public boolean drawImage​(java.awt.Image img,
                                 int dx1,
                                 int dy1,
                                 int dx2,
                                 int dy2,
                                 int sx1,
                                 int sy1,
                                 int sx2,
                                 int sy2,
                                 java.awt.Color bgcolor,
                                 java.awt.image.ImageObserver observer)
        Specified by:
        drawImage in class java.awt.Graphics
      • drawLine

        public void drawLine​(int x1,
                             int y1,
                             int x2,
                             int y2)
        Draw a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system.
        Specified by:
        drawLine in class java.awt.Graphics
        Parameters:
        x1 - the x coordinate of the first point.
        y1 - the y coordinate of the first point.
        x2 - the x coordinate of the second point.
        y2 - the y coordinate of the second point.
      • drawPolyline

        public void drawPolyline​(int[] xPoints,
                                 int[] yPoints,
                                 int nPoints)
        Specified by:
        drawPolyline in class java.awt.Graphics
      • drawPolygon

        public void drawPolygon​(int[] xPoints,
                                int[] yPoints,
                                int nPoints)
        Draw a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a vertex. The third argument gives the number of vertices. If the arrays are not long enough to define this many vertices, or if the third argument is less than three, then nothing is drawn.
        Specified by:
        drawPolygon in class java.awt.Graphics
        Parameters:
        xPoints - An array of x coordinates.
        yPoints - An array of y coordinates.
        nPoints - The total number of vertices.
      • drawOval

        public void drawOval​(int x,
                             int y,
                             int width,
                             int height)
        Draw an oval bounded by the specified rectangle with the current color.
        Specified by:
        drawOval in class java.awt.Graphics
        Parameters:
        x - The x coordinate of the upper left corner
        y - The y coordinate of the upper left corner
        width - The width of the oval to be filled.
        height - The height of the oval to be filled.
      • drawRect

        public void drawRect​(int x,
                             int y,
                             int width,
                             int height)
        Overrides:
        drawRect in class java.awt.Graphics
      • drawRoundRect

        public void drawRoundRect​(int x,
                                  int y,
                                  int width,
                                  int height,
                                  int arcWidth,
                                  int arcHeight)
        Specified by:
        drawRoundRect in class java.awt.Graphics
      • drawString

        public void drawString​(java.text.AttributedCharacterIterator iterator,
                               int x,
                               int y)
        Specified by:
        drawString in class java.awt.Graphics
      • drawString

        public void drawString​(java.lang.String str,
                               int x,
                               int y)
        Draw a string. "(" is converted to "\(" and ")" is converted to "\) so as to avoid EPS Syntax errors.
        Specified by:
        drawString in class java.awt.Graphics
        Parameters:
        str - The string to draw.
        x - The x location of the string.
        y - The y location of the string.
      • fillArc

        public void fillArc​(int x,
                            int y,
                            int width,
                            int height,
                            int startAngle,
                            int arcAngle)
        Specified by:
        fillArc in class java.awt.Graphics
      • fillPolygon

        public void fillPolygon​(int[] xPoints,
                                int[] yPoints,
                                int nPoints)
        Draw a filled polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a vertex. The third argument gives the number of vertices. If the arrays are not long enough to define this many vertices, or if the third argument is less than three, then nothing is drawn.
        Specified by:
        fillPolygon in class java.awt.Graphics
        Parameters:
        xPoints - An array of x coordinates.
        yPoints - An array of y coordinates.
        nPoints - The total number of vertices.
      • fillOval

        public void fillOval​(int x,
                             int y,
                             int width,
                             int height)
        Fill an oval bounded by the specified rectangle with the current color.
        Specified by:
        fillOval in class java.awt.Graphics
        Parameters:
        x - The x coordinate of the upper left corner
        y - The y coordinate of the upper left corner
        width - The width of the oval to be filled.
        height - The height of the oval to be filled.
      • fillRect

        public void fillRect​(int x,
                             int y,
                             int width,
                             int height)
        Fill the specified rectangle and draw a thin outline around it. The left and right edges of the rectangle are at x and x + width - 1. The top and bottom edges are at y and y + height - 1. The resulting rectangle covers an area width pixels wide by height pixels tall. The rectangle is filled using the brightness of the current color to set the level of gray.
        Specified by:
        fillRect in class java.awt.Graphics
        Parameters:
        x - The x coordinate of the top left corner.
        y - The y coordinate of the top left corner.
        width - The width of the rectangle.
        height - The height of the rectangle.
      • fillRoundRect

        public void fillRoundRect​(int x,
                                  int y,
                                  int width,
                                  int height,
                                  int arcWidth,
                                  int arcHeight)
        Specified by:
        fillRoundRect in class java.awt.Graphics
      • getClip

        public java.awt.Shape getClip()
        Specified by:
        getClip in class java.awt.Graphics
      • getClipBounds

        public java.awt.Rectangle getClipBounds()
        Specified by:
        getClipBounds in class java.awt.Graphics
      • getColor

        public java.awt.Color getColor()
        Get the current color.
        Specified by:
        getColor in class java.awt.Graphics
        Returns:
        The current color.
        See Also:
        setColor(Color)
      • getFont

        public java.awt.Font getFont()
        Specified by:
        getFont in class java.awt.Graphics
      • getFontMetrics

        public java.awt.FontMetrics getFontMetrics​(java.awt.Font f)
        Specified by:
        getFontMetrics in class java.awt.Graphics
      • setFont

        public void setFont​(java.awt.Font font)
        Specified by:
        setFont in class java.awt.Graphics
      • setClip

        public void setClip​(java.awt.Shape clip)
        Specified by:
        setClip in class java.awt.Graphics
      • setClip

        public void setClip​(int x,
                            int y,
                            int width,
                            int height)
        Specified by:
        setClip in class java.awt.Graphics
      • setColor

        public void setColor​(java.awt.Color c)
        Set the current color. Since we are generating gray scale postscript, set a line style. Set the gray level to zero (black).
        Specified by:
        setColor in class java.awt.Graphics
        Parameters:
        c - The desired current color.
        See Also:
        getColor()
      • setPaintMode

        public void setPaintMode()
        Specified by:
        setPaintMode in class java.awt.Graphics
      • setXORMode

        public void setXORMode​(java.awt.Color c1)
        Specified by:
        setXORMode in class java.awt.Graphics
      • showpage

        public void showpage()
        Issue the PostScript showpage command, then write and flush the output. If the output argument of the constructor was null, then write to the clipboard.
      • translate

        public void translate​(int x,
                              int y)
        Specified by:
        translate in class java.awt.Graphics