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


Java BoundedRangeModel.getExtent方法代碼示例

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


在下文中一共展示了BoundedRangeModel.getExtent方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: componentResized

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
@Override
     public void componentResized(ComponentEvent event) {
boolean adjustViewportToBottom = false;

BoundedRangeModel model = scrollBar.getModel();
if ((model.getValue() == model.getMaximum() - model.getExtent())
		|| model.getExtent() >= model.getMaximum()) {
	adjustViewportToBottom = true;
}

model.setExtent(viewport.getHeight());
model.setMaximum(viewport.getView().getHeight());

if (adjustViewportToBottom || !isActive) {
	model.setValue(viewport.getView().getHeight() - viewport.getHeight());
}
     }
 
開發者ID:georgy,項目名稱:gmc,代碼行數:18,代碼來源:SplitTextPane.java

示例4: scrollToCenter

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * 
 */
public void scrollToCenter(boolean horizontal)
{
	JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar()
			: getVerticalScrollBar();

	if (scrollBar != null)
	{
		final BoundedRangeModel model = scrollBar.getModel();
		final int newValue = ((model.getMaximum()) / 2) - model.getExtent()
				/ 2;
		model.setValue(newValue);
	}
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:17,代碼來源:mxGraphComponent.java

示例5: scrollToCenter

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * 
 */
public void scrollToCenter(boolean horizontal) {
  JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar() : getVerticalScrollBar();

  if (scrollBar != null) {
    final BoundedRangeModel model = scrollBar.getModel();
    final int newValue = ((model.getMaximum()) / 2) - model.getExtent() / 2;
    model.setValue(newValue);
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:13,代碼來源:mxGraphComponent.java

示例6: checkScrollBar

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
private void checkScrollBar(AdjustmentEvent e) {
    //  The scroll bar listModel contains information needed to determine
    //  whether the viewport should be repositioned or not.

    JScrollBar scrollBar = (JScrollBar) e.getSource();
    BoundedRangeModel scrollBarModel = scrollBar.getModel();
    int value = scrollBarModel.getValue();
    int extent = scrollBarModel.getExtent();
    int maximum = scrollBarModel.getMaximum();

    boolean valueChanged = previousScrollBarValue != value;
    boolean maximumChanged = previousScrollBarMaximum != maximum;

    //  Check if the user has manually repositioned the scrollbar
    if (valueChanged && !maximumChanged) {
        adjustScrollBar = value + extent >= maximum;
    }

    //  Reset the "value" so we can reposition the viewport and
    //  distinguish between a user scroll and a program scroll.
    //  (ie. valueChanged will be false on a program scroll)
    if (adjustScrollBar) {
        //  Scroll the viewport to the end.
        scrollBar.removeAdjustmentListener(scrollBarAdjustmentListener);
        value = maximum - extent;
        scrollBar.setValue(value);
        scrollBar.addAdjustmentListener(scrollBarAdjustmentListener);
    }

    previousScrollBarValue = value;
    previousScrollBarMaximum = maximum;
}
 
開發者ID:chipKIT32,項目名稱:chipKIT-importer,代碼行數:33,代碼來源:SerialMonitorDisplayPane.java

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

示例8: scrollToCenter

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
/**
 * 
 */
public void scrollToCenter(boolean horizontal) {
	JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar() : getVerticalScrollBar();

	if (scrollBar != null) {
		final BoundedRangeModel model = scrollBar.getModel();
		final int newValue = ((model.getMaximum()) / 2) - model.getExtent() / 2;
		model.setValue(newValue);
	}
}
 
開發者ID:md-k-sarker,項目名稱:OWLAx,代碼行數:13,代碼來源:mxGraphComponent.java

示例9: addJob

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
protected void addJob(ApplicationItem ai) {
	Job j = new Job(ai);
	j.start();
	jobmap.put(ai.getID(), j);
	jobs.add(j);
	BoundedRangeModel m = csp.getVerticalScrollBar().getModel();
	if (m.getValue() + m.getExtent() == m.getMaximum()) {
	    scrollVerticallyOnNextUpdate = true;
	}
	hmodel.fireTableRowsInserted(jobs.size(), jobs.size());
       cmodel.fireTableRowsInserted(jobs.size(), jobs.size());
}
 
開發者ID:swift-lang,項目名稱:swift-k,代碼行數:13,代碼來源:GanttChart.java

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

示例11: isVisibleRow

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
private boolean isVisibleRow(JTable table, int row) {
    JScrollBar vScroll = getVerticalScrollBar(table);
    if (vScroll == null) {
        return true;
    }
    BoundedRangeModel model = vScroll.getModel();
    int rowHeight = table.getRowHeight() * row - model.getValue();
    return 0 <= rowHeight && rowHeight < model.getExtent();
}
 
開發者ID:montsuqi,項目名稱:monsiaj,代碼行數:10,代碼來源:CListHandler.java

示例12: isScrollBarFullyExtended

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
public static boolean isScrollBarFullyExtended(JScrollBar vScrollBar) {
      BoundedRangeModel model = vScrollBar.getModel();
int bottomPos = model.getExtent() + model.getValue() + 10;
int maxPos = model.getMaximum();
      return bottomPos >= maxPos;
  }
 
開發者ID:Ch3ck,項目名稱:ramaTiNuP,代碼行數:7,代碼來源:ChatWindow.java

示例13: checkScrollBar

import javax.swing.BoundedRangeModel; //導入方法依賴的package包/類
private void checkScrollBar(AdjustmentEvent e) {
	// The scroll bar listModel contains information needed to determine
	// whether the viewport should be repositioned or not.

	JScrollBar scrollBar = (JScrollBar) e.getSource();
	BoundedRangeModel listModel = scrollBar.getModel();
	int value = listModel.getValue();
	int extent = listModel.getExtent();
	int maximum = listModel.getMaximum();

	boolean valueChanged = previousValue != value;
	boolean maximumChanged = previousMaximum != maximum;

	// Check if the user has manually repositioned the scrollbar

	if (valueChanged && !maximumChanged) {
		if (viewportPosition == START)
			adjustScrollBar = value != 0;
		else
			adjustScrollBar = value + extent >= maximum;
	}

	// Reset the "value" so we can reposition the viewport and
	// distinguish between a user scroll and a program scroll.
	// (ie. valueChanged will be false on a program scroll)

	if (adjustScrollBar && viewportPosition == END) {
		// Scroll the viewport to the end.
		scrollBar.removeAdjustmentListener(this);
		value = maximum - extent;
		scrollBar.setValue(value);
		scrollBar.addAdjustmentListener(this);
	}

	if (adjustScrollBar && viewportPosition == START) {
		// Keep the viewport at the same relative viewportPosition
		scrollBar.removeAdjustmentListener(this);
		value = value + maximum - previousMaximum;
		scrollBar.setValue(value);
		scrollBar.addAdjustmentListener(this);
	}

	previousValue = value;
	previousMaximum = maximum;
}
 
開發者ID:reds-heig,項目名稱:logisim-evolution,代碼行數:46,代碼來源:SmartScroller.java


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