Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Attributes | Package Attributes | Private Member Functions | Private Attributes | Static Private Attributes
rene.zirkel.graphics.EPSGraphics Class Reference
Collaboration diagram for rene.zirkel.graphics.EPSGraphics:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 EPSGraphics (OutputStream out, double width, double height, int orientation, boolean clip)
void clearRect (int x, int y, int width, int height)
void clipRect (double x, double y, double width, double height)
void drawLine (double x1, double y1, double x2, double y2)
 Draw a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system.
void drawPolygon (double xPoints[], double yPoints[], int nPoints)
 Draw a closed polygon defined by arrays of x and y coordinates.
void drawOval (double x, double y, double width, double height)
 Draw an oval bounded by the specified rectangle with the current color.
void drawRect (double x, double y, double width, double height)
void drawRoundRect (double x, double y, double width, double height, int arcWidth, int arcHeight)
void drawString (java.text.AttributedCharacterIterator iterator, int x, int y)
void drawString (String str, double x, double y)
void drawArc (double x, double y, double width, double height, double startAngle, double arcAngle)
void fillArc (double x, double y, double width, double height, double startAngle, double arcAngle)
void fillChord (double x, double y, double width, double height, double startAngle, double arcAngle)
void fillPolygon (double xPoints[], double yPoints[], int nPoints)
void fillOval (double x, double y, double width, double height)
 Fill an oval bounded by the specified rectangle with the current color.
void fillRect (double x, double y, double width, double height)
 Fill the specified rectangle and draw a thin outline around it.
void fillRoundRect (double x, double y, double width, double height, int arcWidth, int arcHeight)
Shape getClip ()
Rectangle getClipBounds ()
Color getColor ()
Font getFont ()
FontMetrics getFontMetrics (Font f)
FontMetrics getFontMetrics ()
void setFont (Font font)
void setClip (Shape clip)
void setClip (int x, int y, int width, int height)
void setColor (Color c)
 Set the current color.
void setLineWidth (double w)
void setDash (double a, double b)
void clearDash ()
void setPaintMode ()
void setXORMode (Color c1)
void showpage (String name)
 Issue the PostScript showpage command, then write and flush the output.
void close () throws IOException
 Issue the PostScript showpage command, then write and flush the output.

Static Public Attributes

static final int PORTRAIT = 0
static final int LANDSCAPE = 1

Package Attributes

double _height
int _orientation

Private Member Functions

double round (double x)
EpsPoint _convert (double x, double y)
double _convertX (double x)
double _convertY (double y)
boolean _polygon (double xPoints[], double yPoints[], int nPoints)
void _fillPattern ()

Private Attributes

Color _currentColor = Color.black
Font _currentFont
double _width
Hashtable _linepattern = new Hashtable()
OutputStream _out
StringBuffer _buffer = new StringBuffer()
Clipboard _clipboard
double LineWidth = 1
int _patternIndex = 0
FontMetrics FM

Static Private Attributes

static String[] _patterns

Detailed Description

Definition at line 46 of file EPSGraphics.java.


Constructor & Destructor Documentation

rene.zirkel.graphics.EPSGraphics.EPSGraphics ( OutputStream  out,
double  width,
double  height,
int  orientation,
boolean  clip 
) [inline]

Definition at line 84 of file EPSGraphics.java.

                                             {
              _width = width; 
              _height = height; 
              _orientation = orientation; 
              _out = out; 
              _buffer.append("%!PS-Adobe-3.0 EPSF-3.0\n"); 
              _buffer.append("%%Creator: QCircuitBuilder\n"); 
              _buffer.append("%%BoundingBox: 50 50 " + 
                     (int)(50+width) + " "+ (int)(50+height) +"\n"); 
              //_buffer.append("%%Orientation: " + (_orientation == PORTRAIT ? "Portrait" : "Landscape"));
              //_buffer.append("%%PageOrientation: " + (_orientation == PORTRAIT ? "Portrait" : "Landscape"));
              _buffer.append("%%Pages: 1\n"); 
              _buffer.append("%%Page: 1 1\n"); 
              _buffer.append("%%LanguageLevel: 2\n"); 
              if (clip) clipRect(0,0,width,height);
              _buffer.append("/Helvetica findfont 10 scalefont setfont\n");
       }      

Here is the call graph for this function:


Member Function Documentation

EpsPoint rene.zirkel.graphics.EPSGraphics._convert ( double  x,
double  y 
) [inline, private]

Definition at line 420 of file EPSGraphics.java.

                                                      {
              return new EpsPoint(round(x+50),round(_height+50 - y)); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

double rene.zirkel.graphics.EPSGraphics._convertX ( double  x) [inline, private]

Definition at line 424 of file EPSGraphics.java.

       {      return round(x+50);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

double rene.zirkel.graphics.EPSGraphics._convertY ( double  y) [inline, private]

Definition at line 427 of file EPSGraphics.java.

       {      return round(_height+50-y);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 448 of file EPSGraphics.java.

                                   {
              // FIXME: We probably want a fill pattern rather than
              // just a gray scale.
              int red = _currentColor.getRed(); 
              int green = _currentColor.getGreen(); 
              int blue = _currentColor.getBlue(); 
              // Scaling constants so that fully saturated R, G, or B appear
              // different.
              double bluescale = 0.6; // darkest
              double redscale = 0.8; 
              double greenscale = 1.0; // lightest
              double fullscale =
                     Math.sqrt(255.0*255.0*(bluescale*bluescale
                     + redscale*redscale + greenscale*greenscale)); 
              double graylevel =
                     Math.sqrt((double)(red*red*redscale*redscale
                     + blue*blue*bluescale*bluescale
                     + green*green*greenscale*greenscale))/fullscale; 
              _buffer.append("" + graylevel + " setgray\n"); 
              // NOTE -- for debugging, output color spec in comments
              _buffer.append("rgb: " + red + " " +
                     green + " " + blue +"\n"); 
       }
boolean rene.zirkel.graphics.EPSGraphics._polygon ( double  xPoints[],
double  yPoints[],
int  nPoints 
) [inline, private]

Definition at line 433 of file EPSGraphics.java.

                       {
              if (nPoints < 3 || xPoints.length < nPoints
                     || yPoints.length < nPoints) return false; 
              EpsPoint start = _convert(xPoints[0], yPoints[0]); 
              _buffer.append("newpath " + round(start.x) + " " + round(start.y) + " moveto\n"); 
              for (int i = 1; i < nPoints; i++) {
                     EpsPoint vertex = _convert(xPoints[i], yPoints[i]); 
                     _buffer.append("" + round(vertex.x) + " " + round(vertex.y) + " lineto\n"); 
              }
              return true; 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 368 of file EPSGraphics.java.

       {      _buffer.append("[ ] 0 setdash\n");
       }

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.clearRect ( int  x,
int  y,
int  width,
int  height 
) [inline]

Definition at line 103 of file EPSGraphics.java.

       {
       }
void rene.zirkel.graphics.EPSGraphics.clipRect ( double  x,
double  y,
double  width,
double  height 
) [inline]

Definition at line 108 of file EPSGraphics.java.

                                                                              {
              EpsPoint start = _convert(x, y); 
              //_fillPattern();
              _buffer.append("newpath " + round(start.x) + " " + round(start.y) + " moveto\n"); 
              _buffer.append("0 " + round(-height) + " rlineto\n"); 
              _buffer.append("" + round(width) + " 0 rlineto\n"); 
              _buffer.append("0 " + round(height) + " rlineto\n"); 
              _buffer.append("" + round(-width) + " 0 rlineto\n"); 
              _buffer.append("closepath clip\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.close ( ) throws IOException [inline]

Issue the PostScript showpage command, then write and flush the output.

Definition at line 401 of file EPSGraphics.java.

       {
                     _buffer.append("showpage\n"); 
                     _buffer.append("%%EOF"); 
       
                     PrintWriter output=new PrintWriter(_out);
                     
                     output.println(_buffer.toString()); 
                     output.flush(); 
                     
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.drawArc ( double  x,
double  y,
double  width,
double  height,
double  startAngle,
double  arcAngle 
) [inline]

Definition at line 207 of file EPSGraphics.java.

       {      double radius = width/2.0; 
              _buffer.append("newpath " +
                     _convertX(x+radius) + " " + 
                     _convertY(y+radius) + " " + 
                     round(radius) + " " + round(startAngle) + " " + " " +
                     round(startAngle+arcAngle) + " arc stroke\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.drawLine ( double  x1,
double  y1,
double  x2,
double  y2 
) [inline]

Draw a line, using the current color, between the points (x1, y1) and (x2, y2) in this graphics context's coordinate system.

Parameters:
x1the x coordinate of the first point.
y1the y coordinate of the first point.
x2the x coordinate of the second point.
y2the y coordinate of the second point.

Definition at line 132 of file EPSGraphics.java.

       {      EpsPoint start = _convert(x1, y1); 
              EpsPoint end = _convert(x2, y2); 
              _buffer.append("newpath " + round(start.x) + " " + round(start.y) + " moveto\n"); 
              _buffer.append("" + round(end.x) + " " + round(end.y) + " lineto\n"); 
              _buffer.append("stroke\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.drawOval ( double  x,
double  y,
double  width,
double  height 
) [inline]

Draw an oval bounded by the specified rectangle with the current color.

Parameters:
xThe x coordinate of the upper left corner
yThe y coordinate of the upper left corner
widthThe width of the oval to be filled.
heightThe height of the oval to be filled.

Definition at line 171 of file EPSGraphics.java.

       {
              double radius = width/2.0; 
              _buffer.append("newpath " + _convertX(x+radius) + " " + 
                     _convertY(y+radius) + " " + 
                     round(radius) + " 0 360 arc closepath stroke\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.drawPolygon ( double  xPoints[],
double  yPoints[],
int  nPoints 
) [inline]

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.

Parameters:
xPointsAn array of x coordinates.
yPointsAn array of y coordinates.
nPointsThe total number of vertices.

Definition at line 153 of file EPSGraphics.java.

       {      if (!_polygon(xPoints, yPoints, nPoints)) {
                     return; 
              } else {
                     _buffer.append("closepath stroke\n"); 
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.drawRect ( double  x,
double  y,
double  width,
double  height 
) [inline]

Definition at line 179 of file EPSGraphics.java.

                                                                             {
              EpsPoint start = _convert(x, y); 
              _buffer.append("newpath " + round(start.x) + " " + round(start.y) + " moveto\n"); 
              _buffer.append("0 " + round(-height) + " rlineto\n"); 
              _buffer.append("" + round(width) + " 0 rlineto\n"); 
              _buffer.append("0 " + round(height) + " rlineto\n"); 
              _buffer.append("" + round(-width) + " 0 rlineto\n"); 
              _buffer.append("closepath stroke\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.drawRoundRect ( double  x,
double  y,
double  width,
double  height,
int  arcWidth,
int  arcHeight 
) [inline]

Definition at line 189 of file EPSGraphics.java.

                                           {
       }
void rene.zirkel.graphics.EPSGraphics.drawString ( java.text.AttributedCharacterIterator  iterator,
int  x,
int  y 
) [inline]

Definition at line 194 of file EPSGraphics.java.

                            {
       }

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.drawString ( String  str,
double  x,
double  y 
) [inline]

Definition at line 199 of file EPSGraphics.java.

       {
              FontMetrics fm=getFontMetrics();
              EpsPoint start = _convert(x, y); 
              _buffer.append("" + start.x + " " + start.y + " moveto\n"); 
              _buffer.append("(" + str + ") show\n"); 
       }

Here is the call graph for this function:

void rene.zirkel.graphics.EPSGraphics.fillArc ( double  x,
double  y,
double  width,
double  height,
double  startAngle,
double  arcAngle 
) [inline]

Definition at line 217 of file EPSGraphics.java.

       {      double radius = width/2.0;
              _buffer.append("newpath " + 
                     _convertX(x+radius) + " " + _convertY(y+radius) + " " +
                     " moveto " + 
                     _convertX(x+radius) + " " + _convertY(y+radius) + " " + 
                     radius + " " + round(startAngle) + " " +
                     round(startAngle+arcAngle) + 
                     " arc closepath fill\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.fillChord ( double  x,
double  y,
double  width,
double  height,
double  startAngle,
double  arcAngle 
) [inline]

Definition at line 229 of file EPSGraphics.java.

       {      double radius = width/2.0;
              _buffer.append("newpath " + 
                     _convertX(x+radius) + " " + _convertY(y+radius) + " " + 
                     round(radius) + " " + round(startAngle) + " " +
                     round(startAngle+arcAngle) + 
                     " arc fill\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.fillOval ( double  x,
double  y,
double  width,
double  height 
) [inline]

Fill an oval bounded by the specified rectangle with the current color.

Parameters:
xThe x coordinate of the upper left corner
yThe y coordinate of the upper left corner
widthThe width of the oval to be filled.
heightThe height of the oval to be filled.

Definition at line 257 of file EPSGraphics.java.

       {
              double radius = width/2.0; 
              _buffer.append("newpath " + _convertX(x+radius) + " " + 
                     _convertY(y+radius) + " " + 
                     radius + " 0 360 arc closepath fill\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.fillPolygon ( double  xPoints[],
double  yPoints[],
int  nPoints 
) [inline]

Definition at line 239 of file EPSGraphics.java.

       {      if (!_polygon(xPoints, yPoints, nPoints)) {
                     return; 
              } else {
                     _buffer.append("closepath fill\n"); 
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.fillRect ( double  x,
double  y,
double  width,
double  height 
) [inline]

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.
    Parameters:
    xThe x coordinate of the top left corner.
    yThe y coordinate of the top left corner.
    widthThe width of the rectangle.
    heightThe height of the rectangle.

Definition at line 279 of file EPSGraphics.java.

                                                                             {
              EpsPoint start = _convert(x, y); 
              //_fillPattern();
              _buffer.append("newpath " + start.x + " " + start.y + " moveto\n"); 
              _buffer.append("0 " + round(-height) + " rlineto\n"); 
              _buffer.append("" + round(width) + " 0 rlineto\n"); 
              _buffer.append("0 " + round(height) + " rlineto\n"); 
              _buffer.append("" + round(-width) + " 0 rlineto\n"); 
              _buffer.append("closepath gsave fill grestore\n"); 
              _buffer.append("0.5 setlinewidth 0 setgray [] 0 setdash stroke\n"); 
              // reset the gray scale to black
              _buffer.append(round(LineWidth)+" setlinewidth\n"); 
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.fillRoundRect ( double  x,
double  y,
double  width,
double  height,
int  arcWidth,
int  arcHeight 
) [inline]

Definition at line 293 of file EPSGraphics.java.

                                           {
       }

Definition at line 298 of file EPSGraphics.java.

                              {
              return null; 
       }

Definition at line 302 of file EPSGraphics.java.

                                        {
              return null; 
       }

Definition at line 306 of file EPSGraphics.java.

                               {
              return _currentColor; 
       }

Definition at line 310 of file EPSGraphics.java.

                             {
              return _currentFont; 
       }
FontMetrics rene.zirkel.graphics.EPSGraphics.getFontMetrics ( Font  f) [inline]

Definition at line 314 of file EPSGraphics.java.

       {      if (FM==null) FM=new EpsFontMetrics(new Font("dialog",Font.PLAIN,20)); 
              return FM; 
       }

Here is the caller graph for this function:

Definition at line 318 of file EPSGraphics.java.

Here is the call graph for this function:

Here is the caller graph for this function:

double rene.zirkel.graphics.EPSGraphics.round ( double  x) [inline, private]

Definition at line 119 of file EPSGraphics.java.

       {      return Math.round(x*1000.0)/1000.0;
       }

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.setClip ( Shape  clip) [inline]

Definition at line 335 of file EPSGraphics.java.

                                       {
       }
void rene.zirkel.graphics.EPSGraphics.setClip ( int  x,
int  y,
int  width,
int  height 
) [inline]

Definition at line 338 of file EPSGraphics.java.

                                                                {
       }
void rene.zirkel.graphics.EPSGraphics.setColor ( Color  c) [inline]

Set the current color.

Parameters:
cThe desired current color.

Definition at line 344 of file EPSGraphics.java.

                                     {
              _buffer.append(c.getRed()/255.0); 
              _buffer.append(" "); 
              _buffer.append(c.getGreen()/255.0); 
              
              _buffer.append(" "); 
              _buffer.append(c.getBlue()/255.0); 
              
              _buffer.append(" setrgbcolor\n"); 
              // _buffer.append("[] 0 setdash\n");
              // _buffer.append("1 setlinewidth\n");
              
              _currentColor = c; 
       }

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.setDash ( double  a,
double  b 
) [inline]

Definition at line 364 of file EPSGraphics.java.

       {      _buffer.append("["+round(a)+" "+round(b)+" ] 0 setdash\n");
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.setFont ( Font  font) [inline]

Definition at line 322 of file EPSGraphics.java.

                                       {
              int size = font.getSize(); 
              boolean bold = font.isBold(); 
              if (bold) {
                     _buffer.append("/Helvetica-Bold findfont\n"); 
              } else {
                     _buffer.append("/Helvetica findfont\n"); 
              }
              _buffer.append("" + size + " scalefont setfont\n"); 
              _currentFont = font;
              FM=new EpsFontMetrics(font); 
       }

Here is the caller graph for this function:

void rene.zirkel.graphics.EPSGraphics.setLineWidth ( double  w) [inline]

Definition at line 359 of file EPSGraphics.java.

       {      _buffer.append(round(w)+" setlinewidth\n");
              LineWidth=w;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 372 of file EPSGraphics.java.

                                  {
       }
void rene.zirkel.graphics.EPSGraphics.setXORMode ( Color  c1) [inline]

Definition at line 375 of file EPSGraphics.java.

                                        {
       }
void rene.zirkel.graphics.EPSGraphics.showpage ( String  name) [inline]

Issue the PostScript showpage command, then write and flush the output.

Definition at line 382 of file EPSGraphics.java.

                                          {
              try {
                     //_buffer.append("showpage\n"); 
                     _buffer.append("%%EOF"); 
                     
                     PrintWriter output = new PrintWriter(
                            new java.io.FileWriter(name)); 
                     
                     output.println(_buffer.toString()); 
                     output.flush(); 
                     
              }
              catch(Exception e) { e.printStackTrace(); }
       }

Here is the call graph for this function:


Member Data Documentation

StringBuffer rene.zirkel.graphics.EPSGraphics._buffer = new StringBuffer() [private]

Definition at line 59 of file EPSGraphics.java.

Definition at line 60 of file EPSGraphics.java.

Definition at line 53 of file EPSGraphics.java.

Definition at line 54 of file EPSGraphics.java.

Definition at line 55 of file EPSGraphics.java.

Hashtable rene.zirkel.graphics.EPSGraphics._linepattern = new Hashtable() [private]

Definition at line 57 of file EPSGraphics.java.

Definition at line 56 of file EPSGraphics.java.

OutputStream rene.zirkel.graphics.EPSGraphics._out [private]

Definition at line 58 of file EPSGraphics.java.

Definition at line 77 of file EPSGraphics.java.

String [] rene.zirkel.graphics.EPSGraphics._patterns [static, private]
Initial value:
 {
              "[]",
                     "[1 1]",
                     "[4 4]",
                     "[4 4 1 4]",
                     "[2 2]",
                     "[4 2 1 2 1 2]",
                     "[5 3 2 3]",
                     "[3 3]",
                     "[4 2 1 2 2 2]",
                     "[1 2 5 2 1 2 1 2]",
                     "[4 1 2 1]",
       }

Definition at line 63 of file EPSGraphics.java.

Definition at line 55 of file EPSGraphics.java.

FontMetrics rene.zirkel.graphics.EPSGraphics.FM [private]

Definition at line 82 of file EPSGraphics.java.

Definition at line 80 of file EPSGraphics.java.

Definition at line 61 of file EPSGraphics.java.

Definition at line 79 of file EPSGraphics.java.


The documentation for this class was generated from the following file: