Refine search
/** * Creates a new {@code ScrollingAWTTerminal} with customizable settings. * @param deviceConfiguration How to configure the terminal virtual device * @param fontConfiguration What kind of fonts to use * @param colorConfiguration Which color schema to use for ANSI colors */ @SuppressWarnings({"SameParameterValue", "WeakerAccess"}) public ScrollingAWTTerminal( TerminalEmulatorDeviceConfiguration deviceConfiguration, SwingTerminalFontConfiguration fontConfiguration, TerminalEmulatorColorConfiguration colorConfiguration) { this.scrollBar = new Scrollbar(Scrollbar.VERTICAL); this.awtTerminal = new AWTTerminal( deviceConfiguration, fontConfiguration, colorConfiguration, new ScrollController()); setLayout(new BorderLayout()); add(awtTerminal, BorderLayout.CENTER); add(scrollBar, BorderLayout.EAST); this.scrollBar.setMinimum(0); this.scrollBar.setMaximum(20); this.scrollBar.setValue(0); this.scrollBar.setVisibleAmount(20); this.scrollBar.addAdjustmentListener(new ScrollbarListener()); this.scrollModelUpdateBySystem = false; }
int value = scrollBar.getValue(); int maximum = scrollBar.getMaximum(); int visibleAmount = scrollBar.getVisibleAmount(); if(lastMaximum < maximum && lastMaximum - visibleAmount - value == 0) { value = scrollBar.getValue() + (maximum - lastMaximum); if(scrollBar.getMaximum() != maximum) { scrollBar.setMaximum(maximum); if(scrollBar.getVisibleAmount() != visibleAmount) { scrollBar.setVisibleAmount(visibleAmount); if(scrollBar.getValue() != value) { scrollBar.setValue(value);
public synchronized void adjustmentValueChanged(AdjustmentEvent e) { Object source = e.getSource(); for (int i=0; i<slider.size(); i++) { if (source==slider.elementAt(i)) { Scrollbar sb = (Scrollbar)source; int index = ((Integer)sliderIndexes.get(i)).intValue(); TextField tf = (TextField)numberField.elementAt(index); double scale = ((Double)sliderScales.get(i)).doubleValue(); int digits = ((Integer)sliderDigits.get(i)).intValue(); tf.setText(""+IJ.d2s(sb.getValue()/scale,digits)); } } }
public void textValueChanged(TextEvent e) { notifyListeners(e); if (slider==null) return; Object source = e.getSource(); for (int i=0; i<slider.size(); i++) { int index = ((Integer)sliderIndexes.get(i)).intValue(); if (source==numberField.elementAt(index)) { TextField tf = (TextField)numberField.elementAt(index); double value = Tools.parseDouble(tf.getText()); if (!Double.isNaN(value)) { Scrollbar sb = (Scrollbar)slider.elementAt(i); double scale = ((Double)sliderScales.get(i)).doubleValue(); sb.setValue((int)(value*scale)); } } } }
/** Displays a color selection dialog and returns the color selected by the user. */ public Color getColor() { GenericDialog gd = frame!=null?new GenericDialog(title, frame):new GenericDialog(title); gd.addSlider("Red:", 0, 255, red); gd.addSlider("Green:", 0, 255, green); gd.addSlider("Blue:", 0, 255, blue); panel = new ColorPanel(initialColor); gd.addPanel(panel, GridBagConstraints.CENTER, new Insets(10, 0, 0, 0)); colors = gd.getNumericFields(); for (int i=0; i<colors.size(); i++) ((TextField)colors.elementAt(i)).addTextListener(this); sliders = gd.getSliders(); for (int i=0; i<sliders.size(); i++) ((Scrollbar)sliders.elementAt(i)).addAdjustmentListener(this); gd.showDialog(); if (gd.wasCanceled()) return null; int red = (int)gd.getNextNumber(); int green = (int)gd.getNextNumber(); int blue = (int)gd.getNextNumber(); return new Color(red, green, blue); }
private void setWidth(int width) { if (gd==null) return; Vector numericFields = gd.getNumericFields(); TextField widthField = (TextField)numericFields.elementAt(0); widthField.setText(""+width); Vector sliders = gd.getSliders(); Scrollbar sb = (Scrollbar)sliders.elementAt(0); sb.setValue(width); }
private void updateScrollbars() { int max = items.size()+1; if(items.size() > visibleItemCount) { vscroll.setMaximum(max); vscroll.setVisibleAmount(visibleItemCount); vscroll.setVisible(true); } else { vscroll.setValue(0); vscroll.setMaximum(max); vscroll.setVisibleAmount(max); if (scrollbarDisplayPolicy == SCROLLBARS_ASNEEDED) { vscroll.setVisible(false); } } int myWidth = getSize().width-HMARGIN*2; hscroll.setMaximum(maxwidth); hscroll.setVisibleAmount(myWidth); if (maxwidth > myWidth) { hscroll.setVisible(true); } else { if (scrollbarDisplayPolicy == SCROLLBARS_ASNEEDED) { hscroll.setVisible(false); } } }
@Override public void run(final ImageProcessor ip) { if(image.getRoi() == null) { IJ.error("Selection required"); return; Roi roiCopy = (Roi)image.getRoi().clone(); copy = ip.duplicate(); final GenericDialog gd = new GenericDialog("Adjust local threshold"); gd.addSlider("min value", 0, 255, lastMinThreshold); gd.addSlider("max value", 0, 255, lastMaxThreshold); final Scrollbar minSlider = (Scrollbar)gd.getSliders().get(0); final Scrollbar maxSlider = (Scrollbar)gd.getSliders().get(1); minSlider.addAdjustmentListener(listener); maxSlider.addAdjustmentListener(listener); applyThreshold(ip, image.getRoi(), lastMinThreshold, lastMaxThreshold); image.updateAndDraw();
protected boolean adjustNodeColors(final Node<T> nd) { final Color color = null == nd.color ? this.color : nd.color; final GenericDialog gd = new GenericDialog("Node colors"); gd.addSlider("Red: ", 0, 255, color.getRed()); gd.addSlider("Green: ", 0, 255, color.getGreen()); gd.addSlider("Blue: ", 0, 255, color.getBlue()); final Scrollbar red = (Scrollbar)gd.getSliders().get(0); final Scrollbar green = (Scrollbar)gd.getSliders().get(1); final Scrollbar blue = (Scrollbar)gd.getSliders().get(2); final Color original = nd.color; // may be null final SliderListener slc = new SliderListener() { red.addAdjustmentListener(slc); green.addAdjustmentListener(slc); blue.addAdjustmentListener(slc); final String[] choices = {"this node only", "nodes until next branch or end node", "entire subtree"}; gd.addChoice("Apply to:", choices, choices[0]); final Color c = new Color(red.getValue(), green.getValue(), blue.getValue()); switch (gd.getNextChoiceIndex()) { case 0:
protected GenericDialog makeAdjustPropertiesDialog() { Rectangle box = getBoundingBox(null); GenericDialog gd = new GD("Properties of #" + id, this); gd.addStringField("title: ", title); gd.addNumericField("x: ", box.x, 2); gd.addNumericField("y: ", box.y, 2); gd.addNumericField("scale_x: ", 1, 2); gd.addNumericField("scale_y: ", 1, 2); gd.addCheckbox("locked", locked); final Scrollbar alp = (Scrollbar)gd.getSliders().get(0); final Scrollbar red = (Scrollbar)gd.getSliders().get(1); final Scrollbar green = (Scrollbar)gd.getSliders().get(2); final Scrollbar blue = (Scrollbar)gd.getSliders().get(3); final TextField talp = (TextField)gd.getNumericFields().get(5); alp.addAdjustmentListener(sla); red.addAdjustmentListener(slc); green.addAdjustmentListener(slc); blue.addAdjustmentListener(slc); talp.addTextListener(sla); tred.addTextListener(slc); tgreen.addTextListener(slc); tblue.addTextListener(slc);
@Override public void run(String args) { int defaultNo = 1; final Image3DUniverse univ = new Image3DUniverse(512, 512); displayCube(univ); Transform3D initialRot = new Transform3D(); Transform3D tmp = new Transform3D(); initialRot.rotY(Math.PI/4); tmp.rotX(-Math.PI/4); initialRot.mul(tmp); // univ.getGlobalRotate().setTransform(initialRot); univ.show(); displayCase(univ, defaultNo); GenericDialog gd = new GenericDialog("ImageJ 3D Viewer"); gd.addSlider("case: ", 0, 255, defaultNo); final Scrollbar slider = (Scrollbar)gd.getSliders().get(0); slider.addAdjustmentListener(new AdjustmentListener() { @Override public void adjustmentValueChanged(AdjustmentEvent e) { displayCase(univ, slider.getValue()); } }); gd.setModal(false); gd.showDialog(); if(gd.wasCanceled()) return; }
synchronized private final int adjustResampling() { if (resample > 0) return resample; final GenericDialog gd = new GenericDialog("Resample"); final int default_resample = estimateResamplingFactor(); gd.addSlider("Resample: ", 1, Math.max(default_resample, 100), -1 != resample ? resample : default_resample); gd.showDialog(); if (gd.wasCanceled()) { resample = -1 != resample ? resample : default_resample; // current or default value return resample; } resample = ((java.awt.Scrollbar)gd.getSliders().get(0)).getValue(); return resample; }
public void changePointSize(final Content c) { if (!checkSel(c)) return; final GenericDialog gd = new GenericDialog("Point size", univ.getWindow()); final float oldS = (c.getLandmarkPointSize()); final float minS = oldS / 10f; final float maxS = oldS * 10f; gd.addSlider("Size", minS, maxS, oldS); final TextField textField = (TextField) gd.getNumericFields().get(0); textField.addTextListener(new TextListener() { ((Scrollbar) gd.getSliders().get(0)) .addAdjustmentListener(new AdjustmentListener() {
@Override public void windowClosed(final WindowEvent e) { if (null != transp_adjuster) transp_adjuster.quit(); if (gd.wasCanceled()) { final float newTr = oldTr / 100f; ci.setTransparency(newTr); univ.fireContentChanged(c); return; } // apply to all instants of the content if (aBox.getState()) c.setTransparency(ci.getTransparency()); record(SET_TRANSPARENCY, Float.toString(((Scrollbar) gd.getSliders() .get(0)).getValue() / 100f)); } });
public void run(ImageProcessor ip) { roiManager = RoiManager.getInstance(); if (roiManager == null || roiManager.getCount() < 2) { IJ.error("Need at least two oval selections in the ROI Manager"); return; int currentSlice = image.getCurrentSlice(); Roi savedRoi = image.getRoi(); image.setRoi(rois[currentSlice - 1]); GenericDialog gd = new GenericDialog("Circle interpolator"); gd.addSlider("slice", 1, image.getStackSize(), currentSlice); SliderListener listener = new SliderListener(); listener.textField = (TextField)gd.getNumericFields().lastElement(); Scrollbar slider = (Scrollbar)gd.getSliders().lastElement(); slider.addAdjustmentListener(listener); gd.addCheckbox("plot_average_intensity", true); gd.addCheckbox("combine_plots", false);
cScroll = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, c + 1); add(cScroll); if (ij != null) cScroll.addKeyListener(ij); cScroll.addAdjustmentListener(this); cScroll.setFocusable(false); cScroll.setUnitIncrement(1); cScroll.setBlockIncrement(1); zScroll = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, z + 1); add(zScroll); if (ij != null) zScroll.addKeyListener(ij); zScroll.addAdjustmentListener(this); zScroll.setFocusable(false); int blockIncrement = Math.max(z / 10, 1); zScroll.setUnitIncrement(1); zScroll.setBlockIncrement(blockIncrement); tScroll = new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, t + 1); add(tScroll); if (ij != null) tScroll.addKeyListener(ij); tScroll.addAdjustmentListener(this); tScroll.setFocusable(false); int blockIncrement = Math.max(t / 10, 1); tScroll.setUnitIncrement(1); tScroll.setBlockIncrement(blockIncrement); new Scrollbar(Scrollbar.HORIZONTAL, 1, 1, 1, cLengths[i] + 1); cSliders[i].addAdjustmentListener(this);
public StackWindow(ImagePlus imp, ImageCanvas ic) { super(imp, ic); addScrollbars(imp); addMouseWheelListener(this); if (sliceSelector==null && this.getClass().getName().indexOf("Image5D")!=-1) sliceSelector = new Scrollbar(); // prevents Image5D from crashing pack(); ic = imp.getCanvas(); if (ic!=null) ic.setMaxBounds(); show(); int previousSlice = imp.getCurrentSlice(); if (previousSlice>1 && previousSlice<=imp.getStackSize()) imp.setSlice(previousSlice); else imp.setSlice(1); thread = new Thread(this, "zSelector"); thread.start(); }
GUI( final ImagePlus imp ) { window = imp.getWindow(); canvas = imp.getCanvas(); scrollBar = ( Scrollbar )( ( Panel )window.getComponent( 1 ) ).getComponent( 1 ); scrollBarValue = scrollBar.getValue(); scrollBarVisible = scrollBar.getVisibleAmount(); scrollBarMin = scrollBar.getMinimum(); scrollBarMax = scrollBar.getMaximum(); ij = IJ.getInstance(); }