Example usage for javax.swing JScrollBar getVisibleAmount

List of usage examples for javax.swing JScrollBar getVisibleAmount

Introduction

In this page you can find the example usage for javax.swing JScrollBar getVisibleAmount.

Prototype

public int getVisibleAmount() 

Source Link

Document

Returns the scrollbar's extent, aka its "visibleAmount".

Usage

From source file:net.sf.jabref.gui.maintable.MainTable.java

public void ensureVisible(int row) {
    JScrollBar vert = pane.getVerticalScrollBar();
    int y = row * getRowHeight();
    if ((y < vert.getValue()) || ((y > (vert.getValue() + vert.getVisibleAmount()))
            && (model.getSearchState() != MainTableDataModel.DisplayOption.FLOAT))) {
        scrollToCenter(row, 1);/* ww  w  .j  a  va2  s  .  c  o m*/
    }

}

From source file:net.sf.jabref.gui.MainTable.java

public void ensureVisible(int row) {
    JScrollBar vert = pane.getVerticalScrollBar();
    int y = row * getRowHeight();
    if ((y < vert.getValue()) || ((y > (vert.getValue() + vert.getVisibleAmount())) && !isFloatSearchActive)) {
        scrollToCenter(row, 1);// w  w w.  ja  va2s  .  co  m
    }

}

From source file:com.att.aro.ui.view.waterfalltab.WaterfallPanel.java

/**
 * Setting the time range for the graph.
 * @param low//from  ww w.ja va2 s.c o m
 * @param high
 */
private void setTimeRange(double low, double high) {

    double lTime = low;
    double hTime = high;
    boolean zoomInEnabled = true;
    boolean zoomOutEnabled = true;
    JScrollBar scrollBarr = getHorizontalScroll();
    if (hTime > traceDuration) {
        double delta = hTime - traceDuration;
        lTime = lTime - delta;
        hTime = hTime - delta;
        if (lTime < 0) {
            lTime = 0.0;
        }
    }

    if (hTime - lTime <= 1.0) {
        hTime = lTime + 1.0;
        zoomInEnabled = false;
    }

    if ((hTime - lTime) < traceDuration) {
        zoomOutEnabled = true;
    } else {
        zoomOutEnabled = false;
    }

    //      logger.log(Level.FINE, "Range set to {0} - {1}", new Object[] {low, high});
    scrollBarr.setValue((int) lTime);
    scrollBarr.setVisibleAmount((int) Math.ceil(hTime - lTime));
    scrollBarr.setBlockIncrement(scrollBarr.getVisibleAmount());

    // Enable zoom buttons appropriately
    zoomOutButton.setEnabled(zoomOutEnabled);
    zoomInButton.setEnabled(zoomInEnabled);
}

From source file:org.forester.archaeopteryx.ControlPanel.java

void zoomOutY(final float factor) {
    final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
    treepanel.multiplyUrtFactor(0.9f);//w w  w  .ja  va2  s . co m
    if ((treepanel.getYdistance() * factor) > 0.0) {
        final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
        final double x = (sb.getMaximum() - sb.getMinimum()) / (sb.getValue() + (sb.getVisibleAmount() / 2.0));
        treepanel.setYdistance((treepanel.getYdistance() * factor));
        getMainPanel().adjustJScrollPane();
        treepanel.resetPreferredSize();
        getMainPanel().getCurrentScrollPane().getViewport().validate();
        sb.setValue(ForesterUtil
                .roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0)));
        treepanel.resetPreferredSize();
        treepanel.updateOvSizes();
    }
}

From source file:org.forester.archaeopteryx.ControlPanel.java

void zoomInY(final float factor) {
    final JScrollBar sb = getMainPanel().getCurrentScrollPane().getVerticalScrollBar();
    final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
    treepanel.multiplyUrtFactor(1.1f);//  w w  w .java  2 s  .com
    final double x = (sb.getMaximum() - sb.getMinimum()) / (sb.getValue() + (sb.getVisibleAmount() / 2.0));
    treepanel.setYdistance((treepanel.getYdistance() * factor));
    getMainPanel().adjustJScrollPane();
    treepanel.resetPreferredSize();
    getMainPanel().getCurrentScrollPane().getViewport().validate();
    sb.setValue(
            ForesterUtil.roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0)));
    treepanel.resetPreferredSize();
    treepanel.updateOvSizes();
}

From source file:org.forester.archaeopteryx.ControlPanel.java

void zoomInX(final float factor, final float x_correction_factor) {
    final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
    final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
    treepanel.multiplyUrtFactor(1f);/*from  w w w  . j  a  v a 2 s.c  om*/
    if ((treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)
            || (treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
            || isDrawPhylogram(getMainPanel().getCurrentTabIndex())
            || (getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP)) {
        final double x = (sb.getMaximum() - sb.getMinimum()) / (sb.getValue() + (sb.getVisibleAmount() / 2.0));
        treepanel.setXdistance((treepanel.getXdistance() * factor));
        treepanel.setXcorrectionFactor((treepanel.getXcorrectionFactor() * x_correction_factor));
        getMainPanel().adjustJScrollPane();
        treepanel.resetPreferredSize();
        getMainPanel().getCurrentScrollPane().getViewport().validate();
        sb.setValue(ForesterUtil
                .roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0)));
    } else {
        final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
        treepanel.setXdistance((treepanel.getXdistance() * factor));
        treepanel.setXcorrectionFactor((treepanel.getXcorrectionFactor() * x_correction_factor));
        getMainPanel().adjustJScrollPane();
        treepanel.resetPreferredSize();
        getMainPanel().getCurrentScrollPane().getViewport().validate();
        sb.setValue(sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount());
    }
    treepanel.resetPreferredSize();
    treepanel.updateOvSizes();
}

From source file:org.forester.archaeopteryx.ControlPanel.java

void zoomOutX(final float factor, final float x_correction_factor) {
    final TreePanel treepanel = getMainPanel().getCurrentTreePanel();
    treepanel.multiplyUrtFactor(1f);//from   w  w w .java 2 s .c o  m
    if ((treepanel.getXdistance() * factor) > 0.0) {
        final JScrollBar sb = getMainPanel().getCurrentScrollPane().getHorizontalScrollBar();
        if ((treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.CIRCULAR)
                || (treepanel.getPhylogenyGraphicsType() == PHYLOGENY_GRAPHICS_TYPE.UNROOTED)
                || isDrawPhylogram(getMainPanel().getCurrentTabIndex())
                || (getOptions().getCladogramType() == CLADOGRAM_TYPE.NON_LINED_UP)) {
            getMainPanel().adjustJScrollPane();
            treepanel.resetPreferredSize();
            getMainPanel().getCurrentScrollPane().getViewport().validate();
            final double x = (sb.getMaximum() - sb.getMinimum())
                    / (sb.getValue() + (sb.getVisibleAmount() / 2.0));
            treepanel.setXdistance((treepanel.getXdistance() * factor));
            treepanel.setXcorrectionFactor((treepanel.getXcorrectionFactor() * x_correction_factor));
            getMainPanel().adjustJScrollPane();
            treepanel.resetPreferredSize();
            getMainPanel().getCurrentScrollPane().getViewport().validate();
            sb.setValue(ForesterUtil
                    .roundToInt(((sb.getMaximum() - sb.getMinimum()) / x) - (sb.getVisibleAmount() / 2.0)));
        } else {
            final int x = sb.getMaximum() - sb.getMinimum() - sb.getVisibleAmount() - sb.getValue();
            treepanel.setXdistance(treepanel.getXdistance() * factor);
            treepanel.setXcorrectionFactor(treepanel.getXcorrectionFactor() * x_correction_factor);
            if (x > 0) {
                getMainPanel().adjustJScrollPane();
                treepanel.resetPreferredSize();
                getMainPanel().getCurrentScrollPane().getViewport().validate();
                sb.setValue(sb.getMaximum() - sb.getMinimum() - x - sb.getVisibleAmount());
            }
        }
        treepanel.resetPreferredSize();
        treepanel.updateOvSizes();
    }
}