public void testIsKnown() { class M extends DefaultBoundedRangeModel { @Override public void setValue(int n) { super.setValue(n); if (n > 10) { super.setValue(10); throw new CancelException(); } } } M model = new M(); LiveEngine instance = new LiveEngine(model); Map<?,?> path = instance.trace(Collections.singleton(last), Collections.<Object>singleton(list)); assertEquals("Model stops at 10", 10, model.getValue()); assertEquals("No path found", null, path); }
/** * Creates a new {@code RangeOptionUI} for the given * {@code RangeOption}. * * @param option The {@code RangeOption} to make a user interface for * @param editable boolean whether user can modify the setting */ public RangeOptionUI(final RangeOption option, boolean editable) { super(option, editable); JSlider slider = getComponent(); slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0, 0, option.getItemValues().size()-1)); Hashtable<Integer, JComponent> labels = new Hashtable<>(); int index = 0; for (String string : option.getItemValues().values()) { if (option.localizeLabels()) { labels.put(index, Utility.localizedLabel(string)); } else { labels.put(index, new JLabel(string)); } index++; } slider.setLabelTable(labels); slider.setValue(option.getValueRank()); slider.setMajorTickSpacing(1); slider.setSnapToTicks(true); }
/** * Creates a new {@code PercentageOptionUI} for the given * {@code PercentageOption}. * * @param option The {@code PercentageOption} to make a user * interface for. * @param editable boolean whether user can modify the setting */ public PercentageOptionUI(final PercentageOption option, boolean editable) { super(option, editable); JSlider slider = getComponent(); slider.setModel(new DefaultBoundedRangeModel(option.getValue(), 0, 0, 100)); Hashtable<Integer, JComponent> labels = new Hashtable<>(); labels.put(0, new JLabel("0 %")); labels.put(25, new JLabel("25 %")); labels.put(50, new JLabel("50 %")); labels.put(75, new JLabel("75 %")); labels.put(100, new JLabel("100 %")); slider.setLabelTable(labels); slider.setValue(option.getValue()); slider.setMajorTickSpacing(5); slider.setSnapToTicks(false); }
public HierarchiesPane(int tabPlacement, Locale locale, boolean child) { super(tabPlacement); addMouseListener(this); popupMenu = new JPopupMenu(); if(child) { swapMenuItem = new JMenuItem("Swap comparator", KeyEvent.VK_S); addMenuItem(swapMenuItem); } else { openMenuItem = new JMenuItem("Move to new window", KeyEvent.VK_W); addMenuItem(openMenuItem); } //int h = getHeight(); int h = getPreferredSize().height; if(h > 0) h -= thumbWidth * 2; if(h < thumbWidth) h = 2 * thumbWidth; splitter = new DefaultBoundedRangeModel((h + 1)/2, 0, 0, h); splitter.addChangeListener(this); setLocale(locale); }
public PopupVolumeButton(final PlayBin playbin) { this(new DefaultBoundedRangeModel() { private static final long serialVersionUID = 1462054216375236024L; @Override public int getMaximum() { return 100; } @Override public int getMinimum() { return 0; } @Override public int getValue() { return (int) ((playbin.getVolume() * 100.0) + 0.5); } @Override public void setValue(int percent) { playbin.setVolume(Math.max(Math.min((double) percent, 100d), 0d) / 100.0d); } }); }
public Result testgetHorizontalVisibility() { InstrumentedJTextField ijt = new InstrumentedJTextField(); InstrumentedUILog.clear(); if (!ijt.getHorizontalVisibility().getClass().equals(DefaultBoundedRangeModel.class)) { return failed ("getHorizontalVisibility returns a wrong type value"); } InstrumentedUILog.clear(); if (ijt.getHorizontalVisibility() == null) { return failed("getHorizontalVisibility returns null"); } if (!InstrumentedUILog .equals(new Object[][] { { "JTextField.getHorizontalVisibility"}, } )) { InstrumentedUILog.printLogAsArray(); return failed("expected getHorizontalVisibility not to call any additional methods"); } return passed(); }
/** * Creates a new <code>RangeOptionUI</code> for the given * <code>RangeOption</code>. * * @param option The <code>RangeOption</code> to make a user interface for * @param editable boolean whether user can modify the setting */ public RangeOptionUI(GUI gui, final RangeOption option, boolean editable) { super(gui, option, editable); JSlider slider = getComponent(); slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0, 0, option.getItemValues().size() - 1)); Hashtable<Integer, JComponent> labels = new Hashtable<Integer, JComponent>(); int index = 0; for (String string : option.getItemValues().values()) { if (option.localizeLabels()) { labels.put(index, new JLabel(Messages.message(string))); } else { labels.put(index, new JLabel(string)); } index++; } slider.setLabelTable(labels); slider.setValue(option.getValueRank()); slider.setMajorTickSpacing(1); slider.setSnapToTicks(true); }
/** * Creates a new <code>PercentageOptionUI</code> for the given * <code>PercentageOption</code>. * * @param option The <code>PercentageOption</code> to make a user interface for * @param editable boolean whether user can modify the setting */ public PercentageOptionUI(GUI gui, final PercentageOption option, boolean editable) { super(gui, option, editable); JSlider slider = getComponent(); slider.setModel(new DefaultBoundedRangeModel(option.getValue(), 0, 0, 100)); Hashtable<Integer, JComponent> labels = new Hashtable<Integer, JComponent>(); labels.put(new Integer(0), new JLabel("0 %")); labels.put(new Integer(25), new JLabel("25 %")); labels.put(new Integer(50), new JLabel("50 %")); labels.put(new Integer(75), new JLabel("75 %")); labels.put(new Integer(100), new JLabel("100 %")); slider.setLabelTable(labels); slider.setValue(option.getValue()); slider.setMajorTickSpacing(5); slider.setSnapToTicks(false); }
private void initComponents() { setLayout(new BorderLayout()); // if (UIUtils.isNimbus()) { progressDelegateModel = new DefaultBoundedRangeModel(4, 1, 0, 10); progressDelegate = new JProgressBar(progressDelegateModel); add(progressDelegate, BorderLayout.CENTER); // } else { // setBorder(new ThinBevelBorder(BevelBorder.LOWERED)); // setOpaque(false); // } }
protected void createThumbs(int n) { thumbNum = n; sliderModels = new BoundedRangeModel[n]; thumbRenderers = new Icon[n]; fillColors = new Color[n]; for (int i = 0; i < n; i++) { sliderModels[i] = new DefaultBoundedRangeModel(50, 0, 0, 100); thumbRenderers[i] = null; fillColors[i] = null; } }
public BoundedRangeModel createModel(final int min, final int max) { return new DefaultBoundedRangeModel(value.get(), 0, min, max) { @Override public void setValue(final int n) { super.setValue(n); set(n); } }; }
private DefaultBoundedRangeModel copy (BoundedRangeModel m) { return new DefaultBoundedRangeModel( m.getValue(), m.getExtent(), m.getMinimum(), m.getMaximum()); }
/** * Constructs a new model. Precondition: * <code>minimum <= value <= maximum</code>. */ public SliderWithSpinnerModel(double value, double minimum, double maximum, double increment, double precision) { minimum = Math.min(minimum, value); maximum = Math.max(maximum, value); this.precision = precision; this.increment = increment; this.boundedRangeModel = new DefaultBoundedRangeModel( (int) (value / precision), 0, (int) (minimum / precision), (int) (maximum / precision)); }
public ClassySharkExporter(ClassySharkDumpStrategy dumpStrategy) { super(); JFrame owner = new JFrame("ClassySharkExporter"); JFileChooser fileChooser = new JFileChooser(); fileChooser.setCurrentDirectory(new File(System.getProperty("user.home"))); int result = fileChooser.showOpenDialog(owner); if (result == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); final JDialog dialog = new JDialog(owner, "ClassyShark Exporter", true); BoundedRangeModel model = new DefaultBoundedRangeModel(); JProgressBar progressBar = new JProgressBar(model); dialog.add(progressBar); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.setResizable(false); dialog.setPreferredSize(new Dimension(300, 100)); dialog.pack(); dialog.setLocationRelativeTo(owner); BoundedRangeModelTask task = new BoundedRangeModelTask(model, dumpStrategy); task.go(() -> dialog.setVisible(false), selectedFile); dialog.setVisible(true); dialog.dispose(); System.exit(0); } }
public ModernSlider(int orientation, int min, int max, int value) { this.orientation = JSlider.HORIZONTAL; sliderModel = new DefaultBoundedRangeModel(value, 0, min, max); sliderModel.addChangeListener(changeListener); updateUI(); init(); }
private void updateProgressBar() { if (models.isEmpty()) { progressBar.setModel(new DefaultBoundedRangeModel()); progressBar.setEnabled(false); progressBar.setVisible(false); } else if (models.size() == 1) { progressBar.setModel(models.get(0)); progressBar.setEnabled(true); progressBar.setVisible(true); } else { progressBar.setModel(new DefaultBoundedRangeModel()); progressBar.setEnabled(true); progressBar.setVisible(true); } }
public JSliderEditor() { super( SwingConstants.HORIZONTAL); listeners = new Vector<CellEditorListener>(); super.setToolTipText( ""); sliderModel.addChangeListener( new ChangeListener() { @Override public void stateChanged( ChangeEvent e) { DefaultBoundedRangeModel source = (DefaultBoundedRangeModel) e.getSource(); tooltip.setValue( source.getValue()+"%"); } }); }
public JSlider getReconstructionHeightSlider() { if (reconstructionHeightSlider == null) { reconstructionHeightSlider = new JSlider(new DefaultBoundedRangeModel(BookPlot.RECONSTRUCTION_HEIGHT, 0, BookPlot.MIN_RECONSTRUCTION_HEIGHT, BookPlot.MAX_RECONSTRUCTION_HEIGHT)) { private static final long serialVersionUID = 1L; @Override public String getToolTipText(MouseEvent ev) { return _R("{0} px", getValue()); } }; reconstructionHeightSlider.setToolTipText(""); Dimension size = reconstructionHeightSlider.getPreferredSize(); size.width = 135; reconstructionHeightSlider.setPreferredSize(size); reconstructionHeightSlider.setMinimumSize(size); reconstructionHeightSlider.setMaximumSize(size); reconstructionHeightSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { plot.setReconstructionHeight(reconstructionHeightSlider.getValue()); } }); } return reconstructionHeightSlider; }
private JPanel getValueScalePanel() { valueScaleSlider = new LogarithmicJSlider(new DefaultBoundedRangeModel()) { private static final long serialVersionUID = 1L; @Override public String getToolTipText(MouseEvent ev) { return getValue() + "%"; } }; DefaultBoundedRangeModel m = currentPlot.getValueScaleRangeModel(); this.valueScaleModel = (DefaultBoundedRangeModel) valueScaleSlider.getModel(); this.valueScaleModel.setRangeProperties(m.getValue(), m.getExtent(), m.getMinimum(), m.getMaximum(), m.getValueIsAdjusting()); Dimension d = valueScaleSlider.getPreferredSize(); d.width = 100; valueScaleSlider.setToolTipText(""); valueScaleSlider.setPreferredSize(d); valueScaleSlider.setMinimumSize(d); valueScaleSlider.setMaximumSize(d); this.valueScaleModel.addChangeListener(this); TitledSliderPanel retPanel = new TitledSliderPanel(_("Value scale"), valueScaleSlider); JPanel p = new JPanel(new BorderLayout()); p.add(retPanel, BorderLayout.NORTH); return p; }
public void testUninstallListeners() throws Exception { assertEquals(2, barUI.incrButton.getMouseListeners().length); assertEquals(1, bar.getMouseListeners().length); assertEquals(1, bar.getPropertyChangeListeners().length); assertEquals(2, ((DefaultBoundedRangeModel) bar.getModel()).getChangeListeners().length); barUI.uninstallListeners(); assertEquals(0, bar.getMouseListeners().length); assertEquals(0, bar.getPropertyChangeListeners().length); assertEquals(1, ((DefaultBoundedRangeModel) bar.getModel()).getChangeListeners().length); assertEquals(1, barUI.incrButton.getMouseListeners().length); }
public BlackPercentageSelector() { this.model = new DefaultBoundedRangeModel(50, 0, 0, 100); this.label = new JLabel(this.model.getValue() + "%"); this.slider = new JSlider(this.model); this.slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { BlackPercentageSelector.this.stateChanged(event); } }); }
public CenterOfHistogramSelector() { this.model = new DefaultBoundedRangeModel(50, 0, 0, 100); this.label = new JLabel(this.model.getValue() + "%"); this.slider = new JSlider(this.model); this.slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent event) { CenterOfHistogramSelector.this.stateChanged(event); } }); }
public void setMaxNumSamples(int maxNumSamples) { if (maxNumSamples != numSamplesSlider.getMaximum()) { Integer value = rootBinder.get().get(RootModel.desiredNumSamples); if (value == null) { value = numSamplesSlider.getValue(); } value = Math.min(value, maxNumSamples); DefaultBoundedRangeModel newModel = new DefaultBoundedRangeModel(value, 0, 1, maxNumSamples); numSamplesSlider.setModel(newModel); numSamplesSlider.setEnabled(maxNumSamples > 1); updateNumSamplesLabel(); } }
/** * */ private void initComponents() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); setOpaque(false); //iBarvovnik = new JSlider(JSlider.VERTICAL, 0, 255, 128); //iBarvovnik = new JSlider(Board.hodnotyObsazenosti.getBarvovnikModel()); iBarvovnik = new JSlider(JSlider.VERTICAL); iBarvovnik.setOpaque(false); iBarvovnik.setToolTipText("Nastavení stupně šedi kruhů (161 m), kterými se zobrazí kešemi obsazené oblasti."); iBarvovnik.setFocusable(false); DefaultBoundedRangeModel barvovnikModel = new DefaultBoundedRangeModel(128, 0, 0, 255); iBarvovnik.setModel(barvovnikModel); iPruhlednik = new JSlider(JSlider.VERTICAL); // iPruhlednik = new JSlider(Board.hodnotyObsazenosti.getPruhlednikModel()); iPruhlednik.setOpaque(false); iPruhlednik.setToolTipText("Nastavení průhlednosti kruhů (161 m), kterými se zobrazí kešemi obsazené oblasti."); iPruhlednik.setFocusable(false); DefaultBoundedRangeModel pruhlednikModel = new DefaultBoundedRangeModel(128, 0, 0, 255); iPruhlednik.setModel(pruhlednikModel); add(Box.createRigidArea(new Dimension(0,20))); add(iBarvovnik); add(Box.createRigidArea(new Dimension(0,20))); add(iPruhlednik); add(Box.createRigidArea(new Dimension(0,20))); }
public void setModel(BoundedRangeModel m) { if (model_ != null) { model_.removeChangeListener(this); } model_ = m == null ? new DefaultBoundedRangeModel() : m; if (model_ != null) { model_.addChangeListener(this); } repaint(); }
public synchronized void setProgressModel(BoundedRangeModel brm) { if (progressModel_ != null) { progressModel_.removeChangeListener(this); } progressModel_ = (brm == null) ? new DefaultBoundedRangeModel() : brm; if (progressModel_ != null) { progressModel_.addChangeListener(this); } }
/** * * Creates a new volume slider controlling the designated volume type (music or sound) * * @param type * the sound type to control. * * @param demo * the sound clip to play on each change. This clip represents an idea of how loud/soft the setting is * */ public VolumeSlider(final SoundType type, final Clip demo) { super(); final BoundedRangeModel model = new DefaultBoundedRangeModel(SoundSettings.getVolumePercentForType(type), 0, 0, 100) { private static final long serialVersionUID = 1L; }; model.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { type.adjustPercentage(model.getValue() ); // Don't play demo sound unless slider has come to a rest, or that would get annoying real fast. if (!(model.getValueIsAdjusting() ) && model.getValue() != 0) { float gain = SoundUtils.resolveDecibelOffsetFromPercentage(model.getValue() ); FloatControl gainControl = (FloatControl) demo.getControl(FloatControl.Type.MASTER_GAIN); gainControl.setValue(gain); demo.stop(); demo.setFramePosition(0); demo.start(); } } }); setModel(model); setOpaque(false); setBorder(null); setUI(new MonkeyShinesSliderUI(this) ); }
private void executeQueryImpl(final String oqlQuery) { final BoundedRangeModel progressModel = new DefaultBoundedRangeModel(0, 10, 0, 100); SwingUtilities.invokeLater(new Runnable() { public void run() { BrowserUtils.performTask(new Runnable() { public void run() { final AtomicInteger counter = new AtomicInteger(RESULTS_LIMIT); progressModel.setMaximum(100); final StringBuilder sb = new StringBuilder(); final boolean[] oddRow = new boolean[1]; Color oddRowBackground = UIUtils.getDarker( UIUtils.getProfilerResultsBackground()); final String oddRowBackgroundString = "rgb(" + oddRowBackground.getRed() + "," + //NOI18N oddRowBackground.getGreen() + "," + //NOI18N oddRowBackground.getBlue() + ")"; //NOI18N sb.append("<table border='0' width='100%'>"); // NOI18N try { analysisRunning.compareAndSet(false, true); queryController.queryStarted(progressModel); progressUpdater.submit(new ProgressUpdater(progressModel)); engine.executeQuery(oqlQuery, new ObjectVisitor() { public boolean visit(Object o) { sb.append(oddRow[0] ? "<tr><td style='background-color: " + // NOI18N oddRowBackgroundString + ";'>" : "<tr><td>"); // NOI18N oddRow[0] = !oddRow[0]; dump(o, sb); sb.append("</td></tr>"); // NOI18N return counter.decrementAndGet() == 0 || (!analysisRunning.get() && !engine.isCancelled()); // process all hits while the analysis is running } }); if (counter.get() == 0) { sb.append("<tr><td><h4>"); // NOI18N sb.append(NbBundle.getMessage(OQLController.class, "OQL_TOO_MANY_RESULTS_MSG")); // NOI18N sb.append("</h4></td></tr>"); // NOI18N } else if (counter.get() == RESULTS_LIMIT) { sb.append("<tr><td><h4>"); // NOI18N sb.append(NbBundle.getMessage(OQLController.class, "OQL_NO_RESULTS_MSG")); // NOI18N sb.append("</h4></td></tr>" ); // NOI18N } sb.append("</table>"); // NOI18N resultsController.setResult(sb.toString()); finalizeQuery(); } catch (OQLException oQLException) { StringBuilder errorMessage = new StringBuilder(); errorMessage.append("<h2>").append(NbBundle.getMessage(OQLController.class, "OQL_QUERY_ERROR")).append("</h2>"); // NOI18N errorMessage.append(NbBundle.getMessage(OQLController.class, "OQL_QUERY_PLZ_CHECK")); // NOI18N errorMessage.append("<hr>"); // noi18n errorMessage.append(oQLException.getLocalizedMessage().replace("\n", "<br>").replace("\r", "<br>")); resultsController.setResult(errorMessage.toString()); finalizeQuery(); } } }); } }); }
static DefaultBoundedRangeModelBuilder fromField(Instance instance, String field, Heap heap) { Object model = instance.getValueOfField(field); if (!(model instanceof Instance)) return null; if (!DetailsUtils.isSubclassOf((Instance)model, DefaultBoundedRangeModel.class.getName())) return null; return new DefaultBoundedRangeModelBuilder((Instance)model, heap); }
protected DefaultBoundedRangeModel createInstanceImpl() { return new DefaultBoundedRangeModel(value, extent, min, max); }
/** * */ public CircledProgressBar() { this(new DefaultBoundedRangeModel()); }
public static BoundedRangeModel toBoundedRangeModel(SpinnerNumberModel m) { return new DefaultBoundedRangeModel((int)((Float)(m.getValue())).floatValue(), 0, (int)((Float)(m.getMinimum())).floatValue(), (int)((Float)(m.getMaximum())).floatValue()); }
public DefaultBoundedRangeModel getYRangeModel() { return yRangeModel; }
public DefaultBoundedRangeModel getTimeScaleRangeModel() { return timeScaleRangeModel; }
public DefaultBoundedRangeModel getValueScaleRangeModel() { return valueScaleRangeModel; }
public DefaultBoundedRangeModel getChannelHeightRangeModel() { return channelHeightRangeModel; }