home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Extras / ODesign / SetupPSE.exe / data.z / OSPolygon.java < prev    next >
Encoding:
Java Source  |  1997-01-24  |  1.6 KB  |  89 lines

  1. package COM.odi.demo.OSDraw;
  2.  
  3. /**
  4.  *      <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
  5.  */
  6.  
  7. import COM.odi.*;
  8. import COM.odi.util.OSVector;
  9. import java.awt.*;
  10.  
  11. /*
  12.  * Class OSPolygon is a persistence-capable class
  13.  * BitMapObject subclass
  14.  * Capable of being a discrete instance in the database
  15.  */
  16.  
  17. public class OSPolygon extends BitMapObject {
  18.  
  19.   // Database fields modelled from class java.awt.Polygon
  20.  
  21.   private OSVector points;
  22.  
  23.   private OSColor color;
  24.  
  25.   private boolean fill;
  26.  
  27.   public OSPolygon() {
  28.     points = new OSVector();
  29.     color = new OSColor(0, 0, 0);
  30.     fill = false;
  31.   }
  32.  
  33.   // Method to draw the figure
  34.   
  35.   public void drawFigure(Graphics g) {
  36.     Polygon polyFigure = getPolygon();
  37.     g.setColor(color.getColor());
  38.     if (fill) {
  39.       g.fillPolygon(polyFigure);
  40.     }
  41.     else {
  42.       g.drawPolygon(polyFigure);
  43.     }
  44.   }
  45.  
  46.   // Methods to access private data
  47.  
  48.   public int getSize() {
  49.     return points.size();
  50.   }
  51.  
  52.   public Polygon getPolygon() {
  53.     Polygon poly = new Polygon();
  54.     for (int i = 0; i < points.size(); i++) {
  55.       OSPoint point = (OSPoint)points.elementAt(i);
  56.       Point p = point.getPoint();
  57.       poly.addPoint(p.x, p.y);
  58.     }
  59.     return poly;
  60.   }
  61.  
  62.   public void addPoint(int x, int y) {
  63.     points.addElement(new OSPoint(x, y));
  64.   }
  65.  
  66.   public Color getColor() {
  67.     return color.getColor();
  68.   }
  69.  
  70.   public void setColor(Color color) {
  71.     this.color.setColor(color);
  72.   }
  73.  
  74.   public boolean getFillStatus() {
  75.     return fill;
  76.   }
  77.  
  78.   public void setFillStatus(boolean fill) {
  79.     this.fill = fill;
  80.   }
  81.  
  82.   // Default hashCode method
  83.  
  84.   public int hashCode() {
  85.     return super.hashCode();
  86.   }
  87. }
  88.  
  89.