src/share/classes/javax/swing/JViewport.java

Print this page




1569     //
1570     // NOTE: the code below uses paintForceDoubleBuffered for historical
1571     // reasons.  If we're going to allow a blit we've already accounted for
1572     // everything that paintImmediately and _paintImmediately does, for that
1573     // reason we call into paintForceDoubleBuffered to diregard whether or
1574     // not setDoubleBuffered(true) was invoked on the view.
1575     //
1576 
1577     private void blitDoubleBuffered(JComponent view, Graphics g,
1578                                     int clipX, int clipY, int clipW, int clipH,
1579                                     int blitFromX, int blitFromY, int blitToX, int blitToY,
1580                                     int blitW, int blitH) {
1581         // NOTE:
1582         //   blitFrom/blitTo are in JViewport coordinates system
1583         //     not the views coordinate space.
1584         //   clip* are in the views coordinate space.
1585         RepaintManager rm = RepaintManager.currentManager(this);
1586         int bdx = blitToX - blitFromX;
1587         int bdy = blitToY - blitFromY;
1588 

1589         // Shift the scrolled region





1590         rm.copyArea(this, g, blitFromX, blitFromY, blitW, blitH, bdx, bdy,
1591                     false);
1592 


1593         // Paint the newly exposed region.
1594         int x = view.getX();
1595         int y = view.getY();
1596         g.translate(x, y);
1597         g.setClip(clipX, clipY, clipW, clipH);
1598         view.paintForceDoubleBuffered(g);
1599         g.translate(-x, -y);
1600     }
1601 
1602     /**
1603      * Called to paint the view, usually when <code>blitPaint</code>
1604      * can not blit.
1605      *
1606      * @param g the <code>Graphics</code> context within which to paint
1607      */
1608     private void paintView(Graphics g) {
1609         Rectangle clip = g.getClipBounds();
1610         JComponent view = (JComponent)getView();
1611 
1612         if (view.getWidth() >= getWidth()) {




1569     //
1570     // NOTE: the code below uses paintForceDoubleBuffered for historical
1571     // reasons.  If we're going to allow a blit we've already accounted for
1572     // everything that paintImmediately and _paintImmediately does, for that
1573     // reason we call into paintForceDoubleBuffered to diregard whether or
1574     // not setDoubleBuffered(true) was invoked on the view.
1575     //
1576 
1577     private void blitDoubleBuffered(JComponent view, Graphics g,
1578                                     int clipX, int clipY, int clipW, int clipH,
1579                                     int blitFromX, int blitFromY, int blitToX, int blitToY,
1580                                     int blitW, int blitH) {
1581         // NOTE:
1582         //   blitFrom/blitTo are in JViewport coordinates system
1583         //     not the views coordinate space.
1584         //   clip* are in the views coordinate space.
1585         RepaintManager rm = RepaintManager.currentManager(this);
1586         int bdx = blitToX - blitFromX;
1587         int bdy = blitToY - blitFromY;
1588 
1589         Composite oldComposite = null;
1590         // Shift the scrolled region
1591         if (g instanceof Graphics2D) {
1592             Graphics2D g2d = (Graphics2D) g;
1593             oldComposite = g2d.getComposite();
1594             g2d.setComposite(AlphaComposite.Src);
1595         }
1596         rm.copyArea(this, g, blitFromX, blitFromY, blitW, blitH, bdx, bdy,
1597                     false);
1598         if (oldComposite != null) {
1599             ((Graphics2D) g).setComposite(oldComposite);
1600         }
1601         // Paint the newly exposed region.
1602         int x = view.getX();
1603         int y = view.getY();
1604         g.translate(x, y);
1605         g.setClip(clipX, clipY, clipW, clipH);
1606         view.paintForceDoubleBuffered(g);
1607         g.translate(-x, -y);
1608     }
1609 
1610     /**
1611      * Called to paint the view, usually when <code>blitPaint</code>
1612      * can not blit.
1613      *
1614      * @param g the <code>Graphics</code> context within which to paint
1615      */
1616     private void paintView(Graphics g) {
1617         Rectangle clip = g.getClipBounds();
1618         JComponent view = (JComponent)getView();
1619 
1620         if (view.getWidth() >= getWidth()) {