Results 1 to 9 of 9
  1. #1
    Kratos321's Avatar
    Kratos321 is offline Member
    Join Date
    May 2011
    Posts
    31
    Rep Power
    0

    Post Alternative way to create a circle propagation?

    I've written the following code for the propagation of a circle. Is there an alternative or more efficient way to do this other than increasing the length by 2 for ever 1 decrease of the x and y values of the top left corner?

    btw c.maxx and c.maxy calculates the maximum pixels for the width and length of output screen on my ide.

    Im using HSA console on "Ready to Program with Java IDE".

    thanks for any suggestions.


    Java Code:
    // The "CircleProjection" class.
    import java.awt.*;
    import hsa.Console;
    
    public class CircleProjection
    {
        static Console c;           // The output console
    
        public static void main (String[] args)
        {
            c = new Console ();
    
            int r = 0;
            int i = 0, a, b;
    
            a = (c.maxx ()) / 2;
            b = (c.maxy ()) / 2;
    
            while (i == 0)
            {
    
                c.setColor (new Color (0, 0, 255));
    
                c.drawOval (a, b, r, r);
    
                try
                {
                    Thread.currentThread ().sleep (1);
                } //end of try
                catch (Exception e)
                {
                } //end of catch
    
                c.setColor (new Color (255, 255, 255));
    
                c.drawOval (a, b, r, r);
    
                a--;
                b--;
                r = r + 2;
    
                if (b == 0)
                {
                    a = (c.maxx ()) / 2;
                    b = (c.maxy ()) / 2;
                    r = 0;
                }
    
            } //end of while loop
        } // main method
    } // CircleProjection class
    Last edited by Fubarable; 05-26-2011 at 04:48 AM. Reason: code tags added

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default

    increasing the length by 2 for ever 1 decrease of the x and y values
    Have you taken a piece of paper and drawn a grid and drawn the circles? What do you have to do to keep the circles centered on the same point?

  3. #3
    Kratos321's Avatar
    Kratos321 is offline Member
    Join Date
    May 2011
    Posts
    31
    Rep Power
    0

    Default

    I'm not entirely sure.....well i know i have to make the radius originate from the center and constant throughout. Other than that...?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default

    I'm not entirely sure.
    Have you taken a piece of paper and drawn a grid and drawn the circles?

  5. #5
    Kratos321's Avatar
    Kratos321 is offline Member
    Join Date
    May 2011
    Posts
    31
    Rep Power
    0

    Default

    yes i just did, and i still can't figure out another method. any hints on what i should be looking for?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default

    I don't know if there is another method.

    Wait till JosAH takes a look.

  7. #7
    Kratos321's Avatar
    Kratos321 is offline Member
    Join Date
    May 2011
    Posts
    31
    Rep Power
    0

    Default

    yeah ok sure. who is that btw?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,409
    Rep Power
    25

    Default

    Scan thru some of the forums and you should see where he has answered some questions.

  9. #9
    Kratos321's Avatar
    Kratos321 is offline Member
    Join Date
    May 2011
    Posts
    31
    Rep Power
    0

Similar Threads

  1. alternative for ajax
    By site4u in forum New To Java
    Replies: 6
    Last Post: 04-28-2011, 01:15 PM
  2. Is there an alternative to OBEX?
    By danielpereira in forum Advanced Java
    Replies: 0
    Last Post: 10-17-2010, 11:36 PM
  3. Is EJB an alternative for JDBC?
    By makpandian in forum Enterprise JavaBeans (EJB)
    Replies: 4
    Last Post: 01-06-2010, 09:14 AM
  4. Any Alternative to Swing?
    By Niveditha in forum AWT / Swing
    Replies: 13
    Last Post: 06-27-2008, 09:39 AM
  5. propagation required in the transacctions of Spring
    By Heather in forum Web Frameworks
    Replies: 2
    Last Post: 07-03-2007, 09:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •