< prev index next >

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

Print this page

        

*** 44,75 **** * information. When you scroll, what moves is the viewport. It is like * peering through a camera's viewfinder. Moving the viewfinder upwards * brings new things into view at the top of the picture and loses * things that were at the bottom. * <p> ! * By default, <code>JViewport</code> is opaque. To change this, use the ! * <code>setOpaque</code> method. * <p> * <b>NOTE:</b>We have implemented a faster scrolling algorithm that * does not require a buffer to draw in. The algorithm works as follows: * <ol><li>The view and parent view and checked to see if they are ! * <code>JComponents</code>, * if they aren't, stop and repaint the whole viewport. * <li>If the viewport is obscured by an ancestor, stop and repaint the whole * viewport. * <li>Compute the region that will become visible, if it is as big as * the viewport, stop and repaint the whole view region. ! * <li>Obtain the ancestor <code>Window</code>'s graphics and ! * do a <code>copyArea</code> on the scrolled region. * <li>Message the view to repaint the newly visible region. * <li>The next time paint is invoked on the viewport, if the clip region * is smaller than the viewport size a timer is kicked off to repaint the * whole region. * </ol> * In general this approach is much faster. Compared to the backing store * approach this avoids the overhead of maintaining an offscreen buffer and ! * having to do two <code>copyArea</code>s. * Compared to the non backing store case this * approach will greatly reduce the painted region. * <p> * This approach can cause slower times than the backing store approach * when the viewport is obscured by another window, or partially offscreen. --- 44,75 ---- * information. When you scroll, what moves is the viewport. It is like * peering through a camera's viewfinder. Moving the viewfinder upwards * brings new things into view at the top of the picture and loses * things that were at the bottom. * <p> ! * By default, {@code JViewport} is opaque. To change this, use the ! * {@code setOpaque} method. * <p> * <b>NOTE:</b>We have implemented a faster scrolling algorithm that * does not require a buffer to draw in. The algorithm works as follows: * <ol><li>The view and parent view and checked to see if they are ! * {@code JComponents}, * if they aren't, stop and repaint the whole viewport. * <li>If the viewport is obscured by an ancestor, stop and repaint the whole * viewport. * <li>Compute the region that will become visible, if it is as big as * the viewport, stop and repaint the whole view region. ! * <li>Obtain the ancestor {@code Window}'s graphics and ! * do a {@code copyArea} on the scrolled region. * <li>Message the view to repaint the newly visible region. * <li>The next time paint is invoked on the viewport, if the clip region * is smaller than the viewport size a timer is kicked off to repaint the * whole region. * </ol> * In general this approach is much faster. Compared to the backing store * approach this avoids the overhead of maintaining an offscreen buffer and ! * having to do two {@code copyArea}s. * Compared to the non backing store case this * approach will greatly reduce the painted region. * <p> * This approach can cause slower times than the backing store approach * when the viewport is obscured by another window, or partially offscreen.
*** 91,101 **** * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @author Hans Muller * @author Philip Milne * @see JScrollPane --- 91,101 ---- * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. * * @author Hans Muller * @author Philip Milne * @see JScrollPane
*** 119,138 **** * The default is false. */ protected boolean isViewSizeSet = false; /** ! * The last <code>viewPosition</code> that we've painted, so we know how * much of the backing store image is valid. */ protected Point lastPaintPosition = null; /** * True when this viewport is maintaining an offscreen image of its * contents, so that some scrolling can take place using fast "bit-blit" * operations instead of by accessing the view object to construct the ! * display. The default is <code>false</code>. * * @deprecated As of Java 2 platform v1.3 * @see #setScrollMode */ @Deprecated --- 119,138 ---- * The default is false. */ protected boolean isViewSizeSet = false; /** ! * The last {@code viewPosition} that we've painted, so we know how * much of the backing store image is valid. */ protected Point lastPaintPosition = null; /** * True when this viewport is maintaining an offscreen image of its * contents, so that some scrolling can take place using fast "bit-blit" * operations instead of by accessing the view object to construct the ! * display. The default is {@code false}. * * @deprecated As of Java 2 platform v1.3 * @see #setScrollMode */ @Deprecated
*** 140,190 **** /** The view image used for a backing store. */ protected transient Image backingStoreImage = null; /** ! * The <code>scrollUnderway</code> flag is used for components like ! * <code>JList</code>. When the downarrow key is pressed on a ! * <code>JList</code> and the selected ! * cell is the last in the list, the <code>scrollpane</code> autoscrolls. * Here, the old selected cell needs repainting and so we need * a flag to make the viewport do the optimized painting * only when there is an explicit call to ! * <code>setViewPosition(Point)</code>. ! * When <code>setBounds</code> is called through other routes, * the flag is off and the view repaints normally. Another approach ! * would be to remove this from the <code>JViewport</code> ! * class and have the <code>JList</code> manage this case by using ! * <code>setBackingStoreEnabled</code>. The default is ! * <code>false</code>. */ protected boolean scrollUnderway = false; /* * Listener that is notified each time the view changes size. */ private ComponentListener viewListener = null; ! /* Only one <code>ChangeEvent</code> is needed per ! * <code>JViewport</code> instance since the * event's only (read-only) state is the source property. The source * of events generated here is always "this". */ private transient ChangeEvent changeEvent = null; /** ! * Use <code>graphics.copyArea</code> to implement scrolling. * This is the fastest for most applications. * * @see #setScrollMode * @since 1.3 */ public static final int BLIT_SCROLL_MODE = 1; /** * Draws viewport contents into an offscreen image. ! * This was previously the default mode for <code>JTable</code>. * This mode may offer advantages over "blit mode" * in some cases, but it requires a large chunk of extra RAM. * * @see #setScrollMode * @since 1.3 --- 140,190 ---- /** The view image used for a backing store. */ protected transient Image backingStoreImage = null; /** ! * The {@code scrollUnderway} flag is used for components like ! * {@code JList}. When the downarrow key is pressed on a ! * {@code JList} and the selected ! * cell is the last in the list, the {@code scrollpane} autoscrolls. * Here, the old selected cell needs repainting and so we need * a flag to make the viewport do the optimized painting * only when there is an explicit call to ! * {@code setViewPosition(Point)}. ! * When {@code setBounds} is called through other routes, * the flag is off and the view repaints normally. Another approach ! * would be to remove this from the {@code JViewport} ! * class and have the {@code JList} manage this case by using ! * {@code setBackingStoreEnabled}. The default is ! * {@code false}. */ protected boolean scrollUnderway = false; /* * Listener that is notified each time the view changes size. */ private ComponentListener viewListener = null; ! /* Only one {@code ChangeEvent} is needed per ! * {@code JViewport} instance since the * event's only (read-only) state is the source property. The source * of events generated here is always "this". */ private transient ChangeEvent changeEvent = null; /** ! * Use {@code graphics.copyArea} to implement scrolling. * This is the fastest for most applications. * * @see #setScrollMode * @since 1.3 */ public static final int BLIT_SCROLL_MODE = 1; /** * Draws viewport contents into an offscreen image. ! * This was previously the default mode for {@code JTable}. * This mode may offer advantages over "blit mode" * in some cases, but it requires a large chunk of extra RAM. * * @see #setScrollMode * @since 1.3
*** 233,258 **** // A Timer is used instead of just a repaint as it appeared to offer // better performance. /** ! * This is set to true in <code>setViewPosition</code> * if doing a window blit and the viewport is obscured. */ private transient boolean repaintAll; /** ! * This is set to true in paint, if <code>repaintAll</code> * is true and the clip rectangle does not match the bounds. * If true, and scrolling happens the * repaint manager is not cleared which then allows for the repaint * previously invoked to succeed. */ private transient boolean waitingForRepaint; /** ! * Instead of directly invoking repaint, a <code>Timer</code> * is started and when it fires, repaint is invoked. */ private transient Timer repaintTimer; /** --- 233,258 ---- // A Timer is used instead of just a repaint as it appeared to offer // better performance. /** ! * This is set to true in {@code setViewPosition} * if doing a window blit and the viewport is obscured. */ private transient boolean repaintAll; /** ! * This is set to true in paint, if {@code repaintAll} * is true and the clip rectangle does not match the bounds. * If true, and scrolling happens the * repaint manager is not cleared which then allows for the repaint * previously invoked to succeed. */ private transient boolean waitingForRepaint; /** ! * Instead of directly invoking repaint, a {@code Timer} * is started and when it fires, repaint is invoked. */ private transient Timer repaintTimer; /**
*** 271,281 **** * This flag allows to invoke that method while ScrollPaneLayout#layoutContainer * is running. */ private boolean viewChanged; ! /** Creates a <code>JViewport</code>. */ public JViewport() { super(); setLayout(createLayoutManager()); setOpaque(true); updateUI(); --- 271,281 ---- * This flag allows to invoke that method while ScrollPaneLayout#layoutContainer * is running. */ private boolean viewChanged; ! /** Creates a {@code JViewport}. */ public JViewport() { super(); setLayout(createLayoutManager()); setOpaque(true); updateUI();
*** 285,306 **** /** * Returns the L&amp;F object that renders this component. * ! * @return a <code>ViewportUI</code> object * @since 1.3 */ public ViewportUI getUI() { return (ViewportUI)ui; } /** * Sets the L&amp;F object that renders this component. * ! * @param ui the <code>ViewportUI</code> L&amp;F object * @see UIDefaults#getUI * @beaninfo * bound: true * hidden: true * attribute: visualUpdate true --- 285,306 ---- /** * Returns the L&amp;F object that renders this component. * ! * @return a {@code ViewportUI} object * @since 1.3 */ public ViewportUI getUI() { return (ViewportUI)ui; } /** * Sets the L&amp;F object that renders this component. * ! * @param ui the {@code ViewportUI} L&amp;F object * @see UIDefaults#getUI * @beaninfo * bound: true * hidden: true * attribute: visualUpdate true
*** 335,387 **** return uiClassID; } /** ! * Sets the <code>JViewport</code>'s one lightweight child, ! * which can be <code>null</code>. * (Since there is only one child which occupies the entire viewport, ! * the <code>constraints</code> and <code>index</code> * arguments are ignored.) * ! * @param child the lightweight <code>child</code> of the viewport ! * @param constraints the <code>constraints</code> to be respected * @param index the index * @see #setView */ protected void addImpl(Component child, Object constraints, int index) { setView(child); } /** ! * Removes the <code>Viewport</code>s one lightweight child. * * @see #setView */ public void remove(Component child) { child.removeComponentListener(viewListener); super.remove(child); } /** ! * Scrolls the view so that <code>Rectangle</code> * within the view becomes visible. * <p> * This attempts to validate the view before scrolling if the ! * view is currently not valid - <code>isValid</code> returns false. * To avoid excessive validation when the containment hierarchy is * being created this will not validate if one of the ancestors does not * have a peer, or there is no validate root ancestor, or one of the ! * ancestors is not a <code>Window</code> or <code>Applet</code>. * <p> * Note that this method will not scroll outside of the ! * valid viewport; for example, if <code>contentRect</code> is larger * than the viewport, scrolling will be confined to the viewport's * bounds. * ! * @param contentRect the <code>Rectangle</code> to display * @see JComponent#isValidateRoot * @see java.awt.Component#isValid */ public void scrollRectToVisible(Rectangle contentRect) { Component view = getView(); --- 335,387 ---- return uiClassID; } /** ! * Sets the {@code JViewport}'s one lightweight child, ! * which can be {@code null}. * (Since there is only one child which occupies the entire viewport, ! * the {@code constraints} and {@code index} * arguments are ignored.) * ! * @param child the lightweight {@code child} of the viewport ! * @param constraints the {@code constraints} to be respected * @param index the index * @see #setView */ protected void addImpl(Component child, Object constraints, int index) { setView(child); } /** ! * Removes the {@code Viewport}s one lightweight child. * * @see #setView */ public void remove(Component child) { child.removeComponentListener(viewListener); super.remove(child); } /** ! * Scrolls the view so that {@code Rectangle} * within the view becomes visible. * <p> * This attempts to validate the view before scrolling if the ! * view is currently not valid - {@code isValid} returns false. * To avoid excessive validation when the containment hierarchy is * being created this will not validate if one of the ancestors does not * have a peer, or there is no validate root ancestor, or one of the ! * ancestors is not a {@code Window} or {@code Applet}. * <p> * Note that this method will not scroll outside of the ! * valid viewport; for example, if {@code contentRect} is larger * than the viewport, scrolling will be confined to the viewport's * bounds. * ! * @param contentRect the {@code Rectangle} to display * @see JComponent#isValidateRoot * @see java.awt.Component#isValid */ public void scrollRectToVisible(Rectangle contentRect) { Component view = getView();
*** 463,480 **** } } } /** ! * Ascends the <code>Viewport</code>'s parents stopping when * a component is found that returns ! * <code>true</code> to <code>isValidateRoot</code>. ! * If all the <code>Component</code>'s parents are visible, ! * <code>validate</code> will then be invoked on it. The ! * <code>RepaintManager</code> is then invoked with ! * <code>removeInvalidComponent</code>. This ! * is the synchronous version of a <code>revalidate</code>. */ private void validateView() { Component validateRoot = SwingUtilities.getValidateRoot(this, false); if (validateRoot == null) { --- 463,480 ---- } } } /** ! * Ascends the {@code Viewport}'s parents stopping when * a component is found that returns ! * {@code true} to {@code isValidateRoot}. ! * If all the {@code Component}'s parents are visible, ! * {@code validate} will then be invoked on it. The ! * {@code RepaintManager} is then invoked with ! * {@code removeInvalidComponent}. This ! * is the synchronous version of a {@code revalidate}. */ private void validateView() { Component validateRoot = SwingUtilities.getValidateRoot(this, false); if (validateRoot == null) {
*** 547,566 **** /** * The viewport "scrolls" its child (called the "view") by the * normal parent/child clipping (typically the view is moved in ! * the opposite direction of the scroll). A non-<code>null</code> border, * or non-zero insets, isn't supported, to prevent the geometry * of this component from becoming complex enough to inhibit ! * subclassing. To create a <code>JViewport</code> with a border, ! * add it to a <code>JPanel</code> that has a border. ! * <p>Note: If <code>border</code> is non-<code>null</code>, this * method will throw an exception as borders are not supported on ! * a <code>JViewPort</code>. * ! * @param border the <code>Border</code> to set * @exception IllegalArgumentException this method is not implemented */ public final void setBorder(Border border) { if (border != null) { throw new IllegalArgumentException("JViewport.setBorder() not supported"); --- 547,566 ---- /** * The viewport "scrolls" its child (called the "view") by the * normal parent/child clipping (typically the view is moved in ! * the opposite direction of the scroll). A non-{@code null} border, * or non-zero insets, isn't supported, to prevent the geometry * of this component from becoming complex enough to inhibit ! * subclassing. To create a {@code JViewport} with a border, ! * add it to a {@code JPanel} that has a border. ! * <p>Note: If {@code border} is non-{@code null}, this * method will throw an exception as borders are not supported on ! * a {@code JViewPort}. * ! * @param border the {@code Border} to set * @exception IllegalArgumentException this method is not implemented */ public final void setBorder(Border border) { if (border != null) { throw new IllegalArgumentException("JViewport.setBorder() not supported");
*** 568,593 **** } /** * Returns the insets (border) dimensions as (0,0,0,0), since borders ! * are not supported on a <code>JViewport</code>. * ! * @return a <code>Rectangle</code> of zero dimension and zero origin * @see #setBorder */ public final Insets getInsets() { return new Insets(0, 0, 0, 0); } /** ! * Returns an <code>Insets</code> object containing this ! * <code>JViewport</code>s inset values. The passed-in ! * <code>Insets</code> object will be reinitialized, and * all existing values within this object are overwritten. * ! * @param insets the <code>Insets</code> object which can be reused * @return this viewports inset values * @see #getInsets * @beaninfo * expert: true */ --- 568,593 ---- } /** * Returns the insets (border) dimensions as (0,0,0,0), since borders ! * are not supported on a {@code JViewport}. * ! * @return a {@code Rectangle} of zero dimension and zero origin * @see #setBorder */ public final Insets getInsets() { return new Insets(0, 0, 0, 0); } /** ! * Returns an {@code Insets} object containing this ! * {@code JViewport}s inset values. The passed-in ! * {@code Insets} object will be reinitialized, and * all existing values within this object are overwritten. * ! * @param insets the {@code Insets} object which can be reused * @return this viewports inset values * @see #getInsets * @beaninfo * expert: true */
*** 626,641 **** bsg.dispose(); } } /** ! * The <code>JViewport</code> overrides the default implementation of ! * this method (in <code>JComponent</code>) to return false. * This ensures ! * that the drawing machinery will call the <code>Viewport</code>'s ! * <code>paint</code> ! * implementation rather than messaging the <code>JViewport</code>'s * children directly. * * @return false */ public boolean isOptimizedDrawingEnabled() { --- 626,641 ---- bsg.dispose(); } } /** ! * The {@code JViewport} overrides the default implementation of ! * this method (in {@code JComponent}) to return false. * This ensures ! * that the drawing machinery will call the {@code Viewport}'s ! * {@code paint} ! * implementation rather than messaging the {@code JViewport}'s * children directly. * * @return false */ public boolean isOptimizedDrawingEnabled() {
*** 667,687 **** return new Point(0,0); } } /** ! * Depending on whether the <code>backingStore</code> is enabled, * either paint the image through the backing store or paint * just the recently exposed part, using the backing store * to "blit" the remainder. * <blockquote> * The term "blit" is the pronounced version of the PDP-10 * BLT (BLock Transfer) instruction, which copied a block of * bits. (In case you were curious.) * </blockquote> * ! * @param g the <code>Graphics</code> context within which to paint */ public void paint(Graphics g) { int width = getWidth(); int height = getHeight(); --- 667,687 ---- return new Point(0,0); } } /** ! * Depending on whether the {@code backingStore} is enabled, * either paint the image through the backing store or paint * just the recently exposed part, using the backing store * to "blit" the remainder. * <blockquote> * The term "blit" is the pronounced version of the PDP-10 * BLT (BLock Transfer) instruction, which copied a block of * bits. (In case you were curious.) * </blockquote> * ! * @param g the {@code Graphics} context within which to paint */ public void paint(Graphics g) { int width = getWidth(); int height = getHeight();
*** 819,829 **** } /** * Sets the bounds of this viewport. If the viewport's width ! * or height has changed, fire a <code>StateChanged</code> event. * * @param x left edge of the origin * @param y top edge of the origin * @param w width in pixels * @param h height in pixels --- 819,829 ---- } /** * Sets the bounds of this viewport. If the viewport's width ! * or height has changed, fire a {@code StateChanged} event. * * @param x left edge of the origin * @param y top edge of the origin * @param w width in pixels * @param h height in pixels
*** 876,920 **** } /** * Returns the current scrolling mode. * ! * @return the <code>scrollMode</code> property * @see #setScrollMode * @since 1.3 */ public int getScrollMode() { return scrollMode; } /** ! * Returns <code>true</code> if this viewport is maintaining * an offscreen image of its contents. * ! * @return <code>true</code> if <code>scrollMode</code> is ! * <code>BACKINGSTORE_SCROLL_MODE</code> * * @deprecated As of Java 2 platform v1.3, replaced by ! * <code>getScrollMode()</code>. */ @Deprecated public boolean isBackingStoreEnabled() { return scrollMode == BACKINGSTORE_SCROLL_MODE; } /** * If true if this viewport will maintain an offscreen * image of its contents. The image is used to reduce the cost ! * of small one dimensional changes to the <code>viewPosition</code>. * Rather than repainting the entire viewport we use ! * <code>Graphics.copyArea</code> to effect some of the scroll. * * @param enabled if true, maintain an offscreen backing store * * @deprecated As of Java 2 platform v1.3, replaced by ! * <code>setScrollMode()</code>. */ @Deprecated public void setBackingStoreEnabled(boolean enabled) { if (enabled) { setScrollMode(BACKINGSTORE_SCROLL_MODE); --- 876,920 ---- } /** * Returns the current scrolling mode. * ! * @return the {@code scrollMode} property * @see #setScrollMode * @since 1.3 */ public int getScrollMode() { return scrollMode; } /** ! * Returns {@code true} if this viewport is maintaining * an offscreen image of its contents. * ! * @return {@code true} if {@code scrollMode} is ! * {@code BACKINGSTORE_SCROLL_MODE} * * @deprecated As of Java 2 platform v1.3, replaced by ! * {@code getScrollMode()}. */ @Deprecated public boolean isBackingStoreEnabled() { return scrollMode == BACKINGSTORE_SCROLL_MODE; } /** * If true if this viewport will maintain an offscreen * image of its contents. The image is used to reduce the cost ! * of small one dimensional changes to the {@code viewPosition}. * Rather than repainting the entire viewport we use ! * {@code Graphics.copyArea} to effect some of the scroll. * * @param enabled if true, maintain an offscreen backing store * * @deprecated As of Java 2 platform v1.3, replaced by ! * {@code setScrollMode()}. */ @Deprecated public void setBackingStoreEnabled(boolean enabled) { if (enabled) { setScrollMode(BACKINGSTORE_SCROLL_MODE);
*** 929,951 **** (view instanceof JComponent) && view.isOpaque(); } /** ! * Returns the <code>JViewport</code>'s one child or <code>null</code>. * ! * @return the viewports child, or <code>null</code> if none exists * * @see #setView */ public Component getView() { return (getComponentCount() > 0) ? getComponent(0) : null; } /** ! * Sets the <code>JViewport</code>'s one lightweight child ! * (<code>view</code>), which can be <code>null</code>. * * @param view the viewport's new lightweight child * * @see #getView */ --- 929,951 ---- (view instanceof JComponent) && view.isOpaque(); } /** ! * Returns the {@code JViewport}'s one child or {@code null}. * ! * @return the viewports child, or {@code null} if none exists * * @see #setView */ public Component getView() { return (getComponentCount() > 0) ? getComponent(0) : null; } /** ! * Sets the {@code JViewport}'s one lightweight child ! * ({@code view}), which can be {@code null}. * * @param view the viewport's new lightweight child * * @see #getView */
*** 986,996 **** /** * If the view's size hasn't been explicitly set, return the * preferred size, otherwise return the view's current size. * If there is no view, return 0,0. * ! * @return a <code>Dimension</code> object specifying the size of the view */ public Dimension getViewSize() { Component view = getView(); if (view == null) { --- 986,996 ---- /** * If the view's size hasn't been explicitly set, return the * preferred size, otherwise return the view's current size. * If there is no view, return 0,0. * ! * @return a {@code Dimension} object specifying the size of the view */ public Dimension getViewSize() { Component view = getView(); if (view == null) {
*** 1006,1016 **** /** * Sets the size of the view. A state changed event will be fired. * ! * @param newSize a <code>Dimension</code> object specifying the new * size of the view */ public void setViewSize(Dimension newSize) { Component view = getView(); if (view != null) { --- 1006,1016 ---- /** * Sets the size of the view. A state changed event will be fired. * ! * @param newSize a {@code Dimension} object specifying the new * size of the view */ public void setViewSize(Dimension newSize) { Component view = getView(); if (view != null) {
*** 1029,1039 **** /** * Returns the view coordinates that appear in the upper left * hand corner of the viewport, or 0,0 if there's no view. * ! * @return a <code>Point</code> object giving the upper left coordinates */ public Point getViewPosition() { Component view = getView(); if (view != null) { Point p = view.getLocation(); --- 1029,1039 ---- /** * Returns the view coordinates that appear in the upper left * hand corner of the viewport, or 0,0 if there's no view. * ! * @return a {@code Point} object giving the upper left coordinates */ public Point getViewPosition() { Component view = getView(); if (view != null) { Point p = view.getLocation();
*** 1049,1059 **** /** * Sets the view coordinates that appear in the upper left * hand corner of the viewport, does nothing if there's no view. * ! * @param p a <code>Point</code> object giving the upper left coordinates */ public void setViewPosition(Point p) { Component view = getView(); if (view == null) { --- 1049,1059 ---- /** * Sets the view coordinates that appear in the upper left * hand corner of the viewport, does nothing if there's no view. * ! * @param p a {@code Point} object giving the upper left coordinates */ public void setViewPosition(Point p) { Component view = getView(); if (view == null) {
*** 1130,1163 **** } } /** ! * Returns a rectangle whose origin is <code>getViewPosition</code> ! * and size is <code>getExtentSize</code>. * This is the visible part of the view, in view coordinates. * ! * @return a <code>Rectangle</code> giving the visible part of * the view using view coordinates. */ public Rectangle getViewRect() { return new Rectangle(getViewPosition(), getExtentSize()); } /** * Computes the parameters for a blit where the backing store image ! * currently contains <code>oldLoc</code> in the upper left hand corner ! * and we're scrolling to <code>newLoc</code>. * The parameters are modified * to return the values required for the blit. * * @param dx the horizontal delta * @param dy the vertical delta ! * @param blitFrom the <code>Point</code> we're blitting from ! * @param blitTo the <code>Point</code> we're blitting to ! * @param blitSize the <code>Dimension</code> of the area to blit * @param blitPaint the area to blit * @return true if the parameters are modified and we're ready to blit; * false otherwise */ protected boolean computeBlit( --- 1130,1163 ---- } } /** ! * Returns a rectangle whose origin is {@code getViewPosition} ! * and size is {@code getExtentSize}. * This is the visible part of the view, in view coordinates. * ! * @return a {@code Rectangle} giving the visible part of * the view using view coordinates. */ public Rectangle getViewRect() { return new Rectangle(getViewPosition(), getExtentSize()); } /** * Computes the parameters for a blit where the backing store image ! * currently contains {@code oldLoc} in the upper left hand corner ! * and we're scrolling to {@code newLoc}. * The parameters are modified * to return the values required for the blit. * * @param dx the horizontal delta * @param dy the vertical delta ! * @param blitFrom the {@code Point} we're blitting from ! * @param blitTo the {@code Point} we're blitting to ! * @param blitSize the {@code Dimension} of the area to blit * @param blitPaint the area to blit * @return true if the parameters are modified and we're ready to blit; * false otherwise */ protected boolean computeBlit(
*** 1225,1235 **** /** * Returns the size of the visible part of the view in view coordinates. * ! * @return a <code>Dimension</code> object giving the size of the view */ @Transient public Dimension getExtentSize() { return getSize(); } --- 1225,1235 ---- /** * Returns the size of the visible part of the view in view coordinates. * ! * @return a {@code Dimension} object giving the size of the view */ @Transient public Dimension getExtentSize() { return getSize(); }
*** 1238,1271 **** /** * Converts a size in pixel coordinates to view coordinates. * Subclasses of viewport that support "logical coordinates" * will override this method. * ! * @param size a <code>Dimension</code> object using pixel coordinates ! * @return a <code>Dimension</code> object converted to view coordinates */ public Dimension toViewCoordinates(Dimension size) { return new Dimension(size); } /** * Converts a point in pixel coordinates to view coordinates. * Subclasses of viewport that support "logical coordinates" * will override this method. * ! * @param p a <code>Point</code> object using pixel coordinates ! * @return a <code>Point</code> object converted to view coordinates */ public Point toViewCoordinates(Point p) { return new Point(p); } /** * Sets the size of the visible part of the view using view coordinates. * ! * @param newExtent a <code>Dimension</code> object specifying * the size of the view */ public void setExtentSize(Dimension newExtent) { Dimension oldExtent = getExtentSize(); if (!newExtent.equals(oldExtent)) { --- 1238,1271 ---- /** * Converts a size in pixel coordinates to view coordinates. * Subclasses of viewport that support "logical coordinates" * will override this method. * ! * @param size a {@code Dimension} object using pixel coordinates ! * @return a {@code Dimension} object converted to view coordinates */ public Dimension toViewCoordinates(Dimension size) { return new Dimension(size); } /** * Converts a point in pixel coordinates to view coordinates. * Subclasses of viewport that support "logical coordinates" * will override this method. * ! * @param p a {@code Point} object using pixel coordinates ! * @return a {@code Point} object converted to view coordinates */ public Point toViewCoordinates(Point p) { return new Point(p); } /** * Sets the size of the visible part of the view using view coordinates. * ! * @param newExtent a {@code Dimension} object specifying * the size of the view */ public void setExtentSize(Dimension newExtent) { Dimension oldExtent = getExtentSize(); if (!newExtent.equals(oldExtent)) {
*** 1281,1291 **** * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") // Same-version serialization only protected class ViewListener extends ComponentAdapter implements Serializable { --- 1281,1291 ---- * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") // Same-version serialization only protected class ViewListener extends ComponentAdapter implements Serializable {
*** 1295,1364 **** } } /** * Creates a listener for the view. ! * @return a <code>ViewListener</code> */ protected ViewListener createViewListener() { return new ViewListener(); } /** * Subclassers can override this to install a different ! * layout manager (or <code>null</code>) in the constructor. Returns ! * the <code>LayoutManager</code> to install on the <code>JViewport</code>. * ! * @return a <code>LayoutManager</code> */ protected LayoutManager createLayoutManager() { return ViewportLayout.SHARED_INSTANCE; } /** ! * Adds a <code>ChangeListener</code> to the list that is * notified each time the view's * size, position, or the viewport's extent size has changed. * ! * @param l the <code>ChangeListener</code> to add * @see #removeChangeListener * @see #setViewPosition * @see #setViewSize * @see #setExtentSize */ public void addChangeListener(ChangeListener l) { listenerList.add(ChangeListener.class, l); } /** ! * Removes a <code>ChangeListener</code> from the list that's notified each * time the views size, position, or the viewports extent size * has changed. * ! * @param l the <code>ChangeListener</code> to remove * @see #addChangeListener */ public void removeChangeListener(ChangeListener l) { listenerList.remove(ChangeListener.class, l); } /** ! * Returns an array of all the <code>ChangeListener</code>s added * to this JViewport with addChangeListener(). * ! * @return all of the <code>ChangeListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ public ChangeListener[] getChangeListeners() { return listenerList.getListeners(ChangeListener.class); } /** ! * Notifies all <code>ChangeListeners</code> when the views * size, position, or the viewports extent size has changed. * * @see #addChangeListener * @see #removeChangeListener * @see EventListenerList --- 1295,1364 ---- } } /** * Creates a listener for the view. ! * @return a {@code ViewListener} */ protected ViewListener createViewListener() { return new ViewListener(); } /** * Subclassers can override this to install a different ! * layout manager (or {@code null}) in the constructor. Returns ! * the {@code LayoutManager} to install on the {@code JViewport}. * ! * @return a {@code LayoutManager} */ protected LayoutManager createLayoutManager() { return ViewportLayout.SHARED_INSTANCE; } /** ! * Adds a {@code ChangeListener} to the list that is * notified each time the view's * size, position, or the viewport's extent size has changed. * ! * @param l the {@code ChangeListener} to add * @see #removeChangeListener * @see #setViewPosition * @see #setViewSize * @see #setExtentSize */ public void addChangeListener(ChangeListener l) { listenerList.add(ChangeListener.class, l); } /** ! * Removes a {@code ChangeListener} from the list that's notified each * time the views size, position, or the viewports extent size * has changed. * ! * @param l the {@code ChangeListener} to remove * @see #addChangeListener */ public void removeChangeListener(ChangeListener l) { listenerList.remove(ChangeListener.class, l); } /** ! * Returns an array of all the {@code ChangeListener}s added * to this JViewport with addChangeListener(). * ! * @return all of the {@code ChangeListener}s added or an empty * array if no listeners have been added * @since 1.4 */ public ChangeListener[] getChangeListeners() { return listenerList.getListeners(ChangeListener.class); } /** ! * Notifies all {@code ChangeListeners} when the views * size, position, or the viewports extent size has changed. * * @see #addChangeListener * @see #removeChangeListener * @see EventListenerList
*** 1376,1390 **** } } /** * Always repaint in the parents coordinate system to make sure ! * only one paint is performed by the <code>RepaintManager</code>. * * @param tm maximum time in milliseconds before update ! * @param x the <code>x</code> coordinate (pixels over from left) ! * @param y the <code>y</code> coordinate (pixels down from top) * @param w the width * @param h the height * @see java.awt.Component#update(java.awt.Graphics) */ public void repaint(long tm, int x, int y, int w, int h) { --- 1376,1390 ---- } } /** * Always repaint in the parents coordinate system to make sure ! * only one paint is performed by the {@code RepaintManager}. * * @param tm maximum time in milliseconds before update ! * @param x the {@code x} coordinate (pixels over from left) ! * @param y the {@code y} coordinate (pixels down from top) * @param w the width * @param h the height * @see java.awt.Component#update(java.awt.Graphics) */ public void repaint(long tm, int x, int y, int w, int h) {
*** 1395,1412 **** super.repaint(tm,x,y,w,h); } /** ! * Returns a string representation of this <code>JViewport</code>. * This method * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not ! * be <code>null</code>. * ! * @return a string representation of this <code>JViewport</code> */ protected String paramString() { String isViewSizeSetString = (isViewSizeSet ? "true" : "false"); String lastPaintPositionString = (lastPaintPosition != null ? --- 1395,1412 ---- super.repaint(tm,x,y,w,h); } /** ! * Returns a string representation of this {@code JViewport}. * This method * is intended to be used only for debugging purposes, and the * content and format of the returned string may vary between * implementations. The returned string may be empty but may not ! * be {@code null}. * ! * @return a string representation of this {@code JViewport} */ protected String paramString() { String isViewSizeSetString = (isViewSizeSet ? "true" : "false"); String lastPaintPositionString = (lastPaintPosition != null ?
*** 1424,1435 **** // Following is used when doBlit is true. // /** * Notifies listeners of a property change. This is subclassed to update ! * the <code>windowBlit</code> property. ! * (The <code>putClientProperty</code> property is final). * * @param propertyName a string containing the property name * @param oldValue the old value of the property * @param newValue the new value of the property */ --- 1424,1435 ---- // Following is used when doBlit is true. // /** * Notifies listeners of a property change. This is subclassed to update ! * the {@code windowBlit} property. ! * (The {@code putClientProperty} property is final). * * @param propertyName a string containing the property name * @param oldValue the old value of the property * @param newValue the new value of the property */
*** 1493,1503 **** /** * If the repaint manager has a dirty region for the view, the view is * asked to paint. * ! * @param g the <code>Graphics</code> context within which to paint */ private void flushViewDirtyRegion(Graphics g, Rectangle dirty) { JComponent view = (JComponent) getView(); if(dirty != null && dirty.width > 0 && dirty.height > 0) { dirty.x += view.getX(); --- 1493,1503 ---- /** * If the repaint manager has a dirty region for the view, the view is * asked to paint. * ! * @param g the {@code Graphics} context within which to paint */ private void flushViewDirtyRegion(Graphics g, Rectangle dirty) { JComponent view = (JComponent) getView(); if(dirty != null && dirty.width > 0 && dirty.height > 0) { dirty.x += view.getX();
*** 1517,1527 **** } /** * Used when blitting. * ! * @param g the <code>Graphics</code> context within which to paint * @return true if blitting succeeded; otherwise false */ private boolean windowBlitPaint(Graphics g) { int width = getWidth(); int height = getHeight(); --- 1517,1527 ---- } /** * Used when blitting. * ! * @param g the {@code Graphics} context within which to paint * @return true if blitting succeeded; otherwise false */ private boolean windowBlitPaint(Graphics g) { int width = getWidth(); int height = getHeight();
*** 1611,1624 **** view.paintForceDoubleBuffered(g); g.translate(-x, -y); } /** ! * Called to paint the view, usually when <code>blitPaint</code> * can not blit. * ! * @param g the <code>Graphics</code> context within which to paint */ private void paintView(Graphics g) { Rectangle clip = g.getClipBounds(); JComponent view = (JComponent)getView(); --- 1611,1624 ---- view.paintForceDoubleBuffered(g); g.translate(-x, -y); } /** ! * Called to paint the view, usually when {@code blitPaint} * can not blit. * ! * @param g the {@code Graphics} context within which to paint */ private void paintView(Graphics g) { Rectangle clip = g.getClipBounds(); JComponent view = (JComponent)getView();
*** 1647,1657 **** /** * Returns true if the viewport is not obscured by one of its ancestors, * or its ancestors children and if the viewport is showing. Blitting * when the view isn't showing will work, ! * or rather <code>copyArea</code> will work, * but will not produce the expected behavior. */ private boolean canUseWindowBlitter() { if (!isShowing() || (!(getParent() instanceof JComponent) && !(getView() instanceof JComponent))) { --- 1647,1657 ---- /** * Returns true if the viewport is not obscured by one of its ancestors, * or its ancestors children and if the viewport is showing. Blitting * when the view isn't showing will work, ! * or rather {@code copyArea} will work, * but will not produce the expected behavior. */ private boolean canUseWindowBlitter() { if (!isShowing() || (!(getParent() instanceof JComponent) && !(getView() instanceof JComponent))) {
*** 1743,1762 **** return accessibleContext; } /** * This class implements accessibility support for the ! * <code>JViewport</code> class. It provides an implementation of the * Java Accessibility API appropriate to viewport user-interface elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") // Same-version serialization only protected class AccessibleJViewport extends AccessibleJComponent { /** --- 1743,1762 ---- return accessibleContext; } /** * This class implements accessibility support for the ! * {@code JViewport} class. It provides an implementation of the * Java Accessibility API appropriate to viewport user-interface elements. * <p> * <strong>Warning:</strong> * Serialized objects of this class will not be compatible with * future Swing releases. The current serialization support is * appropriate for short term storage or RMI between applications running * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; ! * has been added to the {@code java.beans} package. * Please see {@link java.beans.XMLEncoder}. */ @SuppressWarnings("serial") // Same-version serialization only protected class AccessibleJViewport extends AccessibleJComponent { /**
< prev index next >