ImageGraphicAttributepublic final class ImageGraphicAttribute extends GraphicAttribute The ImageGraphicAttribute class provides an opportunity to insert images to a
text. |
Fields Summary |
---|
private Image | fImageThe image. | private float | fOriginXThe origin x. | private float | fOriginYThe origin y. | private float | fImgWidthThe img width. | private float | fImgHeightThe img height. |
Constructors Summary |
---|
public ImageGraphicAttribute(Image image, int alignment, float originX, float originY)Instantiates a new ImageGraphicAttribute with the specified image,
alignment and origins.
super(alignment);
this.fImage = image;
this.fOriginX = originX;
this.fOriginY = originY;
this.fImgWidth = fImage.getWidth(null);
this.fImgHeight = fImage.getHeight(null);
| public ImageGraphicAttribute(Image image, int alignment)Instantiates a new ImageGraphicAttribute with the specified image and
alignment.
this(image, alignment, 0, 0);
|
Methods Summary |
---|
public void | draw(java.awt.Graphics2D g2, float x, float y)
g2.drawImage(fImage, (int)(x - fOriginX), (int)(y - fOriginY), null);
| public boolean | equals(java.awt.font.ImageGraphicAttribute iga)Compares the specified ImageGraphicAttribute object with this
ImageGraphicAttribute object.
if (iga == null) {
return false;
}
if (iga == this) {
return true;
}
return (fOriginX == iga.fOriginX && fOriginY == iga.fOriginY
&& getAlignment() == iga.getAlignment() && fImage.equals(iga.fImage));
| public boolean | equals(java.lang.Object obj)Compares the specified Object with this ImageGraphicAttribute object.
try {
return equals((ImageGraphicAttribute)obj);
} catch (ClassCastException e) {
return false;
}
| public float | getAdvance()
return Math.max(0, fImgWidth - fOriginX);
| public float | getAscent()
return Math.max(0, fOriginY);
| public java.awt.geom.Rectangle2D | getBounds()
return new Rectangle2D.Float(-fOriginX, -fOriginY, fImgWidth, fImgHeight);
| public float | getDescent()
return Math.max(0, fImgHeight - fOriginY);
| public int | hashCode()Returns a hash code of this ImageGraphicAttribute object.
HashCode hash = new HashCode();
hash.append(fImage.hashCode());
hash.append(getAlignment());
return hash.hashCode();
|
|