本文整理匯總了Java中org.eclipse.swt.widgets.ScrollBar.setMaximum方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollBar.setMaximum方法的具體用法?Java ScrollBar.setMaximum怎麽用?Java ScrollBar.setMaximum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.widgets.ScrollBar
的用法示例。
在下文中一共展示了ScrollBar.setMaximum方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateScroll
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public void updateScroll(){
Rectangle rect = this.composite.getBounds();
Rectangle client = this.composite.getClientArea();
ScrollBar vBar = this.composite.getVerticalBar();
vBar.setMaximum(Math.round(this.height));
vBar.setThumb(Math.min(rect.height, client.height));
}
示例2: updateScroll
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
protected void updateScroll(){
if( this.clientArea != null ){
int borderWidth = this.editor.getBorderWidth();
ScrollBar vBar = this.editor.getVerticalBar();
ScrollBar hBar = this.editor.getHorizontalBar();
vBar.setMaximum(Math.round(this.height + (borderWidth * 2)));
vBar.setThumb(Math.round(Math.min(this.height + (borderWidth * 2), this.clientArea.height)));
hBar.setMaximum(Math.round(this.width + (borderWidth * 2)));
hBar.setThumb(Math.round(Math.min(this.width + (borderWidth * 2), this.clientArea.width)));
}
}
示例3: updateScroll
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public void updateScroll(){
Rectangle bounds = getBounds();
Rectangle client = getClientArea();
ScrollBar hBar = getHorizontalBar();
ScrollBar vBar = getVerticalBar();
hBar.setMaximum(this.width);
vBar.setMaximum(this.height);
hBar.setThumb(Math.min(bounds.width, client.width));
vBar.setThumb(Math.min(bounds.height, client.height));
}
示例4: resizeScrollBars
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
void resizeScrollBars() {
// Set the max and thumb for the image canvas scroll bars.
ScrollBar horizontal = imageCanvas.getHorizontalBar();
ScrollBar vertical = imageCanvas.getVerticalBar();
Rectangle canvasBounds = imageCanvas.getClientArea();
int width = Math.round(imageData.width * xscale);
if (width > canvasBounds.width) {
// The image is wider than the canvas.
horizontal.setEnabled(true);
horizontal.setMaximum(width);
horizontal.setThumb(canvasBounds.width);
horizontal.setPageIncrement(canvasBounds.width);
}
else {
// The canvas is wider than the image.
horizontal.setEnabled(false);
if (ix != 0) {
// Make sure the image is completely visible.
ix = 0;
imageCanvas.redraw();
}
}
int height = Math.round(imageData.height * yscale);
if (height > canvasBounds.height) {
// The image is taller than the canvas.
vertical.setEnabled(true);
vertical.setMaximum(height);
vertical.setThumb(canvasBounds.height);
vertical.setPageIncrement(canvasBounds.height);
}
else {
// The canvas is taller than the image.
vertical.setEnabled(false);
if (iy != 0) {
// Make sure the image is completely visible.
iy = 0;
imageCanvas.redraw();
}
}
}
示例5: updateScrollBarProperties
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Move the scrollbar to reflect the current visible items position.
*
* @param bar
* - the scroll bar to move
* @param clientSize
* - Client (visible) area size
* @param totalSize
* - Total Size
*/
private void updateScrollBarProperties(ScrollBar bar, int clientSize,
int totalSize) {
if (bar == null)
return;
bar.setMinimum(0);
bar.setPageIncrement(clientSize);
bar.setMaximum(totalSize);
bar.setThumb(clientSize);
// Let the group renderer use a custom increment value.
if (groupRenderer != null)
bar.setIncrement(groupRenderer.getScrollBarIncrement());
if (totalSize > clientSize) {
if (DEBUG)
System.out.println("Enabling scrollbar"); //$NON-NLS-1$
bar.setEnabled(true);
bar.setVisible(true);
bar.setSelection(translate);
// Ensure that translate has a valid value.
validateTranslation();
} else {
if (DEBUG)
System.out.println("Disabling scrollbar"); //$NON-NLS-1$
bar.setEnabled(false);
bar.setVisible(false);
bar.setSelection(0);
translate = 0;
}
}
示例6: setupScrollBar
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void setupScrollBar(ScrollBar sb, boolean visible, int ca, int b, int size) {
if (sb == null)
return;
sb.setVisible(visible);
if (!visible)
sb.setSelection(0);
else {
sb.setPageIncrement(ca - sb.getIncrement());
int max = b + size - ca;
sb.setMaximum(max);
sb.setThumb(size > max ? max : size);
}
}
示例7: updateScrollbar
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Setup the scrollbar based on the item counts specified. Note: This doesn't change the current selected position of the
* scrollbar.
*
* @param scrollBar
* the scrollbar to configure.
* @param viewportSize
* how many columns or rows are currently visible in the
* viewport.
* @param maximumSize
* the maximum number of columns or rows.
* @param lastPageSize
* the maximum number of columns or rows that currently fits onto
* the last page of the viewport. For rows, this is at the bottom
* of the grid, for columns this is over on the right).
*/
private void updateScrollbar(final ScrollBar scrollBar, final int viewportSize, final int maximumSize, final int lastPageSize, final int firstVisibleIndex, final int lastVisibleIndex, final boolean isLastCropped) {
//
// The scrollbar doesn't quite hold the total number of items. Because we want the last item to live at the bottom
// of the grid (for rows) or the right edge of the grid (for columns) rather than the top/left, we stop scrolling
// when the last item is in position.
//
final int cappedMax = maximumSize - (lastPageSize - 1);
//
// The scrollbar is only required, if there are items beyond either of the viewport edged.
//
final boolean firstScrolledOff = (firstVisibleIndex > 0); // The first row or column that's visible, ISN'T the first one, we need a scrollbar to be able to see it again.
final boolean lastScrolledOff = ((lastVisibleIndex + 1) < maximumSize); // The last row or column that's visible, ISN'T the last one.
final boolean visible = (firstScrolledOff || ((lastScrolledOff || (isLastCropped)) && (maximumSize > 1)));
scrollBar.setMaximum(cappedMax);
scrollBar.setThumb(1);
scrollBar.setPageIncrement(Math.min(viewportSize, cappedMax));
scrollBar.setIncrement(1);
scrollBar.setVisible(visible);
scrollBar.setEnabled(visible);
// System.out.println(String.format("[%s:%s] -> Scroll page [%s] visible-rows [%s] maximum-model [%s] maximum-bar [%s] last-page [%s] last-vis-idx [%s] last-cropped [%s] firstScrolledOff [%s] lastScrolledOff [%s] visible [%s]",
// getData("org.eclipse.swtbot.widget.key"),
// (scrollBar.getStyle() & SWT.VERTICAL) != 0 ? "VERTICAL" : "HORIZONTAL",
// scrollBar.getPageIncrement(),
// viewportSize,
// maximumSize,
// scrollBar.getMaximum(),
// lastPageSize,
// lastVisibleIndex,
// isLastCropped,
// firstScrolledOff,
// lastScrolledOff,
// visible));
}
示例8: updateScrollBarsPropertiesHorizontal
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Move the scrollbar to reflect the current visible items position.
*/
private void updateScrollBarsPropertiesHorizontal() {
final ScrollBar bar = getHorizontalBar();
if (bar == null) {
return;
}
final int areaWidth = _clientArea.width;
final int contentWidth = _contentVirtualWidthScrollbar;
bar.setMinimum(0);
bar.setMaximum(contentWidth);
bar.setPageIncrement(areaWidth);
bar.setThumb(areaWidth);
bar.setIncrement(16);
if (contentWidth > areaWidth) {
// show scrollbar
bar.setEnabled(true);
bar.setVisible(true);
bar.setSelection(_galleryPosition);
// Ensure that translate has a valid value.
validateGalleryPosition();
} else {
// hide scrollbar
bar.setEnabled(false);
bar.setVisible(false);
bar.setSelection(0);
_galleryPosition = 0;
}
}
示例9: updateScrollBarsPropertiesVertical
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Move the scrollbar to reflect the current visible items position.
*/
private void updateScrollBarsPropertiesVertical() {
final ScrollBar bar = getVerticalBar();
if (bar == null) {
return;
}
final int clientAreaSize = _clientArea.height;
final int contentSize = _contentVirtualHeight;
bar.setMinimum(0);
bar.setMaximum(contentSize);
bar.setPageIncrement(clientAreaSize);
bar.setThumb(clientAreaSize);
bar.setIncrement(16);
if (contentSize > clientAreaSize) {
// show scrollbar
bar.setEnabled(true);
bar.setVisible(true);
bar.setSelection(_galleryPosition);
// Ensure that translate has a valid value.
validateGalleryPosition();
} else {
// hide scrollbar
bar.setEnabled(false);
bar.setVisible(false);
bar.setSelection(0);
_galleryPosition = 0;
}
}
示例10: layout
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Our layout performs these jobs:
* 1. compute the width that is needed to display the amount of days in the plan
* 2. update the horizontal scroll bar to match the new width
* 3. resize the children to fit their contents
*/
@Override
protected void layout(Composite composite, boolean flushCache) {
if (inLayout) {
return;
}
DaysComposite sc = (DaysComposite)composite;
ScrollBar hBar = sc.getHorizontalBar();
int compositeHeight = sc.getSize().y;
int scrollBarHeight = hBar.getSize().y;
if (scrollBarHeight >= compositeHeight) {
// the view is so short that only the horizontal bar can be seen
return;
}
try {
inLayout = true;
int childHeight = compositeHeight - scrollBarHeight;
int clientWidth = sc.getClientArea().width;
int contentWidth;
int childWidth = DEFAULT_WIDTH;
Control[] children = composite.getChildren();
if (children.length == 0) {
contentWidth = clientWidth;
} else {
Control representative = children[0];
Point size = representative.computeSize(SWT.DEFAULT, childHeight, flushCache);
childWidth = size.x;
contentWidth = Math.max(dayCount * childWidth, clientWidth);
}
hBar.setMaximum (contentWidth);
hBar.setThumb (Math.min (contentWidth, clientWidth));
for (Control child : children) {
child.setSize(childWidth, childHeight);
}
} finally {
inLayout = false;
}
}
示例11: recalcScrollBars
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Calculates the extends and visibility of horizontal and vertical
* scroll bars.
*/
void recalcScrollBars() {
ScrollBar hScrollBar = getHorizontalBar();
ScrollBar vScrollBar = getVerticalBar();
// If either horizontal or vertical scrolling is enabled
if ((hScrollBar != null) || (vScrollBar != null)) {
// Compute default size of control
Point size = computeSize(SWT.DEFAULT, SWT.DEFAULT);
// Get the visible client area
Rectangle clientArea = getClientArea();
if (hScrollBar != null) {
// Show horizontal scroll bar if content does not fit horizontally
hScrollBar.setVisible(size.x > clientArea.width);
// Set the maximum horizontal scroll to be the default width of
// control minus what will show in the client area.
hScrollBar.setMaximum(size.x);
hScrollBar.setThumb(clientArea.width);
hScrollBar.setPageIncrement(clientArea.width);
}
if (vScrollBar != null) {
// Show vertical scroll bar if content does not fit vertically
vScrollBar.setVisible(size.y > clientArea.height);
// Set the maximum vertical scroll to be the default height of
// control minus what will show in the client area.
vScrollBar.setMaximum(size.y);
vScrollBar.setIncrement(verticalScrollIncrement);
vScrollBar.setThumb(clientArea.height);
vScrollBar.setPageIncrement(clientArea.height);
}
}
}
示例12: setContent
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Set the content that will be scrolled.
*
* @param content
* the control to be displayed in the content area
*
* @exception SWTException
* <ul>
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been
* disposed</li>
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
* thread that created the receiver</li>
* </ul>
*/
public void setContent(Control content) {
checkWidget();
if (this.content != null && !this.content.isDisposed()) {
this.content.removeListener(SWT.Resize, contentListener);
this.content.setBounds(new Rectangle(-200, -200, 0, 0));
}
this.content = content;
ScrollBar vBar = getVerticalBar();
ScrollBar hBar = getHorizontalBar();
if (this.content != null) {
if (vBar != null) {
vBar.setMaximum(0);
vBar.setThumb(0);
vBar.setSelection(0);
}
if (hBar != null) {
hBar.setMaximum(0);
hBar.setThumb(0);
hBar.setSelection(0);
}
content.setLocation(0, 0);
layout(false);
this.content.addListener(SWT.Resize, contentListener);
} else {
if (hBar != null)
hBar.setVisible(alwaysShowScroll);
if (vBar != null)
vBar.setVisible(alwaysShowScroll);
}
}
示例13: updateScroll
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
protected void updateScroll(){
ScrollBar vBar = this.previewComposite.getVerticalBar();
Rectangle client = this.pageComposite.getClientArea();
vBar.setMaximum(Math.round(this.bounds.getHeight() - this.bounds.getY()) + (MARGIN_TOP + MARGIN_BOTTOM));
vBar.setThumb(Math.min(Math.round(this.bounds.getHeight() - this.bounds.getY()) + (MARGIN_TOP + MARGIN_BOTTOM), client.height));
}
示例14: syncScrollBars
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
* Synchronize the scrollbar with the image. If the transform is out
* of range, it will correct it. This function considers only following
* factors :<b> transform, image size, client area</b>.
*/
public void syncScrollBars() {
if (sourceImage == null) {
redraw();
return;
}
AffineTransform af = transform;
double sx = af.getScaleX(), sy = af.getScaleY();
double tx = af.getTranslateX(), ty = af.getTranslateY();
if (tx > 0) tx = 0;
if (ty > 0) ty = 0;
ScrollBar horizontal = getHorizontalBar();
horizontal.setIncrement(getClientArea().width / 100);
horizontal.setPageIncrement(getClientArea().width);
Rectangle imageBound = sourceImage.getBounds();
int cw = getClientArea().width, ch = getClientArea().height;
if (imageBound.width * sx > cw) { /* image is wider than client area */
horizontal.setMaximum((int) (imageBound.width * sx));
horizontal.setEnabled(true);
if (((int) - tx) > horizontal.getMaximum() - cw)
tx = -horizontal.getMaximum() + cw;
} else { /* image is narrower than client area */
horizontal.setEnabled(false);
tx = (cw - imageBound.width * sx) / 2; //center if too small.
}
horizontal.setSelection((int) (-tx));
horizontal.setThumb((getClientArea().width));
ScrollBar vertical = getVerticalBar();
vertical.setIncrement(getClientArea().height / 100);
vertical.setPageIncrement((getClientArea().height));
if (imageBound.height * sy > ch) { /* image is higher than client area */
vertical.setMaximum((int) (imageBound.height * sy));
vertical.setEnabled(true);
if (((int) - ty) > vertical.getMaximum() - ch)
ty = -vertical.getMaximum() + ch;
} else { /* image is less higher than client area */
vertical.setEnabled(false);
ty = (ch - imageBound.height * sy) / 2; //center if too small.
}
vertical.setSelection((int) (-ty));
vertical.setThumb((getClientArea().height));
/* update transform. */
af = AffineTransform.getScaleInstance(sx, sy);
af.preConcatenate(AffineTransform.getTranslateInstance(tx, ty));
transform = af;
redraw();
}
示例15: disableScrollBar
import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void disableScrollBar(ScrollBar scrollBar) {
scrollBar.setMinimum(0);
scrollBar.setMaximum(1);
scrollBar.setThumb(1);
scrollBar.setEnabled(false);
}