Back to index

wims  3.65+svn20090927
Public Member Functions | Package Attributes | Private Member Functions
XYZApp Class Reference

An applet to put a Cehmical model into a page. More...

Inheritance diagram for XYZApp:
Inheritance graph
[legend]
Collaboration diagram for XYZApp:
Collaboration graph
[legend]

List of all members.

Public Member Functions

void init ()
void run ()
void start ()
void stop ()
boolean mouseDown (Event e, int x, int y)
boolean mouseDrag (Event e, int x, int y)
void update (Graphics g)
void paint (Graphics g)

Package Attributes

XYZChemModel md
boolean painted = true
float xfac
int prevx
int prevy
float xtheta
float ytheta
float scalefudge = 1
Matrix3D amat = new Matrix3D()
Matrix3D tmat = new Matrix3D()
String mdname = null
String message = null
Image backBuffer
Graphics backGC

Private Member Functions

synchronized void setPainted ()
synchronized void waitPainted ()

Detailed Description

An applet to put a Cehmical model into a page.

Definition at line 246 of file XYZApp.java.


Member Function Documentation

void XYZApp.init ( ) [inline]

Definition at line 260 of file XYZApp.java.

                       {
       mdname = getParameter("model");
       try {
           scalefudge = Float.valueOf(getParameter("scale")).floatValue();
       } catch(Exception e) {
       };
       amat.yrot(20);
       amat.xrot(20);
       if (mdname == null)
           mdname = "model.obj";
       resize(size().width <= 20 ? 400 : size().width,
              size().height <= 20 ? 400 : size().height);
    }

Here is the call graph for this function:

boolean XYZApp.mouseDown ( Event  e,
int  x,
int  y 
) [inline]

Definition at line 312 of file XYZApp.java.

                                                    {
       prevx = x;
       prevy = y;
       return true;
    }
boolean XYZApp.mouseDrag ( Event  e,
int  x,
int  y 
) [inline]

Definition at line 317 of file XYZApp.java.

                                                    {
       tmat.unit();
       float xtheta = (prevy - y) * (360.0f / size().width);
       float ytheta = (x - prevx) * (360.0f / size().height);
       tmat.xrot(xtheta);
       tmat.yrot(ytheta);
       amat.mult(tmat);
       if (painted) {
           painted = false;
           repaint();
       }
       prevx = x;
       prevy = y;
       return true;
    }

Here is the call graph for this function:

void XYZApp.paint ( Graphics  g) [inline]

Definition at line 337 of file XYZApp.java.

                                  {
       if (md != null) {
           md.mat.unit();
           md.mat.translate(-(md.xmin + md.xmax) / 2,
                          -(md.ymin + md.ymax) / 2,
                          -(md.zmin + md.zmax) / 2);
           md.mat.mult(amat);
           // md.mat.scale(xfac, -xfac, 8 * xfac / size().width);
           md.mat.scale(xfac, -xfac, 16 * xfac / size().width);
           md.mat.translate(size().width / 2, size().height / 2, 8);
           md.transformed = false;
           if (backBuffer != null) {
              backGC.setColor(getBackground());
              backGC.fillRect(0,0,size().width,size().height);
              md.paint(backGC);
              g.drawImage(backBuffer, 0, 0, this);
           } else
              md.paint(g);
           setPainted();
       } else if (message != null) {
           g.drawString("Error in model:", 3, 20);
           g.drawString(message, 10, 40);
       }
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void XYZApp.run ( ) [inline]

Definition at line 273 of file XYZApp.java.

                      {
       InputStream is = null;
       try {
           Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
           is = new URL(getDocumentBase(), mdname).openStream();
           XYZChemModel m = new XYZChemModel (is);
           Atom.setApplet(this);
           md = m;
           m.findBB();
           float xw = m.xmax - m.xmin;
           float yw = m.ymax - m.ymin;
           float zw = m.zmax - m.zmin;
           if (yw > xw)
              xw = yw;
           if (zw > xw)
              xw = zw;
           float f1 = size().width / xw;
           float f2 = size().height / xw;
           xfac = 0.7f * (f1 < f2 ? f1 : f2) * scalefudge;
           backBuffer = createImage(size().width, size().height);
           backGC = backBuffer.getGraphics();
       } catch(Exception e) {
           e.printStackTrace();
           md = null;
           message = e.toString();
       }
       try {
           if (is != null)
              is.close();
       } catch(Exception e) {
       }
       repaint();
    }

Here is the call graph for this function:

synchronized void XYZApp.setPainted ( ) [inline, private]

Definition at line 361 of file XYZApp.java.

                                           {
       painted = true;
       notifyAll();
    }

Here is the caller graph for this function:

void XYZApp.start ( ) [inline]

Definition at line 306 of file XYZApp.java.

                        {
       if (md == null && message == null)
           new Thread(this).start();
    }
void XYZApp.stop ( ) [inline]

Definition at line 310 of file XYZApp.java.

                       {
    }
void XYZApp.update ( Graphics  g) [inline]

Definition at line 332 of file XYZApp.java.

                                   {
       if (backBuffer == null)
           g.clearRect(0, 0, size().width, size().height);
       paint(g);
    }

Here is the call graph for this function:

synchronized void XYZApp.waitPainted ( ) [inline, private]

Definition at line 365 of file XYZApp.java.

                                            {
       while (!painted)
           try { wait(); } catch (Exception e) {}
       painted = false;
    }

Member Data Documentation

Matrix3D XYZApp.amat = new Matrix3D() [package]

Definition at line 253 of file XYZApp.java.

Image XYZApp.backBuffer [package]

Definition at line 256 of file XYZApp.java.

Graphics XYZApp.backGC [package]

Definition at line 257 of file XYZApp.java.

Definition at line 247 of file XYZApp.java.

String XYZApp.mdname = null [package]

Definition at line 254 of file XYZApp.java.

String XYZApp.message = null [package]

Definition at line 255 of file XYZApp.java.

Definition at line 248 of file XYZApp.java.

int XYZApp.prevx [package]

Definition at line 250 of file XYZApp.java.

int XYZApp.prevy [package]

Definition at line 250 of file XYZApp.java.

float XYZApp.scalefudge = 1 [package]

Definition at line 252 of file XYZApp.java.

Matrix3D XYZApp.tmat = new Matrix3D() [package]

Definition at line 253 of file XYZApp.java.

float XYZApp.xfac [package]

Definition at line 249 of file XYZApp.java.

float XYZApp.xtheta [package]

Definition at line 251 of file XYZApp.java.

float XYZApp.ytheta [package]

Definition at line 251 of file XYZApp.java.


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