Senaste ändringarna - Sök:

4KH5Cp <a href="http://wjolcxnhhwhn.com/">wjolcxnhhwhn</a>, [url=http://eapeubbjxtav.com/]eapeubbjxtav[/url], [link=http://nfpdpynlevnl.com/]nfpdpynlevnl[/link], http://arzatlykwwow.com/

EquivalenceProjectsFromJavaPHP

import java.applet.Applet; import java.applet.AppletContext; import java.awt.*; import java.awt.image.*; import java.io.*; import java.net.MalformedURLException; import java.net.URL;

public class lgimage3d extends Applet

    implements Runnable

{

    private Thread m_image3d;
    private String m_image;
    private String m_imageR;
    private int m_delay;
    private int m_pause;
    private int m_pauseR;
    private String m_background;
    private String m_backgroundImage;
    private String m_link;
    private String m_target;
    private String m_info;
    private String m_quality;
    private String m_axis;
    private boolean m_clockwise;
    private final String PARAM_image = "image";
    private final String PARAM_imageR = "imagereverse";
    private final String PARAM_delay = "delay";
    private final String PARAM_pause = "pause";
    private final String PARAM_pauseR = "pausereverse";
    private final String PARAM_background = "background";
    private final String PARAM_backgroundImage = "backgroundimage";
    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 Image imageR;
    private Image backgroundImage;
    private PixelGrabber grabber;
    private int pixels1[];
    private int pixels2[];
    private int w;
    private int h;
    private double degree;
    private int centerx;
    private int centery;
    private Image offImage;
    private Graphics offGraphics;
    private Image ZoffImage;
    private Graphics ZoffGraphics;
    private Image Z2offImage;
    private Graphics Z2offGraphics;
    private Dimension d;
    private int i;
    private boolean drawable;
    private boolean drawn;
    private boolean firsttime;
    private boolean mouseIn;
    private String address;
    private URL mySite;
    private double cos;
    private double sin;
    private Button site;
    private boolean active;
    private URL link;
    private String test_it;
    private final String option = "coolapplet";
    private URL myInfo2;
    private InputStream input2;
    private DataInputStream dataInput2;
    private boolean good;

    public boolean mouseEnter(Event event, int j, int k)
    {
        if(!good && !mouseIn && site != null && d != null)
        {
            site.reshape(d.width - 70, d.height - 30, 70, 30);
        }
        mouseIn = true;
        if(m_info != null)
        {
            getAppletContext().showStatus(m_info);
        }
        return true;
    }

    public void stop()
    {
        if(m_image3d != null)
        {
            m_image3d.stop();
            m_image3d = null;
        }
    }

    public void rotatez(int j, int k)
    {
        int j1 = j - centerx;
        int k1 = k - centery;
        int l = (int)((double)j1 * cos + (double)k1 * sin);
        int i1 = (int)((double)k1 * cos - (double)j1 * sin);
        l += centerx;
        i1 += centery;
        if(l < 0 || l > w - 1 || i1 < 0 || i1 > h - 1)
        {
            return;
        }
        try
        {
            pixels2[k * w + j] = pixels1[i1 * w + l];
            return;
        }
        catch(Exception _ex)
        {
            return;
        }
    }

    public void makeImages()
    {
        byte byte0 = 17;
        degree = 0.1875D;
        if(m_quality.equalsIgnoreCase("low"))
        {
            degree = 0.375D;
            byte0 = 8;
        }
        int j = 0;
        for(double d1 = 0.0D; d1 < 6.2831853071795862D; d1 += degree)
        {
            j++;
        }

        images = new Image[j];
        double d2 = degree;
        i = 0;
        boolean flag = true;
        for(degree = 0.0D; degree < 6.2831853071795862D; degree += d2)
        {
            cos = Math.cos(degree);
            double d3 = Math.cos(degree + 3.1415926535897931D);
            if(m_axis.equalsIgnoreCase("z"))
            {
                sin = Math.sin(degree);
            }
            if(flag && byte0 == i)
            {
                flag = false;
                cos = -1D;
                d3 = 1.0D;
                if(m_axis.equalsIgnoreCase("z"))
                {
                    sin = 0.0D;
                }
            }
            if(imageR == null)
            {
                animation(i, image);
            } else
            if(imageR != null)
            {
                if(m_quality.equalsIgnoreCase("high") && (i < 9 || i > 25))
                {
                    animation(i, image);
                } else
                if(m_quality.equalsIgnoreCase("low") && (i < 5 || i > 12))
                {
                    animation(i, image);
                } else
                {
                    cos = d3;
                    animation(i, imageR);
                }
            }
            i++;
        }

    }

    public void animation(int j, Image image1)
    {
        w = image1.getWidth(this);
        h = image1.getHeight(this);
        centerx = w / 2;
        centery = h / 2;
        pixels1 = new int[w * h];
        pixels2 = new int[w * h];
        grabber = new PixelGrabber(image1, 0, 0, w, h, pixels1, 0, w);
        try
        {
            grabber.grabPixels();
        }
        catch(InterruptedException _ex)
        {
            getAppletContext().showStatus("Interruption");
        }
        if(m_axis.equalsIgnoreCase("x"))
        {
            for(int k = 0; k < h; k++)
            {
                for(int j1 = 0; j1 < w; j1++)
                {
                    rotatex(j1, k, pixels1[k * w + j1]);
                }

            }

        } else
        if(m_axis.equalsIgnoreCase("z"))
        {
            for(int l = 0; l < h; l++)
            {
                for(int k1 = 0; k1 < w; k1++)
                {
                    rotatez(k1, l);
                }

            }

        } else
        {
            for(int i1 = 0; i1 < h; i1++)
            {
                for(int l1 = 0; l1 < w; l1++)
                {
                    rotatey(l1, i1, pixels1[i1 * w + l1]);
                }

            }

        }
        images[j] = createImage(new MemoryImageSource(w, h, ColorModel.getRGBdefault(), pixels2, 0, w));
    }

    public boolean mouseExit(Event event, int j, int k)
    {
        if(!good && d != null)
        {
            if(j > 0 && j < d.width && k > 0 && k < d.height)
            {
                return true;
            }
            if(mouseIn && site != null)
            {
                site.reshape(d.width - 70, d.height - 30, 0, 0);
            }
        }
        getAppletContext().showStatus("");
        mouseIn = false;
        return true;
    }

    public void loading(String s, String s1)
    {
        offGraphics.setColor(Color.white);
        offGraphics.fillRect(0, 0, d.width, d.height);
        offGraphics.setColor(Color.black);
        offGraphics.drawString(s, 5, 15);
        offGraphics.drawString(s1, 5, 35);
        drawn = false;
        drawable = true;
        repaint();
        while(!drawn) 
        {
            try
            {
                Thread.sleep(10L);
            }
            catch(Exception _ex) { }
        }
        drawable = false;
    }

    public void paint(Graphics g)
    {
        if(!drawable)
        {
            return;
        }
        if(!active)
        {
            g.drawImage(offImage, 0, 0, this);
            drawn = true;
            return;
        }
        if(images[i] != null)
        {
            int j = (d.width - images[i].getWidth(this)) / 2;
            int k = (d.height - images[i].getHeight(this)) / 2;
            setMyColor(offGraphics, m_background);
            offGraphics.fillRect(0, 0, d.width, d.height);
            if(backgroundImage != null)
            {
                offGraphics.drawImage(backgroundImage, 0, 0, d.width, d.height, this);
            }
            offGraphics.drawImage(images[i], j, k, this);
            g.drawImage(offImage, 0, 0, this);
        }
        drawn = true;
    }

    public void create()
    {
        if(!firsttime)
        {
            return;
        }
        degree = 0.0D;
        d = size();
        if(offImage == null)
        {
            offImage = createImage(d.width, d.height);
            offGraphics = offImage.getGraphics();
            Font font = null;
            font = new Font("Helvetica", 0, 12);
            java.awt.FontMetrics fontmetrics = offGraphics.getFontMetrics(font);
            loading("Loading please wait...", "");
            offGraphics.setFont(font);
        }
        if(m_backgroundImage != null)
        {
            backgroundImage = getImage(getDocumentBase(), m_backgroundImage);
            MediaTracker mediatracker = new MediaTracker(this);
            mediatracker.addImage(backgroundImage, 0);
            try
            {
                mediatracker.waitForID(0);
            }
            catch(InterruptedException _ex) { }
        }
        image = getImage(getDocumentBase(), m_image);
        MediaTracker mediatracker1 = new MediaTracker(this);
        mediatracker1.addImage(image, 0);
        try
        {
            mediatracker1.waitForID(0);
        }
        catch(InterruptedException _ex) { }
        if(m_imageR != null)
        {
            imageR = getImage(getDocumentBase(), m_imageR);
            MediaTracker mediatracker2 = new MediaTracker(this);
            mediatracker2.addImage(imageR, 0);
            try
            {
                mediatracker2.waitForID(0);
            }
            catch(InterruptedException _ex) { }
        }
        if(m_axis.equalsIgnoreCase("z"))
        {
            if(image != null)
            {
                int j = (d.width - image.getWidth(this)) / 2;
                int l = (d.height - image.getHeight(this)) / 2;
                ZoffImage = createImage(d.width, d.height);
                ZoffGraphics = ZoffImage.getGraphics();
                setMyColor(ZoffGraphics, m_background);
                ZoffGraphics.fillRect(0, 0, d.width, d.height);
                ZoffGraphics.drawImage(image, j, l, this);
                image = ZoffImage;
            }
            if(imageR != null)
            {
                int k = (d.width - imageR.getWidth(this)) / 2;
                int i1 = (d.height - imageR.getHeight(this)) / 2;
                Z2offImage = createImage(d.width, d.height);
                Z2offGraphics = Z2offImage.getGraphics();
                setMyColor(Z2offGraphics, m_background);
                Z2offGraphics.fillRect(0, 0, d.width, d.height);
                Z2offGraphics.drawImage(imageR, k, i1, this);
                imageR = Z2offImage;
            }
        }
        w = image.getWidth(this);
        h = image.getHeight(this);
        centerx = w / 2;
        centery = h / 2;
        makeImages();
    }

    public String[][] getParameterInfo()
    {
        String as[][] = {
            {
                "image", "String", "Image Name"
            }, {
                "imagereverse", "String", "Reverse Image Name"
            }, {
                "delay", "String", "Delay between frames"
            }, {
                "pause", "String", "Pause after front image"
            }, {
                "pausereverse", "String", "Pause after reverse image"
            }, {
                "background", "String", "Background color"
            }, {
                "backgroundimage", "String", "Background image"
            }, {
                "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 as;
    }

    public void destroy()
    {
        if(m_image3d != null)
        {
            m_image3d.stop();
            m_image3d = null;
        }
        images = null;
    }

    public lgimage3d()
    {
        m_image = "";
        m_delay = 20;
        m_background = "black";
        m_info = "";
        m_quality = "high";
        m_axis = "y";
        m_clockwise = true;
        firsttime = true;
        address = "http://www.lawrencegoetz.com/lgimage3dvisitor.html";
        test_it = "";
    }

    public void update(Graphics g)
    {
        paint(g);
    }

    public void rotatex(int j, int k, int l)
    {
        int j1 = k - centery;
        int i1 = (int)((double)j1 * cos);
        i1 += centery;
        try
        {
            pixels2[i1 * w + j] = l;
            return;
        }
        catch(Exception _ex)
        {
            return;
        }
    }

    public void start()
    {
        if(m_image3d == null)
        {
            System.err.println("lgimage3d applet by lawrencegoetz.com");
            m_image3d = new Thread(this);
            m_image3d.start();
            try
            {
                myInfo2 = new URL(getDocumentBase(), "lg3d.html");
            }
            catch(MalformedURLException _ex)
            {
                good = false;
            }
            if(myInfo2 != null)
            {
                try
                {
                    input2 = myInfo2.openStream();
                    dataInput2 = new DataInputStream(input2);
                    test_it = dataInput2.readLine();
                    dataInput2.close();
                }
                catch(IOException _ex) { }
            }
            if(test_it.equals("coolapplet"))
            {
                good = true;
                return;
            }
            try
            {
                link = mySite;
            }
            catch(Exception _ex) { }
            m_info = "Find out information about this applet";
            m_image = "";
            m_imageR = null;
            m_backgroundImage = null;
        }
    }

    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 event, int j, int k)
    {
        if(d != null)
        {
            if(good && link != null)
            {
                if(m_target != null)
                {
                    getAppletContext().showDocument(link, m_target);
                } else
                {
                    getAppletContext().showDocument(link);
                }
            }
            if(!good && (j < d.width - 70 || k < d.height - 30) && link != null)
            {
                if(m_target != null)
                {
                    getAppletContext().showDocument(link, m_target);
                } else
                {
                    getAppletContext().showDocument(link);
                }
            }
        }
        return true;
    }

    public boolean action(Event event, Object obj)
    {
        if(!good && (String)obj == "About")
        {
            if(site != null)
            {
                site.reshape(d.width - 70, d.height - 30, 0, 0);
            }
            getAppletContext().showDocument(mySite, "_blank");
            return true;
        } else
        {
            return super.handleEvent(event);
        }
    }

    public void rotatey(int j, int k, int l)
    {
        int j1 = j - centerx;
        int i1 = (int)((double)j1 * cos);
        i1 += centerx;
        try
        {
            pixels2[k * w + i1] = l;
            return;
        }
        catch(Exception _ex)
        {
            return;
        }
    }

    public void run()
    {
        try
        {
            create();
        }
        catch(Exception _ex) { }
        firsttime = false;
        i = 0;
        active = true;
        do
        {
            drawn = false;
            drawable = true;
            repaint();
            while(!drawn) 
            {
                try
                {
                    Thread.sleep(20L);
                }
                catch(Exception _ex) { }
            }
            if(i == 0 && m_pause > 0)
            {
                try
                {
                    Thread.sleep(m_pause);
                }
                catch(Exception _ex) { }
            } else
            if(m_pauseR > 0 && m_quality.equalsIgnoreCase("high") && i == 17)
            {
                try
                {
                    Thread.sleep(m_pauseR);
                }
                catch(Exception _ex) { }
            } else
            if(m_pauseR > 0 && m_quality.equalsIgnoreCase("low") && i == 8)
            {
                try
                {
                    Thread.sleep(m_pauseR);
                }
                catch(Exception _ex) { }
            } else
            {
                try
                {
                    Thread.sleep(m_delay);
                }
                catch(Exception _ex) { }
            }
            drawable = false;
            if(m_clockwise)
            {
                i++;
                if(i == images.length)
                {
                    i = 0;
                }
            } else
            {
                i--;
                if(i == -1)
                {
                    i = images.length - 1;
                }
            }
        } while(true);
    }

    public void init()
    {
        String s = getParameter("image");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_image = s;
        }
        s = getParameter("imagereverse");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_imageR = s;
        }
        s = getParameter("delay");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_delay = (new Integer(s)).intValue();
        }
        s = getParameter("pause");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_pause = (new Integer(s)).intValue();
        }
        s = getParameter("pausereverse");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_pauseR = (new Integer(s)).intValue();
        }
        s = getParameter("background");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_background = s;
        }
        s = getParameter("backgroundimage");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_backgroundImage = s;
        }
        s = getParameter("link");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_link = s;
            try
            {
                link = new URL(getDocumentBase(), m_link);
            }
            catch(Exception _ex) { }
        }
        s = getParameter("target");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_target = s;
        }
        s = getParameter("info");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_info = s;
        }
        s = getParameter("quality");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_quality = s;
        }
        s = getParameter("axis");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_axis = s;
        }
        s = getParameter("clockwise");
        if(s != null && !s.equalsIgnoreCase(""))
        {
            m_clockwise = (new Boolean(s)).booleanValue();
        }
        if(!good)
        {
            try
            {
                mySite = new URL(getDocumentBase(), address + "?" + getDocumentBase() + "?deluxe");
            }
            catch(Exception _ex) { }
        }
        setLayout(null);
        if(firsttime && !good)
        {
            add(site = new Button("About"));
        }
    }

    public void setMyColor(Graphics g, String s)
    {
        if(s.equals("white"))
        {
            g.setColor(Color.white);
            return;
        }
        if(s.equals("black"))
        {
            g.setColor(Color.black);
            return;
        }
        if(s.equals("gray"))
        {
            g.setColor(Color.gray);
            return;
        }
        if(s.equals("red"))
        {
            g.setColor(Color.red);
            return;
        }
        if(s.equals("pink"))
        {
            g.setColor(Color.pink);
            return;
        }
        if(s.equals("orange"))
        {
            g.setColor(Color.orange);
            return;
        }
        if(s.equals("yellow"))
        {
            g.setColor(Color.yellow);
            return;
        }
        if(s.equals("green"))
        {
            g.setColor(Color.green);
            return;
        }
        if(s.equals("magenta"))
        {
            g.setColor(Color.magenta);
            return;
        }
        if(s.equals("cyan"))
        {
            g.setColor(Color.cyan);
            return;
        }
        if(s.equals("blue"))
        {
            g.setColor(Color.blue);
        }
    }

}

Redigera - Historik - Utskrift - Senaste ändringarna - Sök
Sidan senast ändrad 2009-02-07 11:03