当前位置: 首页>>代码示例>>Java>>正文


Java BoundedRangeModel类代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ReferencesBrowserController.java

示例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();
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:OQLControllerUI.java

示例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);
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:19,代码来源:mxGraphComponent.java

示例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;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:22,代码来源:SliderWithSpinner.java

示例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
	}
}
 
开发者ID:valsr,项目名称:SweetHome3D,代码行数:18,代码来源:VideoPanel.java

示例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();
    }
}
 
开发者ID:vilie,项目名称:javify,代码行数:32,代码来源:BasicSliderUI.java

示例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);
}
 
开发者ID:gstreamer-java,项目名称:gstreamer1.x-java,代码行数:18,代码来源:PopupVolumeButton.java

示例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);
}
 
开发者ID:umple,项目名称:umple,代码行数:21,代码来源:PaletteColorSliderModel.java

示例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());
}
 
开发者ID:mathieulegoc,项目名称:SmartTokens,代码行数:28,代码来源:SkinnableScrollBarUI.java

示例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);
        }
    }
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:20,代码来源:GanttChart.java

示例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;
}
 
开发者ID:geralddejong,项目名称:darwinathome,代码行数:18,代码来源:TensegrityDemo.java

示例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();
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:TextField.java

示例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()));
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:BasicScrollPaneUI.java

示例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();
       }
   }
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:BasicScrollBarUI.java

示例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;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:26,代码来源:BasicScrollBarUI.java


注:本文中的javax.swing.BoundedRangeModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。