I would like to make a graph like this one:
http://www.cis.ksu.edu/~schmidt/CIS200/gifV6html/Ch5/bargraph.gif
This is what I have, but I am pretty lost on how to get any further.
setBar1 - setBar6 are supposed to be each of the bars and I guess I am
supposed to use setAxes in setBar but I am not sure how.
hope someone can help
----------------------------------------------------------------------------
--------------
import java.awt.*;
import javax.swing.*;
import java.text.*;
class BarGraphWriter extends JPanel
{ private int width;
private int height;
private String sentence1 = "";
private String sentence2 = "";
private String sentence3 = "";
private String sentence4 = "";
private String sentence5 = "";
private String sentence6 = "";
private int x_position;
private int y_position;
public BarGraphWriter(int w, int h)
{ width = w;
height = h;
x_position = width / 5;
y_position = height / 2;
JFrame my_frame = new JFrame();
my_frame.getContentPane().add(this);
my_frame.setTitle("Graph");
my_frame.setSize(width, height);
my_frame.setVisible(true);
}
public void paintComponent(Graphics g)
{ super.paintComponent(g);
g.setColor(Color.red);
g.drawString(sentence1, x_position, y_position);
g.drawString(sentence2, x_position, y_position);
g.drawString(sentence3, x_position, y_position);
g.drawString(sentence4, x_position, y_position);
g.drawString(sentence5, x_position, y_position);
g.drawString(sentence6, x_position, y_position);
}
public void setAxes(int x_pos, int y_pos, String top_label, int y_height)
{
}
public void setBar1(String label, int height, Color c)
{
}
public void setBar2(String label, int height, Color c)
{
}
public void setBar3(String label, int height, Color c)
{
}
public void setBar4(String label, int height, Color c)
{
}
public void setBar5(String label, int height, Color c)
{
}
public void setBar6(String label, int height, Color c)
{
}
}
public class TestGraph
{ public static void main(String[] a)
{ BarGraphWriter e = new BarGraphWriter();
e.setTitle("Days in first four months of the year");
e.setAxes(20, 120, "30", 90);
int scale_factor = 3;
e.setBar1("Jan", 31 * scale_factor, Color.red);
e.setBar2("Feb", 28 * scale_factor, Color.white);
e.setBar3("Mar", 31 * scale_factor, Color.blue);
e.setBar4("Apr", 30 * scale_factor, Color.red);
}
}
IchBin - 29 Nov 2004 23:03 GMT
> I would like to make a graph like this one:
>
[quoted text clipped - 89 lines]
> }
> }
Could try an open source product called: JFreeChart
at http://www.jfree.org/jfreechart/index.html

Signature
Thanks in Advance...
IchBin
__________________________________________________________________________
'The meeting of two personalities is like the contact of two chemical
substances:
if there is any reaction, both are transformed.'
- Carl Gustav Jung, (1875-1961), psychiatrist and psychologist
JS - 29 Nov 2004 23:25 GMT
I have to pay 40$ to see the source code!
JS
Chris Smith - 29 Nov 2004 23:42 GMT
> I have to pay 40$ to see the source code!
No you don't. You have to pay $40 to see the documentation. That kinda
sucks, but at least it's the developer making small amounts of money (as
opposed to, say, JBoss or MySQL, where venture capitalists are getting
rich).

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
JS - 29 Nov 2004 23:45 GMT
> > I have to pay 40$ to see the source code!
>
> No you don't. You have to pay $40 to see the documentation. That kinda
> sucks, but at least it's the developer making small amounts of money (as
> opposed to, say, JBoss or MySQL, where venture capitalists are getting
> rich).
hmmm when I press the "Source Code" tab I get this text:
Demo Collection - Source Code
The complete source code for this demo collection is available to download
when you purchase the JFreeChart Developer Guide from Object Refinery
Limited. The guide is a 400+ page document (in Acrobat PDF format) packed
full of useful information about JFreeChart, and costs US$39.95 per copy
(including free updates for 1 year). It is written by David Gilbert, the
original author and maintainer of JFreeChart.
To purchase your copy please visit the following URL:
http://www.object-refinery.com/jfreechart/guide.html
Your financial support is vital for the continuing success of the JFreeChart
Project. Thanks for supporting us so that we may continue to develop free
software!
Dave Gilbert
JFreeChart Project Leader
Special Note:
Please do not be confused by our efforts to raise funds by selling
documentation and support for JFreeChart. The class library itself is, and
will always remain, completely free under the terms of the GNU Lesser
General Public License (LGPL).
So I guess the source code will only be available for download when you buy
the documentation.
JS
Murray - 29 Nov 2004 23:46 GMT
>I have to pay 40$ to see the source code!
>
> JS
No, the $40 is for the developer documentation. Src is provided free
JS - 30 Nov 2004 00:56 GMT
> >I have to pay 40$ to see the source code!
> >
> > JS
>
> No, the $40 is for the developer documentation. Src is provided free
But how do I get access to it? When I press the "Source Code" tab I get this
text box instead of the source code:
Demo Collection - Source Code
The complete source code for this demo collection is available to download
when you purchase the JFreeChart Developer Guide from Object Refinery
Limited. The guide is a 400+ page document (in Acrobat PDF format) packed
full of useful information about JFreeChart, and costs US$39.95 per copy
(including free updates for 1 year). It is written by David Gilbert, the
original author and maintainer of JFreeChart.
To purchase your copy please visit the following URL:
http://www.object-refinery.com/jfreechart/guide.html
Your financial support is vital for the continuing success of the JFreeChart
Project. Thanks for supporting us so that we may continue to develop free
software!
Dave Gilbert
JFreeChart Project Leader
Special Note:
Please do not be confused by our efforts to raise funds by selling
documentation and support for JFreeChart. The class library itself is, and
will always remain, completely free under the terms of the GNU Lesser
General Public License (LGPL).
IchBin - 30 Nov 2004 01:11 GMT
>>"JS" <dsa.@asdf.com> wrote in message
>
[quoted text clipped - 33 lines]
> will always remain, completely free under the terms of the GNU Lesser
> General Public License (LGPL).
Source is in the subdirectory: \jfreechart-Version\src\org\jfree\chart
Do a little looking around first... before you jump up and down!

Signature
Thanks in Advance...
IchBin
__________________________________________________________________________
'The meeting of two personalities is like the contact of two chemical
substances:
if there is any reaction, both are transformed.'
- Carl Gustav Jung, (1875-1961), psychiatrist and psychologist
JS - 30 Nov 2004 07:57 GMT
> Source is in the subdirectory: \jfreechart-Version\src\org\jfree\chart
>
> Do a little looking around first... before you jump up and down!
Actually I was looking in that folder but could not seem to find the
demo.java files. But I guees its because each graph use some of the same
classes. Until now I have only been writing them in one file but its
beginning to get at bit to comprehensive.
JS