|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
yops.Graphic
yops.Image
public class Image
An Image is a visual display of a picture represented as a raster of pixels in an (x,y) coordinate system, with (0,0) at the upper left. An image can be loaded from a gif or jpg image file. Also, the pixels of an image can be individually set.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class yops.Graphic |
|---|
THICK_STROKE |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
Image()
Creates a new Image with a default width and height. |
|
Image(GraphicsPanel panel,
int x,
int y,
int width,
int height)
Creates a new image by copying a rectangular region from the main image of the given GraphicsPanel. |
|
Image(Image img,
int x,
int y,
int width,
int height)
Creates a new Image by copying a rectangular region from the main image of the given Image. |
|
Image(int width,
int height)
Creates a new Image with the given width and height. |
|
| Method Summary | |
|---|---|
void |
copy(Image destination)
Copies this Image into the given destination image. |
void |
copy(int srcX,
int srcY,
int width,
int height,
Image destination)
Copies a rectangular potion of this image into the given destination image. |
void |
copy(int srcX,
int srcY,
int width,
int height,
Image destination,
int destX,
int destY)
Copies a rectangular potion of this image into the given destination image. |
void |
fillRegion(int x,
int y,
int width,
int height,
Color color)
Fills a rectangular region of the image with the given color. |
void |
fillRegion(int x,
int y,
int width,
int height,
int rgb)
Fills a rectangular region of the image with the given color. |
int |
getPixel(int x,
int y)
Returns the value of the pixel with the given coordinates. |
Color |
getPixelColor(int x,
int y)
Returns a Color object for the color of the pixel with the given coordinates. |
Dimension |
getPreferredSize()
This returns the size of the image, for use by Java's layout manager. |
void |
loadImage(String imageFile)
Loads a gif or jpeg file into the raster. |
void |
paint(Graphics g)
Paints the Image when requested by the Java's graphics system, using the current zoom and rotation. |
void |
setCopyAsDisplayed(boolean copyAsDisplayed)
When copyAsDisplayed is set to true, the current zoom and rotation are taken into account every time the image is copied. |
void |
setPixel(int x,
int y,
Color c)
Sets the the pixel with the given coordinates to the given color. |
void |
setPixel(int x,
int y,
int rgb)
Sets the the pixel with the given coordinates to the given integer value. |
void |
setRotation(double degrees)
Rotates the image display about its center within its rectangular frame. |
void |
setZoom(double percent)
Scales the image display by the given percentage, keeping the center fixed within its rectangular frame. |
void |
swapPixels(int x1,
int y1,
int x2,
int y2)
Swaps the color values of the two pixels with coordinates (x1,y1) and (x2,y2). |
| Methods inherited from class yops.Graphic |
|---|
add, isFilled, setCenter, setFillColor, setFilled, setLineColor, setUpperLeft, toString |
| Methods inherited from class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Image()
public Image(int width,
int height)
width - in pixelsheight - in pixels
public Image(GraphicsPanel panel,
int x,
int y,
int width,
int height)
GraphicsPanel.
panel - the GraphicsPanel whose image should be copied fromx - the left pixel coordinate of the region to be copiedy - the top pixel coordinate of the region to be copiedwidth - in pixelsheight - in pixels
public Image(Image img,
int x,
int y,
int width,
int height)
img - the image that should be copied fromx - the left pixel coordinate of the region to be copiedy - the top pixel coordinate of the region to be copiedwidth - in pixelsheight - in pixels| Method Detail |
|---|
public Dimension getPreferredSize()
getPreferredSize in class JComponentpublic void loadImage(String imageFile)
imageFile - the full path name of the file to be loadedpublic void setRotation(double degrees)
degrees - the angle of rotation, in the counter clockwise directionpublic void setZoom(double percent)
percent - the zoom factor, as a percentagepublic void setCopyAsDisplayed(boolean copyAsDisplayed)
copyAsDisplayed - whether or not zooming and rotation should be used during image copyingpublic void copy(Image destination)
destination - the image into which this image should be copied
public void copy(int srcX,
int srcY,
int width,
int height,
Image destination)
srcX - the left pixel coordiniate of the region to be copiedsrcY - the top pixel coordiniate of the region to be copiedwidth - of the region to be copied, in pixelsheight - of the region to be copied, in pixelsdestination - the image into which this image should be copied
public void copy(int srcX,
int srcY,
int width,
int height,
Image destination,
int destX,
int destY)
srcX - the left pixel coordiniate of the region to be copiedsrcY - the top pixel coordiniate of the region to be copiedwidth - of the region to be copied, in pixelsheight - of the region to be copied, in pixelsdestination - the image into which this image should be copieddestX - the x coordinate of the upper left corner within the destination, where the image should be copieddestY - the y coordinate of the upper left corner within the destination, where the image should be copied
public void fillRegion(int x,
int y,
int width,
int height,
Color color)
x - the left pixel coordinate of the regiony - the top pixel coordinate of the regionwidth - in pixelsheight - in pixelscolor - the color to be used for filling
public void fillRegion(int x,
int y,
int width,
int height,
int rgb)
x - the left pixel coordinate of the regiony - the top pixel coordinate of the regionwidth - in pixelsheight - in pixelsrgb - the color to be used for filling, expressed as an int, with 8 bits each for red (bits 16-23), green (bits 8-15), and blue (bits 0-7).
public Color getPixelColor(int x,
int y)
x - y -
public int getPixel(int x,
int y)
x - y -
public void setPixel(int x,
int y,
Color c)
x - y - c - the desired color for pixel (x,y)
public void setPixel(int x,
int y,
int rgb)
x - y - rgb - the desired color for pixel (x,y), expressed as an int, with 8 bits each for red (bits 16-23), green (bits 8-15), and blue (bits 0-7).
public void swapPixels(int x1,
int y1,
int x2,
int y2)
x1 - x coordinate of the first pixely1 - y coordinate of the first pixelx2 - x coordinate of the second pixely2 - y coordinate of the second pixelpublic void paint(Graphics g)
Component.repaint(). (If you do not see this graphic, it may not have been added to
a visible container, or it may be behind another graphic.)
paint in class JComponent
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||