Register | Log in | RSS channel for codegravity.com homepage Bookmark!

284/2NEW projects | 71 services | 215 websites | 834/3NEW freelancers | 2126 topics | advertise



Login:



Forgot your password?
Forgot your username?
Create an account
JoomlaWatch Agent

Users

Most active users today from total of 109:
Peerke, garikello, jakkrit, dayanand, andrew_saber, giakhanh, mohalb, carmachhh, fguyon, dfireablaze, phoeker, ozedfr, boho, ashish_php, blackie, amoluca, JDev, tinytim007, Pascale, mayas_salman


19.9%United States United States
17.9%India India
9.3%Germany Germany
5.5%Russian Federation Russian Federation
4.4%United Kingdom United Kingdom
4.3%France France
4%Australia Australia
3.8%Netherlands Netherlands
3.8%Poland Poland
3.7%Italy Italy

Today: 976
Yesterday: 1402
This Week: 5266
Last Week: 8869
This Month: 2378
Last Month: 37593
Total: 117058


Partners:

HTML5, CSS3, SVG, tutorials

Freelance ColdFusion, Flex, PHP

Olejomalby, abstraktne obrazy

Camping Europe

WinAsm Studio

Vyšné Ružbachy

Sochy, Reštaurovanie

R.E.M.

Valid XHTML 1.0 Transitional

RSS feed:

Statistics:
Search Engine Genie Promotion Widget
Home

JFreeChart in an Applet

I wanted to use JFreeChart in my applet application, here is the way how to include the generated graph image into your applet. You have to bind the applet's Graphics with the Image generated by the jfreechart. Here's the main trick: chart.draw( (Graphics2D)g,getBounds());

import org.jfree.chart.JFreeChart;

import org.jfree.chart.ChartUtilities;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import java.net.URL;

public class Test extends Applet {

public void init() {
// It is required but does not need anything.
}

// This method gets called when the applet is terminated
// That's when the user goes to another page or exits the browser.
public void stop() {
// no actions needed here now.
}

// The standard method that you have to use to paint things on screen
// This overrides the empty Applet method, you can't called it "display" for example.

public void paint(Graphics g) {
//method to draw text on screen
// String first, then x and y coordinate.
// Create a simple XY chart
XYSeries series = new XYSeries("XYGraph");
series.add(1, 1);
series.add(2, 2);
series.add(3, 1);
series.add(4, 9);
series.add(5, 10);
series.add(6, 60);
// Add the series to your data set
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
// Generate the graph
JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", // Title
"x-axis", // x-axis Label
"y-axis", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
  chart.setAntiAlias(true);
 
 
if ( chart!=null ) {
chart.draw( (Graphics2D)g,getBounds()); //repaints the whole chart
}
 
}

 }

 

Add comment


Security code
Refresh

No Tweets

Add URL of a programming website
register as a freelancer
submit your project
open freelance projects you can work on
webmaster resources
write paid blog posts about programming - tips and articles
bugs and features

Recommended: (advertise)
Download Joomlawatch 1.2.12



Advertise Here
-
Promote your services and get the new customers from the community of webmasters / programmers visiting CodeGravity.com


Freelancers, create paid articles
-
Looking for freelancers with experiences in Java to write paid articles on their experiences


Outsource your project
-
Submit your project description with all the requirements to more than 600 freelancers from around the world for FREE.

FastDomain.com -
Fast Domain hosting. Hostmonster alternative. Also for $6.95/month.

Green Geeks Hosting -
World's best selling green web hosting

HostMonster.com -
best cheap Joomla Web hosting. Website joomlawatchdemo.com is hosted by them with domain for $6,95/mo.

Register as a Freelancer -
Submit your project experiences, programming languages and your other skills



News from Twitter:
No Tweets
RSS Feeds:new

rss Freelance
rss Projects
rss Forum
rss Resources

Popular:
MathGuard
download mathguard
Random screenshot:

linoopz15.jpg


Poll

At what price would you purchase JoomlaWatch ad-free license?
 
Privacy policy | Advertise | Donate | Doucovanie Nemcina
Joomla Visitors Google Map
Loading map...
Joomla Visitors Google Map
Visitors Google Map Agent

Locations of visitors to this page


©2003-2010 Codegravity.com