|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--element.DrawingWindow
A simple drawing window class. Allows the programmer to construct a free standing or contained slate to draw on.
Field Summary | |
protected static java.awt.Graphics |
exampleContext
A context for finding out information about fonts on this device. |
Constructor Summary | |
DrawingWindow()
Constructs a 200x200 standalone drawing window. |
|
DrawingWindow(java.awt.Container c)
Construct a 200x200 drawing window within another container. |
|
DrawingWindow(int width,
int height)
Construct a free-standing drawing window of a particular size. |
|
DrawingWindow(int width,
int height,
java.awt.Container c)
Construct a contained drawing window of a particular size. |
|
DrawingWindow(int width,
int height,
java.lang.String title)
Construct a drawing window with a paritcular dimension and title |
Method Summary | |
char |
awaitKey()
Wait for a key to be pressed. |
Pt |
awaitMouseClick()
post: blocks until mouse is released returns point of press |
Pt |
awaitMousePress()
Waits for the mouse to be pressed. |
Pt |
awaitMouseRelease()
Waits for the mouse to be released. |
Rect |
bounds()
Determine the current size of the drawing window's canvas. |
void |
clear(Drawable d)
Erases a general drawable object. |
void |
clearArc(int x,
int y,
int width,
int height,
int sa,
int da)
Erase a portion of an oval. |
void |
clearCircle(int x,
int y,
int radius)
Erase the circle described by (x,y,radius) |
void |
clearLine(int x0,
int y0,
int x1,
int y1)
Erases a line from (x0,y0) to (x1,y1). |
void |
clearLine(Pt src,
Pt dest)
Erases a line from (x0, y0) to (x1, y1) |
void |
clearOval(int x,
int y,
int width,
int height)
Erase the oval described by the rectangle (x,y,width,height) |
void |
clearPt(int x,
int y)
Erases the point at (x,y). |
void |
clearRect(int x,
int y,
int width,
int height)
Erase the rectangle described by (x,y,width,height). |
void |
clearRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Erase a rounded rectangle. |
void |
clearText(Text t)
Erases a positioned text element on the screen. |
void |
draw(Drawable d)
Draws a general drawable object. |
void |
drawArc(int x,
int y,
int width,
int height,
int sa,
int da)
Draw (or invert) a portion of an oval. |
void |
drawCircle(int x,
int y,
int radius)
Draw the circle described by (x,y,radius) |
void |
drawLine(int x0,
int y0,
int x1,
int y1)
Draws a line from (x0,y0) to (x1,y1). |
void |
drawLine(Pt src,
Pt dest)
Draws a line from src to dest. |
void |
drawOval(int x,
int y,
int width,
int height)
Draw the oval described by the rectangle (x,y,width,height) |
void |
drawPt(int x,
int y)
Draw a single point at (x,y). |
void |
drawRect(int x,
int y,
int width,
int height)
Draw the rectangle described by (x,y,width,height) |
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draw (or invert) the rounded rectangle. |
void |
drawString(java.lang.String s,
int x,
int y)
Draws a text string at the point (x,y) |
void |
drawText(Text t)
Draws a positioned text element on the screen. |
void |
fill(Drawable d)
Fills in a general drawable object. |
void |
fillArc(int x,
int y,
int width,
int height,
int sa,
int da)
Fill (or invert) a solid portion of an oval. |
void |
fillCircle(int x,
int y,
int radius)
Fill in (or invert) the circle described by (x,y,radius) |
void |
fillLine(int x0,
int y0,
int x1,
int y1)
Fills the line from src to dest. |
void |
fillLine(Pt src,
Pt dest)
Draws a line from src to dest. |
void |
fillOval(int x,
int y,
int width,
int height)
Fill the oval described by the rectangle (x,y,width,height) |
void |
fillPt(int x,
int y)
Fills the point at (x,y). |
void |
fillRect(int x,
int y,
int width,
int height)
Fill in the rectangle described by (x,y,width,height). |
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Fill (or invert) the rounded rectangle. |
void |
fillText(Text t)
Draws a positioned text element on the screen. |
Pt |
getMouse()
Get the current mouse position as a Pt. |
void |
hold()
Hold the updating process until the matching release. |
void |
invertMode()
Sets the drawing mode to invert the drawings on the screen. |
void |
line(int dx,
int dy)
Draws a line relative to the current position. |
void |
lineTo(int x,
int y)
Draws a line from the current position to a point (x,y). |
void |
lineTo(Pt p)
Draws a line segment from the current position to p. |
boolean |
mousePressed()
Return true iff the mouse is currently pressed. |
void |
move(int dx,
int dy)
Moves to a position relative to the current position. |
void |
moveTo(int x,
int y)
Moves the current position to (x,y). |
void |
moveTo(Pt p)
Moves the current position to p. |
void |
paintMode()
Sets the drawing mode to accumulate drawings on the screen. |
void |
release()
Release the updating process, allowing real-time drawing to the window. |
void |
setBackground(java.awt.Color c)
Sets the background color for the window to c. |
void |
setForeground(java.awt.Color c)
Sets the foreground color for the window to c. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected static java.awt.Graphics exampleContext
Constructor Detail |
public DrawingWindow()
public DrawingWindow(java.awt.Container c)
c
- the container that holds the drawing window.public DrawingWindow(int width, int height)
width
- the desired width of the window.height
- the desired height of the window.public DrawingWindow(int width, int height, java.awt.Container c)
width
- the desired width of the windowheight
- the desired height of the windowc
- the frame/panel/applet that contains the windowpublic DrawingWindow(int width, int height, java.lang.String title)
width
- the desired width of the windowheight
- the desired height of the windowtitle
- the title of the windowMethod Detail |
public void hold()
public void release()
public Rect bounds()
public Pt getMouse()
public boolean mousePressed()
public Pt awaitMousePress()
public Pt awaitMouseRelease()
public Pt awaitMouseClick()
public char awaitKey()
public void moveTo(int x, int y)
x
- the new current horizontal positiony
- the new current vertical positionpublic void moveTo(Pt p)
p
- the new current position.public void move(int dx, int dy)
dx
- the horizontal offset to the new current position.dy
- the vertical offset to the new current position.public void lineTo(int x, int y)
x
- the horizontal component of the far endpointy
- the vertical component of the far endpointmoveTo(int, int)
public void lineTo(Pt p)
p
- the far endpoint of the line segment.moveTo(int, int)
public void line(int dx, int dy)
dx
- the horizontal span of the line segmentdy
- the vertical span of the line segmentpublic void drawPt(int x, int y)
x
- the horizontal coordinate of the pointy
- the vertical coordinate of the pointpublic void fillPt(int x, int y)
x
- the horizontal coordinate of the pointy
- the vertical coordinate of the pointdrawPt(int, int)
public void clearPt(int x, int y)
x
- the horizontal coordinate of the pointy
- the vertical coordinate of the pointpublic void drawLine(int x0, int y0, int x1, int y1)
x0
- the horizontal position of one end of liney0
- the vertical position of one end of the linex1
- the horizontal position of other end of liney1
- the vertical position of other end of the linepublic void drawLine(Pt src, Pt dest)
src
- the beginning of the line segmentdest
- the end of the line segmentpublic void fillLine(int x0, int y0, int x1, int y1)
x0
- the horizontal position of one end of liney0
- the vertical position of one end of the linex1
- the horizontal position of other end of liney1
- the vertical position of other end of the linedrawLine(int, int, int, int)
public void fillLine(Pt src, Pt dest)
src
- the beginning of the line segmentdest
- the end of the line segmentdrawLine(int, int, int, int)
public void clearLine(int x0, int y0, int x1, int y1)
x0
- the horizontal position of one end of liney0
- the vertical position of one end of the linex1
- the horizontal position of other end of liney1
- the vertical position of other end of the linepublic void clearLine(Pt src, Pt dest)
src
- the beginning of the line segmentdest
- the end of the line segmentpublic void setForeground(java.awt.Color c)
c
- a java.awt.Color describing the color of drawingpublic void setBackground(java.awt.Color c)
c
- a java.awt.Color describing the color of drawingpublic void paintMode()
invertMode()
public void invertMode()
paintMode()
public void fill(Drawable d)
d
- the drawable object to be filled in.public void clear(Drawable d)
d
- the drawable object to be erased.public void draw(Drawable d)
d
- the general object to be drawn.public void drawRect(int x, int y, int width, int height)
x
- the left coordinate of the rectangley
- the top coordinate of the rectanglewidth
- the width of the rectangleheight
- the height of the rectanglepublic void fillRect(int x, int y, int width, int height)
x
- the left coordinate of the rectangle.y
- the top coordinate of the rectanglewidth
- the width of the rectangle to be drawnheight
- the height of the rectangle to be drawnpublic void clearRect(int x, int y, int width, int height)
x
- the left coordinate of the rectangle.y
- the top coordinate of the rectanglewidth
- the width of the rectangle to be drawnheight
- the height of the rectangle to be drawnpublic void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
x
- the left coordinate of the rounded rectangle.y
- the top coordinate of the rounded rectanglewidth
- the width of the rounded rectangle to be drawnheight
- the height of the rounded rectangle to be drawnarcwidth
- the bounding box width of the arc used to make the cornersarcheight
- the bounding box height of the arc used to make the cornerspublic void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
x
- the left coordinate of the rounded rectangle.y
- the top coordinate of the rounded rectanglewidth
- the width of the rounded rectangle to be drawnheight
- the height of the rounded rectangle to be drawnarcwidth
- the bounding box width of the arc used to make the cornersarcheight
- the bounding box height of the arc used to make the cornerspublic void clearRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
x
- the left coordinate of the rounded rectangle.y
- the top coordinate of the rounded rectanglewidth
- the width of the rounded rectangle to be drawnheight
- the height of the rounded rectangle to be drawnarcwidth
- the bounding box width of the arc used to make the cornersarcheight
- the bounding box height of the arc used to make the cornerspublic void drawOval(int x, int y, int width, int height)
x
- the left coordinate of the ovaly
- the top coordinate of the ovalwidth
- the width of the ovalheight
- the height of the ovalpublic void fillOval(int x, int y, int width, int height)
x
- the left coordinate of the ovaly
- the top coordinate of the ovalwidth
- the width of the ovalheight
- the height of the ovalpublic void clearOval(int x, int y, int width, int height)
x
- the left coordinate of the ovaly
- the top coordinate of the ovalwidth
- the width of the ovalheight
- the height of the ovalpublic void drawCircle(int x, int y, int radius)
x
- the left coordinate of the circley
- the top coordinate of the circleradius
- the radius of the circlepublic void fillCircle(int x, int y, int radius)
x
- the left coordinate of the circley
- the top coordinate of the circleradius
- the radius of the circlepublic void clearCircle(int x, int y, int radius)
x
- the left coordinate of the circley
- the top coordinate of the circleradius
- the radius of the circlepublic void drawArc(int x, int y, int width, int height, int sa, int da)
x
- the left coordinate of the rectangle that describes the ovaly
- the top coordinate of the rectangle that describes the ovalwidth
- the width of the oval to be drawnheight
- the height of the ovalsa
- the starting angle of the arcda
- the angle spanned by the arcpublic void fillArc(int x, int y, int width, int height, int sa, int da)
x
- the left coordinate of the rectangle that describes the ovaly
- the top coordinate of the rectangle that describes the ovalwidth
- the width of the oval to be drawnheight
- the height of the ovalsa
- the starting angle of the arcda
- the angle spanned by the arcpublic void clearArc(int x, int y, int width, int height, int sa, int da)
x
- the left coordinate of the rectangle that describes the ovaly
- the top coordinate of the rectangle that describes the ovalwidth
- the width of the oval to be drawnheight
- the height of the ovalsa
- the starting angle of the arcda
- the angle spanned by the arcpublic void drawString(java.lang.String s, int x, int y)
s
- the text to be drawnx
- the horizontal location of the texty
- the vertical location of the textpublic void drawText(Text t)
t
- a text element that describe the location of a stringpublic void fillText(Text t)
t
- a text element that describe the location of a stringdrawText(element.Text)
public void clearText(Text t)
t
- a text element that describe the location of a string
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |