當前位置: 首頁>>代碼示例>>Java>>正文


Java ScrollBar.setEnabled方法代碼示例

本文整理匯總了Java中org.eclipse.swt.widgets.ScrollBar.setEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java ScrollBar.setEnabled方法的具體用法?Java ScrollBar.setEnabled怎麽用?Java ScrollBar.setEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.widgets.ScrollBar的用法示例。


在下文中一共展示了ScrollBar.setEnabled方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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();
		}
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:41,代碼來源:ImageAnalyzer.java

示例2: 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;
	}

}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:46,代碼來源:Gallery.java

示例3: 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));
	}
 
開發者ID:GrandmasterTash,項目名稱:jGrid,代碼行數:53,代碼來源:Grid.java

示例4: 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;
	}
}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:43,代碼來源:GalleryMT20.java

示例5: 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;
	}
}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:42,代碼來源:GalleryMT20.java

示例6: 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();
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:57,代碼來源:SWTImageCanvas.java

示例7: 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);
}
 
開發者ID:heartsome,項目名稱:translationstudio8,代碼行數:7,代碼來源:NatTable.java

示例8: syncScrollBars

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
 * SYNC the scroll-bars with the image.
 */
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;

	Rectangle imageBound = sourceImage.getBounds( );
	int cw = getClientArea( ).width, ch = getClientArea( ).height;

	ScrollBar horizontal = getHorizontalBar( );

	if ( horizontal != null )
	{
		horizontal.setIncrement( ( getClientArea( ).width / 100 ) );
		horizontal.setPageIncrement( getClientArea( ).width );

		if ( imageBound.width * sx > cw )
		{
			horizontal.setMaximum( (int) ( imageBound.width * sx ) );
			horizontal.setEnabled( true );
			if ( ( (int) -tx ) > horizontal.getMaximum( ) - cw )
				tx = -horizontal.getMaximum( ) + cw;
		}
		else
		{
			horizontal.setEnabled( false );
			tx = ( cw - imageBound.width * sx ) / 2;
		}
		horizontal.setSelection( (int) ( -tx ) );
		horizontal.setThumb( ( getClientArea( ).width ) );
	}
	ScrollBar vertical = getVerticalBar( );
	if ( vertical != null )
	{
		vertical.setIncrement( ( getClientArea( ).height / 100 ) );
		vertical.setPageIncrement( ( getClientArea( ).height ) );
		if ( imageBound.height * sy > ch )
		{
			vertical.setMaximum( (int) ( imageBound.height * sy ) );
			vertical.setEnabled( true );
			if ( ( (int) -ty ) > vertical.getMaximum( ) - ch )
				ty = -vertical.getMaximum( ) + ch;
		}
		else
		{
			vertical.setEnabled( false );
			ty = ( ch - imageBound.height * sy ) / 2;
		}
		vertical.setSelection( (int) ( -ty ) );
		vertical.setThumb( ( getClientArea( ).height ) );
	}

	af = AffineTransform.getScaleInstance( sx, sy );
	af.preConcatenate( AffineTransform.getTranslateInstance( tx, ty ) );
	transform = af;

	redraw( );
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:72,代碼來源:IconCanvas.java

示例9: syncScrollBars

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
 * SYNC the scroll-bars with the image.
 */
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;

	Rectangle imageBound = sourceImage.getBounds( );
	int cw = getClientArea( ).width, ch = getClientArea( ).height;

	ScrollBar horizontal = getHorizontalBar( );

	if ( horizontal != null )
	{
		horizontal.setIncrement( (int) ( getClientArea( ).width / 100 ) );
		horizontal.setPageIncrement( getClientArea( ).width );

		if ( imageBound.width * sx > cw )
		{
			horizontal.setMaximum( (int) ( imageBound.width * sx ) );
			horizontal.setEnabled( true );
			if ( ( (int) -tx ) > horizontal.getMaximum( ) - cw )
				tx = -horizontal.getMaximum( ) + cw;
		}
		else
		{
			horizontal.setEnabled( false );
			tx = ( cw - imageBound.width * sx ) / 2;
		}
		horizontal.setSelection( (int) ( -tx ) );
		horizontal.setThumb( (int) ( getClientArea( ).width ) );
	}
	ScrollBar vertical = getVerticalBar( );
	if ( vertical != null )
	{
		vertical.setIncrement( (int) ( getClientArea( ).height / 100 ) );
		vertical.setPageIncrement( (int) ( getClientArea( ).height ) );
		if ( imageBound.height * sy > ch )
		{
			vertical.setMaximum( (int) ( imageBound.height * sy ) );
			vertical.setEnabled( true );
			if ( ( (int) -ty ) > vertical.getMaximum( ) - ch )
				ty = -vertical.getMaximum( ) + ch;
		}
		else
		{
			vertical.setEnabled( false );
			ty = ( ch - imageBound.height * sy ) / 2;
		}
		vertical.setSelection( (int) ( -ty ) );
		vertical.setThumb( (int) ( getClientArea( ).height ) );
	}

	af = AffineTransform.getScaleInstance( sx, sy );
	af.preConcatenate( AffineTransform.getTranslateInstance( tx, ty ) );
	transform = af;

	redraw( );
}
 
開發者ID:eclipse,項目名稱:birt,代碼行數:72,代碼來源:ImageCanvas.java


注:本文中的org.eclipse.swt.widgets.ScrollBar.setEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。