|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectradtools.graphing.GraphicsWrapper
public class GraphicsWrapper
Wrapper class for Graphics object, contains outside information to translate applet styled coordinate system to with origin in upper left corner to user-defined coordinate system with origin set by x and y range
TODO: Unit tests, Code review, Javadoc review, Seal/Finalize
| Field Summary | |
|---|---|
(package private) double |
cx1
Rectangle coordinates in traditional Cartesian coordinates of the graph. |
(package private) double |
cx2
Rectangle coordinates in traditional Cartesian coordinates of the graph. |
(package private) double |
cy1
Rectangle coordinates in traditional Cartesian coordinates of the graph. |
(package private) double |
cy2
Rectangle coordinates in traditional Cartesian coordinates of the graph. |
protected Graphics |
graphics
Inherent graphics context object that contains the color and spatial information |
(package private) double |
kx
Scale factors to take zoom ratio into account when drawing the inset graph within the larger screen |
(package private) double |
ky
Scale factors to take zoom ratio into account when drawing the inset graph within the larger screen |
(package private) double |
ox
Scaled origin coordinates used to appropriately left/right shift |
(package private) double |
oy
Scaled origin coordinates used to appropriately left/right shift |
(package private) int |
sx1
Rectangle coordinates of the total screen containing the graph sx1 (west), sx2(east) sy1 (south), sy2 (north) |
(package private) int |
sx2
Rectangle coordinates of the total screen containing the graph sx1 (west), sx2(east) sy1 (south), sy2 (north) |
(package private) int |
sy1
Rectangle coordinates of the total screen containing the graph sx1 (west), sx2(east) sy1 (south), sy2 (north) |
(package private) int |
sy2
Rectangle coordinates of the total screen containing the graph sx1 (west), sx2(east) sy1 (south), sy2 (north) |
(package private) int |
tickHalfWidth
Number of pixels long of half an axis tick |
(package private) int |
ticks
Default number of ticks on an axis |
(package private) int |
xMargin
Number of pixels for the margin between the graph and the surrounding border |
(package private) int |
yMargin
Number of pixels for the margin between the graph and the surrounding border |
| Constructor Summary | |
|---|---|
GraphicsWrapper(Graphics _graphics)
Sets default values for the screen boundaries and the x and y range of the inset graph |
|
| Method Summary | |
|---|---|
void |
abscissa(String label)
Draws the x-axis and labels it with input string |
double |
cx(int x)
Translate window to Cartesian coordinates |
double |
cy(int y)
Translate window to Cartesian coordinates |
void |
drawFunctionHeat(double[] x_points,
double[] y_points,
double[] z_points,
double colorGradient,
int colorSpectrum)
Draws a three dimensional heat graph given three arrays of doubles The scope of the input determines the color gradient shift Colors are specified by Hue, Saturation and Brightness (ranging from [0,1]) and are converted to RGB values |
void |
drawFunctionLines(double[] x_points,
double[] y_points,
int flag)
Draws a two dimensional line graph given two arrays of doubles |
void |
drawLine(double x1,
double y1,
double x2,
double y2)
Translates input Cartesian coordinates for the drawLine inherent to the graphics object and draws it |
void |
drawPoint(double x,
double y)
Draws defined circles at discrete point (x,y) in current graph context's color |
void |
drawRect(double x1,
double y2,
double x2,
double y1)
Draws the rectangle defined by the (x1, y2) and (x2, y1) as opposite corners with the current color of the graphics context translated to the graphics coordinate system |
void |
drawString(String message,
double x,
double y,
int dx,
int dy)
Draws the text given by the specified string, using this graphics context's current font and color. |
boolean |
equals(GraphicsWrapper compare)
Tests the equality based on the inner graphics wrapper |
void |
fillRect(double x1,
double y2,
double x2,
double y1)
Fills the rectangle defined by the (x1, y2) and (x2, y1) as opposite corners with the current color of the graphics context translated to the graphics coordinate system |
int |
hashCode()
Returns a hash code value for the GraphicsWrapper object, based on the Graphics object |
void |
insetScreenRect()
Sets the surrounding screen as a border around the graph with a margin set by xMargin and yMargin |
void |
insetScreenRect(int dx,
int dy)
Sets the surrounding screen as a border around the graph with a margin set by input parameters dx, dy |
void |
ordinate(String label)
Draws the y-axis and labels it with the input string |
void |
setScreenRect(int sx1,
int sy2,
int sx2,
int sy1)
Sets the boundaries of the enclosing screen that frames the graph |
void |
setXRange(double a,
double b)
Translates the input x Cartesian coordinate boundaries into the relevant boundaries for the inset graph and for the surrounding screen |
void |
setYRange(double a,
double b)
Translates the input y Cartesian coordinate boundaries into the relevant boundaries for the inset graph and for the surrounding screen |
String |
toString()
The string representation of the GraphicsWrapper object, based on the Graphics object |
int |
wx(double x)
Translate Cartesian to window coordinates |
double |
wy(double y)
Translate Cartesian to window coordinates |
void |
xTicks()
Draws evenly spaced ticks on the x axis for the full range of the x axis |
void |
xTicks(double y,
double x1,
double x2,
double spacing)
Draws ticks on the x axis from x1 to x2, with each tick evenly spaced apart |
void |
xTicks(int n)
Draws n evenly spaced ticks on the x axis for the full range of the x axis |
void |
yTicks()
Draws evenly spaced ticks on the y axis for the full range of the y axis |
void |
yTicks(double x,
double y1,
double y2,
double spacing)
Draws ticks on the y axis from y1 to y2, with each tick evenly spaced apart |
void |
yTicks(int n)
Draws n evenly spaced ticks on the y axis for the full range of the y axis |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
double ox
double oy
double kx
double ky
double cx1
double cy2
double cx2
double cy1
int sx1
int sy2
int sx2
int sy1
int tickHalfWidth
int ticks
int xMargin
int yMargin
protected final Graphics graphics
| Constructor Detail |
|---|
public GraphicsWrapper(Graphics _graphics)
_graphics - The intrinsic graphics object| Method Detail |
|---|
public void abscissa(String label)
label - The text that labels the x-axispublic double cx(int x)
x - Window x coordinate
public double cy(int y)
y - Window y coordinate
public void drawFunctionHeat(double[] x_points,
double[] y_points,
double[] z_points,
double colorGradient,
int colorSpectrum)
x_points - Array of x valuesy_points - Array of y valuesz_points - Array of z valuescolorGradient - Order of magnitude of the inputs to determine how rapidly the colors should shiftcolorSpectrum - Breadth of color spectrum to be created and graphed from
public void drawFunctionLines(double[] x_points,
double[] y_points,
int flag)
x_points - Array of x valuesy_points - Array of y valuesflag - Indicates what color the line should be
public void drawLine(double x1,
double y1,
double x2,
double y2)
x1 - start x Cartesian coordinatey1 - start y Cartesian coordinatex2 - end x Cartesian coordinatey2 - end y Cartesian coordinate
public void drawPoint(double x,
double y)
x - Cartesian x coordinatey - Cartesian y coordinate
public void drawRect(double x1,
double y2,
double x2,
double y1)
x1 - Cartesian x coordinate of first cornery2 - Cartesian y coordinate of first cornerx2 - Cartesian x coordinate of opposite cornery1 - Cartesian y coordinate of opposite corner
public void drawString(String message,
double x,
double y,
int dx,
int dy)
message - The text to be drawnx - The x Cartesian coordinate on the graphy - The y Cartesian coordinate on the graphdx - The number of pixels in the x direction to shift within the surrounding screendy - The number of pixels in the y direction to shift within the surrounding screenpublic boolean equals(GraphicsWrapper compare)
compare - The GraphicsWrapper object to compare
public void fillRect(double x1,
double y2,
double x2,
double y1)
x1 - Cartesian x coordinate of first cornery2 - Cartesian y coordinate of first cornerx2 - Cartesian x coordinate of opposite cornery1 - Cartesian y coordinate of opposite cornerpublic int hashCode()
hashCode in class Objectpublic void insetScreenRect()
public void insetScreenRect(int dx,
int dy)
dx - Number of pixels for margin between graph and screen in x directiondy - Number of pixels for margin between graph and screen in y directionpublic void ordinate(String label)
label - The text that labels the y-axis
public void setScreenRect(int sx1,
int sy2,
int sx2,
int sy1)
sx1 - new western boundary ( x direction )sy2 - new southern boundary ( y direction )sx2 - new eastern boundary ( x direction )sy1 - new northern boundary ( y direction )
public void setXRange(double a,
double b)
a - new west boundary (x) in Cartesian coordinatesb - new east boundary (x) in Cartesian coordinates
public void setYRange(double a,
double b)
a - new south boundary (y) in Cartesian coordinatesb - new north boundary (y) in Cartesian coordinatespublic String toString()
toString in class Objectpublic int wx(double x)
x - Cartesian x coordinate
public double wy(double y)
y - Cartesian y coordinate
public void xTicks()
public void xTicks(double y,
double x1,
double x2,
double spacing)
y - The height of the tickx1 - The starting x tickx2 - The ending x tickspacing - Number of pixels between each tickpublic void xTicks(int n)
n - Number of ticks to be drawnpublic void yTicks()
public void yTicks(double x,
double y1,
double y2,
double spacing)
x - Number of ticks to be drawny1 - The starting y ticky2 - The ending y tickspacing - Number of pixels between each tickpublic void yTicks(int n)
n - Number of ticks to be drawn
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||