Summary of Objectdraw API
void begin () |
Initialize the program. |
void onMouseClick(Location point) |
Define actions to take when the mouse button is clicked. |
void onMousePress(Location point) |
Define actions to take when the mouse button is pressed. |
void onMouseRelease(Location point) |
Define actions to take when the mouse button is released. |
void onMouseEnter(Location point) |
Define actions to take when the mouse enters the window. |
void onMouseExit(Location point) |
Define actions to take when the mouse exits the window. |
void onMouseDrag(Location point) |
Define actions to take when the mouse is moved with the mouse button down. |
void onMouseMove(Location point) |
Define actions to take when the mouse is moved with the mouse button up. |
Image getImage(String fileName) |
Loads a gif or jpeg file |
double System.currentTimeMillis() |
Returns the time in milliseconds. |
void run() |
The active behavior of the object. |
void start() |
Call this method at the end of the constructor. It will result in your active object coming to life with its run method executing. |
void pause(double interval) |
Causes the active object to pause execution for interval milliseconds. |
double getTime() |
Returns the time in milliseconds. |
FramedRect(double x, double y, double width, double height, DrawingCanvas canvas); |
The parameters to a rectangle or oval constructor describe the rectangle bounding the object to be drawn. You can either:
You can fill these shapes or just frame their perimeters. |
FramedOval(double x, double y, double width, double height, DrawingCanvas canvas); |
VisibleImage(Image image, Location origin, DrawingCanvas c) VisibleImage(Image image, double x, double y, DrawingCanvas c) VisibleImage(Image image, Location origin, int width, int height, DrawingCanvas c) VisibleImage(Image image, double x, double y, int width, int height, DrawingCanvas c) |
The parameters to a drawable image constructor require you to specify the upper left corner of the image, either using a Location object or a pair of values for x and y. You can also optionally resize the image by giving a width and height. If you do not specify a width and height, it will use the size that the Image itself has. |
Text(String text, double x, double y, DrawingCanvas canvas); |
The coordinates specify the leftmost point of the text's baseline. |
Line(double startX, double startY, double endX, double endY, DrawingCanvas canvas); |
A line is described by giving its end points. |
boolean contains(Location someLocation ) |
If a line, determine if the line contains a point; if 2-D, determine if the object's bounding box contains a point. |
Color getColor() |
Access/change an object's color. |
void move(double xOffset, double yOffset); |
Move an object relative to its current position. |
void moveTo(double x, double y); void moveTo(Location someLocation); |
Move an object to point specified by coordinates. |
void hide(); |
Make an object invisible or visible on the display. Check if it is visible. |
void removeFromCanvas(); |
Permanently remove an object from the canvas. |
void addToCanvas (DrawingCanvas c); |
Add the object to a canvas. This removes it from the current canvas because it can only be on one canvas at a time. |
void sendForward(); |
Alter the stacking order that controls how overlapping objects appear. |
Location getStart() |
Access the coordinates of the starting or ending point of the line. |
void setStart(Location someLocation ); |
Change either or both of a line's end points. |
double getX() |
Access one or both coordinates of the upper left corner of an object's bounding rectangle. |
double getWidth() |
Access the dimensions of an object's bounding rectangle. |
boolean overlaps (Drawable2DInterface item) |
Returns true if the bounding rectangle of the item passed in overlaps with the bounding rectangle of the current object. |
void setWidth(double width ); |
Change the width or height of a shape. |
void setText(String text); |
Change the characters displayed. |
void setFontSize(int pointSize ); |
Change the font size used. |
void setBold(); |
Change the style in which text is displayed. |
void setFont (Font someFont) |
Change the font used. |
Color(int redness, int greenness, int blueness); |
Mix a new color. Parameter values are numbers between 0 and 255. |
Location(double x, double y); |
Build a coordinate pair object for the point (x,y). |
RandomIntGenerator(int min, int max) |
Builds a random number generator that returns numbers between min and max, inclusive. |
int getRed() |
Access any of the color values associated with a Color. |
double getX() |
Access either of the elements of a coordinate pair. |
int nextValue () |
Returns the next random number. |