home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / in4wjcxu / src / como / commlet / draw / gooval.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  1.2 KB  |  74 lines

  1.  
  2. package como.commlet.draw;
  3.  
  4. import como.io.*;
  5. import como.util.*;
  6. import java.awt.*;
  7. import java.io.*;
  8. import java.util.*; import java.lang.*;
  9.  
  10. /******
  11. * GOPolygon
  12. */
  13. public class GOOval extends GORect
  14. {
  15.  
  16.     public GOOval()
  17.     {
  18.         super();
  19.         filled = false;
  20.     }        
  21.     public GraphicsObject getNew ()  {
  22.         GOOval go = new GOOval();
  23.         go.color = color;
  24.         go.name = name;
  25.         go.x = x;
  26.         go.y = y;
  27.         go.width = 0;
  28.         go.height = 0;
  29.         go.filled = filled;
  30.         return go;
  31.     }
  32.  
  33.     public void draw(Graphics g,Color c)
  34.     {
  35.         lastgraphics = g;
  36.         g.setColor(c);
  37.         if ((width !=0) && (height !=0)) {
  38.             int x0,y0,w,h;
  39.             if (width > 0) {
  40.                 x0 = x; 
  41.                 w = width; 
  42.             } 
  43.             else { 
  44.                 x0 = x + width; 
  45.                 w = -width; 
  46.             }
  47.             if (height > 0) {
  48.                 y0 = y; 
  49.                 h = height; 
  50.             } 
  51.             else {
  52.                 y0 = y + height; 
  53.                 h = -height; 
  54.             }
  55.             if (filled) g.fillOval(x0,y0,w,h); 
  56.             else g.drawOval(x0,y0,w,h);
  57.         }
  58.     }        
  59.     public String toString() {
  60.     return super.toString() + "Width = "+width+"Height = "+height;
  61.     }
  62.     public void save(ObjectOutputStream s) throws IOException {
  63.         super.save(s);
  64.         s.writeInt(width);
  65.         s.writeInt(height);
  66.     }
  67.     public void load(ObjectInputStream s) throws IOException {
  68.         super.load(s);
  69.         width = s.readInt();
  70.         height = s.readInt();
  71.     }
  72. }
  73.  
  74.