|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.msoe.se1010.winPlotter.WinPlotter
public class WinPlotter
WinPlotter - a programmable drawing window class.
Constructor Summary | |
---|---|
WinPlotter()
Default constructor. |
Method Summary | |
---|---|
void |
drawPoint(double x,
double y)
Draws a point at the specified logical coordinates using the current pen color |
void |
drawTo(double x,
double y)
Draws a line from the current pen position to the specified logical coordinates, using the current pen color. |
void |
erase()
Erases the contents of the current WinPlotter window |
void |
moveTo(double x,
double y)
Moves the pen from the current pen position to the specified logical coordinates. |
void |
printAt(double x,
double y,
java.lang.String text)
Prints a text string at the specified logical coordinates using the current pen color |
void |
setBackgroundColor(int red,
int green,
int blue)
Sets the background color of the WinPlotter window |
boolean |
setGrid(boolean showGrid,
double xinc,
double yinc,
java.awt.Color gridColor)
Specifies whether a grid is to be automatically drawn within the WinPlotter window, and sets the grid increment |
void |
setPenColor(int red,
int green,
int blue)
Sets the pen color used for drawing lines |
boolean |
setPlotBoundaries(double xmin,
double ymin,
double xmax,
double ymax)
Sets the logical extents of plotting coordinates, corresponding to the lower left and upper right corners of the window. |
void |
setVisible(boolean visibilityFlag)
Hides or displays the WinPlotter window. |
void |
setWindowListener(java.awt.event.WindowListener wl)
Registers a WindowListener to the underlying SketchPad JFrame. |
boolean |
setWindowSize(int width,
int height)
Sets the size of an individual WinPlotter window |
void |
setWindowTitle(java.lang.String title)
Sets the title of an individual WinPlotter window |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WinPlotter()
When a new WinPlotter instance is created, its window is initialized to appear at screen coordinates (10,10) with a size of 200 units in both x and y. The background color is initialized to WHITE, and the pen color is initialized to BLACK. The window title is initialized to "A plot of something". The logical boundaries of the window are initialized to (0,0), corresponding to the lower left corner of the window, and (100,100) corresponding to the upper right corner of the window. The pen position is initialized to (0,0) in logical coordinates coordinates extend to the right, while positive y (vertical) coordinates' extend upward.
Note: All WinPlotter objects must be closed before the hosting application program will terminate.
Method Detail |
---|
public void setWindowListener(java.awt.event.WindowListener wl)
wl
- reference to an object that implements the WindowListener interface.public void drawTo(double x, double y)
x
- - x (horizontal) coordinate of the line endpointy
- - y (vertical) coordinate of the line endpointpublic void erase()
public void moveTo(double x, double y)
x
- - x (horizontal) coordinate of the pen positiony
- - y (vertical) coordinate of the pen positionpublic void drawPoint(double x, double y)
x
- - x (horizontal) coordinate of the pointy
- - y (vertical) coordinate of the pointpublic void printAt(double x, double y, java.lang.String text)
x
- - x (horizontal) coordinate of the first character in the stringy
- - y (vertical) coordinate of the first character in the stringpublic void setBackgroundColor(int red, int green, int blue)
red
- - the red component of the color valuegreen
- - the green component of the color valueblue
- - the blue component of the color value
background colors are specified as values of primary color components (red, green, blue)
The valid range for values for the color components is 0 - 255. If an invalid value is supplied for a color component, the value 0 is automagically substituted. No error is generated.
public void setPenColor(int red, int green, int blue)
red
- - the red component of the color valuegreen
- - the green component of the color valueblue
- - the blue component of the color value
Pen colors are specified as values of primary color components (red, green, blue)
The valid range for values for the color components is 0 - 255. If an invalid value is supplied for a color component, the value 0 is automatically substituted. No error is generated.
public boolean setWindowSize(int width, int height)
width
- - window width in pixel unitsheight
- - window height in pixel units
public boolean setPlotBoundaries(double xmin, double ymin, double xmax, double ymax)
xmin
- - minimum x coordinate (corresponding to left window boundary)ymin
- - minimum y coordinate (corresponding to bottom window boundary)xmax
- - maximum x coordinate (corresponding to right window boundary)ymax
- - maximum y coordinate (corresponding to top window boundary)
public boolean setGrid(boolean showGrid, double xinc, double yinc, java.awt.Color gridColor)
showGrid
- - flag indicating whether to display a gridxinc
- - grid increment in logical x coordinatesyinc
- - grid increment in logical y coordinatesgridColor
- - grid color
public void setWindowTitle(java.lang.String title)
title
- - the window titlepublic void setVisible(boolean visibilityFlag)
visibilityFlag
- set this argument to false to hide the window; true to show it
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |