home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-01-24 | 1.6 KB | 92 lines |
- package COM.odi.demo.OSDraw;
-
- /**
- * <H3>Copyright (C) Object Design Inc. 1996, 1997</H3>
- */
-
- import COM.odi.*;
- import java.awt.*;
-
- /*
- * Class OSText is a persistence-capable class
- * BitMapObject subclass
- * Capable of being a discrete instance in the database
- */
-
- public class OSText extends BitMapObject {
-
- // Database fields
-
- private String caption;
- private int x;
- private int y;
-
- private String name; // Name of font
- private int style; // Style of font
- private int size; // Size of font
-
- private OSColor color;
-
- public OSText(String caption, int x, int y) {
- this.caption = caption;
- this.x = x;
- this.y = y;
- name = "Arial";
- style = Font.PLAIN;
- size = 12;
- color = new OSColor(0, 0, 0);
- }
-
- // Method to draw the figure
-
- public void drawFigure(Graphics g) {
- g.setColor(color.getColor());
- g.setFont(new Font(name, style, size));
- g.drawString(getString(), x, y);
- }
-
- // Methods to access private data
-
- public String getString() {
- return caption;
- }
-
- public void setString(String caption) {
- this.caption = caption;
- }
-
- public Point getPoint() {
- return new Point(x, y);
- }
-
- public void setPoint(Point point) {
- x = point.x;
- y = point.y;
- }
-
- public Font getFont() {
- return new Font(name, style, size);
- }
-
- public void setFont(Font font) {
- name = font.getName();
- style = font.getStyle();
- size = font.getSize();
- }
-
- public Color getColor() {
- return color.getColor();
- }
-
- public void setColor(Color color) {
- this.color.setColor(color);
- }
-
- // Default hashCode method
-
- public int hashCode() {
- return super.hashCode();
- }
- }
-
-