本文整理汇总了Java中javax.swing.BoundedRangeModel类的典型用法代码示例。如果您正苦于以下问题:Java BoundedRangeModel类的具体用法?Java BoundedRangeModel怎么用?Java BoundedRangeModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundedRangeModel类属于javax.swing包,在下文中一共展示了BoundedRangeModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProgressPanel
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
Dialog createProgressPanel(final String message, BoundedRangeModel model) {
Dialog dialog;
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(10, 10));
panel.setBorder(new EmptyBorder(15, 15, 15, 15));
panel.add(new JLabel(message), BorderLayout.NORTH);
final Dimension ps = panel.getPreferredSize();
ps.setSize(Math.max(ps.getWidth(), DEFAULT_WIDTH), Math.max(ps.getHeight(), DEFAULT_HEIGHT));
panel.setPreferredSize(ps);
final JProgressBar progress = new JProgressBar();
if (model == null) {
progress.setIndeterminate(true);
} else {
progress.setStringPainted(true);
progress.setModel(model);
}
panel.add(progress, BorderLayout.SOUTH);
dialog = DialogDisplayer.getDefault().createDialog(new DialogDescriptor(panel, Bundle.ReferencesBrowserController_ProgressDialogCaption(), true, new Object[] { },
DialogDescriptor.CANCEL_OPTION, DialogDescriptor.RIGHT_ALIGN,
null, null));
return dialog;
}
示例2: queryStarted
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
public void queryStarted(final BoundedRangeModel model) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateUIState();
progressLabel.setText(Bundle.OQLControllerUI_ExecutingQueryMsg());
progressBar.setModel(model);
progressBar.setMaximumSize(new Dimension(progressBar.getMaximumSize().width,
progressBar.getPreferredSize().height));
contentsPanel.remove(controlPanel);
contentsPanel.add(progressPanel, BorderLayout.SOUTH);
progressPanel.invalidate();
contentsPanel.revalidate();
contentsPanel.repaint();
}
});
}
示例3: maintainScrollBar
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
/**
*
*/
protected void maintainScrollBar(boolean horizontal, double factor,
boolean center)
{
JScrollBar scrollBar = (horizontal) ? getHorizontalScrollBar()
: getVerticalScrollBar();
if (scrollBar != null)
{
BoundedRangeModel model = scrollBar.getModel();
int newValue = (int) Math.round(model.getValue() * factor)
+ (int) Math.round((center) ? (model.getExtent()
* (factor - 1) / 2) : 0);
model.setValue(newValue);
}
}
示例4: createSlider
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
private static JSlider createSlider(BoundedRangeModel model,
int orientation, boolean drawLabels) {
JSlider slider = new JSlider(model);
slider.setOrientation(orientation);
slider.setAlignmentY(Component.TOP_ALIGNMENT);
if (drawLabels) {
Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
labelTable.put(new Integer(model.getMinimum()), new JLabel(
((Integer) model.getMinimum()).toString()));
labelTable.put(new Integer(model.getMaximum()), new JLabel(
((Integer) model.getMaximum()).toString()));
slider.setLabelTable(labelTable);
slider.setPaintLabels(true);
}
// slider.setBorder(BorderFactory.createEmptyBorder(10,5,10,5));
return slider;
}
示例5: ImageSourceStream
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
public ImageSourceStream(VideoFormat format, FrameGenerator frameGenerator, Camera[] framesPath,
final BoundedRangeModel progressModel)
{
this.frameGenerator = frameGenerator;
this.framesPath = framesPath;
this.progressModel = progressModel;
this.format = format;
try
{
// Retrieve main thread AppContext instance by reflection
this.mainThreadContext = Class.forName("sun.awt.AppContext").getMethod("getAppContext").invoke(null);
}
catch (Throwable ex)
{
// Let's consider app context is not necessary for the program
}
}
示例6: propertyChange
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
/**
* Called when one of the properties change. The UI should recalculate any
* rectangles if necessary and repaint.
*
* @param e A {@link PropertyChangeEvent}.
*/
public void propertyChange(PropertyChangeEvent e)
{
// Check for orientation changes.
String prop = e.getPropertyName();
if (prop.equals("orientation")
|| prop.equals("inverted")
|| prop.equals("labelTable")
|| prop.equals("majorTickSpacing")
|| prop.equals("minorTickSpacing")
|| prop.equals("paintTicks")
|| prop.equals("paintTrack")
|| prop.equals("paintLabels"))
{
calculateGeometry();
slider.repaint();
}
else if (e.getPropertyName().equals("model"))
{
BoundedRangeModel oldModel = (BoundedRangeModel) e.getOldValue();
oldModel.removeChangeListener(changeListener);
slider.getModel().addChangeListener(changeListener);
calculateThumbLocation();
slider.repaint();
}
}
示例7: PopupVolumeButton
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
public PopupVolumeButton(BoundedRangeModel model) {
/*
* Construct the popup for the volume slider
*/
volumePanel = new JPanel();
volumePanel.setLayout(new BoxLayout(volumePanel, BoxLayout.Y_AXIS));
volumeSlider = new JSlider(model);
volumeSlider.addChangeListener(volumeChanged);
volumeSlider.setOrientation(SwingConstants.VERTICAL);
volumePanel.add(new JLabel(highVolumeIcon));
volumeSlider.setAlignmentX(0.25f);
volumePanel.add(volumeSlider);
volumePanel.add(new JLabel(lowVolumeIcon));
volumePanel.validate();
setAction(volumeAction);
}
示例8: configureSlider
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
/**
* Configures a JSlider for this model.
* If the JSlider is already configured for another model,
* it is unconfigured first.
*/
@Override
public void configureSlider(int componentIndex, JSlider slider) {
if (slider.getClientProperty("colorSliderModel") != null) {
((DefaultColorSliderModel) slider.getClientProperty("colorSliderModel")).unconfigureSlider(slider);
}
if (!(slider.getUI() instanceof PaletteColorSliderUI)) {
slider.setUI((PaletteColorSliderUI) PaletteColorSliderUI.createUI(slider));
}
BoundedRangeModel brm = getBoundedRangeModel(componentIndex);
slider.setModel(brm);
slider.putClientProperty("colorSliderModel", this);
slider.putClientProperty("colorComponentIndex", componentIndex);
addColorSlider(slider);
}
示例9: 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());
}
示例10: 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);
}
}
}
示例11: createSlider
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
private JSlider createSlider(String title, final BoundedRangeModel model, JPanel p, GridBagConstraints gbc, final Runnable runnable) {
gbc.gridy++;
gbc.gridx = 0;
JLabel titleLabel = new JLabel(title);
p.add(titleLabel, gbc);
gbc.gridx = 1;
JSlider slider = new JSlider(model);
p.add(slider, gbc);
if (runnable != null) {
model.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) {
jobs.add(runnable);
}
});
}
return slider;
}
示例12: 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();
}
}
示例13: propertyChange
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
public void propertyChange(final PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (StringConstants.MODEL_PROPERTY_CHANGED.equals(propertyName)) {
BoundedRangeModel oldValue = (BoundedRangeModel)e.getOldValue();
if (oldValue != null) {
oldValue.removeChangeListener(hsbChangeListener);
}
BoundedRangeModel newValue = (BoundedRangeModel)e.getNewValue();
if (newValue != null) {
newValue.addChangeListener(hsbChangeListener);
}
} else if (StringConstants.COMPONENT_ORIENTATION.equals(propertyName)) {
hsbChangeListener.stateChanged(new ChangeEvent(e.getSource()));
}
}
示例14: propertyChange
import javax.swing.BoundedRangeModel; //导入依赖的package包/类
public void propertyChange(final PropertyChangeEvent e) {
String propertyName = e.getPropertyName();
if (StringConstants.COMPONENT_ORIENTATION.equals(propertyName)) {
uninstallKeyboardActions();
installKeyboardActions();
} else if (StringConstants.MODEL_PROPERTY_CHANGED.equals(propertyName)) {
BoundedRangeModel oldValue = (BoundedRangeModel)e.getOldValue();
if (oldValue != null) {
oldValue.removeChangeListener(modelListener);
}
BoundedRangeModel newValue = (BoundedRangeModel)e.getNewValue();
if (newValue != null) {
newValue.addChangeListener(modelListener);
}
}
if (scrollbar != null) {
scrollbar.revalidate();
scrollbar.repaint();
}
}
示例15: 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;
}
}