public class ImagePortrayal2D extends RectanglePortrayal2D
ImagePortrayal2D draws an image centered on the Portrayal's origin. Images are not stretched to fill the info.draw.height x info.draw.width rectangle. Instead, if the image is taller than it is wide, then the width of the image will be info.draw.width * scale and the height will stay in proportion; else the height of the image will be info.draw.height * scale and the width will stay in proportion.
Modifier and Type | Field and Description |
---|---|
java.awt.Image |
image |
filled, paint, scale
TYPE_HIT_OBJECT, TYPE_SELECTED_OBJECT
Constructor and Description |
---|
ImagePortrayal2D(java.lang.Class c,
java.lang.String resourceName)
Creates an ImagePortrayal2D by loading an Image resource using getClass().getResource()
|
ImagePortrayal2D(java.lang.Class c,
java.lang.String resourceName,
double scale)
Creates an ImagePortrayal2D by loading an Image resource using getClass().getResource(), and scaled with the given scale.
|
ImagePortrayal2D(java.awt.Image image)
Creates an ImagePortrayal2D with the given image.
|
ImagePortrayal2D(java.awt.Image image,
double scale)
Creates an ImagePortrayal2D with the given image, and scaled with the given scale..
|
ImagePortrayal2D(javax.swing.ImageIcon icon)
Creates an ImagePortrayal2D with the image inside the given ImageIcon.
|
ImagePortrayal2D(javax.swing.ImageIcon icon,
double scale)
Creates an ImagePortrayal2D with the image inside the given ImageIcon, and scaled with the given scale.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(java.lang.Object object,
java.awt.Graphics2D graphics,
DrawInfo2D info)
Draw a the given object with an origin at (info.draw.x, info.draw.y),
and with the coordinate system scaled by so that 1 unit is in the x and
y directions are equal to info.draw.width and info.draw.height respectively
in pixels.
|
hitObject
getInspector, getName, getStatus, handleMouseEvent, setSelected
public ImagePortrayal2D(javax.swing.ImageIcon icon, double scale)
public ImagePortrayal2D(javax.swing.ImageIcon icon)
public ImagePortrayal2D(java.lang.Class c, java.lang.String resourceName, double scale)
public ImagePortrayal2D(java.lang.Class c, java.lang.String resourceName)
public ImagePortrayal2D(java.awt.Image image)
public ImagePortrayal2D(java.awt.Image image, double scale)
public void draw(java.lang.Object object, java.awt.Graphics2D graphics, DrawInfo2D info)
Portrayal2D
draw
in interface Portrayal2D
draw
in class RectanglePortrayal2D