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 / OSText.java < prev    next >
Encoding:
Java Source  |  1997-01-24  |  1.6 KB  |  92 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 OSText is a persistence-capable class
  12.  * BitMapObject subclass
  13.  * Capable of being a discrete instance in the database
  14.  */
  15.  
  16. public class OSText extends BitMapObject {
  17.  
  18.   // Database fields
  19.  
  20.   private String caption;
  21.   private int x;
  22.   private int y;
  23.  
  24.   private String name;        // Name of font
  25.   private int style;        // Style of font
  26.   private int size;        // Size of font
  27.  
  28.   private OSColor color;
  29.  
  30.   public OSText(String caption, int x, int y) {
  31.     this.caption = caption;
  32.     this.x = x;
  33.     this.y = y;
  34.     name = "Arial";
  35.     style = Font.PLAIN;
  36.     size = 12;
  37.     color = new OSColor(0, 0, 0);
  38.   }
  39.  
  40.   // Method to draw the figure
  41.   
  42.   public void drawFigure(Graphics g) {
  43.     g.setColor(color.getColor());
  44.     g.setFont(new Font(name, style, size));
  45.     g.drawString(getString(), x, y);
  46.   }
  47.  
  48.   // Methods to access private data
  49.  
  50.   public String getString() {
  51.     return caption;
  52.   }
  53.  
  54.   public void setString(String caption) {
  55.     this.caption = caption;
  56.   }
  57.  
  58.   public Point getPoint() {
  59.     return new Point(x, y);
  60.   }
  61.  
  62.   public void setPoint(Point point) {
  63.     x = point.x;
  64.     y = point.y;
  65.   }
  66.  
  67.   public Font getFont() {
  68.     return new Font(name, style, size);
  69.   }
  70.  
  71.   public void setFont(Font font) {
  72.     name = font.getName();
  73.     style = font.getStyle();
  74.     size = font.getSize();
  75.   }
  76.  
  77.   public Color getColor() {
  78.     return color.getColor();
  79.   }
  80.  
  81.   public void setColor(Color color) {
  82.     this.color.setColor(color);
  83.   }
  84.  
  85.   // Default hashCode method
  86.  
  87.   public int hashCode() {
  88.     return super.hashCode();
  89.   }
  90. }
  91.  
  92.