|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--java.applet.Applet | +--uk.co.jscieng.SciGraphBase | +--uk.co.jscieng.SciGraph
The SciGraph
class is the interface into the JSGL, a Scientific
Graphics Library for Java. This library was written for the book
`Introductory Java for Scientists and Engineers' by Richard J. Davies
and is described at much greater length in that book. The methods that you
should use are those declared as public static
.
Note that this library can be used to write either applications or
applets. In the first case, write your application as normal using a
main
method:
public static void main(String[] argv)And simply call the methods of
SciGraph
as desired. In the
second case, you should define a class that extends SciGraph
,
and write a main
method with the prototype:
public void main()Your class is then a subclass of
Applet
and should be used the
class that you name in the code
part of the Applet
tag in your HTML.
You can write a program which can be run in both ways by writing:
public class MyClass extends SciGraph { public static void main(String[] argv) { ... } public void main() { main(new String[1]) } }
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Constructor Summary | |
SciGraph()
|
Method Summary | |
static void |
clear()
clear removes all previous drawing from the graph window. |
static void |
functionPlot(Plottable p)
A version of functionPlot that defaults to drawing the
graph in black using the whole width of the graph window with one point
every 10 pixels horizontally. |
static void |
functionPlot(Plottable p,
java.awt.Color c)
A version of functionPlot that defaults to drawing the
graph using the whole width of the graph window with one point every
10 pixels horizontally. |
static void |
functionPlot(Plottable p,
java.awt.Color c,
double pixelgap)
A version of functionPlot that defaults to drawing the
graph using the whole width of the graph window. |
static void |
functionPlot(Plottable p,
double pixelgap)
A version of functionPlot that defaults to drawing the
graph in black using the whole width of the graph window. |
static void |
functionPlot(Plottable p,
double left,
double right)
A version of functionPlot that defaults to drawing the
graph in black with one point every 10 pixels horizontally. |
static void |
functionPlot(Plottable p,
double left,
double right,
java.awt.Color c)
A version of functionPlot that defaults to drawing the
graph with one point every 10 pixels horizontally. |
static void |
functionPlot(Plottable p,
double left,
double right,
java.awt.Color c,
double pixelgap)
functionPlot draws a graph of a function. |
static void |
functionPlot(Plottable p,
double left,
double right,
double pixelgap)
A version of functionPlot that defaults to black. |
static void |
line(double xend,
double yend)
A version of line that continues drawing from the last point
to be drawn in the graph, continuing using that same color that that point
was drawn in. |
static void |
line(double xend,
double yend,
java.awt.Color c)
A version of line that continues drawing from the last point
to be drawn in the graph. |
static void |
line(double xstart,
double ystart,
double xend,
double yend)
A version of line that defaults to a black line. |
static void |
line(double xstart,
double ystart,
double xend,
double yend,
java.awt.Color c)
line draws a line in the graph window between two points. |
static void |
linePlot(double[] array)
A version of linePlot that draws the graph across the entire
width of the graph window, using black. |
static void |
linePlot(double[] array,
java.awt.Color c)
A version of linePlot that draws the graph across the entire
width of the graph window. |
static void |
linePlot(double[] array,
double left,
double right)
A version of linePlot that defaults to black. |
static void |
linePlot(double[] array,
double left,
double right,
java.awt.Color c)
linePlot draws a line graph from a set of values stored in
array . |
static void |
parametricPlot(Plottable x,
Plottable y)
A version of parametricPlot that defaults to drawing the
graph in black with a range from 0 to 1 and with fifty points. |
static void |
parametricPlot(Plottable x,
Plottable y,
java.awt.Color c)
A version of parametricPlot that defaults to drawing the
graph with a range from 0 to 1 and with fifty points. |
static void |
parametricPlot(Plottable x,
Plottable y,
java.awt.Color c,
int points)
A version of parametricPlot that defaults a range from
0 to 1. |
static void |
parametricPlot(Plottable x,
Plottable y,
double start,
double finish)
A version of parametricPlot that defaults to drawing the
graph in black with fifty points. |
static void |
parametricPlot(Plottable x,
Plottable y,
double start,
double finish,
java.awt.Color c)
A version of parametricPlot that defaults to drawing the
graph with fifty points. |
static void |
parametricPlot(Plottable x,
Plottable y,
double start,
double finish,
java.awt.Color c,
int points)
parametricPlot draws a graph in which both x and y
coordinates are functions of a third variable. |
static void |
parametricPlot(Plottable x,
Plottable y,
double start,
double finish,
int points)
A version of parametricPlot that defaults to black. |
static void |
parametricPlot(Plottable x,
Plottable y,
int points)
A version of parametricPlot that defaults to drawing the
graph in black with a range from 0 to 1. |
static void |
point(double x,
double y)
A version of point that defaults to black points. |
static void |
point(double x,
double y,
java.awt.Color c)
point plots a single point in the graph window. |
static void |
print(boolean b)
A version of print that takes a boolean . |
static void |
print(char c)
A version of print that takes a character. |
static void |
print(char[] s)
A version of print that takes an array of characters. |
static void |
print(double d)
A version of print that takes a double . |
static void |
print(float f)
A version of print that takes a floating point number. |
static void |
print(int i)
A version of print that takes an integer. |
static void |
print(long l)
A version of print that takes a long integer. |
static void |
print(java.lang.Object obj)
A version of print that takes an object. |
static void |
print(java.lang.String s)
print outputs a line of text into the text window. |
static void |
println()
A version of println that just moves to a new line. |
static void |
println(boolean b)
A version of println that takes a boolean . |
static void |
println(char c)
A version of println that takes a character. |
static void |
println(char[] s)
A version of println that takes an array of characters. |
static void |
println(double d)
A version of println that takes a double . |
static void |
println(float f)
A version of println that takes a floating point number. |
static void |
println(int i)
A version of println that takes an integer. |
static void |
println(long l)
A version of println that takes a long integer. |
static void |
println(java.lang.Object obj)
A version of println that takes an object. |
static void |
println(java.lang.String s)
println outputs a line of text into the text window and
then moves to the start of a new line of output. |
static java.lang.String |
readln()
readln stops execution of your program, allows the user to
enter some text and then returns that text as a string when they click on
the Input button in the window. |
static void |
showGraph(double left,
double right,
double bottom,
double top)
An version of showGraph defaulting to 300 pixels each way. |
static void |
showGraph(double left,
double right,
double bottom,
double top,
int width,
int height)
showGraph creates and shows a graph window. |
static void |
showText()
An overloaded version of showText which defaults to a window
80 characters wide and 24 characters tall. |
static void |
showText(int width,
int height)
showText creates and shows the text window in which
print , println and readln occur. |
static void |
stepPlot(double[] array)
A version of stepPlot that draws the bars in black across
the entire width of the graph window. |
static void |
stepPlot(double[] array,
java.awt.Color c)
A version of stepPlot that draws the bars across the
entire width of the graph window. |
static void |
stepPlot(double[] array,
double left,
double right)
A version of stepPlot that defaults to black. |
static void |
stepPlot(double[] array,
double left,
double right,
java.awt.Color c)
stepPlot draws a bar-chart based on an array of values. |
static java.lang.String |
stringOf(double x,
int n)
stringOf converts a floating point number into a
string containing a fixed number of digits. |
Methods inherited from class uk.co.jscieng.SciGraphBase |
destroy,
init,
main,
paint |
Methods inherited from class java.applet.Applet |
getAppletContext,
getAppletInfo,
getAudioClip,
getAudioClip,
getCodeBase,
getDocumentBase,
getImage,
getImage,
getLocale,
getParameter,
getParameterInfo,
isActive,
newAudioClip,
play,
play,
resize,
resize,
setStub,
showStatus,
start,
stop |
Methods inherited from class java.awt.Panel |
addNotify |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getAlignmentX,
getAlignmentY,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getInsets,
getLayout,
getMaximumSize,
getMinimumSize,
getPreferredSize,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
paramString,
preferredSize,
print,
printComponents,
processContainerEvent,
processEvent,
remove,
remove,
removeAll,
removeContainerListener,
removeNotify,
setFont,
setLayout,
update,
validate,
validateTree |
Methods inherited from class java.awt.Component |
action,
add,
addComponentListener,
addFocusListener,
addInputMethodListener,
addKeyListener,
addMouseListener,
addMouseMotionListener,
addPropertyChangeListener,
addPropertyChangeListener,
bounds,
checkImage,
checkImage,
coalesceEvents,
contains,
contains,
createImage,
createImage,
disable,
disableEvents,
dispatchEvent,
enable,
enable,
enableEvents,
enableInputMethods,
firePropertyChange,
getBackground,
getBounds,
getBounds,
getColorModel,
getComponentOrientation,
getCursor,
getDropTarget,
getFont,
getFontMetrics,
getForeground,
getGraphics,
getHeight,
getInputContext,
getInputMethodRequests,
getLocation,
getLocation,
getLocationOnScreen,
getName,
getParent,
getPeer,
getSize,
getSize,
getToolkit,
getTreeLock,
getWidth,
getX,
getY,
gotFocus,
handleEvent,
hasFocus,
hide,
imageUpdate,
inside,
isDisplayable,
isDoubleBuffered,
isEnabled,
isFocusTraversable,
isLightweight,
isOpaque,
isShowing,
isValid,
isVisible,
keyDown,
keyUp,
list,
list,
list,
location,
lostFocus,
mouseDown,
mouseDrag,
mouseEnter,
mouseExit,
mouseMove,
mouseUp,
move,
nextFocus,
paintAll,
postEvent,
prepareImage,
prepareImage,
printAll,
processComponentEvent,
processFocusEvent,
processInputMethodEvent,
processKeyEvent,
processMouseEvent,
processMouseMotionEvent,
remove,
removeComponentListener,
removeFocusListener,
removeInputMethodListener,
removeKeyListener,
removeMouseListener,
removeMouseMotionListener,
removePropertyChangeListener,
removePropertyChangeListener,
repaint,
repaint,
repaint,
repaint,
requestFocus,
reshape,
setBackground,
setBounds,
setBounds,
setComponentOrientation,
setCursor,
setDropTarget,
setEnabled,
setForeground,
setLocale,
setLocation,
setLocation,
setName,
setSize,
setSize,
setVisible,
show,
show,
size,
toString,
transferFocus |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public SciGraph()
Method Detail |
public static void showText(int width, int height)
showText
creates and shows the text window in which
print
, println
and readln
occur.width
- The width of the window in charactersheight
- The height of the window in charactersprint(java.lang.String)
,
println(java.lang.String)
,
readln()
public static void showText()
showText
which defaults to a window
80 characters wide and 24 characters tall.public static void print(java.lang.String s)
print
outputs a line of text into the text window. The output
does not automatically move to a new line after this. This command
corresponds to java.lang.System.out.print
.s
- The string to be written.println(java.lang.String)
public static void print(java.lang.Object obj)
print
that takes an object.public static void print(char[] s)
print
that takes an array of characters.public static void print(char c)
print
that takes a character.public static void print(int i)
print
that takes an integer.public static void print(long l)
print
that takes a long integer.public static void print(float f)
print
that takes a floating point number.public static void print(double d)
print
that takes a double
.public static void print(boolean b)
print
that takes a boolean
.public static void println(java.lang.String s)
println
outputs a line of text into the text window and
then moves to the start of a new line of output.s
- The string to be written.print(java.lang.String)
public static void println()
println
that just moves to a new line.public static void println(java.lang.Object obj)
println
that takes an object.public static void println(char[] s)
println
that takes an array of characters.public static void println(char c)
println
that takes a character.public static void println(int i)
println
that takes an integer.public static void println(long l)
println
that takes a long integer.public static void println(float f)
println
that takes a floating point number.public static void println(double d)
println
that takes a double
.public static void println(boolean b)
println
that takes a boolean
.public static java.lang.String stringOf(double x, int n)
stringOf
converts a floating point number into a
string containing a fixed number of digits.x
- The floating point number.n
- The number of digits to return.public static java.lang.String readln()
readln
stops execution of your program, allows the user to
enter some text and then returns that text as a string when they click on
the Input
button in the window. Execution of your program
then continues.public static void showGraph(double left, double right, double bottom, double top, int width, int height)
showGraph
creates and shows a graph window. The window is
width
pixels wide and height
pixels tall on
screen. However, internally it uses a coordinate system that is defined
by left
, right
, bottom
and
top
.left
- The left hand edge of the window in internal coordinates.right
- The right hand edge of the window in internal coordinates.bottom
- The bottom edge of the window in internal coordinates.top
- The top edge of the window in internal coordinates.width
- The width of the window in pixels.height
- The height of the window in pixels.public static void showGraph(double left, double right, double bottom, double top)
showGraph
defaulting to 300 pixels each way.public static void clear()
clear
removes all previous drawing from the graph window.public static void point(double x, double y, java.awt.Color c)
point
plots a single point in the graph window.x
- The x-coordinate of the point.y
- The y-coordinate of the point.c
- The color of the point.public static void point(double x, double y)
point
that defaults to black points.public static void line(double xstart, double ystart, double xend, double yend, java.awt.Color c)
line
draws a line in the graph window between two points.xstart
- The x-coordinate of the start of the line.ystart
- The y-coordinate of the start of the line.xend
- The x-coordinate of the end of the line.yend
- The y-coordinate of the end of the line.c
- The color of the line.public static void line(double xstart, double ystart, double xend, double yend)
line
that defaults to a black line.public static void line(double xend, double yend, java.awt.Color c)
line
that continues drawing from the last point
to be drawn in the graph.public static void line(double xend, double yend)
line
that continues drawing from the last point
to be drawn in the graph, continuing using that same color that that point
was drawn in.public static void functionPlot(Plottable p, double left, double right, java.awt.Color c, double pixelgap)
functionPlot
draws a graph of a function. The function is
passed using a Plottable
object, and the graph is drawn for
x values between left
and right
. The graph is
drawn in the color c
with one point every pixelgap
pixels horizontally across the screen.p
- A Plottable
object containing the function to draw.left
- The left hand end of the range in which to draw it.right
- The right hand end of the range in which to draw it.c
- The color in which to draw it.pixelgap
- The number of pixels horizontally across the screen
between points.Plottable
,
parametricPlot(uk.co.jscieng.Plottable, uk.co.jscieng.Plottable, double, double, java.awt.Color, int)
,
stepPlot(double[], double, double, java.awt.Color)
,
linePlot(double[], double, double, java.awt.Color)
public static void functionPlot(Plottable p, double left, double right, double pixelgap)
functionPlot
that defaults to black.public static void functionPlot(Plottable p, java.awt.Color c, double pixelgap)
functionPlot
that defaults to drawing the
graph using the whole width of the graph window.public static void functionPlot(Plottable p, double pixelgap)
functionPlot
that defaults to drawing the
graph in black using the whole width of the graph window.public static void functionPlot(Plottable p, double left, double right, java.awt.Color c)
functionPlot
that defaults to drawing the
graph with one point every 10 pixels horizontally.public static void functionPlot(Plottable p, double left, double right)
functionPlot
that defaults to drawing the
graph in black with one point every 10 pixels horizontally.public static void functionPlot(Plottable p, java.awt.Color c)
functionPlot
that defaults to drawing the
graph using the whole width of the graph window with one point every
10 pixels horizontally.public static void functionPlot(Plottable p)
functionPlot
that defaults to drawing the
graph in black using the whole width of the graph window with one point
every 10 pixels horizontally.public static void parametricPlot(Plottable x, Plottable y, double start, double finish, java.awt.Color c, int points)
parametricPlot
draws a graph in which both x and y
coordinates are functions of a third variable. The functions are passed
using Plottable
objects, and the graph is drawn for values
of the third variable between start
and finish
.
The graph is drawn in the color c
with one point every
step
across the range of the third variable.x
- A Plottable
object mapping the third variable to x.y
- A Plottable
object mapping the third variable to y.start
- The start of the range of the third variable.finish
- The end of the range of the third variable.c
- The color in which to draw it.points
- The number of points to calculate for the graph.Plottable
,
functionPlot(uk.co.jscieng.Plottable, double, double, java.awt.Color, double)
,
stepPlot(double[], double, double, java.awt.Color)
,
linePlot(double[], double, double, java.awt.Color)
public static void parametricPlot(Plottable x, Plottable y, double start, double finish, int points)
parametricPlot
that defaults to black.public static void parametricPlot(Plottable x, Plottable y, java.awt.Color c, int points)
parametricPlot
that defaults a range from
0 to 1.public static void parametricPlot(Plottable x, Plottable y, int points)
parametricPlot
that defaults to drawing the
graph in black with a range from 0 to 1.public static void parametricPlot(Plottable x, Plottable y, double start, double finish, java.awt.Color c)
parametricPlot
that defaults to drawing the
graph with fifty points.public static void parametricPlot(Plottable x, Plottable y, double start, double finish)
parametricPlot
that defaults to drawing the
graph in black with fifty points.public static void parametricPlot(Plottable x, Plottable y, java.awt.Color c)
parametricPlot
that defaults to drawing the
graph with a range from 0 to 1 and with fifty points.public static void parametricPlot(Plottable x, Plottable y)
parametricPlot
that defaults to drawing the
graph in black with a range from 0 to 1 and with fifty points.public static void stepPlot(double[] array, double left, double right, java.awt.Color c)
stepPlot
draws a bar-chart based on an array of values.
The values in array
are drawn with equal width bars between
the edge of an interval defined by left
and
right
. They are drawn in the color c
.array
- The values to use in the bar chart.left
- The left hand edge of the chart.right
- The right hand edge of the chart.c
- The color of the chart.functionPlot(uk.co.jscieng.Plottable, double, double, java.awt.Color, double)
,
parametricPlot(uk.co.jscieng.Plottable, uk.co.jscieng.Plottable, double, double, java.awt.Color, int)
,
linePlot(double[], double, double, java.awt.Color)
public static void stepPlot(double[] array, double left, double right)
stepPlot
that defaults to black.public static void stepPlot(double[] array, java.awt.Color c)
stepPlot
that draws the bars across the
entire width of the graph window.public static void stepPlot(double[] array)
stepPlot
that draws the bars in black across
the entire width of the graph window.public static void linePlot(double[] array, double left, double right, java.awt.Color c)
linePlot
draws a line graph from a set of values stored in
array
. The points of the graph are evenly distributed across
the interval between left
and right
and the
lines between them are drawn in the color c
.array
- The values for the point on the graph.left
- The left hand edge of the graph.right
- The right hand edge of the graph.c
- The color of the graph.functionPlot(uk.co.jscieng.Plottable, double, double, java.awt.Color, double)
,
parametricPlot(uk.co.jscieng.Plottable, uk.co.jscieng.Plottable, double, double, java.awt.Color, int)
,
stepPlot(double[], double, double, java.awt.Color)
public static void linePlot(double[] array, double left, double right)
linePlot
that defaults to black.public static void linePlot(double[] array, java.awt.Color c)
linePlot
that draws the graph across the entire
width of the graph window.public static void linePlot(double[] array)
linePlot
that draws the graph across the entire
width of the graph window, using black.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |