Hello,

I have a control that allows a child component to be expanded and hidden from 
view using an animated effect.  Think of opening and closing a drawer from your 
desk.

Anyway, the part of the software that creates the animation effect looks pretty 
much like this:
[code]
Rectangle bounds = [i]Bounds of component to be animated, initially collapsed 
(width = 0)[/i]
JComponent parent = [i]The parent of the animated component[/i]
Graphics2D g = (Graphics2D)parent.getGraphics().create();

while ( animating )
{
    long start = System.currentTimeMillis();
    g.fill( bounds );
    System.err.println( "fill " + bounds + ": " +
        ( System.currentTimeMillis() - start ) + " ms" );

    if ( expanding )
    {
        bounds.width = bounds.width + 15; /* Creates animating effect */
    }
    else /* for collapsing */
    {
        Rectangle prevBounds = new Rectangle( bounds );

        bounds.width = bounds.width - 15;

        Area bigArea = new Area( prevBounds );
        bigArea.subtract( new Area( bounds ) );

        start = System.currentTimeMillis();
        parent.paintImmediately( bigArea.getBounds() );
        System.err.println( "paintImmediately: " +
            ( System.currentTimeMillis() - start ) + " ms" );
    }
}
[/code]
After all this, the [i]animated[/i] component is added to the parent at 
[i]bounds[/i] if expanding or removed prior to this if collapsing.

My question relates to the performance of these operations.  On JavaSE 
1.5.0_08, the lines I have added that print the number of milliseconds taken in 
the calls to [i]fill[/i] and [i]paintImmediately[/i] produce the following 
output:
[pre]
fill java.awt.Rectangle[x=0,y=277,width=0,height=516]: 2 ms
fill java.awt.Rectangle[x=0,y=277,width=15,height=516]: 0 ms
fill java.awt.Rectangle[x=0,y=277,width=30,height=516]: 1 ms
fill java.awt.Rectangle[x=0,y=277,width=45,height=516]: 0 ms
... Now collapsing
paintImmediately: 4 ms
fill java.awt.Rectangle[x=0,y=277,width=442,height=516]: 0 ms
paintImmediately: 11 ms
fill java.awt.Rectangle[x=0,y=277,width=427,height=516]: 0 ms
paintImmediately: 2 ms
fill java.awt.Rectangle[x=0,y=277,width=412,height=516]: 1 ms
paintImmediately: 2 ms
[/pre]
And that looks pretty good!  However, running with 1.6.0 gives me this output:
[pre]
fill java.awt.Rectangle[x=0,y=277,width=0,height=516]: 2 ms
fill java.awt.Rectangle[x=0,y=277,width=15,height=516]: 19 ms
fill java.awt.Rectangle[x=0,y=277,width=30,height=516]: 20 ms
fill java.awt.Rectangle[x=0,y=277,width=45,height=516]: 20 ms
... Now collapsing
paintImmediately: 6 ms
fill java.awt.Rectangle[x=0,y=277,width=442,height=516]: 16 ms
paintImmediately: 3 ms
fill java.awt.Rectangle[x=0,y=277,width=427,height=516]: 24 ms
paintImmediately: 4 ms
fill java.awt.Rectangle[x=0,y=277,width=412,height=516]: 20 ms
paintImmediately: 4 ms
[/pre]
Which is clearly much slower, at least in the [i]fill[/i] operation.  So, what 
could be the reason for this?

My platform is a Blade 2500 (Silver) 2xSPARC IIIi, 4GB running Solaris 8_04.  
My (perhaps) relevant JVM flags are:
[pre]
-Xms1536m
-Xmx2048m
-Xconcurrentio
-XX:+UseConcMarkSweepGC
-d64
-Dawt.toolkit=sun.awt.X11.XToolkit
[/pre]

Any advice or suggestions would be greatly appreciated!

Thanks,
-Garrett Wampole
[Message sent by forum member 'gwampole' (gwampole)]

http://forums.java.net/jive/thread.jspa?messageID=195131

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to