コード例 #1
0
  /**
   * Called to set the URL to browse, and reset the scrollbars.
   *
   * @param url indicates document to view.
   * @throws IOException if an error occures
   */
  public void setURL(final URL url) throws IOException {
    final URL old = getURL();
    super.setURL(url);

    if (old == null) {
      // bcr      getImageWait().setBufferMode(DjVuImage.COMPLETE_BUFFER);
      setScrollbar(Scrollbar.HORIZONTAL, new Scrollbar(Scrollbar.HORIZONTAL));
      setScrollbar(Scrollbar.VERTICAL, new Scrollbar(Scrollbar.VERTICAL));
      hScroll.setUnitIncrement(16);
      vScroll.setUnitIncrement(16);
    }
  }
コード例 #2
0
 /**
  * Called to process scrollbar events.
  *
  * @param event to process.
  */
 public void adjustmentValueChanged(AdjustmentEvent event) {
   try {
     final Scrollbar hScroll = getScrollbar(Scrollbar.HORIZONTAL);
     final Scrollbar vScroll = getScrollbar(Scrollbar.VERTICAL);
     final Point scrollPosition = getScrollPosition();
     setScrollPosition(
         (hScroll != null) ? hScroll.getValue() : scrollPosition.x,
         (vScroll != null) ? vScroll.getValue() : scrollPosition.y);
   } catch (final Throwable exp) {
     exp.printStackTrace(DjVuOptions.err);
     System.gc();
   }
 }
コード例 #3
0
  // Called to update the scrollbar properties.
  private void updateScrollbars() {
    final DjVuImage image = getImage();
    if (image != null) {
      final Dimension viewportSize = getViewportSize();
      final Dimension imageSize = image.getSize();
      final Point scrollPosition = getScrollPosition();
      final Scrollbar hScroll = getScrollbar(Scrollbar.HORIZONTAL);
      final Scrollbar vScroll = getScrollbar(Scrollbar.VERTICAL);

      if (hScroll != null) {
        hScroll.setValues(scrollPosition.x, viewportSize.width, 0, imageSize.width);
      }

      if (vScroll != null) {
        vScroll.setValues(scrollPosition.y, viewportSize.height, 0, imageSize.height);
      }
    }
  }
コード例 #4
0
  /**
   * Set either the horizontal or vertical scrollbar.
   *
   * @param orientation either Scrollbar.HORIZONTAL or Scrollbar.VERTICAL
   * @param scrollbar component.
   */
  public void setScrollbar(int orientation, Scrollbar scrollbar) {
    if (orientation == Scrollbar.HORIZONTAL) {
      hScroll = scrollbar;
    } else {
      vScroll = scrollbar;
    }

    scrollbar.addAdjustmentListener(this);
    updateScrollbars();
  }