|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.AbstractPaintable
edu.neu.ccs.gui.ImagePaintable
An ImagePaintable creates an AbstractPaintable
using an image, image icon, filename, or URL.
Specifically, an ImagePaintable object may be created using
one of the following:
In 2.3.2, the method getBounds2D was modified to use the
default Bounds2D rectangle if that rectangle is non-null
before making any other tests or computations.
In 2.3.3, the code was made parallel to that of the new class
ImagePaintableLite. The class ImagePaintable
retains image data throughout the life time of an instance and thus may
paint more rapidly at the cost of larger memory footprint.
In 2.3.5, the class was refactored to be consistent with
the new Paintable interface and
the new AbstractPaintable class.
In 2.4.0, this class was updated to be consistent with refinements
to the Paintable interface.
ImagePaintableLite| Field Summary | |
private int |
height
The image height. |
private Image |
image
The image. |
static String |
SET_IMAGE
Bound property name for set image. |
static String |
SET_TOP_LEFT_CORNER
Bound property name for set top left point. |
private int |
width
The image width. |
private double |
xCorner
The top left corner x-position. |
private double |
yCorner
The top left corner y-position. |
| Fields inherited from class edu.neu.ccs.gui.AbstractPaintable |
SET_BACKGROUND_PAINT, SET_BACKGROUND_TILE |
| Fields inherited from interface edu.neu.ccs.gui.Paintable |
REMOVE_PAINTABLE, SET_CLIPPING_SHAPE, SET_DEFAULT_BOUNDS2D, SET_DEFAULT_CENTER, SET_DEFAULT_ORIGINAL_BOUNDS2D, SET_DEFAULT_ORIGINAL_CENTER, SET_MUTATOR, SET_OPACITY, SET_PAINTABLE, SET_VISIBLE, SHIFT_PAINTABLE |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Constructor Summary | |
ImagePaintable()
The default constructor that does not specify the image. |
|
ImagePaintable(Image image)
The constructor to specify the image directly. |
|
ImagePaintable(Image image,
double x,
double y)
The constructor to specify the image directly and the top left corner (x, y). |
|
ImagePaintable(ImageIcon imageicon)
The constructor to specify the image by image icon. |
|
ImagePaintable(ImageIcon imageicon,
double x,
double y)
The constructor to specify the image by image icon and the top left corner (x, y). |
|
ImagePaintable(ImageIcon imageicon,
Point2D corner)
The constructor to specify the image by image icon and the top left corner. |
|
ImagePaintable(Image image,
Point2D corner)
The constructor to specify the image directly and the top left corner. |
|
ImagePaintable(String filename)
The constructor to specify the image by file name. |
|
ImagePaintable(String filename,
double x,
double y)
The constructor to specify the image by file name and the top left corner (x, y). |
|
ImagePaintable(String filename,
Point2D corner)
The constructor to specify the image by file name and the top left corner. |
|
ImagePaintable(URL url)
The constructor to specify the image by URL. |
|
ImagePaintable(URL url,
double x,
double y)
The constructor to specify the image by URL and the top left corner (x, y). |
|
ImagePaintable(URL url,
Point2D corner)
The constructor to specify the image by URL and the top left corner. |
|
| Method Summary | |
XRect |
getActualBounds2D()
Returns the actual bounds of the original paintable or null if the paintable is effectively empty. |
Image |
getImage()
Returns the encapsulated image. |
int |
getImageHeight()
Returns the image height. |
int |
getImageWidth()
Returns the image width. |
Point2D |
getTopLeftCorner()
Returns a copy of the top left corner. |
boolean |
originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation. |
void |
originalPaint(Graphics g)
Paints onto a Graphics context using information
from this object but without the use of the mutator transform. |
void |
setImage(Image image)
Sets the image directly. |
void |
setImageByFileName(String filename)
Sets the image by file name. |
void |
setImageByImageIcon(ImageIcon imageicon)
Sets the image by image icon. |
void |
setImageByURL(URL url)
Sets the image by URL. |
private void |
setImageSizeParameters()
Sets the image width and height based on the current image or sets this data to (0, 0) if the current image is undefined. |
void |
setTopLeftCorner(double x,
double y)
Sets the top left corner with the given corner (x, y). |
void |
setTopLeftCorner(Point2D corner)
Sets the top left corner with the given corner. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String SET_IMAGE
public static final String SET_TOP_LEFT_CORNER
private Image image
private double xCorner
private double yCorner
private int width
private int height
| Constructor Detail |
public ImagePaintable()
The default constructor that does not specify the image.
Other constructors:
- ImagePaintable(Image)
- ImagePaintable(Image, Point2D)
- ImagePaintable(Image, double, double)
- ImagePaintable(ImageIcon)
- ImagePaintable(ImageIcon, Point2D)
- ImagePaintable(ImageIcon, double, double)
- ImagePaintable(String)
- ImagePaintable(String, Point2D)
- ImagePaintable(String, double, double)
- ImagePaintable(URL)
- ImagePaintable(URL, Point2D)
- ImagePaintable(URL, double, double)
public ImagePaintable(Image image)
The constructor to specify the image directly.
image - the imageImagePaintable()
public ImagePaintable(Image image,
Point2D corner)
The constructor to specify the image directly and the top left corner.
image - the imagecorner - the top left cornerImagePaintable()
public ImagePaintable(Image image,
double x,
double y)
The constructor to specify the image directly and the top left corner (x, y).
image - the imagex - the x-coordinate of the top left cornery - the y-coordinate of the top left cornerImagePaintable()public ImagePaintable(ImageIcon imageicon)
The constructor to specify the image by image icon.
imageicon - the imageicon to define the imageImagePaintable()
public ImagePaintable(ImageIcon imageicon,
Point2D corner)
The constructor to specify the image by image icon and the top left corner.
imageicon - the imageicon to define the imagecorner - the top left cornerImagePaintable()
public ImagePaintable(ImageIcon imageicon,
double x,
double y)
The constructor to specify the image by image icon and the top left corner (x, y).
imageicon - the imageicon to define the imagex - the x-coordinate of the top left cornery - the y-coordinate of the top left cornerImagePaintable()public ImagePaintable(String filename)
The constructor to specify the image by file name.
filename - the filename for the file with the imageImagePaintable()
public ImagePaintable(String filename,
Point2D corner)
The constructor to specify the image by file name and the top left corner.
filename - the filename for the file with the imagecorner - the top left cornerImagePaintable()
public ImagePaintable(String filename,
double x,
double y)
The constructor to specify the image by file name and the top left corner (x, y).
filename - the filename for the file with the imagex - the x-coordinate of the top left cornery - the y-coordinate of the top left cornerImagePaintable()public ImagePaintable(URL url)
The constructor to specify the image by URL.
url - the URL location for the imageImagePaintable()
public ImagePaintable(URL url,
Point2D corner)
url - the URL location for the imagecorner - the top left cornerImagePaintable()
public ImagePaintable(URL url,
double x,
double y)
url - the URL location for the imagex - the x-coordinate of the top left cornery - the y-coordinate of the top left cornerImagePaintable()| Method Detail |
public final void originalPaint(Graphics g)
Paints onto a Graphics context using information
from this object but without the use of the mutator transform.
If the current image or the graphics context is null,
this method will not paint.
originalPaint in interface PaintableoriginalPaint in class AbstractPaintableg - the graphics context on which to paintpublic final XRect getActualBounds2D()
Returns the actual bounds of the original paintable or
null if the paintable is effectively empty.
getActualBounds2D in interface PaintablegetActualBounds2D in class AbstractPaintable
public final boolean originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation.
originalContains in interface PaintableoriginalContains in class AbstractPaintablex - the x-coordinate of the pointy - the y-coordinate of the point
public final void setImage(Image image)
Sets the image directly.
Fires property change: SET_IMAGE.
image - the imagepublic final void setImageByImageIcon(ImageIcon imageicon)
Sets the image by image icon.
If the image icon is null,
the encapsulated image is set to null.
Fires property change: SET_IMAGE.
imageicon - the imageicon to define the imagepublic final void setImageByFileName(String filename)
Sets the image by file name.
If the file name is null,
the encapsulated image is set to null.
Fires property change: SET_IMAGE.
filename - the filename for the file with the imagepublic final void setImageByURL(URL url)
Sets the image by URL.
If the url is null,
the encapsulated image is set to null.
Fires property change: SET_IMAGE.
url - the URL location for the imagepublic final Image getImage()
public final void setTopLeftCorner(Point2D corner)
Sets the top left corner with the given corner.
A null parameter is ignored.
Fires property change: SET_TOP_LEFT_CORNER.
corner - the top left corner
public final void setTopLeftCorner(double x,
double y)
Sets the top left corner with the given corner (x, y).
Fires property change: SET_TOP_LEFT_CORNER.
x - the x-coordinate of the top left cornery - the y-coordinate of the top left cornerpublic final Point2D getTopLeftCorner()
Returns a copy of the top left corner.
public final int getImageWidth()
Returns the image width.
If the current image is null, this method returns 0.
public final int getImageHeight()
Returns the image height.
If the current image is null, this method returns 0.
private final void setImageSizeParameters()
Sets the image width and height based on the current image or sets this data to (0, 0) if the current image is undefined.
Fires property change: SET_IMAGE.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||