|
Hello,
I have a JPanel which paints an image, the image
size is typically 256x256 or 512x512.
To the JPanel I have added some small (e.g. 32x32)
widgets which are also JPanels. These appear close to the borders of the main
JPanel and are superimposed over the main image. They provide pan, zoom
functionality, etc so the user can drag on the widgets to pan and zoom the main
image (which is 'under' the widgets).
When the mouse enters one of the widgets, its color
changes to indicate that it is active.
This triggers the paintComponent( ) for both the
widget's own JPanel and the main image's JPanel.
In the paintComponent( ) for the main image JPanel,
I want to save the AffineTransform ONLY IF THE REPAINT IS FOR THE IMAGE AND NOT
FOR THE WIDGET. (Even though I do the same calls to set the AffineTransform for
Graphics inside the main image's paintComponent( ), the result is slightly
different when triggered by a widget, than when triggered by the main panel
itself, i.e. when calling g2.getTransform( ) the result is slightly
different.)
Inside the main image's paintComponent( ) I can
examine the dimensions of the getClipBounds( ) and make a pretty good guess as
to what triggered the repaint. But because the image itself can be panned and
zoomed, often the clip rect for the whole image is about the size of a
widget.
Is there some other test that I could perform
inside paintComponent( ) to find out if the painting is due to one of the
widgets as opposed to the image panel itself?
Thank you,
Ted Hill
|
- [JAVA2D] paintComponent( ) question Ted Hill
- [JAVA2D] paintComponent( ) question Ted Hill
