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 / OSRectangle.java < prev    next >
Encoding:
Java Source  |  1997-01-24  |  1.6 KB  |  94 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 java.awt.*;
  9.  
  10. /*
  11.  * Class OSRectangle is a persistence-capable class
  12.  * BitMapObject subclass
  13.  * Capable of being a discrete instance in the database
  14.  */
  15.  
  16. public class OSRectangle extends BitMapObject {
  17.  
  18.   // Database fields
  19.  
  20.   private int x1;
  21.   private int y1;
  22.   private int x2;
  23.   private int y2;
  24.  
  25.   private OSColor color; // Color of Rectangle
  26.  
  27.   private boolean fill;
  28.  
  29.   public OSRectangle(int x1, int y1, int x2, int y2) {
  30.     this.x1 = x1;
  31.     this.y1 = y1;
  32.     this.x2 = x2;
  33.     this.y2 = y2;
  34.     color = new OSColor(0, 0, 0);
  35.     fill = false;
  36.   }
  37.  
  38.   // Method to draw the figure
  39.  
  40.   public void drawFigure(Graphics g) {
  41.     g.setColor(color.getColor());
  42.     if (fill) {
  43.       g.fillRect(x1, y1, x2 - x1, y2 - y1);
  44.     }
  45.     else {
  46.       g.drawRect(x1, y1, x2 - x1, y2 - y1);
  47.     }
  48.   }
  49.  
  50.  
  51.   // Methods to access private fields
  52.  
  53.   public Point getFirstPoint() {
  54.     return new Point(x1, y1);
  55.   }
  56.  
  57.   public Point getSecondPoint() {
  58.     return new Point(x2, y2);
  59.   }
  60.  
  61.   public void setFirstPoint(Point point) {
  62.     x1 = point.x;
  63.     y1 = point.y;
  64.   }
  65.  
  66.   public void setSecondPoint(Point point) {
  67.     x2 = point.x;
  68.     y2 = point.y;
  69.   }
  70.  
  71.   public Color getColor() {
  72.     return color.getColor();
  73.   }
  74.  
  75.   public void setColor(Color color) {
  76.     this.color.setColor(color);
  77.   }
  78.  
  79.   public boolean getFillStatus() {
  80.     return fill;
  81.   }
  82.  
  83.   public void setFillStatus(boolean fill) {
  84.     this.fill = fill;
  85.   }
  86.  
  87.   // Default hashCode method
  88.  
  89.   public int hashCode() {
  90.     return super.hashCode();
  91.   }
  92. }
  93.  
  94.