本文整理汇总了Java中javax.swing.BoundedRangeModel.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java BoundedRangeModel.getValue方法的具体用法?Java BoundedRangeModel.getValue怎么用?Java BoundedRangeModel.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.BoundedRangeModel
的用法示例。
在下文中一共展示了BoundedRangeModel.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stateChanged
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
public void stateChanged(ChangeEvent e) {
if (e.getSource() == scalesp) {
scale = ((Number) scalesp.getValue()).doubleValue() * INITIAL_SCALE;
repaint();
}
else if (e.getSource() == hsb.getModel()) {
BoundedRangeModel m = hsb.getModel();
if (offset != m.getValue()) {
offset = m.getValue();
repaint();
}
}
else if (e.getSource() == csp.getVerticalScrollBar().getModel()) {
if (scrollVerticallyOnNextUpdate) {
scrollVerticallyOnNextUpdate = false;
csp.getVerticalScrollBar().getModel().setValue(Integer.MAX_VALUE);
}
}
}
示例2: scrollRectToVisible
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
/**
* Horizontally scrolls text to make specified rectangle
* visible. Uses bounded range model value for
* scrolling. Repaints TextField.
*/
@Override
void scrollRectToVisible(Rectangle r) {
final int x = r.x;
final Insets insets = getTextFieldKit().getInsets();
final BoundedRangeModel brm = getTextFieldKit().getHorizontalVisibility();
final int oldValue = brm.getValue();
final int width = getModelRect().width;
if (x > width - insets.right) {
final int newVal = oldValue + (x - width + insets.right) + 2;
brm.setValue(newVal);
repaint();
}
if (x < insets.left) {
brm.setValue(oldValue - (insets.left - x) - 2);
repaint();
}
}
示例3: 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;
}
}
示例4: scrollRectToVisible
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
/**
* Horizontally scrolls text to make specified rectangle
* visible. Uses bounded range model value for
* scrolling. Repaints TextField.
*/
@Override
void scrollRectToVisible(Rectangle r) {
int x = r.x;
Insets insets = getTextFieldKit().getInsets();
BoundedRangeModel brm = getTextFieldKit().getHorizontalVisibility();
int oldValue = brm.getValue();
int width = getModelRect().width;
if (x > width - insets.right) {
int newVal = oldValue + (x - width + insets.right) + 2;
brm.setValue(newVal);
repaint();
}
if (x < insets.left) {
brm.setValue(oldValue - (insets.left - x) - 2);
repaint();
}
}
示例5: 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());
}
}
示例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;
}
示例7: copy
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
private DefaultBoundedRangeModel copy (BoundedRangeModel m)
{
return new DefaultBoundedRangeModel(
m.getValue(),
m.getExtent(),
m.getMinimum(),
m.getMaximum());
}
示例8: paintDeterminate
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
/**
* @param g
*/
private void paintDeterminate(final Graphics g) {
final BoundedRangeModel model = circleBar.getModel();
final double progress = model.getValue() / (double) model.getMaximum();
this.paint(g, progress, circleBar.getNonvalueClipPainter(), circleBar.getValueClipPainter());
}
示例9: hsbStateChanged
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
private void hsbStateChanged(JViewport viewport, ChangeEvent e) {
BoundedRangeModel model = (BoundedRangeModel) (e.getSource());
Point p = viewport.getViewPosition();
int value = model.getValue();
if (scrollpane.getComponentOrientation().isLeftToRight()) {
p.x = value;
} else {
int max = viewport.getViewSize().width;
int extent = viewport.getExtentSize().width;
int oldX = p.x;
/*
* Set new X coordinate based on "value".
*/
p.x = max - extent - value;
/*
* If setValue() was called before "extent" was fixed, turn
* setValueCalled flag on.
*/
if ((extent == 0) && (value != 0) && (oldX == max)) {
setValueCalled = true;
} else {
/*
* When a pane without a horizontal scroll bar was reduced
* and the bar appeared, the viewport should show the right
* side of the view.
*/
if ((extent != 0) && (oldX < 0) && (p.x == 0)) {
p.x += value;
}
}
}
viewport.setViewPosition(p);
}
示例10: 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());
}
示例11: adjustmentValueChanged
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
public void adjustmentValueChanged(AdjustmentEvent e) {
JScrollBar sb = (JScrollBar)e.getSource();
BoundedRangeModel m = sb.getModel();
int vval = m.getValue();
float dv = previous - vval;
previous = vval;
if(dv != 0 && scrollBarsMayControlAdjusting) {
// get the uniform scale of all transforms
float layoutScale = (float) vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).getScale();
dv *= layoutScale;
AffineTransform at = AffineTransform.getTranslateInstance(0, dv);
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).preConcatenate(at);
}
}
示例12: adjustmentValueChanged
import javax.swing.BoundedRangeModel; //导入方法依赖的package包/类
public void adjustmentValueChanged(AdjustmentEvent e) {
JScrollBar sb = (JScrollBar)e.getSource();
BoundedRangeModel m = sb.getModel();
int vval = m.getValue();
float dv = previous - vval;
previous = vval;
if(dv != 0 && scrollBarsMayControlAdjusting) {
// get the uniform scale of all transforms
float layoutScale = (float) vv.getLayoutTransformer().getScale();
dv *= layoutScale;
AffineTransform at = AffineTransform.getTranslateInstance(0, dv);
vv.getLayoutTransformer().preConcatenate(at);
}
}
示例13: 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;
}
示例14: 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();
}
示例15: 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;
}