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 / OSLine.java < prev    next >
Encoding:
Java Source  |  1997-01-24  |  1.3 KB  |  79 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 OSLine is a persistence-capable class
  12.  * Subclass of BitMapObject
  13.  * Capable of being a discrete instance in the database
  14.  */
  15.  
  16. public class OSLine 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 physical object
  26.  
  27.   // Constructors
  28.  
  29.   public OSLine(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.   }
  36.  
  37.   // Method to draw the figure
  38.  
  39.   public void drawFigure(Graphics g) {
  40.     g.setColor(color.getColor());
  41.     g.drawLine(x1, y1, x2, y2);
  42.   }
  43.  
  44.   // Methods that access private fields
  45.  
  46.   public Point getFirstPoint() {
  47.     return new Point(x1, y1);
  48.   }
  49.  
  50.   public Point getSecondPoint() {
  51.     return new Point(x2, y2);
  52.   }
  53.  
  54.   public void setFirstPoint(Point point) {
  55.     x1 = point.x;
  56.     y1 = point.y;
  57.   }
  58.  
  59.   public void setSecondPoint(Point point) {
  60.     x2 = point.x;
  61.     y2 = point.y;
  62.   }
  63.  
  64.   public Color getColor() {
  65.     return color.getColor();
  66.   }
  67.  
  68.   public void setColor(Color color) {
  69.     this.color.setColor(color);
  70.   }
  71.  
  72.   // Default hashCode method
  73.  
  74.   public int hashCode() {
  75.     return super.hashCode();
  76.   }
  77. }
  78.  
  79.