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


Java BoundedRangeModel.getMinimum方法代碼示例

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


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

示例1: updateScrollBarValueFromMouseLocation

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * Updaates the scrollbar model based on the given mouse location.
 */
private void updateScrollBarValueFromMouseLocation(int mouseLocation) {
    // most of the below logic was lifted from BasicScrollBarUI. the logic here has been
    // greatly simplified here through the use of the ScrollBarOrientation.

    BoundedRangeModel model = scrollbar.getModel();
    Rectangle thumbBounds = getThumbBounds();
    Rectangle trackBounds = getTrackBounds();

    // calculate what the value of the scrollbar should be.
    int minimumPossibleThumbPosition = fOrientation.getPosition(trackBounds.getLocation());
    int maximumPossibleThumbPosition = getMaximumPossibleThumbPosition(trackBounds, thumbBounds);
    int actualThumbPosition = Math.min(maximumPossibleThumbPosition,
            Math.max(minimumPossibleThumbPosition, mouseLocation));

    // calculate the new value for the scroll bar (the top of the scroll thumb) based
    // on the dragged location.
    float valueMax = model.getMaximum() - model.getExtent();
    float valueRange = valueMax - model.getMinimum();
    float thumbValue = actualThumbPosition - minimumPossibleThumbPosition;
    float thumbRange = maximumPossibleThumbPosition - minimumPossibleThumbPosition;
    int value = (int) Math.ceil((thumbValue / thumbRange) * valueRange);

    scrollbar.setValue(value + model.getMinimum());
}
 
開發者ID:mathieulegoc,項目名稱:SmartTokens,代碼行數:28,代碼來源:SkinnableScrollBarUI.java

示例2: calculateThumbBounds

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
void calculateThumbBounds(final BoundedRangeModel model) {
    int extent = model.getExtent();
    int viewSize = model.getMaximum() - model.getMinimum();
    if (viewSize == 0) {
        setThumbBounds(0, 0, 0, 0);
        return;
    }
    int proposedThumbSize = (int)((float)getTrackSize() * extent / viewSize);
    int thumbSize = getThumbSize(proposedThumbSize);
    int availableTrackSize = getTrackSize() - thumbSize;
    if (availableTrackSize <= 0) {
        if (proposedThumbSize == thumbSize) {
            Rectangle trackBounds = getTrackBounds();
            setThumbBounds(trackBounds.x, trackBounds.y, trackBounds.width, trackBounds.height);
        } else {
            setThumbBounds(0, 0, 0, 0);
        }
    } else {
        int availableScrollingSize = viewSize - extent;
        int offset = (availableScrollingSize > 0 ? availableTrackSize * model.getValue() / availableScrollingSize : 0) + getButtonSize(decrButton);
        Rectangle newThumbBounds = newThumbBounds(offset, thumbSize);
        setThumbBounds(newThumbBounds.x, newThumbBounds.y, newThumbBounds.width, newThumbBounds.height);
        trackListener.offset = offset;
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:BasicScrollBarUI.java

示例3: copy

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
private DefaultBoundedRangeModel copy (BoundedRangeModel m)
{
    return new DefaultBoundedRangeModel(
            m.getValue(),
            m.getExtent(),
            m.getMinimum(),
            m.getMaximum());
}
 
開發者ID:Audiveris,項目名稱:audiveris,代碼行數:9,代碼來源:SheetAssembly.java

示例4: setValueOnDragging

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
void setValueOnDragging(final MouseEvent e, final int currentMouseX, final int currentMouseY, final int initialModelValue) {
    BoundedRangeModel model = scrollbar.getModel();
    int extent = model.getExtent();
    int viewSize = model.getMaximum() - model.getMinimum();
    int availableScrollingSize = viewSize - extent;
    int thumbSize = getThumbSize(Math.round(getTrackSize() * extent / viewSize));
    int availableTrackSize = getTrackSize() - thumbSize;
    int offset = getOffset(e, currentMouseX, currentMouseY);
    int modelIncrement = availableTrackSize != 0 ? offset * availableScrollingSize / availableTrackSize : 0;
    model.setValue(initialModelValue + modelIncrement);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:12,代碼來源:BasicScrollBarUI.java

示例5: getMoveCameraToPoint

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
public static Point getMoveCameraToPoint(final ClassView cv, final double zoom, final JScrollPane pane) {
	final Point2D centre = cv.getCentre();
	final JScrollBar vertSB  = pane.getVerticalScrollBar();
	final JScrollBar horizSB = pane.getHorizontalScrollBar();
	Point pt = new Point();
	
	BoundedRangeModel model = vertSB.getModel();
	int value	= model.getValue();
	final int cy 	= pane.getHeight()/2 + value;
	int newValue 	= value+(int)(centre.getY()*zoom)-cy;

	if(newValue>model.getMaximum())
		newValue = model.getMaximum();
	else if(newValue<model.getMinimum())
		newValue = model.getMinimum();

	pt.y = newValue;

	model = horizSB.getModel();
	value	= model.getValue();
	final int cx 	= pane.getWidth()/2 + value;
	newValue 	= value+(int)(centre.getX()*zoom)-cx;

	if(newValue>model.getMaximum())
		newValue = model.getMaximum();
	else if(newValue<model.getMinimum())
		newValue = model.getMinimum();
	
	pt.x = newValue;
	
	return pt;
}
 
開發者ID:arnobl,項目名稱:kompren,代碼行數:33,代碼來源:Completioner.java

示例6: mouseWheelMoved

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
@Override
public void mouseWheelMoved(MouseWheelEvent e) {

	int valueTime = 0;
	BoundedRangeModel timeModel = null;

	Object source = e.getSource();
	if (!(source instanceof SignalPlot)) {
		return;
	}

	// prevent from conflicting with tools
	if (signalView.isToolEngaged()) {
		return;
	}

	SignalPlot plot = (SignalPlot) source;

	int rotation = -e.getWheelRotation();

	if (timeEnabled) {

		timeModel = plot.getTimeScaleRangeModel();

		valueTime = timeModel.getValue();

		int maxTime = timeModel.getMaximum();
		int minTime = timeModel.getMinimum();
		float stepTime = (maxTime - minTime) / 20F;
		valueTime = valueTime + (int)(stepTime*rotation);
		valueTime = Math.max(minTime, Math.min(maxTime, valueTime));

	}

	BoundedRangeModel channelModel = plot.getChannelHeightRangeModel();
	int valueChannel = channelModel.getValue();

	int maxChannel = channelModel.getMaximum();
	int minChannel = channelModel.getMinimum();
	float stepChannel = (maxChannel - minChannel) / 20F;
	valueChannel = valueChannel + (int)(stepChannel*rotation);
	valueChannel = Math.max(minChannel, Math.min(maxChannel, valueChannel));

	JViewport viewport = plot.getViewport();

	Point viewportPoint = viewport.getViewPosition();
	Dimension viewportSize = viewport.getExtentSize();
	Point p = e.getPoint();
	Point2D.Float p2 = plot.toSignalSpace(p);

	// suppress centerpoint compensation in order to compensate around mouse pointer
	plot.setCompensationEnabled(false);

	try {
		if (timeEnabled) {
			timeModel.setValue(valueTime);
		}
		channelModel.setValue(valueChannel);

		// viewport needs to be validated after change, so that getSize returns a valid value
		viewport.validate();
		Dimension plotSize = plot.getSize();

		Point newP = plot.toPixelSpace(p2);
		newP.x = newP.x - (p.x - viewportPoint.x);
		newP.y = newP.y - (p.y - viewportPoint.y);

		newP.x = Math.max(0, Math.min(plotSize.width - viewportSize.width, newP.x));
		newP.y = Math.max(0, Math.min(plotSize.height - viewportSize.height, newP.y));

		viewport.setViewPosition(newP);
	} finally {
		plot.setCompensationEnabled(true);
	}

}
 
開發者ID:BrainTech,項目名稱:svarog,代碼行數:77,代碼來源:ZoomMouseWheelListener.java


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