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


Java ScrollBar.setVisible方法代碼示例

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


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

示例1: setScrollbar

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
void setScrollbar() {
	if (itemCount == 0) { return; }
	final ScrollBar verticalBar = getVerticalBar();
	if (verticalBar == null) { return; }
	final int height = getClientArea().height;
	final ParameterExpandItem item = items[itemCount - 1];
	int maxHeight = item.y + bandHeight + spacing;
	if (item.expanded) {
		maxHeight += item.height;
	}

	// claim bottom free space
	if (yCurrentScroll > 0 && height > maxHeight) {
		yCurrentScroll = Math.max(0, yCurrentScroll + maxHeight - height);
		layoutItems(0, false);
	}
	maxHeight += yCurrentScroll;

	final int selection = Math.min(yCurrentScroll, maxHeight);
	final int increment = verticalBar.getIncrement();
	final int pageIncrement = verticalBar.getPageIncrement();
	verticalBar.setValues(selection, 0, maxHeight, height, increment, pageIncrement);
	verticalBar.setVisible(maxHeight > height);
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:25,代碼來源:ParameterExpandBar.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: 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);
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:14,代碼來源:ViewerCanvas.java

示例4: 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

示例5: setVertical

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public void setVertical(final boolean isVerticalGallery) {

		_isVertical = isVerticalGallery;
		_isHorizontal = !isVerticalGallery;

		if (isVerticalGallery) {

			// gallery is vertical

			final ScrollBar hBar = getHorizontalBar();
			if (hBar != null) {
				hBar.setVisible(false);
			}

			// reset to the last vertical width

			_itemWidth = _verticalItemWidth;
			_itemHeight = (int) (_itemWidth / _itemRatio);

		} else {

			// gallery is horizontal

			final ScrollBar vBar = getVerticalBar();
			if (vBar != null) {
				vBar.setVisible(false);
			}
		}

		// this will also set horizontal image height
		onResize();
	}
 
開發者ID:wolfgang-ch,項目名稱:mytourbook,代碼行數:33,代碼來源:GalleryMT20.java

示例6: 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

示例7: 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

示例8: 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);
		}
	}
}
 
開發者ID:MentorEmbedded,項目名稱:p2-installer,代碼行數:38,代碼來源:DetailTree.java

示例9: 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);
	}
}
 
開發者ID:ghillairet,項目名稱:gef-gwt,代碼行數:46,代碼來源:ScrolledComposite.java

示例10: DayViewer

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public DayViewer(Composite parent, TreeTableColumnConfiguration configuration, final DayColumnProvider dayColumnProvider, IWorkbenchPartSite site) {
	composite = new DayComposite(parent, configuration);
	composite.addMouseAdapter(mouseAdapter);

	TreeTableComposite treeTableComposite = composite.getTreeTableComposite();
	final ScrollBar vBar = treeTableComposite.getTree().getVerticalBar();
	if (vBar != null) {
		vBar.setVisible(true);
	}
	treeTableViewer = new MergeTreeViewer(treeTableComposite, configuration, site) {

		private boolean initialized = false;
		
		@Override
		protected void inputChanged(Object input, Object oldInput) {
			initialized = false;
			super.inputChanged(input, oldInput);
			initialized = true;
		}
		
		@Override
		protected void createChildren(Widget widget) {
			if (initialized && (widget instanceof Tree)) {
				// SPF-11700 -- avoid repeated attempts to create the children of an empty tree
				return;
			}
			super.createChildren(widget);
		}

		@Override
		protected ViewerComparator getDefaultViewerComparator() {
			return DayDefaultViewerComparator.INSTANCE;
		}

		@Override
		public Comparator getDefaultComparator() {
			return DayDefaultComparator.INSTANCE;
		}
		
		@Override
		protected ViewerComparator getColumnComparator(ITreeTableColumn treeTableColumn, int sortDirection) {
			return new DayColumnComparator(treeTableColumn, sortDirection == SWT.UP);
		}
		
	};
	contentProvider = new DayContentProvider();
	treeTableViewer.setContentProvider(contentProvider);
	treeTableViewer.setLabelProvider(new DayLabelProvider());
	try {
		treeTableViewer.addFilter(dayFilter);
	} catch (Exception e) {
		LogUtil.error("failed to add the day filter", e);
	}
	totalViewer = new MergeTotalViewer(composite.getTotalComposite());
	composite.pack();
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:57,代碼來源:DayViewer.java

示例11: layout

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
protected void layout(Composite composite, boolean flushCache) {
	if (inLayout)
		return;
	ScrolledComposite sc = (ScrolledComposite) composite;
	if (sc.content == null)
		return;
	ScrollBar hBar = sc.getHorizontalBar();
	ScrollBar vBar = sc.getVerticalBar();
	if (hBar != null) {
		if (hBar.getSize().y >= sc.getSize().y) {
			return;
		}
	}
	if (vBar != null) {
		if (vBar.getSize().x >= sc.getSize().x) {
			return;
		}
	}
	inLayout = true;
	Rectangle contentRect = sc.content.getBounds();
	if (!sc.alwaysShowScroll) {
		boolean hVisible = sc.needHScroll(contentRect, false);
		boolean vVisible = sc.needVScroll(contentRect, hVisible);
		if (!hVisible && vVisible)
			hVisible = sc.needHScroll(contentRect, vVisible);
		if (hBar != null)
			hBar.setVisible(hVisible);
		if (vBar != null)
			vBar.setVisible(vVisible);
	}
	Rectangle hostRect = sc.getClientArea();
	if (sc.expandHorizontal) {
		contentRect.width = Math.max(sc.minWidth, hostRect.width);
	}
	if (sc.expandVertical) {
		contentRect.height = Math.max(sc.minHeight, hostRect.height);
	}

	if (hBar != null) {
		hBar.setMaximum(contentRect.width);
		hBar.setThumb(Math.min(contentRect.width, hostRect.width));
		int hPage = contentRect.width - hostRect.width;
		int hSelection = hBar.getSelection();
		if (hSelection >= hPage) {
			if (hPage <= 0) {
				hSelection = 0;
				hBar.setSelection(0);
			}
			contentRect.x = -hSelection;
		}
	}

	if (vBar != null) {
		vBar.setMaximum(contentRect.height);
		vBar.setThumb(Math.min(contentRect.height, hostRect.height));
		int vPage = contentRect.height - hostRect.height;
		int vSelection = vBar.getSelection();
		if (vSelection >= vPage) {
			if (vPage <= 0) {
				vSelection = 0;
				vBar.setSelection(0);
			}
			contentRect.y = -vSelection;
		}
	}

	sc.content.setBounds(contentRect);
	inLayout = false;
}
 
開發者ID:ghillairet,項目名稱:gef-gwt,代碼行數:70,代碼來源:ScrolledCompositeLayout.java


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