leif        2002/10/25 09:02:00

  Modified:    instrument-client/src/java/org/apache/excalibur/instrument/client
                        InstrumentClientFrame.java
  Log:
  Modify the tiling algorithm so that it attempts to maintain a useful aspect ratio
  for tiles frames.
  
  Revision  Changes    Path
  1.5       +39 -20    
jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/InstrumentClientFrame.java
  
  Index: InstrumentClientFrame.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/instrument-client/src/java/org/apache/excalibur/instrument/client/InstrumentClientFrame.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InstrumentClientFrame.java        17 Oct 2002 15:56:17 -0000      1.4
  +++ InstrumentClientFrame.java        25 Oct 2002 16:02:00 -0000      1.5
  @@ -710,22 +710,30 @@
           ArrayList openframes = getOpenFrames();
           
           int count = openframes.size();
  -        if( count == 0) return;
  +        if ( count == 0)
  +        {
  +            return;
  +        }
           
  -        // Determine the number of rows and columns
  -        int rows = (int) Math.sqrt( count );
  -        int cols = rows;
  +        // Tile the inner frames so that the individual frames will be shaped
  +        //  in a way which is optimized to show the charts that they contain.
  +        //  They should be wider than they are high.
  +        // Try to show all frames in a single column.  Add columns if the
  +        //  individual frame heights are less that 1/3 of their width.
           
  -        // Be sure to have enough grid positions
  -        if ( rows*cols < count )
  +        Dimension size = getDesktopPane().getSize();
  +        int rows = count;
  +        int cols = 1;
  +        int frameWidth = size.width / cols;
  +        int frameHeight = size.height / rows;
  +        while ( frameHeight < frameWidth / 3 )
           {
  -            rows++;
  -            if ( rows*cols < count )
  -            {
  -                cols++;
  -            }
  +            cols++;
  +            rows = (int)Math.ceil( (float)count / cols );
  +            frameWidth = size.width / cols;
  +            frameHeight = size.height / rows;
           }
  -
  +        
           reorganizeFrames( rows, cols, openframes );
       }
       
  @@ -740,7 +748,10 @@
           int count = frames.length;
           
           // No frames
  -        if (count == 0) return new ArrayList();
  +        if (count == 0) 
  +        {
  +            return new ArrayList();
  +        }
       
           // add only open frames to the list
           ArrayList openframes = new ArrayList();
  @@ -748,7 +759,9 @@
           {
               JInternalFrame f = frames[i];
               if( ( f.isClosed() == false ) && ( f.isIcon() == false ) )
  +            {
                   openframes.add( f );
  +            }
           }
           return openframes;
       }
  @@ -773,7 +786,7 @@
   
           for ( int i = 0; i < rows; ++i)
           {
  -            for ( int j = 0; j < cols && ( (i * cols ) + j < count ); ++j) 
  +            for ( int j = 0; j < cols && ( ( i * cols ) + j < count ); ++j ) 
               {
                   JInternalFrame f = (JInternalFrame) frames.get( ( i * cols ) + j );
                   m_desktopPane.getDesktopManager().resizeFrame( f, x, y, w, h );
  @@ -792,8 +805,11 @@
           ArrayList openframes=getOpenFrames();
           
           int count = openframes.size();
  -        if( count == 0) return; 
  -        reorganizeFrames( count,1,openframes );
  +        if ( count == 0 )
  +        {
  +            return;
  +        }
  +        reorganizeFrames( count, 1, openframes );
       }
       
       /**
  @@ -804,7 +820,10 @@
           ArrayList openframes = getOpenFrames();
           
           int count=openframes.size();
  -        if( count == 0) return;
  +        if ( count == 0)
  +        {
  +            return;
  +        }
           reorganizeFrames( 1, count, openframes );
       }
       
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>

Reply via email to