• Post Reply Bookmark Topic Watch Topic
  • New Topic

Swing repainting with non-identity transform

 
dan moore
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,
i have an application that overrides paintComponent() to draw some graphics (a map of roads) on a JPanel. the painting is done by a "ViewManager" object, that also implements zooming and panning by using the Graphics2D transform.
this all works fine... usually. however, when the panel is partially obscured (e.g. by a drop-down menu), it corrupts when redrawn - seemingly when it gets a paint message that has a clipping rectangle that does not touch the top-left of the panel.
has anyone seen this? (better yet, tell us why + how to fix it)
below is the ViewManager code called from the panel's paintComponent() method ("viewTransform" holds the current zoom/pan transform) and a snippet of the debug it produces for the dodgy paints.
thanks in advance for any help.
cheers, dan.

[This message has been edited by Nathan Pruett (edited November 05, 2001).]
 
dan moore
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
apologies for poor code formatting, will try harder next time...
 
dan moore
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, found answer on Sun site forums.
my mistake was using

when this transform should be applied to the current graphics transform using

my understanding is that although the two forms end up with identical and correct transforms being current on the graphics context, only the second form provokes correct updating of other Graphics2D instance information (definitely including clipping region).
i don't normally talk to myself, so this is doubly strange...
cheers, dan.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!