Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Non opaque component painting bug



Am 31.05.2006 um 00:37 schrieb Scott Palmer:


On 30-May-06, at 6:20 PM, Florijan Stamenkovic wrote:

...
Somehow at some point of repainting the top corner position is painted by something that never, at any size comes to that position. Layout manager mess was my first thought, but I tried with BorderLayout as well. It however appears regardless of which layout manager is used. And seems to occur at a point when there is *much* for Swing to do, i.e. recalculating and resizing many containers.


Any thoughts?

Note that the circle that appears in the top corner looks like that of the custom component beside the "Hardware Sample Rate" label. My guess is that something is messing with the transform on the graphics object and not restoring it properly. The Swiong rendering pipeline might call your paint method with the origin translated to where your component is... imagine if you reset it to (0,0) when you were done, when really you should have reset it to the previously saved state.
My guess would be that custom component. The graphics origin could depend on dirty regions or what component asks to repaint etc. Perhaps most of the time the Graphics context passed to the component is normalized to that components rectangle?



Scott

here's the paint code for the jog dial which gets placed on the top left corner (yes, it belongs to "hardware sample rate"). you can see : i do call super.paintComponent, i do reset the affine transform! i use a regular JFrame, i do not modify the content pane, hence i should have a regular opaque top level container .


public void paintComponent( Graphics g )
{
super.paintComponent( g );

final Graphics2D g2 = (Graphics2D) g;
final Stroke strkOrig = g2.getStroke();
final AffineTransform atOrig = g2.getTransform();

g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );


g2.translate( 0.5f + in.left, 0.5f + in.top ); // tricky disco to blur the outlines 'bit more

		if( isEnabled() ) {
			g2.setPaint( pntBack );
			g2.fillOval( 2, 3, 16, 16 );
			g2.setColor( colrLight );
			g2.fillOval( 5, 1, 9, 10 );
	//		g2.setColor( colrArcShadow );
			g2.setPaint( pntArcShadow );
			g2.setStroke( strkArcShadow );
			g2.drawOval( 1, 1, 17, 17 );
	//		g2.drawArc( 1, 1, 17, 17, 0, 180 );

			g2.setStroke( strkArcLight );
			g2.setColor( colrArcLight );
			g2.drawArc( 1, 2, 17, 17, 180, 180 );

g2.setColor( colrOutline );
g2.setStroke( strkOutline );
g2.drawOval( 1, 1, 17, 17 );

g2.translate( bellyPos.getX() * 4 + 10.0, -bellyPos.getY() * 4.5 + 10.0 );
g2.setPaint( pntBelly );
g2.fill( shpBelly );

} else {
g2.setPaint( pntBackD );
g2.fillOval( 2, 3, 16, 16 );
g2.setColor( colrLightD );
g2.fillOval( 5, 1, 9, 10 );
g2.setPaint( pntArcShadowD );
g2.setStroke( strkArcShadow );
g2.drawOval( 1, 1, 17, 17 );


			g2.setStroke( strkArcLight );
			g2.setColor( colrArcLightD );
			g2.drawArc( 1, 2, 17, 17, 180, 180 );

g2.setColor( colrOutlineD );
g2.setStroke( strkOutline );
g2.drawOval( 1, 1, 17, 17 );

g2.translate( bellyPos.getX() * 4 + 10.0, -bellyPos.getY() * 4.5 + 10.0 );
g2.setPaint( pntBellyD );
g2.fill( shpBelly );
}

g2.setStroke( strkOrig );
g2.setTransform( atOrig );
}



_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Non opaque component painting bug (From: Greg Guerin <email@hidden>)
 >Re: Non opaque component painting bug (From: Scott Palmer <email@hidden>)
 >Re: Non opaque component painting bug (From: Florijan Stamenkovic <email@hidden>)
 >Re: Non opaque component painting bug (From: Scott Palmer <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.