|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--acm.graphics.GObject | +--acm.graphics.GPen
public class GPen extends GObject
The GPen class simulates a pen drawing on a canvas. As with the other graphical objects in the acm.graphics package, you use this class by constructing a new GPen object and adding that object to a GCanvas. You can move the pen on the canvas by using the methods setLocation and move and then draw lines using drawLine. The GPen object remembers the series of lines and can therefore repaint the screen image when necessary.
Constructor Summary |
GPen() |
GPen(double x,
double y) |
Method Summary | |
void | drawLine(double dx,
double dy) |
void | drawPolarLine(double r,
double theta) |
void | endFilledRegion() |
void | erasePath() |
GRectangle | getBounds() |
Color | getFillColor() |
Image | getPenImage() |
double | getSpeed() |
void | hidePen() |
boolean | isPenVisible() |
void | scale(double sx,
double sy) |
void | setColor(Color color) |
void | setFillColor(Color color) |
void | setLocation(double x,
double y) |
void | setPenImage(Image image) |
void | setSpeed(double speed) |
void | showPen() |
void | startFilledRegion() |
Inherited Method Summary | |
Color | getColor() |
double | getHeight() |
GPoint | getLocation()GPoint .
|
GDimension | getSize() |
double | getWidth() |
double | getX() |
double | getY() |
boolean | isVisible() |
void | move(double dx, double dy) |
void | movePolar(double r, double theta) |
void | sendBackward() |
void | sendForward() |
void | sendToBack() |
void | sendToFront() |
void | setLocation(GPoint pt) |
void | setVisible(boolean visible) |
Constructor Detail |
public GPen()
Usage: | GPen gpen = new GPen(); |
public GPen(double x,
double y)
Usage: | GPen gpen = new GPen(x, y); | ||||
Parameters: |
|
Method Detail |
public void drawLine(double dx,
double dy)
Usage: | drawLine(dx, dy); | ||||
Parameters: |
|
public final void drawPolarLine(double r,
double theta)
drawPolarLine(1.0, 0);
draws a line extending rightward one inch from the current point. Similarly
drawPolarLine(2.0, 135);
draws a two-inch line extending to the northwest from the current point.
Usage: | drawPolarLine(r, theta); | ||||
Parameters: |
|
public void endFilledRegion()
Usage: | gpen.endFilledRegion(); |
public void erasePath()
Usage: | gpen.erasePath(); |
public GRectangle getBounds()
Usage: | bounds = getBounds(); |
Returns: | A GRectangle representing the bounding box |
public Color getFillColor()
Usage: | Color color = gpen.getFillColor(); |
Returns: | The color used to display the filled region of this object |
public Image getPenImage()
public double getSpeed()
Usage: | double speed = getSpeed(); |
Returns: | The current speed of the pen (0 is slowest, 1 is fastest) |
public void hidePen()
Usage: | gpen.showPen(); |
public boolean isPenVisible()
Usage: | if (isPenVisible(visible)) . . . |
Returns: | true if the pen is visible, otherwise false |
public void scale(double sx,
double sy)
Usage: | gpen.scale(sx, sy); | ||||
Parameters: |
|
public void setColor(Color color)
Usage: | gpen.setColor(color); | ||
Parameter: |
|
public void setFillColor(Color color)
Usage: | gpen.setFillColor(color); | ||
Parameter: |
|
public void setLocation(double x,
double y)
Usage: | gpen.setLocation(x, y); | ||||
Parameters: |
|
public void setPenImage(Image image)
Usage: | pen.setPenImage(image); | ||
Parameter: |
|
public void setSpeed(double speed)
Usage: | setSpeed(speed); | ||
Parameter: |
|
public void showPen()
Usage: | gpen.showPen(); |
public void startFilledRegion()
Usage: | gpen.startFilledRegion(); |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |