uwcse.graphics
Class ImageShape
java.lang.Object
|
+--uwcse.graphics.ShapeImpl
|
+--uwcse.graphics.ImageShape
- All Implemented Interfaces:
- Shape
- public class ImageShape
- extends ShapeImpl
- implements Shape
A class for image shapes (e.g. jpegs). The main operations are to
read the x and y coordinates of the upper-left corner and the
center of the image (getX(), getY(), getCenterX(), and
getCenterY()), to change the position of the image (moveBy(...) and
moveTo(...)), to rotate the position of the image (but not the
image itself) around some point (rotateAround(...)), to read the
width and height of the image (getWidth(), getHeight()), to change
the underlying image (setImage(...)), and add to and remove from a
GWindow (addTo(...) and removeFromWindow()). Other operations are
mainly for internal use, and should not be called by regular client
programs.
Use the getImageFromFilename and getImageFromURL operations on
GWindows to create Image objects, which can then be used to create
ImageShape objects.
Constructor Summary |
ImageShape(java.awt.Image i,
int x,
int y)
Create a new image of the given size. |
Method Summary |
void |
paint(java.awt.Graphics g)
Paint/draw this image onto the given graphics context. |
void |
setImage(java.awt.Image newImage)
Change the image |
static void |
testFromFilename(java.lang.String imageName)
|
static void |
testFromURL(java.lang.String imageURL)
|
java.lang.String |
toString()
Answer the printed representation of this shape. |
Methods inherited from class uwcse.graphics.ShapeImpl |
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, moveTo, recordWindow, removeFromWindow, rotateAround, setColor |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface uwcse.graphics.Shape |
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, moveTo, recordWindow, removeFromWindow, rotateAround, setColor |
ImageShape
public ImageShape(java.awt.Image i,
int x,
int y)
- Create a new image of the given size.
- Parameters:
i
- the imagex
- the x coordinate of the upper left cornery
- the y coordinate of the upper left corner
paint
public void paint(java.awt.Graphics g)
- Paint/draw this image onto the given graphics context.
- Specified by:
paint
in interface Shape
setImage
public void setImage(java.awt.Image newImage)
- Change the image
testFromFilename
public static void testFromFilename(java.lang.String imageName)
testFromURL
public static void testFromURL(java.lang.String imageURL)
toString
public java.lang.String toString()
- Description copied from class:
ShapeImpl
- Answer the printed representation of this shape.
- Overrides:
toString
in class ShapeImpl