#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Moving(translate) a g.fillPolygon()


    Ok, so I have limited coding experience and have only done basic stuff in VB

    So basically i convert my string to char then loop through each char if a char is S i want it to display my own poly.

    I think my problem is calling the method(?) to draw it. If i comment out the loop and just display the chars it works fine.

    ===========================================
    edit:
    I have figured it out, my poly was an invalid shape thus not displaying.

    now after drawing a poly how do i "translate" (move it) in my applet window?
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,714
    Rep Power
    348
    Can you explain what the problem is?

    If letter is a char[], then you can test one of its elements directly using the == operator:
    letter[i] == 'S'
    and not have to convert it to a String.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by NormR
    Can you explain what the problem is?

    If letter is a char[], then you can test one of its elements directly using the == operator:
    letter[i] == 'S'
    and not have to convert it to a String.
    The problem is that my polygon doesnt replace my "S" char.

    basically

    the user enters a word

    i then add the word to a char array

    i then use a loop to check each char in the array and display it exept when the char is "S" i want to display an "S" shaped poly using " fillPolygon(); ".

    all my code for this so far is good exept displaying my own "S" shaped fillPolygon(); instead of the single char "S"


    my code above takes each char and displays each one in a horizontal line exactly 20px away. my hope were that if my if statement sees and S it was draw my drawS polygon
  6. #4
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,714
    Rep Power
    348
    my polygon doesnt replace my "S" char.
    Do you want to clear the graphics area before each time you draw?
    Call the super.paint() method.

    Where does the code change the location of where the polygon will be drawn?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0
    Originally Posted by NormR
    Do you want to clear the graphics area before each time you draw?
    Call the super.paint() method.

    Where does the code change the location of where the polygon will be drawn?


    I have figured it out, my poly was an invalid shape thus not displaying.

    now after drawing a poly how do i "translate" (move it) in my applet window?
  10. #6
  11. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,714
    Rep Power
    348
    Change the x,y values that define its location.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0
    Originally Posted by javanewkid
    I have figured it out, my poly was an invalid shape thus not displaying.

    now after drawing a poly how do i "translate" (move it) in my applet window?
    Hey, how did you go about this issue?.. i have the same problem but for mine, i have drawn out the polygon, but instead of the letter being replaced, the polygon is drawn underneath the entered text.

IMN logo majestic logo threadwatch logo seochat tools logo