home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-01-24 | 1.6 KB | 94 lines |
- package COM.odi.demo.OSDraw;
-
- /**
- * <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
- */
-
- import COM.odi.*;
- import java.awt.*;
-
- /*
- * Class OSRectangle is a persistence-capable class
- * BitMapObject subclass
- * Capable of being a discrete instance in the database
- */
-
- public class OSRectangle extends BitMapObject {
-
- // Database fields
-
- private int x1;
- private int y1;
- private int x2;
- private int y2;
-
- private OSColor color; // Color of Rectangle
-
- private boolean fill;
-
- public OSRectangle(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);
- fill = false;
- }
-
- // Method to draw the figure
-
- public void drawFigure(Graphics g) {
- g.setColor(color.getColor());
- if (fill) {
- g.fillRect(x1, y1, x2 - x1, y2 - y1);
- }
- else {
- g.drawRect(x1, y1, x2 - x1, y2 - y1);
- }
- }
-
-
- // Methods to 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);
- }
-
- public boolean getFillStatus() {
- return fill;
- }
-
- public void setFillStatus(boolean fill) {
- this.fill = fill;
- }
-
- // Default hashCode method
-
- public int hashCode() {
- return super.hashCode();
- }
- }
-
-