|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--edu.neu.ccs.gui.AbstractPaintable
|
+--edu.neu.ccs.gui.ImagePaintableLite
An ImagePaintableLite creates an AbstractPaintable
using an image filename or an image URL.
To save memory, an ImagePaintableLite does not cache its image
but rather retrieves its image as needed for paint operations. Thus the class
trades time for space. This design enables a program to access a much larger
collection of images at one time than would be possible by directly using the
Java classes Image or ImageIcon or the JPT class
ImagePaintable. These other classes all retain the bit data for
an image and thus entail a high memory cost.
ImagePaintable| Field Summary | |
static String |
SET_IMAGE
Bound property name for set image. |
static String |
SET_TOP_LEFT_CORNER
Bound property name for set top left point. |
| Fields inherited from class edu.neu.ccs.gui.AbstractPaintable |
SET_DEFAULT_BOUNDS2D, SET_DEFAULT_CENTER, SET_OPACITY, SET_VISIBLE |
| Constructor Summary | |
ImagePaintableLite()
The default constructor that does not specify the image. |
|
ImagePaintableLite(String filename)
The constructor to specify the image by an image file name. |
|
ImagePaintableLite(String filename,
double x,
double y)
The constructor to specify the image by an image file name and the top left corner (x, y). |
|
ImagePaintableLite(String filename,
Point2D corner)
The constructor to specify the image by an image file name and the top left corner. |
|
ImagePaintableLite(URL url)
The constructor to specify the image by an image URL. |
|
ImagePaintableLite(URL url,
double x,
double y)
The constructor to specify the image by an image URL and the top left corner (x, y). |
|
ImagePaintableLite(URL url,
Point2D corner)
The constructor to specify the image by an image URL and the top left corner. |
|
| Method Summary | |
boolean |
contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable. |
Rectangle2D |
getBounds2D()
Returns the bounds of the paintable based on the default settings or on more detailed computations. |
Point2D |
getCenter()
If the value of getDefaultCenter is non-null,
then this value is returned. |
int |
getImageHeight()
Returns the image height. |
int |
getImageWidth()
Returns the image width. |
Point2D |
getTopLeftCorner()
Returns a copy of the top left corner. |
void |
paint(Graphics g)
Paints onto a Graphics context using information
from this object. |
void |
setImageByFileName(String filename)
Sets the image by file name. |
void |
setImageByURL(URL url)
Sets the image by URL. |
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
| Constructor Detail |
public ImagePaintableLite()
The default constructor that does not specify the image.
Other constructors:
- ImagePaintableLite(String)
- ImagePaintableLite(String, Point2D)
- ImagePaintableLite(String, double, double)
- ImagePaintableLite(URL)
- ImagePaintableLite(URL, Point2D)
- ImagePaintableLite(URL, double, double)
public ImagePaintableLite(String filename)
The constructor to specify the image by an image file name.
filename - the filename for the file with the imageImagePaintableLite()
public ImagePaintableLite(String filename,
Point2D corner)
The constructor to specify the image by an image file name and the top left corner.
filename - the filename for the file with the imagecorner - the top left cornerImagePaintableLite()
public ImagePaintableLite(String filename,
double x,
double y)
The constructor to specify the image by an image 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 cornerImagePaintableLite()public ImagePaintableLite(URL url)
The constructor to specify the image by an image URL.
url - the URL location for the imageImagePaintableLite()
public ImagePaintableLite(URL url,
Point2D corner)
The constructor to specify the image by an image URL and the top left corner.
url - the URL location for the imagecorner - the top left cornerImagePaintableLite()
public ImagePaintableLite(URL url,
double x,
double y)
The constructor to specify the image by an image URL and the top left corner (x, y).
url - the URL location for the imagex - the x-coordinate of the top left cornery - the y-coordinate of the top left cornerImagePaintableLite()| Method Detail |
public final void paint(Graphics g)
Paints onto a Graphics context using information
from this object.
If the image cannot be loaded, this method will not paint.
paint in interface Paintablepaint in class AbstractPaintableg - the graphics context on which to paintAbstractPaintable.getPreparedGraphics2D(Graphics)public final Rectangle2D getBounds2D()
Returns the bounds of the paintable based on the default settings or on more detailed computations.
If the value of getDefaultBounds2D is non-null,
then this value is returned.
Otherwise, if the current image cannot be loaded, this method returns a rectangle of zero width and height located at the top-left corner.
Otherwise, this method returns a copy of the 2-dimensional bounds of the image region as defined by the image width and height and by the top-left corner.
getBounds2D in interface PaintablegetBounds2D in class AbstractPaintablegetTopLeftCorner(),
getImageWidth(),
getImageHeight(),
AbstractPaintable.setDefaultBounds2D(Rectangle2D),
AbstractPaintable.getDefaultBounds2D()public final Point2D getCenter()
If the value of getDefaultCenter is non-null,
then this value is returned.
Otherwise, this method returns the value computed by the method inherited from its superclass.
getCenter in interface PaintablegetCenter in class AbstractPaintableAbstractPaintable.getCenter(),
AbstractPaintable.setDefaultCenter(Point2D),
AbstractPaintable.getDefaultCenter()
public final boolean contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable.
This method returns true if and only if:
getBounds2D.isVisible returns true.
x - the x-coordinate of the pointy - the y-coordinate of the point
public final void setImageByFileName(String filename)
Sets the image by file name.
Fires property change: SET_IMAGE.
filename - the filename for the file with the imagesetImageByURL(URL)public final void setImageByURL(URL url)
Sets the image by URL.
Fires property change: SET_IMAGE.
url - the URL location for the imagesetImageByFileName(String)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 cornersetTopLeftCorner(double, double),
getTopLeftCorner()
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 cornersetTopLeftCorner(Point2D),
getTopLeftCorner()public final Point2D getTopLeftCorner()
Returns a copy of the top left corner.
setTopLeftCorner(Point2D),
setTopLeftCorner(double, double)public final int getImageWidth()
Returns the image width.
If the current image is undefined, this method returns 0.
getImageHeight()public final int getImageHeight()
Returns the image height.
If the current image is undefined, this method returns 0.
getImageWidth()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||