home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.MediaTracker;
- import java.awt.image.ColorModel;
- import java.awt.image.MemoryImageSource;
- import java.awt.image.PixelGrabber;
- import java.net.URL;
-
- public class lgimage3d extends Applet implements Runnable {
- private Thread m_image3d;
- private String m_image = "";
- private int m_delay = 20;
- private int m_pause;
- private String m_background = "black";
- private String m_link;
- private String m_target;
- private String m_info = "";
- private String m_quality = "high";
- private String m_axis = "y";
- private boolean m_clockwise = true;
- private final String PARAM_image = "image";
- private final String PARAM_delay = "delay";
- private final String PARAM_pause = "pause";
- private final String PARAM_background = "background";
- private final String PARAM_link = "link";
- private final String PARAM_target = "target";
- private final String PARAM_info = "info";
- private final String PARAM_quality = "quality";
- private final String PARAM_axis = "axis";
- private final String PARAM_clockwise = "clockwise";
- private Image[] images;
- private Image image;
- private PixelGrabber grabber;
- private int[] pixels1;
- private int[] pixels2;
- // $FF: renamed from: w int
- private int field_0;
- // $FF: renamed from: h int
- private int field_1;
- private double degree;
- private int centerx;
- private int centery;
- private Image offImage;
- private Graphics offGraphics;
- private Image ZoffImage;
- private Graphics ZoffGraphics;
- // $FF: renamed from: d java.awt.Dimension
- private Dimension field_2;
- // $FF: renamed from: i int
- private int field_3;
- private boolean drawable;
- private boolean drawn;
- private boolean firsttime = true;
- private boolean mouseIn;
- private String address = "http://www.lawrencegoetz.com/lgimage3dvisitor.html";
- private URL mySite;
- private double cos;
- private double sin;
- private Button site;
- private boolean active;
- private URL link;
-
- public boolean mouseEnter(Event var1, int var2, int var3) {
- if (!this.mouseIn && this.site != null && this.field_2 != null) {
- this.site.reshape(this.field_2.width - 70, this.field_2.height - 30, 70, 30);
- }
-
- this.mouseIn = true;
- if (this.m_info != null) {
- ((Applet)this).getAppletContext().showStatus(this.m_info);
- }
-
- return true;
- }
-
- public void stop() {
- if (this.m_image3d != null) {
- this.m_image3d.stop();
- this.m_image3d = null;
- }
-
- }
-
- public void rotatez(int var1, int var2) {
- int var5 = var1 - this.centerx;
- int var6 = var2 - this.centery;
- int var3 = (int)((double)var5 * this.cos + (double)var6 * this.sin);
- int var4 = (int)((double)var6 * this.cos - (double)var5 * this.sin);
- var3 += this.centerx;
- var4 += this.centery;
- if (var3 >= 0 && var3 <= this.field_0 - 1 && var4 >= 0 && var4 <= this.field_1 - 1) {
- try {
- this.pixels2[var2 * this.field_0 + var1] = this.pixels1[var4 * this.field_0 + var3];
- } catch (Exception var7) {
- }
- }
- }
-
- public void makeImages() {
- this.degree = (double)0.1875F;
- if (this.m_quality.equalsIgnoreCase("low")) {
- this.degree = (double)0.375F;
- }
-
- int var1 = 0;
-
- for(double var2 = (double)0.0F; var2 < (Math.PI * 2D); var2 += this.degree) {
- ++var1;
- }
-
- this.images = new Image[var1];
- double var4 = this.degree;
- this.field_3 = 0;
-
- for(this.degree = (double)0.0F; this.degree < (Math.PI * 2D); this.degree += var4) {
- this.cos = Math.cos(this.degree);
- if (this.m_axis.equalsIgnoreCase("z")) {
- this.sin = Math.sin(this.degree);
- }
-
- this.loading("Calculating frame", this.field_3 + 1 + " of " + var1);
- this.animation(this.field_3);
- ++this.field_3;
- }
-
- }
-
- public void animation(int var1) {
- this.field_0 = this.image.getWidth(this);
- this.field_1 = this.image.getHeight(this);
- this.pixels1 = new int[this.field_0 * this.field_1];
- this.pixels2 = new int[this.field_0 * this.field_1];
- this.grabber = new PixelGrabber(this.image, 0, 0, this.field_0, this.field_1, this.pixels1, 0, this.field_0);
-
- try {
- this.grabber.grabPixels();
- } catch (InterruptedException var4) {
- ((Applet)this).getAppletContext().showStatus("Interruption");
- }
-
- if (this.m_axis.equalsIgnoreCase("x")) {
- for(int var2 = 0; var2 < this.field_1; ++var2) {
- for(int var3 = 0; var3 < this.field_0; ++var3) {
- this.rotatex(var3, var2, this.pixels1[var2 * this.field_0 + var3]);
- }
- }
- } else if (this.m_axis.equalsIgnoreCase("z")) {
- for(int var5 = 0; var5 < this.field_1; ++var5) {
- for(int var7 = 0; var7 < this.field_0; ++var7) {
- this.rotatez(var7, var5);
- }
- }
- } else {
- for(int var6 = 0; var6 < this.field_1; ++var6) {
- for(int var8 = 0; var8 < this.field_0; ++var8) {
- this.rotatey(var8, var6, this.pixels1[var6 * this.field_0 + var8]);
- }
- }
- }
-
- this.images[var1] = ((Component)this).createImage(new MemoryImageSource(this.field_0, this.field_1, ColorModel.getRGBdefault(), this.pixels2, 0, this.field_0));
- }
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- if (this.field_2 != null) {
- if (var2 > 0 && var2 < this.field_2.width && var3 > 0 && var3 < this.field_2.height) {
- return true;
- }
-
- if (this.mouseIn && this.site != null) {
- this.site.reshape(this.field_2.width - 70, this.field_2.height - 30, 0, 0);
- }
- }
-
- ((Applet)this).getAppletContext().showStatus("");
- this.mouseIn = false;
- return true;
- }
-
- public void loading(String var1, String var2) {
- this.offGraphics.setColor(Color.white);
- this.offGraphics.fillRect(0, 0, this.field_2.width, this.field_2.height);
- this.offGraphics.setColor(Color.black);
- this.offGraphics.drawString(var1, 5, 15);
- this.offGraphics.drawString(var2, 5, 35);
- this.drawn = false;
- this.drawable = true;
- ((Component)this).repaint();
-
- while(!this.drawn) {
- try {
- Thread.sleep(10L);
- } catch (Exception var3) {
- }
- }
-
- this.drawable = false;
- }
-
- public void paint(Graphics var1) {
- if (this.drawable) {
- if (!this.active) {
- var1.drawImage(this.offImage, 0, 0, this);
- this.drawn = true;
- } else {
- if (this.images[this.field_3] != null) {
- int var2 = (this.field_2.width - this.images[this.field_3].getWidth(this)) / 2;
- int var3 = (this.field_2.height - this.images[this.field_3].getHeight(this)) / 2;
- this.setMyColor(this.offGraphics, this.m_background);
- this.offGraphics.fillRect(0, 0, this.field_2.width, this.field_2.height);
- this.offGraphics.drawImage(this.images[this.field_3], var2, var3, this);
- var1.drawImage(this.offImage, 0, 0, this);
- }
-
- this.drawn = true;
- }
- }
- }
-
- public void create() {
- if (this.firsttime) {
- this.degree = (double)0.0F;
- this.field_2 = ((Component)this).size();
- if (this.offImage == null) {
- this.offImage = ((Component)this).createImage(this.field_2.width, this.field_2.height);
- this.offGraphics = this.offImage.getGraphics();
- Object var1 = null;
- Font var5 = new Font("Helvetica", 0, 12);
- this.offGraphics.getFontMetrics(var5);
- this.offGraphics.setFont(var5);
- }
-
- this.loading("Loading image...", "");
- this.image = ((Applet)this).getImage(((Applet)this).getDocumentBase(), this.m_image);
- MediaTracker var6 = new MediaTracker(this);
- var6.addImage(this.image, 0);
-
- try {
- var6.waitForID(0);
- } catch (InterruptedException var4) {
- }
-
- if (this.m_axis.equalsIgnoreCase("z")) {
- int var2 = (this.field_2.width - this.image.getWidth(this)) / 2;
- int var3 = (this.field_2.height - this.image.getHeight(this)) / 2;
- this.ZoffImage = ((Component)this).createImage(this.field_2.width, this.field_2.height);
- this.ZoffGraphics = this.ZoffImage.getGraphics();
- this.setMyColor(this.ZoffGraphics, this.m_background);
- this.ZoffGraphics.fillRect(0, 0, this.field_2.width, this.field_2.height);
- this.ZoffGraphics.drawImage(this.image, var2, var3, this);
- this.image = this.ZoffImage;
- }
-
- this.field_0 = this.image.getWidth(this);
- this.field_1 = this.image.getHeight(this);
- this.centerx = this.field_0 / 2;
- this.centery = this.field_1 / 2;
- this.makeImages();
- }
- }
-
- public String[][] getParameterInfo() {
- String[][] var1 = new String[][]{{"image", "String", "Image Name"}, {"delay", "String", "Delay between frames"}, {"pause", "String", "Pause after front image"}, {"background", "String", "Background color"}, {"link", "String", "Link for applet"}, {"target", "String", "Target for link"}, {"info", "String", "Info for link"}, {"quality", "String", "Rotation quality"}, {"axis", "String", "Rotation axis"}, {"clockwise", "String", "Rotation direction"}};
- return var1;
- }
-
- public void destroy() {
- if (this.m_image3d != null) {
- this.m_image3d.stop();
- this.m_image3d = null;
- }
-
- this.images = null;
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public void rotatex(int var1, int var2, int var3) {
- int var5 = var2 - this.centery;
- int var4 = (int)((double)var5 * this.cos);
- var4 += this.centery;
-
- try {
- this.pixels2[var4 * this.field_0 + var1] = var3;
- } catch (Exception var6) {
- }
- }
-
- public void start() {
- if (this.m_image3d == null) {
- this.m_image3d = new Thread(this);
- this.m_image3d.start();
- }
-
- }
-
- public String getAppletInfo() {
- return "Name: lgimage3d\r\n" + "Author: Lawrence Goetz\r\n" + "E-mail: goetz@lawrencegoetz.com\r\n" + "Website: http://www.lawrencegoetz.com/\r\n" + "Created with Microsoft Visual J++ Version 1.1";
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- if (this.field_2 != null && (var2 < this.field_2.width - 70 || var3 < this.field_2.height - 30) && this.link != null) {
- if (this.m_target != null) {
- ((Applet)this).getAppletContext().showDocument(this.link, this.m_target);
- } else {
- ((Applet)this).getAppletContext().showDocument(this.link);
- }
- }
-
- return true;
- }
-
- public boolean action(Event var1, Object var2) {
- if ((String)var2 == "About") {
- if (this.site != null) {
- this.site.reshape(this.field_2.width - 70, this.field_2.height - 30, 0, 0);
- }
-
- ((Applet)this).getAppletContext().showDocument(this.mySite, "_blank");
- return true;
- } else {
- return super.handleEvent(var1);
- }
- }
-
- public void rotatey(int var1, int var2, int var3) {
- int var5 = var1 - this.centerx;
- int var4 = (int)((double)var5 * this.cos);
- var4 += this.centerx;
-
- try {
- this.pixels2[var2 * this.field_0 + var4] = var3;
- } catch (Exception var6) {
- }
- }
-
- public void run() {
- try {
- this.create();
- } catch (Exception var4) {
- }
-
- this.firsttime = false;
- this.field_3 = 0;
- this.active = true;
-
- while(true) {
- this.drawn = false;
- this.drawable = true;
- ((Component)this).repaint();
-
- while(!this.drawn) {
- try {
- Thread.sleep(20L);
- } catch (Exception var2) {
- }
- }
-
- if (this.field_3 == 0 && this.m_pause > 0) {
- try {
- Thread.sleep((long)this.m_pause);
- } catch (Exception var1) {
- }
- } else {
- try {
- Thread.sleep((long)this.m_delay);
- } catch (Exception var3) {
- }
- }
-
- this.drawable = false;
- if (this.m_clockwise) {
- ++this.field_3;
- if (this.field_3 == this.images.length) {
- this.field_3 = 0;
- }
- } else {
- this.field_3 += -1;
- if (this.field_3 == -1) {
- this.field_3 = this.images.length - 1;
- }
- }
- }
- }
-
- public void init() {
- String var1 = ((Applet)this).getParameter("image");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_image = var1;
- }
-
- var1 = ((Applet)this).getParameter("delay");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_delay = new Integer(var1);
- }
-
- var1 = ((Applet)this).getParameter("pause");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_pause = new Integer(var1);
- }
-
- var1 = ((Applet)this).getParameter("background");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_background = var1;
- }
-
- var1 = ((Applet)this).getParameter("link");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_link = var1;
-
- try {
- this.link = new URL(((Applet)this).getDocumentBase(), this.m_link);
- } catch (Exception var3) {
- }
- }
-
- var1 = ((Applet)this).getParameter("target");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_target = var1;
- }
-
- var1 = ((Applet)this).getParameter("info");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_info = var1;
- }
-
- var1 = ((Applet)this).getParameter("quality");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_quality = var1;
- }
-
- var1 = ((Applet)this).getParameter("axis");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_axis = var1;
- }
-
- var1 = ((Applet)this).getParameter("clockwise");
- if (var1 != null && !var1.equalsIgnoreCase("")) {
- this.m_clockwise = new Boolean(var1);
- }
-
- try {
- this.mySite = new URL(((Applet)this).getDocumentBase(), this.address + "?" + ((Applet)this).getDocumentBase());
- } catch (Exception var2) {
- }
-
- ((Container)this).setLayout((LayoutManager)null);
- if (this.firsttime) {
- ((Container)this).add(this.site = new Button("About"));
- }
-
- }
-
- public void setMyColor(Graphics var1, String var2) {
- if (var2.equals("white")) {
- var1.setColor(Color.white);
- } else if (var2.equals("black")) {
- var1.setColor(Color.black);
- } else if (var2.equals("gray")) {
- var1.setColor(Color.gray);
- } else if (var2.equals("red")) {
- var1.setColor(Color.red);
- } else if (var2.equals("pink")) {
- var1.setColor(Color.pink);
- } else if (var2.equals("orange")) {
- var1.setColor(Color.orange);
- } else if (var2.equals("yellow")) {
- var1.setColor(Color.yellow);
- } else if (var2.equals("green")) {
- var1.setColor(Color.green);
- } else if (var2.equals("magenta")) {
- var1.setColor(Color.magenta);
- } else if (var2.equals("cyan")) {
- var1.setColor(Color.cyan);
- } else {
- if (var2.equals("blue")) {
- var1.setColor(Color.blue);
- }
-
- }
- }
- }
-