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


Java ScrollBar.getSelection方法代碼示例

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


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

示例1: scrollHorizontally

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
void scrollHorizontally(ScrollBar scrollBar) {
	if (image == null) {
		return;
	}
	Rectangle canvasBounds = imageCanvas.getClientArea();
	int width = Math.round(imageData.width * xscale);
	int height = Math.round(imageData.height * yscale);
	if (width > canvasBounds.width) {
		// Only scroll if the image is bigger than the canvas.
		int x = -scrollBar.getSelection();
		if (x + width < canvasBounds.width) {
			// Don't scroll past the end of the image.
			x = canvasBounds.width - width;
		}
		imageCanvas.scroll(x, iy, ix, iy, width, height, false);
		ix = x;
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:19,代碼來源:ImageAnalyzer.java

示例2: scrollVertically

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
void scrollVertically(ScrollBar scrollBar) {
	if (image == null) {
		return;
	}
	Rectangle canvasBounds = imageCanvas.getClientArea();
	int width = Math.round(imageData.width * xscale);
	int height = Math.round(imageData.height * yscale);
	if (height > canvasBounds.height) {
		// Only scroll if the image is bigger than the canvas.
		int y = -scrollBar.getSelection();
		if (y + height < canvasBounds.height) {
			// Don't scroll past the end of the image.
			y = canvasBounds.height - height;
		}
		imageCanvas.scroll(ix, y, ix, iy, width, height, false);
		iy = y;
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:19,代碼來源:ImageAnalyzer.java

示例3: smartScroll

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
protected void smartScroll(boolean force) {
	ScrollBar scrollbar = chatConsole.inputText.getVerticalBar();
	if (scrollbar != null
			&& scrollbar.isVisible()
			&& getPreferences().getBoolean(
					PreferenceKeys.CHAT_IS_SMART_SCROLL_ENABLED)) {

		if (force) {
			setAutoScrolling(true);
		}
		else if (scrollbar.getMaximum() == scrollbar.getSelection()
				+ scrollbar.getThumb()) {
			setAutoScrolling(true);
		} else {
			setAutoScrolling(false);
		}
	}
}
 
開發者ID:evilwan,項目名稱:raptor-chess-interface,代碼行數:19,代碼來源:ChatConsoleController.java

示例4: pageUp

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void pageUp() {
	//
	// Ensure there's an anchor.
	//
	ensureAnchorSet();
	
	//
	// Move the scrollbar down one page.
	//
	final ScrollBar verticalBar = grid.getVerticalBar();
	verticalBar.setSelection(Math.max(verticalBar.getSelection() - verticalBar.getPageIncrement(), verticalBar.getMinimum()));
	
	//
	// Cause a repaint.
	//
	gridModel.fireChangeEvent();
	
	//
	// Move the anchor to the new page.
	//
	if (verticalBar.getSelection() != verticalBar.getMaximum()) {
		final Row<T> row = gridModel.getRows().get(grid.getViewport().getFirstRowIndex());
		gridModel.getSelectionModel().setAnchorElement(row.getElement());
	}
}
 
開發者ID:GrandmasterTash,項目名稱:jGrid,代碼行數:26,代碼來源:GridKeyboardHandler.java

示例5: pageDown

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void pageDown() {
	//
	// Ensure there's an anchor.
	//
	ensureAnchorSet();
	
	//
	// Move the scrollbar down one page.
	//
	final ScrollBar verticalBar = grid.getVerticalBar();
	verticalBar.setSelection(Math.min(verticalBar.getSelection() + verticalBar.getPageIncrement(), verticalBar.getMaximum()));
	
	//
	// Cause a repaint.
	//
	gridModel.fireChangeEvent();
	
	//
	// Move the anchor to the new page.
	//
	if (verticalBar.getSelection() != verticalBar.getMaximum()) {
		final Row<T> row = gridModel.getRows().get(grid.getViewport().getFirstRowIndex());
		gridModel.getSelectionModel().setAnchorElement(row.getElement());
	}
}
 
開發者ID:GrandmasterTash,項目名稱:jGrid,代碼行數:26,代碼來源:GridKeyboardHandler.java

示例6: paintTablature

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public void paintTablature(TGPainter painter){
	this.setPainting(true);
	try{
		this.checkScroll();
		
		int oldWidth = this.width;
		int oldHeight = this.height;
		
		TGRectangle area = createRectangle(getClientArea());
		ScrollBar xScroll = getHorizontalBar();
		ScrollBar yScroll = getVerticalBar();
		this.scrollX = xScroll.getSelection();
		this.scrollY = yScroll.getSelection();
		
		this.tablature.paintTablature(painter, area, -this.scrollX, -this.scrollY);
		
		this.width = Math.round(this.tablature.getViewLayout().getWidth());
		this.height = Math.round(this.tablature.getViewLayout().getHeight());
		
		this.updateScroll();
		
		if( MidiPlayer.getInstance(this.context).isRunning()){
			this.redrawPlayingMode(painter,true);
		}
		// Si no estoy reproduciendo y hay cambios
		// muevo el scroll al compas que tiene el caret
		else if(this.tablature.getCaret().hasChanges() || (this.width != oldWidth || this.height != oldHeight)){
			// Mover el scroll puede necesitar redibujar
			// por eso es importante desmarcar los cambios antes de hacer el moveScrollTo
			this.tablature.getCaret().setChanges(false);
			
			this.moveScrollTo(this.tablature.getCaret().getMeasure(), xScroll, yScroll, area);
		}
	}catch(Throwable throwable){
		throwable.printStackTrace();
	}
	this.setPainting(false);
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:39,代碼來源:TGControl.java

示例7: moveScrollTo

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public boolean moveScrollTo(TGMeasureImpl measure,ScrollBar xScroll,ScrollBar yScroll,TGRectangle area){
	boolean success = false;
	if( measure != null && measure.getTs() != null ){
		int mX = Math.round(measure.getPosX());
		int mY = Math.round(measure.getPosY());
		int mWidth = Math.round(measure.getWidth(this.tablature.getViewLayout()));
		int mHeight = Math.round(measure.getTs().getSize());
		int marginWidth = Math.round(this.tablature.getViewLayout().getFirstMeasureSpacing());
		int marginHeight = Math.round(this.tablature.getViewLayout().getFirstTrackSpacing());
		boolean forceRedraw = false;
		
		//Solo se ajusta si es necesario
		//si el largo del compas es mayor al de la pantalla. nunca se puede ajustar a la medida.
		if( mX < 0 || ( (mX + mWidth ) > area.getWidth() && (area.getWidth() >= mWidth + marginWidth || mX > marginWidth) ) ){
			xScroll.setSelection((this.scrollX + mX) - marginWidth );
			success = true;
		}
		
		//Solo se ajusta si es necesario
		//si el alto del compas es mayor al de la pantalla. nunca se puede ajustar a la medida.
		if( mY < 0 || ( (mY + mHeight ) > area.getHeight() && (area.getHeight() >= mHeight + marginHeight || mY > marginHeight) ) ){
			yScroll.setSelection( (this.scrollY + mY)  - marginHeight );
			success = true;
		}
		
		if(!success){
			// Si la seleccion "real" del scroll es distinta a la anterior, se fuerza el redraw
			forceRedraw = (this.scrollX != xScroll.getSelection() || this.scrollY != yScroll.getSelection());
		}
		
		if(forceRedraw || success){
			redraw();
		}
	}
	return success;
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:37,代碼來源:TGControl.java

示例8: scrollHorizontally

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void scrollHorizontally(ScrollBar scrollBar) {
	if (sourceImage == null)
		return;

	AffineTransform af = transform;
	double tx = af.getTranslateX();
	double select = -scrollBar.getSelection();
	af.preConcatenate(AffineTransform.getTranslateInstance(select - tx, 0));
	transform = af;
	syncScrollBars();
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:12,代碼來源:SWTImageCanvas.java

示例9: scrollVertically

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
private void scrollVertically(ScrollBar scrollBar) {
	if (sourceImage == null)
		return;

	AffineTransform af = transform;
	double ty = af.getTranslateY();
	double select = -scrollBar.getSelection();
	af.preConcatenate(AffineTransform.getTranslateInstance(0, select - ty));
	transform = af;
	syncScrollBars();
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:12,代碼來源:SWTImageCanvas.java

示例10: addToLog

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/**
 * Adds an {@link EventContainer} to the log. Only add the values/occurrences defined by
 * the list of descriptors. If an event is configured to be displayed by value and occurrence,
 * only the values are displayed (as they mark an event occurrence anyway).
 * <p/>This method is only called when at least one of the descriptor list is non empty.
 *
 * @param event
 * @param logParser
 * @param valueDescriptors
 * @param occurrenceDescriptors
 */
protected void addToLog(EventContainer event, EventLogParser logParser,
        ArrayList<ValueDisplayDescriptor> valueDescriptors,
        ArrayList<OccurrenceDisplayDescriptor> occurrenceDescriptors) {
    ScrollBar bar = mLogTable.getVerticalBar();
    boolean scroll = bar.getMaximum() == bar.getSelection() + bar.getThumb();

    // get the date.
    Calendar c = Calendar.getInstance();
    long msec = event.sec * 1000L;
    c.setTimeInMillis(msec);

    // convert the time into a string
    String date = String.format("%1$tF %1$tT", c);

    String eventName = logParser.getTagMap().get(event.mTag);
    String pidName = Integer.toString(event.pid);

    if (valueDescriptors.size() > 0) {
        for (ValueDisplayDescriptor descriptor : valueDescriptors) {
            logDescriptor(event, descriptor, date, pidName, eventName, logParser);
        }
    } else {
        // we display the event. Since the StringBuilder contains the header (date, event name,
        // pid) at this point, there isn't anything else to display.
    }

    // scroll if needed, by showing the last item
    if (scroll) {
        int itemCount = mLogTable.getItemCount();
        if (itemCount > 0) {
            mLogTable.showItem(mLogTable.getItem(itemCount - 1));
        }
    }
}
 
開發者ID:utds3lab,項目名稱:SMVHunter,代碼行數:46,代碼來源:DisplayLog.java

示例11: update

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
/***************************************************************************
 * Update this dialog
 **************************************************************************/
public void update()
{
	m_items.getTable().deselectAll();
	m_items.refresh(true);
	// Show the last item
	ScrollBar vertical = m_items.getTable().getVerticalBar();
	int maximum = vertical.getMaximum();
	int thumb = vertical.getThumb();
	int current = vertical.getSelection();
	if (current >= maximum - thumb)
	{
		m_items.reveal(m_items.getElementAt(m_items.getTable().getItemCount() - 1));
	}
}
 
開發者ID:Spacecraft-Code,項目名稱:SPELL,代碼行數:18,代碼來源:ItemInfoDialog.java

示例12: handleEvent

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public void handleEvent(Event event) {
	// Remove standard behavior
	event.doit = false;

	// Get scrollbar on which the event occurred.
	ScrollBar currentScrollBar = getScrollbar(event);

	int start = currentScrollBar.getSelection();
	int end = start;

	// If an effect is currently running, get the current and target
	// values.
	IEffect current = animationRunner.getEffect();
	if (current instanceof MoveScrollBarEffect) {
		MoveScrollBarEffect mseffect = (MoveScrollBarEffect) current;
		start = mseffect.getCurrent();
		end = mseffect.getEnd();
	}

	end -= event.count * currentScrollBar.getIncrement();

	if (end > currentScrollBar.getMaximum()
			- currentScrollBar.getThumb()) {
		end = currentScrollBar.getMaximum()
				- currentScrollBar.getThumb();
	}

	if (end < currentScrollBar.getMinimum()) {
		end = currentScrollBar.getMinimum();
	}

	animationRunner.runEffect(new MoveScrollBarEffect(currentScrollBar,
			start, end, duration, movement, null, null));

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

示例13: scrollVertical

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
protected void scrollVertical() {
	int areaHeight = getClientArea().height;

	if (gHeight > areaHeight) {
		// image is higher than client area
		ScrollBar bar = getVerticalBar();
		scroll(0, translate - bar.getSelection(), 0, 0,
				getClientArea().width, areaHeight, false);
		translate = bar.getSelection();
	} else {
		translate = 0;
	}
}
 
開發者ID:OpenSoftwareSolutions,項目名稱:PDFReporter-Studio,代碼行數:14,代碼來源:Gallery.java

示例14: scrollHorizontal

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
protected void scrollHorizontal() {

		int areaWidth = getClientArea().width;
		if (gWidth > areaWidth) {
			// image is higher than client area
			ScrollBar bar = getHorizontalBar();
			scroll(translate - bar.getSelection(), 0, 0, 0, areaWidth,
					getClientArea().height, false);
			translate = bar.getSelection();
		} else {
			translate = 0;
		}

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

示例15: onScroll

import org.eclipse.swt.widgets.ScrollBar; //導入方法依賴的package包/類
public void onScroll(final Event event) {
	final ScrollBar verticalBar = getVerticalBar();
	if (verticalBar != null) {
		yCurrentScroll = verticalBar.getSelection();
		layoutItems(0, false);
	}
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:8,代碼來源:ParameterExpandBar.java


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