Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting points. Help!

Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I have is a group of images stored in a jar file that I load into ImageIcons that get placed into a scroll pane that gets put into a label that gets put into a tabbed pane. The ImageIcon can be zoomed in and out
Before I put the "resetPoint" (my home grown method) call in, when I click on the image (which is centered) to drop my begin and end points, the line that gets drawn is off one way or the other in both the X and Y directions. If I click in the very upper left hand corner of the scroll pane and draw a line from there, then it will ALWAYS (no matter if the image is zoomed, etc.) get drawn on the image in its upper left hand corner.
I've tried everything I can think of but the points I use for drawing a line on an image don't match up to what they should. It was suggested that I try using convertPoint but unless I'm using it incorrectly (and I tried every way that seemed to make sense) this doesn't do any good. In fact, the point never gets any conversion at all (what ever comes in, goes out).
Note that the code (restPoint) does work in the X position if the image isn't zoomed in or out (the Y position is shifted up slightly). If the image is shrunk, then the Y position is still high, but the X position is is wrong in that it is both shifted to the left and the line is too short (the end point is too far left when drawing from left to right). If the image is enlarged, then the Y is too far down, and the line is too big with the left to far left, and the right too far right but NOT in proportion!
If anyone knows what I need to do to adjust the points please tell me. The logic I am using SEEMS right to me (scrollpane size / 2 - image size / 2 to get the start of where the image should be)
Here is the relevant code:

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic