> hi,
>
> try this way.
> get the data from the database and set it into some collection objects.
> this part will be taken care by the controller.
>
> if u r using JSPs, then pass the control to this JSP where in u can collect
> the data from the collection objects and
> and pass it as PARAM to APPLET.
> in the applet collect all the PARAM
> this will ensure dynamic parameters..
>
> hope that helps
>
> Rohan
I have code for this incidentally if anyone is interested:
----
<html>
<head><title>AppletGraphs</title></head>
<body>
<applet code="AppletGraphs.class" width=600 height=300>
<param name=data value="10,5,30,5,50,10,90">
<param name=color value="#ff00ff">
</applet>
</body>
</html>
-----
import java.applet.*;
import java.awt.*;
import java.util.*;
public class AppletGraphs extends Applet
{
public void drawLineGraph (Graphics g, int x, int y, int w, int h, int[]
values)
{
g.setColor(Color.black);
g.fillRect(x,y,w,h);
float xstep = (float)w / (float)(values.length-1);
float ystep = (float)h / (float)100;
g.setColor( Color.decode( getParameter("color") ) );
for ( int i=0; i < values.length - 1; i++ )
{
int x1 = x + (int) ( xstep * (i+0) );
int y1 = y + (int) ( h - ystep*values[i+0] );
int x2 = x + (int) ( xstep * (i+1) );
int y2 = y + (int) ( h - ystep*values[i+1] );
g.drawLine(x1,y1,x2,y2);
}
}
public void drawPercentTimeGraph (Graphics g, int[] values)
{
int width = Integer.parseInt( getParameter("width") );
int height = Integer.parseInt( getParameter("height") );
g.setColor(Color.white);
g.fillRect(0,0,width,height);
Font font = new Font("Helvetica", Font.BOLD, 12 );
g.setFont(font);
g.setColor(Color.black);
int left = 20;
int bottom = 20;
for ( int i = 0; i < 100; i += 10 )
{
g.drawString( Integer.toString(i), 0, (int)( (height-bottom) *
(100-i)/100.0 ) );
}
for ( int i = 0; i < 24; i ++ )
{
g.drawString( Integer.toString(i), (int)( left + (width-left)
* i/24.0 ), height );
}
drawLineGraph(g,left,0,width-left,(height-bottom),values);
}
public void paint (Graphics g)
{
StringTokenizer st = new StringTokenizer( getParameter("data"), "," );
int n = st.countTokens();
int[] values = new int[n];
for ( int i = 0; i < n; i++)
{
values[i] = Integer.parseInt( st.nextToken() );
}
drawPercentTimeGraph(g, values);
}
}
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html