Results 1 to 2 of 2

Thread: wykres JAVA

  1. #1
    Ripper is offline Member
    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    Default wykres JAVA

    Welcome

    I'm having trouble creating a plot "analysis of the cost of the temporary sort algorithm.
    (n * n-n) / 2 The script is created in NetBeans.

    Please help because I can not get through?

    code I have is (generate Bidirectional_Bubble_Sort, but no plot):

    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //import java.awt.geom.*
    
    public class Bidirectional_Bubble_Sort2
        {public static void main(String a[])
            {int i;
             int array[] = {12,45,54,53,8,909,33,9,4,99,120,1,3,10};
             System.out.println("Values Before the sort:\n");
             for(i = 0; i < array.length; i++)
             System.out.print( array[i]+"  ");
             System.out.println();
             bidirectionalBubble_srt(array, array.length);
             System.out.print("Values after the sort:\n");
             for(i = 0; i <array.length; i++)
             System.out.print(array[i]+"  ");
             System.out.println();
             System.out.println("PAUSE");
             Bidirectional_Bubble_Sort2 nowy = new Bidirectional_Bubble_Sort2();
    
    
            }
    
             public static void bidirectionalBubble_srt(int T[], int n)
                {int j;
                 int st = -1;
                 while (st <  n)
                    {st++;
                     n--;
                     for (j = st; j <  n; j++)
                        {if (T[j] > T[j + 1])
                            {int Element = T[j];
                             T[j] = T[j + 1];
                             T[j + 1] = Element;
                            }
                        }
                     for (j =  n; --j >= st;)
                        {if (T[j] > T[j + 1])
                            {int Element = T[j];
                             T[j] = T[j + 1];
                             T[j + 1] = Element;
                            }
                        }
                    }
                }
    //------------------------------------------------------------------------------
    
     public void actionPerformed(ActionEvent e)
        {System.out.println("Dzialam");
        }
     JFrame frame;
     JPanel wykres = new JPanel();
     JPanel panel = new JPanel();
     JPanel parametry = new JPanel();
    
     public Bidirectional_Bubble_Sort2()
        {frame = new JFrame("analiza kosztu czasowego");
         frame.setSize(610, 330);
         panel.setLayout(new BorderLayout());
         frame.getContentPane().add(panel);
         panel.add(parametry, BorderLayout.SOUTH);
    
         Panelik wykres = new Panelik();
         wykres.setBackground(Color.white);
         panel.add(wykres);
         frame.setVisible(true);
        }
    }
    
    class Panelik extends JPanel
        {Graphics d;
    
         public void paintComponent(Graphics g)
            {super.paintComponent(g);
    
             //układ wykresu
             g.setColor(Color.black);
             g.drawLine(580, 250, 20, 250); //oś Y
             g.drawLine(20, 20, 20, 250); //oś X
             g.drawLine(15, 30, 20, 20); //strzalka X
             g.drawLine(25, 30, 20, 20); //strzalka X
             g.drawLine(570, 255, 580, 250); //strzalka Y
             g.drawLine(570, 245, 580, 250); //strzalka Y
    
             Font font = new Font("Helvetica", 0, 11);
             g.setFont(font);
             g.drawString("x", 10, 20);
             g.drawString("y", 570, 265);
            
            }
         public void rysuj() {}
    }
    Last edited by Ripper; 11-28-2010 at 02:10 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,773
    Blog Entries
    7
    Rep Power
    21

    Default

    That was Polish; Google translated it to English on behalf of the OP:

    Quote Originally Posted by OP
    Welcome

    I'm having trouble creating a plot "analysis of the cost of the temporary sort algorithm.
    (N * n-n) / 2 The script is created in NetBeans.

    Please help because I can not get through?

    I already have a ready and efficient code:
    @OP: please post in English next time (Google has a couple of nice translators available online).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Posting Permissions

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