Results 1 to 4 of 4

Thread: Selecting Shape

  1. #1
    lifes46 is offline Member
    Join Date
    Mar 2011
    Posts
    4
    Rep Power
    0

    Default Selecting Shape

    Hi, I am currently working on select and moving shape, There are circle, rectangle and line. I am using same logic for rectangle and circle to select the shape using mouse point. I need help in how to select line shape. thanks.


    Java Code:
    if(XMLReader.name[i] ==  "circle"){  
       if((( mousePt.x < nodes.get(i).p.x + width))&&
          (mousePt.x>nodes.get(i).p.x) )
       {
            if((( mousePt.y < nodes.get(i).p.y + height))&& ( mousePt.y>nodes.get(i).p.y) ){
    		selectedD =i;
    		return true;								
    	}							
       }
    					}

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Quote Originally Posted by lifes46 View Post
    Hi, I am currently working on select and moving shape, There are circle, rectangle and line. I am using same logic for rectangle and circle to select the shape using mouse point. I need help in how to select line shape. thanks.
    You need to tell us specifically what help you need.


    Also, don't compare Strings like this:

    Java Code:
    if(XMLReader.name[i] ==  "circle"){

    Instead you'll want to use the equals or equalsIgnoreCase method:

    Java Code:
    if(XMLReader.name[i].equals("circle")){

    The problem is the first code compares if one String object is the same as another, and you really don't care if this is true or not. Instead you are interested in knowing if both Strings hold the same characters in the same order which is what the equals/equalsIgnoreCase check.
    Last edited by Fubarable; 05-05-2011 at 03:48 PM.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Also, you never replied to responses to your question in your other thread. Please correct this as doing this will encourage others to help you in the future.

  4. #4
    lifes46 is offline Member
    Join Date
    Mar 2011
    Posts
    4
    Rep Power
    0

    Default

    Solved the problem. I actually wanted to wanted to detect and select shape "line" so I can move it around the panel.


    Java Code:
    //for loop
    if(line.ptSegDistSq(mousePt)==0.0)
    {
       selectedD =i;
       return true;								
    }

Similar Threads

  1. Selecting a text
    By mathnitin in forum Advanced Java
    Replies: 12
    Last Post: 02-27-2011, 07:04 PM
  2. Selecting every other array
    By Rivy2112 in forum New To Java
    Replies: 10
    Last Post: 10-11-2010, 10:39 PM
  3. Update GUI when selecting language
    By ludberg in forum SWT / JFace
    Replies: 0
    Last Post: 06-04-2010, 05:39 PM
  4. Replies: 1
    Last Post: 04-02-2010, 12:48 PM
  5. selecting a record in database
    By ramachandran in forum New To Java
    Replies: 0
    Last Post: 10-25-2007, 07:06 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
  •