Back to index

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

An applet to put a Chemical/Atomic Lattice model into a page. More...

Inheritance diagram for LatticeViewer:
Inheritance graph
[legend]
Collaboration diagram for LatticeViewer:
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

XYZLatModel 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
boolean label = false
boolean box = false
boolean bonds = false
Image backBuffer
Graphics backGC
Dimension backSize
String param
Color bgcolor
Color bondcolor
Color boxcolor

Private Member Functions

synchronized void newBackBuffer ()
synchronized void setPainted ()
synchronized void waitPainted ()

Detailed Description

An applet to put a Chemical/Atomic Lattice model into a page.

Definition at line 418 of file LatticeViewer.java.


Member Function Documentation

void LatticeViewer.init ( ) [inline]

Definition at line 444 of file LatticeViewer.java.

                       {
       mdname = getParameter("model");
       try {
           scalefudge = Float.valueOf(getParameter("scale")).floatValue();
       } catch(Exception e) {
       };
       try {
           label = Boolean.valueOf(getParameter("label")).booleanValue();
       } catch(Exception e) {
       };
       try {
           box = Boolean.valueOf(getParameter("box")).booleanValue();
       } catch(Exception e) {
       };
       try {
           bonds = Boolean.valueOf(getParameter("bonds")).booleanValue();
       } catch(Exception e) {
       };
       try {
           param = getParameter("bgcolor");
       } catch(Exception e) {
       };
        try {
          Integer i = Integer.valueOf(param, 16);
          bgcolor = new Color(i.intValue());
        } catch (NumberFormatException e) {
          bgcolor = Color.lightGray;
        }
       try {
           param = getParameter("bondcolor");
       } catch(Exception e) {
       };
        try {
          Integer i = Integer.valueOf(param, 16);
          bondcolor = new Color(i.intValue());
        } catch (NumberFormatException e) {
          bondcolor = Color.black;
        };
       try {
           param = getParameter("boxcolor");
       } catch(Exception e) {
       };
        try {
          Integer i = Integer.valueOf(param, 16);
          boxcolor = new Color(i.intValue());
        } catch (NumberFormatException e) {
          boxcolor = Color.red;
        };
       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);
       newBackBuffer();
    }

Here is the call graph for this function:

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

Definition at line 537 of file LatticeViewer.java.

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

Definition at line 542 of file LatticeViewer.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:

synchronized void LatticeViewer.newBackBuffer ( ) [inline, private]

Definition at line 438 of file LatticeViewer.java.

                                              {
       backBuffer = createImage(size().width, size().height);
       backGC = backBuffer.getGraphics();
       backSize = size();
    }

Here is the caller graph for this function:

void LatticeViewer.paint ( Graphics  g) [inline]

Definition at line 563 of file LatticeViewer.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) {
              if (!backSize.equals(size()))
                  newBackBuffer();
                setBackground(bgcolor);
              backGC.setColor(bgcolor);
              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 LatticeViewer.run ( ) [inline]

Definition at line 500 of file LatticeViewer.java.

                      {
       InputStream is = null;
       try {
           Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
           is = new URL(getDocumentBase(), mdname).openStream();
           XYZLatModel m = new XYZLatModel (is, label, box, bonds, bgcolor, bondcolor, boxcolor);
           ScaleableAtom.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;
       } 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 LatticeViewer.setPainted ( ) [inline, private]

Definition at line 591 of file LatticeViewer.java.

                                           {
       painted = true;
       notifyAll();
    }

Here is the caller graph for this function:

void LatticeViewer.start ( ) [inline]

Definition at line 531 of file LatticeViewer.java.

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

Definition at line 535 of file LatticeViewer.java.

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

Definition at line 557 of file LatticeViewer.java.

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

Here is the call graph for this function:

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

Definition at line 596 of file LatticeViewer.java.

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

Member Data Documentation

Definition at line 425 of file LatticeViewer.java.

Image LatticeViewer.backBuffer [package]

Definition at line 431 of file LatticeViewer.java.

Graphics LatticeViewer.backGC [package]

Definition at line 432 of file LatticeViewer.java.

Dimension LatticeViewer.backSize [package]

Definition at line 433 of file LatticeViewer.java.

Color LatticeViewer.bgcolor [package]

Definition at line 435 of file LatticeViewer.java.

Color LatticeViewer.bondcolor [package]

Definition at line 435 of file LatticeViewer.java.

Definition at line 430 of file LatticeViewer.java.

Definition at line 429 of file LatticeViewer.java.

Color LatticeViewer.boxcolor [package]

Definition at line 435 of file LatticeViewer.java.

Definition at line 428 of file LatticeViewer.java.

Definition at line 419 of file LatticeViewer.java.

String LatticeViewer.mdname = null [package]

Definition at line 426 of file LatticeViewer.java.

String LatticeViewer.message = null [package]

Definition at line 427 of file LatticeViewer.java.

Definition at line 420 of file LatticeViewer.java.

String LatticeViewer.param [package]

Definition at line 434 of file LatticeViewer.java.

int LatticeViewer.prevx [package]

Definition at line 422 of file LatticeViewer.java.

int LatticeViewer.prevy [package]

Definition at line 422 of file LatticeViewer.java.

float LatticeViewer.scalefudge = 1 [package]

Definition at line 424 of file LatticeViewer.java.

Definition at line 425 of file LatticeViewer.java.

float LatticeViewer.xfac [package]

Definition at line 421 of file LatticeViewer.java.

float LatticeViewer.xtheta [package]

Definition at line 423 of file LatticeViewer.java.

float LatticeViewer.ytheta [package]

Definition at line 423 of file LatticeViewer.java.


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