/*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* - Neither the name of Oracle nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This source code is provided to illustrate the usage of a given feature
* or technique and has been deliberately simplified. Additional steps
* required for a production-quality application, such as security checks,
* input validation and proper error handling, might not be present in
* this sample code.
*/
/*
* A set of classes to parse, represent and display Chemical compounds in
* .xyz format (see http://chem.leeds.ac.uk/Project/MIME.html)
*/
/** The representation of a Chemical .xyz model */
final class XYZChemModel {
float vert[];
int tvert[];
int ZsortMap[];
static {
}
boolean transformed;
XYZChemModel() {
}
/** Create a Chemical model by parsing an input stream */
this();
st.eolIsSignificant(true);
try {
scan:
while (true) {
case StreamTokenizer.TT_EOF:
break scan;
default:
break;
case StreamTokenizer.TT_WORD:
double x = 0,
y = 0,
z = 0;
}
}
}
}
} // end Switch
} // end while
} // end Try
catch (IOException e) {
}
}
} // end XYZChemModel()
/** Add a vertex to this model */
int i = nvert;
if (i >= maxvert) {
maxvert = 100;
} else {
maxvert *= 2;
}
}
if (a == null) {
a = defaultAtom;
}
atoms[i] = a;
i *= 3;
vert[i] = x;
vert[i + 1] = y;
vert[i + 2] = z;
return nvert++;
}
/** Transform all the points in this model */
void transform() {
return;
}
}
transformed = true;
}
/** Paint this model to a graphics context. It uses the matrix associated
with this model to map from model space to screen space.
The next version of the browser should have double buffering,
which will make this *much* nicer */
return;
}
transform();
int v[] = tvert;
for (int i = nvert; --i >= 0;) {
zs[i] = i * 3;
}
}
/*
* I use a bubble sort since from one iteration to the next, the sort
* order is pretty stable, so I just use what I had last time as a
* "guess" of the sorted order. With luck, this reduces O(N log N)
* to O(N)
*/
boolean flipped = false;
for (int j = 0; j <= i; j++) {
int a = zs[j];
int b = zs[j + 1];
if (v[a + 2] > v[b + 2]) {
zs[j + 1] = a;
zs[j] = b;
flipped = true;
}
}
if (!flipped) {
break;
}
}
return;
}
for (int i = 0; i < lim; i++) {
int j = zs[i];
int grey = v[j + 2];
if (grey < 0) {
grey = 0;
}
if (grey > 15) {
grey = 15;
}
// g.drawString(names[i], v[j], v[j+1]);
// g.drawImage(iBall, v[j] - (iBall.width >> 1), v[j + 1] -
// (iBall.height >> 1));
}
}
/** Find the bounding box of this model */
void findBB() {
if (nvert <= 0) {
return;
}
float v[] = vert;
float x = v[i];
if (x < _xmin) {
_xmin = x;
}
if (x > _xmax) {
_xmax = x;
}
float y = v[i + 1];
if (y < _ymin) {
_ymin = y;
}
if (y > _ymax) {
_ymax = y;
}
float z = v[i + 2];
if (z < _zmin) {
_zmin = z;
}
if (z > _zmax) {
_zmax = z;
}
}
}
}
/** An applet to put a Chemical model into a page */
@SuppressWarnings("serial")
boolean painted = true;
float xfac;
private synchronized void newBackBuffer() {
}
}
public void init() {
try {
}
mdname = "model.obj";
}
addMouseListener(this);
addMouseMotionListener(this);
}
public void destroy() {
removeMouseListener(this);
removeMouseMotionListener(this);
}
public void run() {
try {
md = m;
m.findBB();
}
}
} catch (Exception e) {
}
try {
}
}
repaint();
}
public void start() {
}
}
public void stop() {
}
/* event handling */
}
e.consume();
}
}
}
}
int x = e.getX();
int y = e.getY();
if (painted) {
painted = false;
repaint();
}
prevx = x;
prevy = y;
e.consume();
}
}
if (backBuffer == null) {
}
paint(g);
}
// md.mat.scale(xfac, -xfac, 8 * xfac / getSize().width);
md.transformed = false;
if (backBuffer != null) {
}
} else {
}
setPainted();
}
}
private synchronized void setPainted() {
painted = true;
notifyAll();
}
return "Title: XYZApp \nAuthor: James Gosling \nAn applet to put"
+ " a Chemical model into a page.";
}
{ "model", "path string", "The path to the model to be displayed"
+ " in .xyz format "
+ "(see http://chem.leeds.ac.uk/Project/MIME.html)."
+ " Default is model.obj." },
{ "scale", "float", "Scale factor. Default is 1 (i.e. no scale)." }
};
return info;
}
} // end class XYZApp
class Atom {
private static byte[] data;
private final static int R = 40;
private static int maxr;
private int Rl;
private int Gl;
private int Bl;
static {
int mr = 0;
for (int Y = 2 * R; --Y >= 0;) {
int p = Y * (R * 2) + R - x0;
int x = X + hx;
int y = Y - R + hy;
if (r > mr) {
mr = r;
}
}
}
}
}
}
}
private void Setup() {
byte red[] = new byte[256];
byte green[] = new byte[256];
byte blue[] = new byte[256];
for (int r = 0; r < nBalls; r++) {
float b = (float) (r + 1) / nBalls;
for (int i = maxr; i >= 1; --i) {
float d = (float) i / maxr;
}
}
}
Setup();
}
int size = 10 + r;
}
}