Java 类javax.swing.BoundedRangeModel 实例源码
项目:incubator-netbeans
文件:ReferencesBrowserController.java
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;
}
项目:incubator-netbeans
文件:OQLControllerUI.java
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();
}
});
}
项目:TrabalhoFinalEDA2
文件:mxGraphComponent.java
/**
*
*/
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);
}
}
项目:geoxygene
文件:SliderWithSpinner.java
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;
}
项目:SweetHome3D
文件:VideoPanel.java
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
}
}
项目:javify
文件:BasicSliderUI.java
/**
* 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();
}
}
项目:gstreamer1.x-java
文件:PopupVolumeButton.java
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);
}
项目:jvm-stm
文件:BasicSliderUI.java
/**
* 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();
}
}
项目:umple
文件:PaletteColorSliderModel.java
/**
* 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);
}
项目:SmartTokens
文件:SkinnableScrollBarUI.java
/**
* 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());
}
项目:swift-k
文件:GanttChart.java
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);
}
}
}
项目:darwinathome
文件:TensegrityDemo.java
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;
}
项目:cn1
文件:TextField.java
/**
* 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();
}
}
项目:cn1
文件:BasicScrollPaneUI.java
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()));
}
}
项目:cn1
文件:BasicScrollBarUI.java
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();
}
}
项目:cn1
文件:BasicScrollBarUI.java
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;
}
}
项目:JamVM-PH
文件:BasicSliderUI.java
/**
* 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();
}
}
项目:MediathekView
文件:SkinnableScrollBarUI.java
/**
* 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());
}
项目:GKA1
文件:mxGraphComponent.java
/**
*
*/
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);
}
}
项目:GKA1
文件:mxGraphComponent.java
/**
*
*/
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);
}
}
项目:classpath
文件:BasicSliderUI.java
/**
* 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();
}
}
项目:freeVM
文件:TextField.java
/**
* 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();
}
}
项目:freeVM
文件:BasicScrollPaneUI.java
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()));
}
}
项目:freeVM
文件:BasicScrollBarUI.java
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();
}
}
项目:freeVM
文件:BasicScrollBarUI.java
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;
}
}
项目:freeVM
文件:TextField.java
/**
* 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();
}
}
项目:freeVM
文件:BasicScrollPaneUI.java
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()));
}
}
项目:freeVM
文件:BasicScrollBarUI.java
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();
}
}
项目:freeVM
文件:BasicScrollBarUI.java
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;
}
}
项目:gmc
文件:SplitTextPane.java
@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());
}
}
项目:Puzzledice
文件:mxGraphComponent.java
/**
*
*/
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);
}
}
项目:WMA
文件:mxGraphComponent.java
/**
*
*/
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);
}
}
项目:OnionUmlVisualization
文件:mxGraphComponent.java
/**
*
*/
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);
}
}
项目:incubator-netbeans
文件:Populate.java
private static void create(File root, int val, final BoundedRangeModel progress) throws IOException {
for (int i = 0; i < val; i++) {
final int progval = i;
SwingUtilities.invokeLater(new Runnable() {
public void run() {
progress.setValue(progval);
}
});
boolean xml = i % 5 > 2;
String fname = "file" + i + (xml ? ".xml" : ".txt");
int bit = 0;
int x = i;
while (x > 0) {
if (x % 3 == 0) {
fname = "dir" + bit + File.separatorChar + fname;
}
bit++;
x /= 3;
}
File tomake = new File(root, "test" + File.separatorChar + fname);
tomake.getParentFile().mkdirs();
if (tomake.createNewFile()) {
OutputStream os = new FileOutputStream(tomake);
try {
if (xml) {
Document doc = createXML(i);
XMLUtil.write(doc, os, "UTF-8");
} else {
PrintStream ps = new PrintStream(os);
ps.println("Sample data for file #" + i);
ps.close();
}
} finally {
os.close();
}
}
}
}
项目:incubator-netbeans
文件:MemoryLint.java
BoundedRangeModel getNextDelegate() {
step++;
delegate.setRangeProperties(0, 0, 0, 1, false);
updateValue();
return delegate;
}
项目:incubator-netbeans
文件:InstanceNode.java
private static ChangeListener setProgress(final ProgressHandle pHandle) {
final BoundedRangeModel progress = HeapProgress.getProgress();
ChangeListener cl = new ChangeListener() {
public void stateChanged(ChangeEvent e) {
pHandle.progress(progress.getValue());
}
};
progress.addChangeListener(cl);
return cl;
}
项目:incubator-netbeans
文件:AnalysisController.java
public BoundedRangeModel performAnalysis(boolean[] rulesSelection) {
final List<Rule> selectedRules = new ArrayList();
final List<Rule> allRules = getRules();
for (int i = 0; i < rulesSelection.length; i++) {
if (rulesSelection[i]) {
selectedRules.add(allRules.get(i));
}
}
if (selectedRules.size() > 0) {
analysisRunning = true;
final MemoryLint ml = new MemoryLint(heapFragmentWalker.getHeapFragment());
runningMemoryLint = ml;
BrowserUtils.performTask(new Runnable() {
public void run() {
try {
ml.process(selectedRules);
} catch (Exception e) {
ErrorManager.getDefault().log(ErrorManager.ERROR, e.getMessage());
}
rules = null;
analysisRunning = false;
runningMemoryLint = null;
AnalysisControllerUI ui = (AnalysisControllerUI)getPanel();
ui.displayNewRules();
if (!ml.isInterruped()) ui.setResult(ml.getResults());
}
});
return ml.getGlobalProgress();
} else {
return null;
}
}
项目:incubator-netbeans
文件:HeapWalker.java
private static void setProgress(final ProgressHandle pHandle, final int offset) {
final BoundedRangeModel progress = HeapProgress.getProgress();
progress.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
pHandle.progress(progress.getValue()+offset);
}
});
}
项目:incubator-netbeans
文件:HeapProgress.java
private static void progress(final long value, final long endOffset, final long startOffset) {
BoundedRangeModel model = (BoundedRangeModel) progressThreadLocal.get();
if (model != null) {
long val = PROGRESS_MAX*(value - startOffset)/(endOffset - startOffset);
setValue(model, (int)val);
}
}
项目:incubator-netbeans
文件:HeapProgress.java
static void progressFinish() {
BoundedRangeModel model = (BoundedRangeModel) progressThreadLocal.get();
if (model != null) {
setValue(model, PROGRESS_MAX);
progressThreadLocal.remove();
}
}