Results 1 to 4 of 4
  1. #1
    iamchoilan is offline Member
    Join Date
    Apr 2008
    Posts
    9
    Rep Power
    0

    Default Two problem for my rssi calculation program

    I have downloaded a program, which can calculate rssi signal on a grid sheet.

    1. I want to build a button, when I press the button, it pop up another window which show a graph on the data the program just calculated.

    Can this be done ?

    2. I want to insert a image to be the background of the grids, instead of that piece of white sheet, can this be done ?
    Attached Files Attached Files

  2. #2
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    Yes this can be done, have you ever used paintcomponent before.

  3. #3
    iamchoilan is offline Member
    Join Date
    Apr 2008
    Posts
    9
    Rep Power
    0

    Default

    Sorry I have not used this before, as I am new to java hope someone can solve my problem here...

    Q1. Here is where I want to plot graph.

    Java Code:
    jButton3.setBounds(new Rectangle(8, 5, 70, 22));
    		jButton3.setMargin(new Insets(0, 0, 0, 0));
    		jButton3.setText("Plot");
    		jButton3.addActionListener(new MainSim_jButton3_actionAdapter(this));
    I build a button here, but,

    Java Code:
    class MainSim_jButton3_actionAdapter
        implements ActionListener {
        
    }
    This class is still empty I do not know how to implement the plotting thing...


    Q2. Here is where I want to insert the image.

    Java Code:
    public void paint(Graphics g) {
            g.setColor(Color.white);
            g.fillRect(0, 0, getWidth(), getHeight());
    
    //Here it draw the white part.
    
            g.setColor(Color.gray);
            if (fpPoints != null && fpPoints.length > 0) {
                for (int i = 0; i < fpPoints.length; i++) {
                    g.drawLine(0, pix_grid * i, getWidth(), pix_grid * i);
                }
                for (int j = 0; j < fpPoints[0].length; j++) {
                    g.drawLine(pix_grid * j, 0, pix_grid * j, getHeight());
                }
            }
    
    //And here it draw the gray lines.
    
            super.paint(g);
            String p = "";
            Color cp = Color.black;
            java.util.Random r = new java.util.Random(10);
            if (highlight != null) {
                for (int i = 0; i < highlight.size(); i++) {
                    FpPoint fpp1 = (FpPoint) highlight.get(i);
                    if (!p.equalsIgnoreCase(fpp1.getFPRss())) {
                        //g.setColor(new Color((int)(Math.random()*2)*255, (int)(Math.random()*2)*255, (int)(Math.random()*2)*255));
                        g.setColor(new Color( (int) (r.nextFloat() * 2) * 255, (int) (r.nextFloat() * 2) * 255, (int) (r.nextFloat() * 2) * 255));
                        if (g.getColor().equals(Color.white)) {
                            g.setColor(Color.gray);
                        }
                        p = fpp1.getFPRss();
                    }
                    //g.fillOval(MainSim.m2pixel(fpp1.getPointYm()) - 4, MainSim.m2pixel(fpp1.getPointXm()) - 4, 8, 8);
                    g.fillOval(MainSim.m2pixel(fpp1.getPointYm()) - pix_grid / 2, MainSim.m2pixel(fpp1.getPointXm()) - pix_grid / 2, pix_grid, pix_grid);
                }
            }
    
            if ( apsdata != null ){
                for ( int i = 0 ; i < apsdata.size() ; i ++){
                    ApsData ad = (ApsData) apsdata.get(i);
                    g.setColor(Color.black);
                    g.fillRect(MainSim.m2pixel(ad.getXm()), MainSim.m2pixel(ad.getYm()), 26, 16);
                    g.setColor(Color.white);
                    g.drawString(String.valueOf(ad.getRssiAvg()), MainSim.m2pixel(ad.getXm())+3, MainSim.m2pixel(ad.getYm()) + 13);
                }
            }
        }

  4. #4
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    make an array of your plots and then just iterate through it and plot them as g.drawLine(xvalue of the first one, yValue of the first one, xValue of the next one, yValue of the second one). The hardest part of this is to figure out what the x and y's are.
    My IP address is 127.0.0.1

Similar Threads

  1. Problem with my first Struts program....please help me
    By sireesha in forum Web Frameworks
    Replies: 5
    Last Post: 10-16-2011, 04:19 PM
  2. Two problem for my rssi calculation program
    By iamchoilan in forum Java 2D
    Replies: 12
    Last Post: 04-27-2008, 07:56 PM
  3. Problem with Calculation ....
    By danny000 in forum New To Java
    Replies: 1
    Last Post: 04-15-2008, 02:42 PM
  4. Problem with my program HelloWorld
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-05-2007, 05:32 PM
  5. getting problem in compiling java program?
    By sathish04021984 in forum New To Java
    Replies: 3
    Last Post: 07-30-2007, 09:26 AM

Posting Permissions

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