home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / java / awt / font / ShapeGraphicAttribute.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  1.7 KB  |  85 lines

  1. package java.awt.font;
  2.  
  3. import java.awt.Graphics2D;
  4. import java.awt.Shape;
  5. import java.awt.geom.Rectangle2D;
  6.  
  7. public final class ShapeGraphicAttribute extends GraphicAttribute {
  8.    private Shape fShape;
  9.    private boolean fStroke;
  10.    public static final boolean STROKE = true;
  11.    public static final boolean FILL = false;
  12.    private Rectangle2D fShapeBounds;
  13.  
  14.    public ShapeGraphicAttribute(Shape var1, int var2, boolean var3) {
  15.       super(var2);
  16.       this.fShape = var1;
  17.       this.fStroke = var3;
  18.       this.fShapeBounds = this.fShape.getBounds2D();
  19.    }
  20.  
  21.    public float getAscent() {
  22.       return (float)Math.max((double)0.0F, -this.fShapeBounds.getMinY());
  23.    }
  24.  
  25.    public float getDescent() {
  26.       return (float)Math.max((double)0.0F, this.fShapeBounds.getMaxY());
  27.    }
  28.  
  29.    public float getAdvance() {
  30.       return (float)Math.max((double)0.0F, this.fShapeBounds.getMaxX());
  31.    }
  32.  
  33.    public void draw(Graphics2D var1, float var2, float var3) {
  34.       var1.translate((int)var2, (int)var3);
  35.  
  36.       try {
  37.          if (this.fStroke) {
  38.             var1.draw(this.fShape);
  39.          } else {
  40.             var1.fill(this.fShape);
  41.          }
  42.       } finally {
  43.          var1.translate(-((int)var2), -((int)var3));
  44.       }
  45.  
  46.    }
  47.  
  48.    public Rectangle2D getBounds() {
  49.       Rectangle2D.Float var1 = new Rectangle2D.Float();
  50.       var1.setRect(this.fShapeBounds);
  51.       if (this.fStroke) {
  52.          ++var1.width;
  53.          ++var1.height;
  54.       }
  55.  
  56.       return var1;
  57.    }
  58.  
  59.    public int hashCode() {
  60.       return this.fShape.hashCode();
  61.    }
  62.  
  63.    public boolean equals(Object var1) {
  64.       try {
  65.          return this.equals((ShapeGraphicAttribute)var1);
  66.       } catch (ClassCastException var3) {
  67.          return false;
  68.       }
  69.    }
  70.  
  71.    public boolean equals(ShapeGraphicAttribute var1) {
  72.       if (var1 == null) {
  73.          return false;
  74.       } else if (this == var1) {
  75.          return true;
  76.       } else if (this.fStroke != var1.fStroke) {
  77.          return false;
  78.       } else if (((GraphicAttribute)this).getAlignment() != ((GraphicAttribute)var1).getAlignment()) {
  79.          return false;
  80.       } else {
  81.          return this.fShape.equals(var1.fShape);
  82.       }
  83.    }
  84. }
  85.