/[classpath]/classpath/javax/swing/JViewport.java
ViewVC logotype

Diff of /classpath/javax/swing/JViewport.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.31 by rabbit78, Mon Oct 17 13:45:34 2005 UTC revision 1.32 by abalkiss, Mon Oct 17 19:08:22 2005 UTC
# Line 566  public class JViewport extends JComponen Line 566  public class JViewport extends JComponen
566     */     */
567    public void scrollRectToVisible(Rectangle contentRect)    public void scrollRectToVisible(Rectangle contentRect)
568    {    {
569        Component view = getView();
570        if (view == null)
571          return;    
572          
573      Point pos = getViewPosition();      Point pos = getViewPosition();
574      Rectangle viewBounds = getView().getBounds();      Rectangle viewBounds = getView().getBounds();
575      Rectangle portBounds = getBounds();      Rectangle portBounds = getBounds();
576            
577      // FIXME: should validate the view if it is not valid, however      // FIXME: should validate the view if it is not valid, however
578      // this may cause excessive validation when the containment      // this may cause excessive validation when the containment
579      // hierarchy is being created.      // hierarchy is being created.    
580        
581        // Y-DIRECTION
582            
583      // if contentRect is larger than the portBounds, center the view      // if contentRect is larger than the portBounds, center the view
584      if (contentRect.height > portBounds.height ||      if (contentRect.height > portBounds.height)
585          contentRect.width > portBounds.width)        setViewPosition(new Point(pos.x, contentRect.y));
       {  
         setViewPosition(new Point(contentRect.x, contentRect.y));  
         return;  
       }  
586            
     // Y-DIRECTION  
587      if (contentRect.y < -viewBounds.y)      if (contentRect.y < -viewBounds.y)
588        setViewPosition(new Point(pos.x, contentRect.y));        setViewPosition(new Point(pos.x, contentRect.y));
589      else if (contentRect.y + contentRect.height >      else if (contentRect.y + contentRect.height >
590               -viewBounds.y + portBounds.height)               -viewBounds.y + portBounds.height)    
591        setViewPosition (new Point(pos.x, contentRect.y -        setViewPosition (new Point(pos.x, contentRect.y -
592                                   (portBounds.height - contentRect.height)));                                   (portBounds.height - contentRect.height)));
593            
594      // X-DIRECTION      // X-DIRECTION
595      pos = getViewPosition();      pos = getViewPosition();
596        
597        //  if contentRect is larger than the portBounds, center the view
598        if (contentRect.width> portBounds.width)
599            setViewPosition(new Point(contentRect.x, pos.y));
600    
601      if (contentRect.x < -viewBounds.x)      if (contentRect.x < -viewBounds.x)
602        setViewPosition(new Point(contentRect.x, pos.y));        setViewPosition(new Point(contentRect.x, pos.y));
603      else if (contentRect.x + contentRect.width >      else if (contentRect.x + contentRect.width >

Legend:
Removed from v.1.31  
changed lines
  Added in v.1.32

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26