Java Code Examples for java.awt.event.AdjustmentEvent#UNIT_INCREMENT

The following examples show how to use java.awt.event.AdjustmentEvent#UNIT_INCREMENT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WScrollPanePeer.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 2
Source File: WScrollPanePeer.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 3
Source File: WScrollPanePeer.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 4
Source File: WScrollPanePeer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 5
Source File: WScrollPanePeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 6
Source File: WScrollPanePeer.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    while (hwAncestor != null
           && !(acc.getPeer(hwAncestor) instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = acc.getPeer(hwAncestor);
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 7
Source File: WScrollPanePeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 8
Source File: WScrollPanePeer.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 9
Source File: WScrollPanePeer.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 10
Source File: WScrollPanePeer.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 11
Source File: WScrollPanePeer.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 12
Source File: SampleAnalysisWorkflowManagerIDTIMS.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
@Override
public void adjustmentValueChanged(AdjustmentEvent evt) {
    Adjustable source = evt.getAdjustable();

    // getValueIsAdjusting() returns true if the user is currently
    // dragging the scrollbar's knob and has not picked a final value
    if (evt.getValueIsAdjusting()) {
        // The user is dragging the knob
        return;
    } else {
        ((javax.swing.JScrollBar) source).getParent().repaint();
    }

    // Determine which scrollbar fired the event
    int orient = source.getOrientation();
    if (orient == Adjustable.HORIZONTAL) {
        // Event from horizontal scrollbar
    } else {
        // Event from vertical scrollbar
    }

    // Determine the type of event
    int type = evt.getAdjustmentType();
    switch (type) {
        case AdjustmentEvent.UNIT_INCREMENT:
            // Scrollbar was increased by one unit
            break;
        case AdjustmentEvent.UNIT_DECREMENT:
            // Scrollbar was decreased by one unit
            break;
        case AdjustmentEvent.BLOCK_INCREMENT:
            // Scrollbar was increased by one block
            break;
        case AdjustmentEvent.BLOCK_DECREMENT:
            // Scrollbar was decreased by one block
            break;
        case AdjustmentEvent.TRACK:
            // The knob on the scrollbar was dragged
            break;
    }

    // Get current value
    //int value = evt.getValue();
}
 
Example 13
Source File: SampleAnalysisWorkflowManagerLAICPMS.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
public void adjustmentValueChanged(AdjustmentEvent evt) {
    Adjustable source = evt.getAdjustable();

    // getValueIsAdjusting() returns true if the user is currently
    // dragging the scrollbar's knob and has not picked a final value
    if (evt.getValueIsAdjusting()) {
        // The user is dragging the knob
        return;
    } else {
        ((javax.swing.JScrollBar) source).getParent().repaint();
    }

    // Determine which scrollbar fired the event
    int orient = source.getOrientation();
    if (orient == Adjustable.HORIZONTAL) {
        // Event from horizontal scrollbar
    } else {
        // Event from vertical scrollbar
    }

    // Determine the type of event
    int type = evt.getAdjustmentType();
    switch (type) {
        case AdjustmentEvent.UNIT_INCREMENT:
            // Scrollbar was increased by one unit
            break;
        case AdjustmentEvent.UNIT_DECREMENT:
            // Scrollbar was decreased by one unit
            break;
        case AdjustmentEvent.BLOCK_INCREMENT:
            // Scrollbar was increased by one block
            break;
        case AdjustmentEvent.BLOCK_DECREMENT:
            // Scrollbar was decreased by one block
            break;
        case AdjustmentEvent.TRACK:
            // The knob on the scrollbar was dragged
            break;
    }

    // Get current value
    //int value = evt.getValue();
}
 
Example 14
Source File: WScrollPanePeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}
 
Example 15
Source File: WScrollPanePeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
    if (getScrollChild() == null) {
        return;
    }
    ScrollPane sp = (ScrollPane)WScrollPanePeer.this.target;
    ScrollPaneAdjustable adj = null;

    // ScrollPaneAdjustable made public in 1.4, but
    // get[HV]Adjustable can't be declared to return
    // ScrollPaneAdjustable because it would break backward
    // compatibility -- hence the cast

    if (orient == Adjustable.VERTICAL) {
        adj = (ScrollPaneAdjustable)sp.getVAdjustable();
    } else if (orient == Adjustable.HORIZONTAL) {
        adj = (ScrollPaneAdjustable)sp.getHAdjustable();
    } else {
        if (log.isLoggable(PlatformLogger.Level.FINE)) {
            log.fine("Assertion failed: unknown orient");
        }
    }

    if (adj == null) {
        return;
    }

    int newpos = adj.getValue();
    switch (type) {
      case AdjustmentEvent.UNIT_DECREMENT:
          newpos -= adj.getUnitIncrement();
          break;
      case AdjustmentEvent.UNIT_INCREMENT:
          newpos += adj.getUnitIncrement();
          break;
      case AdjustmentEvent.BLOCK_DECREMENT:
          newpos -= adj.getBlockIncrement();
          break;
      case AdjustmentEvent.BLOCK_INCREMENT:
          newpos += adj.getBlockIncrement();
          break;
      case AdjustmentEvent.TRACK:
          newpos = this.pos;
          break;
      default:
          if (log.isLoggable(PlatformLogger.Level.FINE)) {
              log.fine("Assertion failed: unknown type");
          }
          return;
    }

    // keep scroll position in acceptable range
    newpos = Math.max(adj.getMinimum(), newpos);
    newpos = Math.min(adj.getMaximum(), newpos);

    // set value, this will synchronously fire an AdjustmentEvent
    adj.setValueIsAdjusting(isAdjusting);

    // Fix for 4075484 - consider type information when creating AdjustmentEvent
    // We can't just call adj.setValue() because it creates AdjustmentEvent with type=TRACK
    // Instead, we call private method setTypedValue of ScrollPaneAdjustable.
    AWTAccessor.getScrollPaneAdjustableAccessor().setTypedValue(adj,
                                                                newpos,
                                                                type);

    // Paint the exposed area right away.  To do this - find
    // the heavyweight ancestor of the scroll child.
    Component hwAncestor = getScrollChild();
    while (hwAncestor != null
           && !(hwAncestor.getPeer() instanceof WComponentPeer))
    {
        hwAncestor = hwAncestor.getParent();
    }
    if (log.isLoggable(PlatformLogger.Level.FINE)) {
        if (hwAncestor == null) {
            log.fine("Assertion (hwAncestor != null) failed, " +
                     "couldn't find heavyweight ancestor of scroll pane child");
        }
    }
    WComponentPeer hwPeer = (WComponentPeer)hwAncestor.getPeer();
    hwPeer.paintDamagedAreaImmediately();
}