public class Pen
extends java.lang.Object
Constructor | Description |
---|---|
Pen() |
Constructor that takes no arguments
|
Pen(java.awt.Color color,
int width) |
Constructor that takes the ink color and width
|
Pen(java.awt.Color color,
int width,
boolean penDown) |
Constructor that takes the ink color, width, and penDown flag
|
Modifier and Type | Method | Description |
---|---|---|
void |
addMove(int x1,
int y1,
int x2,
int y2) |
Method to add a path segment if the pen is down
|
void |
clearPath() |
Method to clear the path stored for this pen
|
java.awt.Color |
getColor() |
Method to get the pen (ink) color
|
int |
getWidth() |
Method to get the width of the pen
|
boolean |
isPenDown() |
Method to get pen down status
|
void |
paintComponent(java.awt.Graphics g) |
Metod to paint the pen path
|
void |
setColor(java.awt.Color color) |
Method to set the pen (ink) color
|
void |
setPenDown(boolean value) |
Method to set the pen down value
|
void |
setWidth(int width) |
Method to set the width of the pen
|
public Pen()
public Pen(java.awt.Color color, int width)
color
- the ink colorwidth
- the width in pixelspublic Pen(java.awt.Color color, int width, boolean penDown)
color
- the ink colorwidth
- the width in pixelspenDown
- the flag if the pen is downpublic boolean isPenDown()
public void setPenDown(boolean value)
value
- the new value to usepublic java.awt.Color getColor()
public void setColor(java.awt.Color color)
color
- the color to usepublic int getWidth()
public void setWidth(int width)
width
- the width to use in pixelspublic void addMove(int x1, int y1, int x2, int y2)
x1
- the first xy1
- the first yx2
- the second xy2
- the second ypublic void clearPath()
public void paintComponent(java.awt.Graphics g)
g
- the graphics context