problem while running JFreeChartAppletDemo

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
RaviTeja

problem while running JFreeChartAppletDemo

Post by RaviTeja » Sun Jul 14, 2002 12:33 pm

hi david,

i'm trying to run the JFreeChartAppletDemo.
when i'm trying to do this i'm facing a error saying JFreeChartAppletdemo.class not found .

what may be the reason.i'm using weblogic server.
i created a html file and copied it to the public_html file of weblogic.
the class file JFreeChartAppletdemo.class is present in the
com.jrefinery.chart.demo directory.
i used the codebase in the applet tag and tried to run it .
it gave me the same error "class not found........"


next i took the a jar of the whole com directory and placed in public_html.
so,now both the html file and the class files are in the same directory i.e. public_html directory of weblogic.
i just used the code option of applet tag and tried to run the html file.
it gave me the same error saying "class not found jfreechartappletdemo.class".

what may be the reason david,

thanks in advance


regards
ravi teja

sherman

Re: problem while running JFreeChartAppletDemo

Post by sherman » Mon Jul 15, 2002 7:39 pm

I got the same problem.
When I integrate JFreeChart into the applet, it's running fine on the local machine. But when I put it in the web page, I got class not found exception error.
The html file is as following:
<APPLET ARCHIVE="jcommon-0.6.4.jar,jfreechart-0.9.2.jar,RemoteProteus.jar" CODE = RemoteProteusApplet CODEBASE = "." WIDTH = 1100 HEIGHT = 760>

What could be the problem?
Thanks,
sherman

Sonia

Re: problem while running JFreeChartAppletDemo

Post by Sonia » Mon Jan 06, 2003 4:36 pm

Yes, I've got the same problem too.
It seems that no one answered these problems, is that true that it is unsolvable ?

And I am looking for the instructions in the documentation that shows me how to use the JFreeChartAppletDemo. But I can't.
Does anyone here could kindly show me ?

Thanks so much !

David Gilbert

Re: problem while running JFreeChartAppletDemo

Post by David Gilbert » Tue Jan 07, 2003 11:46 am

I don't use applets myself, so I'm not sure what the solution is. I did have the JFreeChartAppletDemo working at one point, but it was a long time ago and I can't remember what the steps were. I do know you need the Java plug-in, because JFreeChart uses Java2D which isn't present in JDK 1.1.

It goes on my to-do list to get the applet working again and document the steps...

Regards,

Dave Gilbert

David Gilbert

Re: problem while running JFreeChartAppletDemo

Post by David Gilbert » Wed Jan 08, 2003 6:51 pm

OK, I took another look at applets today. I changed the MemoryUsage.java application into an applet and posted it here:

http://www.object-refinery.com/jfreechart/applet.html

The APPLET tag looks like this:

Code: Select all

<APPLET ARCHIVE="jfreechart-0.9.4-premium-demo-applets.jar,jfreechart-0.9.4.jar,jcommon-0.7.1.jar" CODE="com.jrefinery.chart.premium.demo.applet.Applet1" width=640 height=260 ALT="You should see an applet, not this text.">
                  </APPLET>
The first jar file just contains the applet class (com.jrefinery.chart.premium.demo.applet.Applet1), and you also need the jfreechart-0.9.4.jar and jcommon-0.7.1.jar files in the same directory as the HTML file.

I've tested this using the Konqueror web browser (the only browser I have with Java configured). Can anyone confirm whether or not the applet works in other browsers? You will need the Java plug-in installed, JFreeChart won't work in browsers that only support JDK1.1.

Regards,

DG

Versus

Re: problem while running JFreeChartAppletDemo

Post by Versus » Thu Jan 09, 2003 5:48 pm

Works fine on Explorer 6

Artemis

Re: problem while running JFreeChartAppletDemo

Post by Artemis » Fri Jan 10, 2003 8:40 am

Thanks to DG for the demo,

but I've got the MemoryUsage.java but I want to have your applet.
Can you send the source code to me ?

Thanks a lot.

Artemis

David Gilbert

Re: problem while running JFreeChartAppletDemo

Post by David Gilbert » Fri Jan 10, 2003 10:06 pm

Hi Artemis,

This applet is one that I'll include in the "bonus" download for purchasers of the JFreeChart documentation, as I am in the process of writing up the demo for a new "Applet" section in the guide. But since it will take a few weeks before I get the next update out, you can look at the source code below...

Regards,

Dave Gilbert

/* ========================
* JFreeChart Premium Demos
* ========================
*
* Project Info: http://www.object-refinery.com/jfreechart/index.html
* Project Lead: David Gilbert (david.gilbert@object-refinery.com);
*
* (C) Copyright 2000-2003, by Simba Management Limited and Contributors.
*
* This library is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* ------------
* Applet1.java
* ------------
* (C) Copyright 2003, by Simba Management Limited.
*
* Original Author: David Gilbert (for Simba Management Limited);
* Contributor(s): -;
*
* $Id:$
*
* Changes
* -------
* 08-Jan-2003 : Version 1 (DG);
*
*/

package com.jrefinery.chart.premium.demo.applet;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Paint;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JTabbedPane;
import javax.swing.Timer;

import com.jrefinery.data.BasicTimeSeries;
import com.jrefinery.data.CategoryDataset;
import com.jrefinery.data.Millisecond;
import com.jrefinery.data.TimeSeriesCollection;
import com.jrefinery.data.XYDataset;
import com.jrefinery.chart.HorizontalDateAxis;
import com.jrefinery.chart.JFreeChart;
import com.jrefinery.chart.ChartPanel;
import com.jrefinery.chart.ChartFactory;
import com.jrefinery.chart.NumberAxis;
import com.jrefinery.chart.VerticalNumberAxis;
import com.jrefinery.chart.XYPlot;

/**
* A simple applet containing two sample charts in a JTabbedPane.
*
* @author David Gilbert
*/
public class Applet1 extends JApplet {

/** Time series for total memory used. */
private BasicTimeSeries total;

/** Time series for free memory. */
private BasicTimeSeries free;

/**
* Constructs the demo applet.
*/
public Applet1() {

// create two series that automatically discard data more than 30 seconds old...
this.total = new BasicTimeSeries("Total", Millisecond.class);
this.total.setHistoryCount(30000);
this.free = new BasicTimeSeries("Free", Millisecond.class);
this.free.setHistoryCount(30000);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(total);
dataset.addSeries(free);

BasicStroke seriesStroke = new BasicStroke(2f,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

HorizontalDateAxis domain = new HorizontalDateAxis("Time");
VerticalNumberAxis range = new VerticalNumberAxis("Memory");

XYPlot xyplot = new XYPlot(dataset, domain, range);
xyplot.setBackgroundPaint(Color.black);
xyplot.setSeriesPaint(new Paint[] {Color.red, Color.green});
xyplot.setSeriesStroke(0, seriesStroke);

domain.setAutoRange(true);
domain.setLowerMargin(0.0);
domain.setUpperMargin(0.0);
//domain.setGridPaint(Color.green);
//domain.setGridStroke(gridStroke);
domain.setTickLabelsVisible(true);
//domain.setGridLinesVisible(false);
domain.setCrosshairVisible(false);

range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
//range.setGridPaint(Color.green);
// range.setGridStroke(gridStroke);
//range.setGridLinesVisible(true);
range.setCrosshairVisible(false);

JFreeChart chart = new JFreeChart("Memory Usage", JFreeChart.DEFAULT_TITLE_FONT,
xyplot, true);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPopupMenu(null);

getContentPane().add(chartPanel);
new Applet1.DataGenerator().start();

}

/**
* Adds an observation to the 'total memory' time series.
*
* @param y the total memory used.
*/
private void addTotalObservation(double y) {
total.add(new Millisecond(), y);
}

/**
* Adds an observation to the 'free memory' time series.
*
* @param y the free memory.
*/
private void addFreeObservation(double y) {
free.add(new Millisecond(), y);
}

/**
* The data generator.
*/
class DataGenerator extends Timer implements ActionListener {

/**
* Constructor.
*/
DataGenerator() {
super(100, null);
addActionListener(this);
}

/**
* Adds a new free/total memory reading to the dataset.
*
* @param event the action event.
*/
public void actionPerformed(ActionEvent event) {
long f = Runtime.getRuntime().freeMemory();
long t = Runtime.getRuntime().totalMemory();
addTotalObservation(t);
addFreeObservation(f);
}

}

}

Rama Krishna

Re: problem while running JFreeChartAppletDemo

Post by Rama Krishna » Sat Feb 08, 2003 7:47 pm

Thanks David

I Have seen your Applet1 code But I need the HTML file which includes this APPLET and even please tell me where should i keep .JAR files

hope I can expect your response soon

regards
Ramakrishna

Jim Canniff

Re: problem while running JFreeChartAppletDemo

Post by Jim Canniff » Sun Feb 09, 2003 6:38 pm

David,

If I use the link you included, the MemoryUsage applet works fine. However if I copy the source code and compile it, I get two errors when trying to load it into a browser. Any idea what the problem could be? I unzipped the JFreeChart and JCommon jar files into the proper directory structure, as the file compiles fine. The only difference is that I did not compile the Applet1 file into a package and therefore removed the package reference from the html. Any help is very appreciated as I'm still perplexed with how jar files, Path, ClassPath and packages all work (confusingly) together. Thanks, here are the errors from the applet's JavaConsole:

java.lang.NullPointerException: name

at sun.applet.AppletClassLoader.getResourceAsStream(Unknown Source)

at sun.applet.AppletPanel$2.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

java.lang.NoSuchMethodError: com.jrefinery.data.TimeSeriesCollection.addSeries(Lcom/jrefinery/data/BasicTimeSeries;)V

at Applet1.<init>(Applet1.java:86)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

David Gilbert

Re: problem while running JFreeChartAppletDemo

Post by David Gilbert » Tue Feb 11, 2003 10:47 am

Hi Jim,

This line:

java.lang.NoSuchMethodError: com.jrefinery.data.TimeSeriesCollection.addSeries(Lcom/jrefinery/data/BasicTimeSeries;)V

...suggests that you might be mixing code from 0.9.5 and 0.9.4. The BasicTimeSeries class has been renamed TimeSeries in this version update.

Regards,

Dave Gilbert

sai

Project file to open demo classes

Post by sai » Tue Feb 11, 2003 7:08 pm

Hi, there are lot exmples available in
/src/jrefinery/chart/demo

directory. Is there any project file to open all of them them in the JBuilder, instead copying one class at a time to JBuilder??

Thanks in advance?

sai

multiple XY Chart with out filling in single graph image

Post by sai » Tue Feb 11, 2003 7:11 pm

Can any one give me example how to dra XY chart with out solid filling.

I am trying to draw multiple XY charts (line chart for day and value) in a single graph.

Thanks in advance..

jim canniff

Re: problem while running JFreeChartAppletDemo

Post by jim canniff » Tue Feb 11, 2003 7:40 pm

Sai,
If you create a Project in JBuilder you can then right click on the *.jpx file, select "Add Files / Packages" then you can select all the files you want (you can use Ctrl-A to select all files in a folder, like with any windows app). Admittedly it is kind of a pain in that it won't import the subfolders and files. You have to manually create folders in your project to match the actual directory structure. Then right-click each folder and "Add Files".

There may be another way but I have yet to discover it.
Good luck,
-Jim

Locked