812 }
813 }
814 }
815 }
816 lastPaintPosition = getViewLocation();
817 scrollUnderway = false;
818 }
819
820
821 /**
822 * Sets the bounds of this viewport. If the viewport's width
823 * or height has changed, fire a <code>StateChanged</code> event.
824 *
825 * @param x left edge of the origin
826 * @param y top edge of the origin
827 * @param w width in pixels
828 * @param h height in pixels
829 *
830 * @see JComponent#reshape(int, int, int, int)
831 */
832 public void reshape(int x, int y, int w, int h) {
833 boolean sizeChanged = (getWidth() != w) || (getHeight() != h);
834 if (sizeChanged) {
835 backingStoreImage = null;
836 }
837 super.reshape(x, y, w, h);
838 if (sizeChanged || viewChanged) {
839 viewChanged = false;
840
841 fireStateChanged();
842 }
843 }
844
845
846 /**
847 * Used to control the method of scrolling the viewport contents.
848 * You may want to change this mode to get maximum performance for your
849 * use case.
850 *
851 * @param mode one of the following values:
1430 * @param propertyName a string containing the property name
1431 * @param oldValue the old value of the property
1432 * @param newValue the new value of the property
1433 */
1434 protected void firePropertyChange(String propertyName, Object oldValue,
1435 Object newValue) {
1436 super.firePropertyChange(propertyName, oldValue, newValue);
1437 if (propertyName.equals(EnableWindowBlit)) {
1438 if (newValue != null) {
1439 setScrollMode(BLIT_SCROLL_MODE);
1440 } else {
1441 setScrollMode(SIMPLE_SCROLL_MODE);
1442 }
1443 }
1444 }
1445
1446 /**
1447 * Returns true if the component needs to be completely repainted after
1448 * a blit and a paint is received.
1449 */
1450 private boolean needsRepaintAfterBlit() {
1451 // Find the first heavy weight ancestor. isObscured and
1452 // canDetermineObscurity are only appropriate for heavy weights.
1453 Component heavyParent = getParent();
1454
1455 while (heavyParent != null && heavyParent.isLightweight()) {
1456 heavyParent = heavyParent.getParent();
1457 }
1458
1459 if (heavyParent != null) {
1460 ComponentPeer peer = heavyParent.getPeer();
1461
1462 if (peer != null && peer.canDetermineObscurity() &&
1463 !peer.isObscured()) {
1464 // The peer says we aren't obscured, therefore we can assume
1465 // that we won't later be messaged to paint a portion that
1466 // we tried to blit that wasn't valid.
1467 // It is certainly possible that when we blited we were
1468 // obscured, and by the time this is invoked we aren't, but the
1469 // chances of that happening are pretty slim.
|
812 }
813 }
814 }
815 }
816 lastPaintPosition = getViewLocation();
817 scrollUnderway = false;
818 }
819
820
821 /**
822 * Sets the bounds of this viewport. If the viewport's width
823 * or height has changed, fire a <code>StateChanged</code> event.
824 *
825 * @param x left edge of the origin
826 * @param y top edge of the origin
827 * @param w width in pixels
828 * @param h height in pixels
829 *
830 * @see JComponent#reshape(int, int, int, int)
831 */
832 @SuppressWarnings("deprecation")
833 public void reshape(int x, int y, int w, int h) {
834 boolean sizeChanged = (getWidth() != w) || (getHeight() != h);
835 if (sizeChanged) {
836 backingStoreImage = null;
837 }
838 super.reshape(x, y, w, h);
839 if (sizeChanged || viewChanged) {
840 viewChanged = false;
841
842 fireStateChanged();
843 }
844 }
845
846
847 /**
848 * Used to control the method of scrolling the viewport contents.
849 * You may want to change this mode to get maximum performance for your
850 * use case.
851 *
852 * @param mode one of the following values:
1431 * @param propertyName a string containing the property name
1432 * @param oldValue the old value of the property
1433 * @param newValue the new value of the property
1434 */
1435 protected void firePropertyChange(String propertyName, Object oldValue,
1436 Object newValue) {
1437 super.firePropertyChange(propertyName, oldValue, newValue);
1438 if (propertyName.equals(EnableWindowBlit)) {
1439 if (newValue != null) {
1440 setScrollMode(BLIT_SCROLL_MODE);
1441 } else {
1442 setScrollMode(SIMPLE_SCROLL_MODE);
1443 }
1444 }
1445 }
1446
1447 /**
1448 * Returns true if the component needs to be completely repainted after
1449 * a blit and a paint is received.
1450 */
1451 @SuppressWarnings("deprecation")
1452 private boolean needsRepaintAfterBlit() {
1453 // Find the first heavy weight ancestor. isObscured and
1454 // canDetermineObscurity are only appropriate for heavy weights.
1455 Component heavyParent = getParent();
1456
1457 while (heavyParent != null && heavyParent.isLightweight()) {
1458 heavyParent = heavyParent.getParent();
1459 }
1460
1461 if (heavyParent != null) {
1462 ComponentPeer peer = heavyParent.getPeer();
1463
1464 if (peer != null && peer.canDetermineObscurity() &&
1465 !peer.isObscured()) {
1466 // The peer says we aren't obscured, therefore we can assume
1467 // that we won't later be messaged to paint a portion that
1468 // we tried to blit that wasn't valid.
1469 // It is certainly possible that when we blited we were
1470 // obscured, and by the time this is invoked we aren't, but the
1471 // chances of that happening are pretty slim.
|