• Post Reply Bookmark Topic Watch Topic
  • New Topic

scrolling and zooming

 
Roger Ma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am programming a muti-agents system and meet following problems in scrolling the JPanel: I have a lots of objects (constructed by shapes or by some images) but some objects has negative coordinates, e.g., a line from (100,100) to (-100, -100); How can I scroll to see those with negative coord?
how should I zoom the pane (with respect to the center of pane) to see the objects in the system pane?
I have reviewed most items on this topic in the forum but seems no solution right now!
Thanks for help!
Roger
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roger,
What you need to do is keep up with the X and Y minima and adjust the coordinates of your shapes with those offsets in order to shift them into the viewport. For example, if your minimum X coordinate is -134 and your minimum Y coordinate is -246 then you should add 134 and 246 respectively to the X and Y coordinates for all Points that you want to be viewable. You will actually have to add a little more to compensate for the title bar, etc.
Michael Morris
 
Roger Ma
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,
In fact, I use the offset to scroll the whole area. But when drawing shapes, I can see the negative coord by tracking mouse. So I wonder if it is possible to scroll to negative coord of the jpanel directly.
concerning the title, I should agree with you but i will post more later. anyways, thanks for replying.
Roger
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!