home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-01-24 | 1.6 KB | 89 lines |
- package COM.odi.demo.OSDraw;
-
- /**
- * <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
- */
-
- import COM.odi.*;
- import COM.odi.util.OSVector;
- import java.awt.*;
-
- /*
- * Class OSPolygon is a persistence-capable class
- * BitMapObject subclass
- * Capable of being a discrete instance in the database
- */
-
- public class OSPolygon extends BitMapObject {
-
- // Database fields modelled from class java.awt.Polygon
-
- private OSVector points;
-
- private OSColor color;
-
- private boolean fill;
-
- public OSPolygon() {
- points = new OSVector();
- color = new OSColor(0, 0, 0);
- fill = false;
- }
-
- // Method to draw the figure
-
- public void drawFigure(Graphics g) {
- Polygon polyFigure = getPolygon();
- g.setColor(color.getColor());
- if (fill) {
- g.fillPolygon(polyFigure);
- }
- else {
- g.drawPolygon(polyFigure);
- }
- }
-
- // Methods to access private data
-
- public int getSize() {
- return points.size();
- }
-
- public Polygon getPolygon() {
- Polygon poly = new Polygon();
- for (int i = 0; i < points.size(); i++) {
- OSPoint point = (OSPoint)points.elementAt(i);
- Point p = point.getPoint();
- poly.addPoint(p.x, p.y);
- }
- return poly;
- }
-
- public void addPoint(int x, int y) {
- points.addElement(new OSPoint(x, 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();
- }
- }
-
-