Forms
Class MyRectangle
java.lang.Object
|
+--Forms.Forms
|
+--Forms.MyRectangle
- public class MyRectangle
- extends Forms
This class construct a new rectangle.
- Version:
- 1.0
- Author:
- Sebastien Baehni
- See Also:
Forms
|
Constructor Summary |
MyRectangle(int xOrigin,
int yOrigin,
int width,
int height)
The constructor. |
|
Method Summary |
void |
drawRectangle(int[] pixels,
int width,
int height,
Color color)
This method draw a rectangle in an array of pixels with the specified color. |
void |
drawRectangleWithTexture(int[] pixels,
int width,
int height,
Texture texture)
This method draw a rectangle with the given texture. |
boolean |
isSelected(int x,
int y)
This method tells if a point is in the rectangle or not. |
void |
optimizeDrawing(AnimatedImage animatedImage)
This method optimize the drawing of the rectangle. |
void |
translate(int x,
int y,
int maxWidth,
int maxHeight)
This method translate the rectangle to the specified point. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
MyRectangle
public MyRectangle(int xOrigin,
int yOrigin,
int width,
int height)
- The constructor.
- Parameters:
xOrigin - The x origin of a corner of the rectangle.yOrigin - The y origin of a corner of the rectangle.width - The width of the rectangle.height - The height of the rectangle.
drawRectangle
public void drawRectangle(int[] pixels,
int width,
int height,
Color color)
- This method draw a rectangle in an array of pixels with the specified color.
- Parameters:
pixels - The array of pixels on which we want to draw the rectangle.width - The width of the array of pixels.height - The height of the arra of pixels.color - The color we want to draw the rectangle.
drawRectangleWithTexture
public void drawRectangleWithTexture(int[] pixels,
int width,
int height,
Texture texture)
throws TextureError
- This method draw a rectangle with the given texture.
- Parameters:
pixels - The array of pixels on which we want to draw the rectangle.width - The width of the array of pixels.height - The height of the array of pixels.texture - The texture of the rectangle.- Throws:
- TextureError -
optimizeDrawing
public void optimizeDrawing(AnimatedImage animatedImage)
- This method optimize the drawing of the rectangle. It refreshes only the bounding box of the rectangle.
isSelected
public boolean isSelected(int x,
int y)
- This method tells if a point is in the rectangle or not.
- Parameters:
x - The x coordinate of the point we test if it's containing in the rectangle.y - The y coordinate of the point we test if it's containing in the rectangle.- Returns:
- True if the point is in the rectangle, false otherwise.
- Overrides:
- isSelected in class Forms
translate
public void translate(int x,
int y,
int maxWidth,
int maxHeight)
- This method translate the rectangle to the specified point.
- Parameters:
x - The x coordinate the center of the rectangle must be translated.y - The y coordinate the center of the rectangle must be translated.maxWidth - The maximum width the rectangle must be translated. This prevent the rectangle from going out of the the animatedImage.maxHeight - The maximum height the rectangle must be translated. This prevent the rectangle from going out of the the animatedImage.- Overrides:
- translate in class Forms