Re: Java ptolemy plot package.
EasyPtPlot.java:10: package ptolemy.plot does not exist
import ptolemy.plot.*;
^
EasyPtPlot.java:21: cannot access Plot
bad class file: c:\ptplot\Plot.class
class file contains wrong class: ptolemy.plot.Plot
Please remove or make sure it appears in the correct subdirectory of the
classpath.
Plot plotObj = new Plot();
^
2 errors
Maybe I am installing the plot package wrong. I am going to look in the
documentation.
The author says "If this does not work, ask for help."
Anyway here is the code:
// EasyPtPlot.java: simple application plots f(x)
/*
From: "A FIRST COURSE IN SCIENTIFIC COMPUTING" by R Landau
Contributors: K Augustson, R Wangberg, S Haerer,
C Barnes, M Paez, C. Bordeianu
Copyright Princeton University Press, Princeton, 2005
Electronic copyright R Landau Oregon State Univ 2005
Support by National Science Foundation, NPACI-EOT
*/
import ptolemy.plot.*;
public class EasyPtPlot
{
// The domain for the graph. The range is determined automatically.
public static final double Xmin = -5.0, Xmax = 5.0;
public static final int Npoint = 500;
public static void main(String[] args)
{
// Create a Plot object (from the
ptplot package).
Plot plotObj = new Plot();
plotObj.setTitle("f(x) vs x");
plotObj.setXLabel("x");
plotObj.setYLabel("f(x)");
// plotObj.setSize(400, 300);
// plotObj.setXRange(Xmin, Xmax);
// Add some data points to the Plot object, using addPoint.
// In this case, the y values are generated from the function cos(x).
/* Format: plotObj.addPoint(int dataSet, double x, double y, boolean
connect)
dataSet is for plotting multiple functions on the same graph.
connect should be true if a point connects to the previous point.
*/
double xStep = (Xmax - Xmin) / Npoint;
for (double x = Xmin; x <= Xmax; x += xStep)
{
double y = Math.cos(x);
plotObj.addPoint(0, x, y, true);
}
// Create a PlotApplication, to display the Plot object.
PlotApplication app = new PlotApplication(plotObj);
}
}
<mmcnurlin@usfamily.net> wrote in message
news:4602ff21$0$1286$815e3792@news.qwest.net...
I am sorry. The CLASSPATH was .;c:\ptplot. This means to me the classpath
searches the current director and
c:\ptplot
The book was copyrighted in 2005 by Rubin H. Landau.
"Andrew Thompson" <andrewthommo@gmail.com> wrote in message
news:1174530582.468400.162720@d57g2000hsg.googlegroups.com...
On Mar 22, 12:12 pm, <mmcnur...@usfamily.net> wrote:
Please refrain from top-posting.
<http://www.physci.org/codes/javafaq.html#toppost>
I got something to download. The book told me to put
c:\ptplot in the class
How old is the book? Sun's advice (for some
considerable time now) has been to add resources
to projects at compile or run-time.
path. I typed echo %CLASSPATH% and got ;"co:\putlog".
I do not understand what this co:\ptulog is?
Do you have a Windows FS type drive of name
'co'?
The author has a java file called Easy.java. When I compile it gives me
these errors.
import Ptolemy.plot.*;
..
Mote that import could only find a class named..
class file contains wrong class: ptolemy.plot.Plot
Ptolemy.plot.Plot
..as opposed to what it is asking for, which is..
ptolemy.plot.Plot
Java package and class names are case sensitive.
The conventional capitalisation is
all.package.lower.case.ClassNameHasEachWordFirstLetterUpper
Andrew T.