Java applet with image effects, could you help me please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • takeiteasy
    New Member
    • Oct 2006
    • 4

    #1

    Java applet with image effects, could you help me please

    Hello everyone,

    I've got a question about programming by using Java applet and the question is :
    Design a web page containing an applet that simply switches from one image to the next with some transition effects such as :

    Fade: Fade one image out while you fade the next one in.
    Whirlpoo l fade: Building on the fade transition, rather than just fading between images the first image swirls out of focus; the swirl is then reversed and as it 'unswirls' the second image is revealed
    Bathroom window fade: Again building on the fade transition, the image is broken up using a bathroom window effect, and as the effect is reversed the second image is revealed.


    How to proceed

    If you are unsure about how to tackle this exercise, then you may wish to break it down into smaller steps:
    1.Create a basic web page with a static image
    2.Replace the image with an applet that displays the image
    3.Make the applet change between different images, and apply transitional effects to these changes.

    Thanks in advance.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by takeiteasy
    Hello everyone,

    I've got a question about programming by using Java applet and the question is :
    Design a web page containing an applet that simply switches from one image to the next with some transition effects such as :

    Fade: Fade one image out while you fade the next one in.
    Whirlpoo l fade: Building on the fade transition, rather than just fading between images the first image swirls out of focus; the swirl is then reversed and as it 'unswirls' the second image is revealed
    Bathroom window fade: Again building on the fade transition, the image is broken up using a bathroom window effect, and as the effect is reversed the second image is revealed.


    How to proceed

    If you are unsure about how to tackle this exercise, then you may wish to break it down into smaller steps:
    1.Create a basic web page with a static image
    2.Replace the image with an applet that displays the image
    3.Make the applet change between different images, and apply transitional effects to these changes.

    Thanks in advance.
    So where have you got so far? Were you able to create an html page with a picture on it? Were you able to make an applet that diplays a picture?

    Comment

    • takeiteasy
      New Member
      • Oct 2006
      • 4

      #3
      I do not need to make it with HTML
      I need just to make applet that displays pictures with the effects in any Java software like “ Netbeans”

      this is some example of the effects on the pictures.

      http://www.ericharshba rger.org/cgi-bin/j.cgi?imagediss olve/index.html

      http://www.ericharshba rger.org/cgi-bin/j.cgi?imagefade/index.html

      http://www.ericharshba rger.org/cgi-bin/j.cgi?imagefan/index.html

      *** make the effects together ****

      Many Thanks in advance

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by takeiteasy
        I do not need to make it with HTML
        I need just to make applet that displays pictures with the effects in any Java software like “ Netbeans”

        this is some example of the effects on the pictures.

        http://www.ericharshba rger.org/cgi-bin/j.cgi?imagediss olve/index.html

        http://www.ericharshba rger.org/cgi-bin/j.cgi?imagefade/index.html

        http://www.ericharshba rger.org/cgi-bin/j.cgi?imagefan/index.html

        *** make the effects together ****

        Many Thanks in advance
        You still have to write something first. Can you write an applet that displays an image?

        Comment

        • takeiteasy
          New Member
          • Oct 2006
          • 4

          #5
          Originally posted by r035198x
          You still have to write something first. Can you write an applet that displays an image?
          Thank you for your answer .

          the applet is something like that::

          import java.awt.Graphi cs;
          import java.awt.Image;
          import java.net.URL;


          public class NewClass extends javax.swing.JAp plet implements Runnable {
          volatile Thread thread;

          Image img;

          public void ThreadApplet() {
          }


          public void init() {
          try {
          img = getImage(new URL(getDocument Base(), "http://www.hi-seas.com/pics/pool3.jpg"));


          } catch (Exception e) {
          e.printStackTra ce();
          }
          }
          public void start()
          {
          Thread runThread = new Thread(this);
          runThread.start ();
          }

          public void stop()
          {
          thread = null;
          }

          public void run()
          {
          try
          {
          while (thread == Thread.currentT hread())
          {
          repaint();
          Thread.sleep(10 00);
          System.out.prin tln("This is a thread");

          }
          }
          catch (Exception e)
          {
          e.printStackTra ce();
          }
          }
          public void paint(Graphics g)
          {
          g.drawImage(img ,10,10,this);
          }


          }

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by takeiteasy
            Thank you for your answer .

            the applet is something like that::

            import java.awt.Graphi cs;
            import java.awt.Image;
            import java.net.URL;


            public class NewClass extends javax.swing.JAp plet implements Runnable {
            volatile Thread thread;

            Image img;

            public void ThreadApplet() {
            }


            public void init() {
            try {
            img = getImage(new URL(getDocument Base(), "http://www.hi-seas.com/pics/pool3.jpg"));


            } catch (Exception e) {
            e.printStackTra ce();
            }
            }
            public void start()
            {
            Thread runThread = new Thread(this);
            runThread.start ();
            }

            public void stop()
            {
            thread = null;
            }

            public void run()
            {
            try
            {
            while (thread == Thread.currentT hread())
            {
            repaint();
            Thread.sleep(10 00);
            System.out.prin tln("This is a thread");

            }
            }
            catch (Exception e)
            {
            e.printStackTra ce();
            }
            }
            public void paint(Graphics g)
            {
            g.drawImage(img ,10,10,this);
            }


            }
            This will make it alternate between 2 images in the codebase

            Code:
            import java.awt.Graphics;
            import java.awt.Image;
            import java.net.URL;
            
            
            public class NewClass extends javax.swing.JApplet implements Runnable {
            Thread thread;
            
            Image img;
            
            public void ThreadApplet() {
            }
            
            
            public void init() {
            try {
            
            img = getImage(new URL(getDocumentBase(), "Sample.jpg"));
            
            
            } catch (Exception e) {
            e.printStackTrace();
            }
            }
            public void start()
            {
            Thread runThread = new Thread(this);
            runThread.start();
            }
            
            
            
            public void run()
            {
            try
            {
            while (true)
            {
            
            img = getImage(new URL(getDocumentBase(), "sunlogo64x30.gif"));
            repaint();
            Thread.sleep(1000);
            getGraphics().clearRect(10, 10, img.getWidth(this), img.getHeight(this));
            repaint();
            img = getImage(new URL(getDocumentBase(), "Sample.jpg"));
            repaint();
            Thread.sleep(1000);
            getGraphics().clearRect(10, 10, img.getWidth(this), img.getHeight(this));
            System.out.println("This is a thread");
            
            }
            }
            catch (Exception e)
            {
            e.printStackTrace();
            }
            }
            public void paint(Graphics g)
            {
            g.drawImage(img,10,10,this);
            }
            
            
            }

            Comment

            • takeiteasy
              New Member
              • Oct 2006
              • 4

              #7
              Originally posted by r035198x
              This will make it alternate between 2 images in the codebase

              Code:
              import java.awt.Graphics;
              import java.awt.Image;
              import java.net.URL;
              
              
              public class NewClass extends javax.swing.JApplet implements Runnable {
              Thread thread;
              
              Image img;
              
              public void ThreadApplet() {
              }
              
              
              public void init() {
              try {
              
              img = getImage(new URL(getDocumentBase(), "Sample.jpg"));
              
              
              } catch (Exception e) {
              e.printStackTrace();
              }
              }
              public void start()
              {
              Thread runThread = new Thread(this);
              runThread.start();
              }
              
              
              
              public void run()
              {
              try
              {
              while (true)
              {
              
              img = getImage(new URL(getDocumentBase(), "sunlogo64x30.gif"));
              repaint();
              Thread.sleep(1000);
              getGraphics().clearRect(10, 10, img.getWidth(this), img.getHeight(this));
              repaint();
              img = getImage(new URL(getDocumentBase(), "Sample.jpg"));
              repaint();
              Thread.sleep(1000);
              getGraphics().clearRect(10, 10, img.getWidth(this), img.getHeight(this));
              System.out.println("This is a thread");
              
              }
              }
              catch (Exception e)
              {
              e.printStackTrace();
              }
              }
              public void paint(Graphics g)
              {
              g.drawImage(img,10,10,this);
              }
              
              
              }

              Thanks mate for your time and answer.

              I tried with array of images and it is working probably.
              But it is the first step in the program .
              The second step is to do fade effect between images (3 images or 4 ,....)
              Like this website

              http://www.appletcolle ction.com/dissolveimage.h tml


              ****** the code of load array of images is *****

              import java.awt.Graphi cs;
              import java.awt.Image;
              import java.net.URL;


              public class NewClass extends javax.swing.JAp plet implements Runnable {
              volatile Thread thread;

              Image[] img = new Image[3];
              Image image;
              boolean stopped = false;


              public void ThreadApplet() {
              }


              public void init() {
              try {

              for(int i=0;i<3;i++)
              {
              img[i] = getImage(getCod eBase(), i+1+".gif");
              }

              } catch (Exception e) {
              e.printStackTra ce();
              }
              }
              public void start()
              {
              Thread runThread = new Thread(this);
              runThread.start ();
              }

              public void stop()
              {
              thread = null;
              }

              public void run()
              {
              try
              {
              int i=0;
              while(!stopped)
              {
              image = img[i];
              i = (++i)%3;
              try
              {
              Thread.sleep(10 00);
              Thread.yield();
              }
              catch(Exception e)
              {}
              repaint();
              }
              }
              catch (Exception e)
              {
              e.printStackTra ce();
              }
              }

              public void paint(Graphics g)
              {
              g.drawImage(ima ge,10,10,this);
              }
              }

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by takeiteasy
                Thanks mate for your time and answer.

                I tried with array of images and it is working probably.
                But it is the first step in the program .
                The second step is to do fade effect between images (3 images or 4 ,....)
                Like this website

                http://www.appletcolle ction.com/dissolveimage.h tml


                ****** the code of load array of images is *****

                import java.awt.Graphi cs;
                import java.awt.Image;
                import java.net.URL;


                public class NewClass extends javax.swing.JAp plet implements Runnable {
                volatile Thread thread;

                Image[] img = new Image[3];
                Image image;
                boolean stopped = false;


                public void ThreadApplet() {
                }


                public void init() {
                try {

                for(int i=0;i<3;i++)
                {
                img[i] = getImage(getCod eBase(), i+1+".gif");
                }

                } catch (Exception e) {
                e.printStackTra ce();
                }
                }
                public void start()
                {
                Thread runThread = new Thread(this);
                runThread.start ();
                }

                public void stop()
                {
                thread = null;
                }

                public void run()
                {
                try
                {
                int i=0;
                while(!stopped)
                {
                image = img[i];
                i = (++i)%3;
                try
                {
                Thread.sleep(10 00);
                Thread.yield();
                }
                catch(Exception e)
                {}
                repaint();
                }
                }
                catch (Exception e)
                {
                e.printStackTra ce();
                }
                }

                public void paint(Graphics g)
                {
                g.drawImage(ima ge,10,10,this);
                }
                }
                Yeah second step is a bit tricky. I'll have a look at it just now and will keep you posted.
                My first hunch is that we're going to need
                MediaTracker, PixelGrabber and MemoryImageSour ce

                Comment

                • LostInADesert
                  New Member
                  • Oct 2007
                  • 1

                  #9
                  i guess too late........

                  Comment

                  • r035198x
                    MVP
                    • Sep 2006
                    • 13225

                    #10
                    Originally posted by LostInADesert
                    i guess too late........
                    Yep, I guess that's one of those that got lost in a desert ...

                    Comment

                    Working...