Back to index

wims  3.65+svn20090927
Public Member Functions | Package Attributes
GraphWindow Class Reference
Collaboration diagram for GraphWindow:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void plotfunction (String fun)
void paint (Graphics g)

Package Attributes

double[] xdata
double[] ydata
int xpix
int ypix
double xmax
double xmin
double ymax
double ymin
double dy
double dx
int steps
Color bgcolor3 = new Color(164,235,60)

Detailed Description

Definition at line 8 of file GraphWindow.java.


Member Function Documentation

void GraphWindow.paint ( Graphics  g) [inline]

Definition at line 41 of file GraphWindow.java.

                                 {
       g.setColor(bgcolor3);
       g.fillRect(0,0,xpix,ypix);
       g.setColor(Color.red);
       for(int c=0;c<steps-1;c++){
            g.drawLine((int)xdata[c], (int)ydata[c], (int)xdata[c+1], (int)ydata[c+1]);
       }      
       g.setColor(Color.blue);
        g.drawLine(0,(int)((0.6*ypix)*ymax/(dy) + 0.3*ypix),xpix,(int)((0.6*ypix)*ymax/(dy) + 0.3*ypix));
        g.drawLine((int)(-1*xmin*xpix/dx),0,(int)(-1*xmin*xpix/(dx)),ypix );
     } 
void GraphWindow.plotfunction ( String  fun) [inline]

Definition at line 10 of file GraphWindow.java.

                                         {
       Symbols symbols=new Symbols();
       int c=0;
       xmin=-5;
       xmax=5;
       xpix=getSize().width;
       ypix=getSize().height;
       dx=xmax-xmin;
       steps=(int)(10*(dx));
       xdata=new double[steps+10];
       ydata=new double[steps+10];
       ymax=1.0;ymin=-1.0;String Y;double y;
        for (double x = xmin ; x < xmax ; x=x+0.1) {
           Y=fun.replaceAll("x","("+x+")");
           try { y=symbols.eval( Y );} catch (SyntaxException e ) {y=0.0;System.out.println("error "+e); }
           if(y>ymax){ymax=y;}
           if(y<ymin){ymin=y;}
           xdata[c]=(double) (x*(xpix/(dx)) -  xmin*xpix/(dx));
           ydata[c]=y;
           c++;
        }
       ymax=1.2*ymax;
       ymin=1.2*ymin;
       dy=(ymax - ymin);
       if(dy==0){dy=100.0;}
       for(c=0;c<steps;c++){
           ydata[c]=(double) (ydata[c]*(-0.6)*(ypix)/(dy) + (0.6*ypix)*ymax/(dy)) + 0.3*ypix;
       }
       repaint();
    } 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Color GraphWindow.bgcolor3 = new Color(164,235,60) [package]

Definition at line 65 of file GraphWindow.java.

double GraphWindow.dx [package]

Definition at line 63 of file GraphWindow.java.

double GraphWindow.dy [package]

Definition at line 62 of file GraphWindow.java.

int GraphWindow.steps [package]

Definition at line 64 of file GraphWindow.java.

double [] GraphWindow.xdata [package]

Definition at line 54 of file GraphWindow.java.

double GraphWindow.xmax [package]

Definition at line 58 of file GraphWindow.java.

double GraphWindow.xmin [package]

Definition at line 59 of file GraphWindow.java.

int GraphWindow.xpix [package]

Definition at line 56 of file GraphWindow.java.

double [] GraphWindow.ydata [package]

Definition at line 55 of file GraphWindow.java.

double GraphWindow.ymax [package]

Definition at line 60 of file GraphWindow.java.

double GraphWindow.ymin [package]

Definition at line 61 of file GraphWindow.java.

int GraphWindow.ypix [package]

Definition at line 57 of file GraphWindow.java.


The documentation for this class was generated from the following file: