home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-01-24 | 1.3 KB | 79 lines |
- package COM.odi.demo.OSDraw;
-
- /**
- * <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
- */
-
- import COM.odi.*;
- import java.awt.*;
-
- /*
- * Class OSLine is a persistence-capable class
- * Subclass of BitMapObject
- * Capable of being a discrete instance in the database
- */
-
- public class OSLine extends BitMapObject {
-
- // Database fields
-
- private int x1;
- private int y1;
- private int x2;
- private int y2;
-
- private OSColor color; // Color of physical object
-
- // Constructors
-
- public OSLine(int x1, int y1, int x2, int y2) {
- this.x1 = x1;
- this.y1 = y1;
- this.x2 = x2;
- this.y2 = y2;
- color = new OSColor(0, 0, 0);
- }
-
- // Method to draw the figure
-
- public void drawFigure(Graphics g) {
- g.setColor(color.getColor());
- g.drawLine(x1, y1, x2, y2);
- }
-
- // Methods that access private fields
-
- public Point getFirstPoint() {
- return new Point(x1, y1);
- }
-
- public Point getSecondPoint() {
- return new Point(x2, y2);
- }
-
- public void setFirstPoint(Point point) {
- x1 = point.x;
- y1 = point.y;
- }
-
- public void setSecondPoint(Point point) {
- x2 = point.x;
- y2 = point.y;
- }
-
- public Color getColor() {
- return color.getColor();
- }
-
- public void setColor(Color color) {
- this.color.setColor(color);
- }
-
- // Default hashCode method
-
- public int hashCode() {
- return super.hashCode();
- }
- }
-
-