/** * 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; }
StackWindowWith3dRoi(ImagePlus image, ImageCanvas canvas) { super(image, canvas); int i = image.getCurrentSlice(); sliceSelector.addAdjustmentListener(new Listener(i)); }
protected void register() { ImagePlus.addImageListener(this); notifyIfChanged(); if (window == null) return; window.addMouseWheelListener(this); for (Component child : window.getComponents()) if (child instanceof Scrollbar) ((Scrollbar)child).addAdjustmentListener(this); else if (child instanceof Container) for (Component child2 : ((Container)child).getComponents()) if (child2 instanceof Scrollbar) ((Scrollbar)child2).addAdjustmentListener(this); }
public static void addScrollListener(final ImagePlus img, final AdjustmentListener al, final MouseWheelListener ml) { for (final Component c : img.getWindow().getComponents()) { if (c instanceof Scrollbar) ((Scrollbar) c).addAdjustmentListener(al); else if (c instanceof Container) { for (final Component c2 : ((Container) c).getComponents()) { if (c2 instanceof Scrollbar) { ((Scrollbar) c2).addAdjustmentListener(al); } } } } img.getWindow().addMouseWheelListener(ml); }
/** * Sets 'a' as vertical Scrollbar. * The Browser becomes an AdjustmentListener of this scrollbar. */ public void setVerticalScrollbar(Scrollbar a) { vscroll = a; vscroll.addAdjustmentListener(this); vscroll.setMaximum(visibleItemCount); vscroll.setVisibleAmount(visibleItemCount); vscroll.setBlockIncrement(visibleItemCount); }
public ScrollbarWithLabel(StackWindow stackWindow, int value, int visible, int minimum, int maximum, char label) { super(new BorderLayout(2, 0)); this.stackWindow = stackWindow; bar = new Scrollbar(Scrollbar.HORIZONTAL, value, visible, minimum, maximum); icon = new Icon(label); add(icon, BorderLayout.WEST); add(bar, BorderLayout.CENTER); bar.addAdjustmentListener(this); addKeyListener(IJ.getInstance()); }
/** * Sets 'a' as horizontal Scrollbar. * The Browser becomes an AdjustmentListener of this scrollbar. */ public void setHorizontalScrollbar(Scrollbar a) { hscroll = a; hscroll.addAdjustmentListener(this); int myWidth = getSize().width-HMARGIN*2; hscroll.setMaximum(myWidth); hscroll.setVisibleAmount(myWidth); hscroll.setBlockIncrement(20); }
public ScrollbarWithLabel(StackWindow stackWindow, int value, int visible, int minimum, int maximum, char label) { super(new BorderLayout(2, 0)); this.stackWindow = stackWindow; bar = new Scrollbar(Scrollbar.HORIZONTAL, value, visible, minimum, maximum); icon = new Icon(label); add(icon, BorderLayout.WEST); add(bar, BorderLayout.CENTER); bar.addAdjustmentListener(this); addKeyListener(IJ.getInstance()); }
public ScrollbarWithLabel(final int orientation, final int value, final int visible, final int minimum, final int maximum, final String label) { super(new BorderLayout(2, 0)); this.orientation = orientation; bar = new Scrollbar(orientation, value, visible, minimum, maximum); if (label != null) { this.label = new Label(label); } else { this.label = new Label(""); } if (orientation == Scrollbar.HORIZONTAL) add(this.label, BorderLayout.WEST); else if (orientation == Scrollbar.VERTICAL) add(this.label, BorderLayout.NORTH); else throw new IllegalArgumentException("invalid orientation"); add(bar, BorderLayout.CENTER); bar.addAdjustmentListener(this); }
protected void handleImage(ImagePlus image, boolean addAsListener) { ImageWindow window = image.getWindow(); for (Component comp : window.getComponents()) if (comp instanceof Scrollbar) { Scrollbar bar = (Scrollbar)comp; if (addAsListener) bar.addAdjustmentListener(this); else bar.removeAdjustmentListener(this); } if (addAsListener) window.addWindowListener(this); else window.removeWindowListener(this); }
/** 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); }
@Override public void set(final WidgetModel model) { super.set(model); final Number min = model.getMin(); final Number max = model.getMax(); final Number stepSize = model.getStepSize(); scrollBar = new Scrollbar(Adjustable.HORIZONTAL, min.intValue(), 1, min.intValue(), max.intValue() + 1); scrollBar.setUnitIncrement(stepSize.intValue()); scrollBar.addAdjustmentListener(this); getComponent().add(scrollBar, BorderLayout.CENTER); textField = new TextField(6); textField.addTextListener(this); getComponent().add(textField, BorderLayout.EAST); refreshWidget(); }
/** 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); }
/** * Add new event handlers. */ final void takeOverGui() { canvas.addKeyListener( Stack_Rotate.this ); window.addKeyListener( Stack_Rotate.this ); canvas.addMouseMotionListener( Stack_Rotate.this ); canvas.addMouseListener( Stack_Rotate.this ); ij.addKeyListener( Stack_Rotate.this ); window.addMouseWheelListener( Stack_Rotate.this ); scrollBar.addAdjustmentListener( Stack_Rotate.this ); updateScrollBar(); }
/** * Add new event handlers. */ final void takeOverGui() { canvas.addKeyListener( Stack_Rotate.this ); window.addKeyListener( Stack_Rotate.this ); canvas.addMouseMotionListener( Stack_Rotate.this ); canvas.addMouseListener( Stack_Rotate.this ); ij.addKeyListener( Stack_Rotate.this ); window.addMouseWheelListener( Stack_Rotate.this ); scrollBar.addAdjustmentListener( Stack_Rotate.this ); updateScrollBar(); }
/** Constructs a new TextPanel. */ public TextPanel() { tc = new TextCanvas(this); setLayout(new BorderLayout()); add("Center",tc); sbHoriz=new Scrollbar(Scrollbar.HORIZONTAL); sbHoriz.addAdjustmentListener(this); sbHoriz.setFocusable(false); // prevents scroll bar from blinking on Windows add("South", sbHoriz); sbVert=new Scrollbar(Scrollbar.VERTICAL); sbVert.addAdjustmentListener(this); sbVert.setFocusable(false); ImageJ ij = IJ.getInstance(); if (ij!=null) { sbHoriz.addKeyListener(ij); sbVert.addKeyListener(ij); } add("East", sbVert); addPopupMenu(); }
private void addExtraScrollbar( double defaultMaxValue ) { label = new Label(""); add(label); updateLabel( defaultMaxValue ); maxValueScrollbar = new Scrollbar( Scrollbar.HORIZONTAL, (int)defaultMaxValue, 1, 1, 350 ); maxValueScrollbar.addAdjustmentListener( new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { manuallyChangedAlready = true; int newValue = e.getValue(); maxChanged( newValue ); } } ); add(maxValueScrollbar); pack(); }
/** Constructs a new TextPanel. */ public TextPanel() { tc = new TextCanvas(this); setLayout(new BorderLayout()); add("Center",tc); sbHoriz=new Scrollbar(Scrollbar.HORIZONTAL); sbHoriz.addAdjustmentListener(this); sbHoriz.setFocusable(false); // prevents scroll bar from blinking on Windows add("South", sbHoriz); sbVert=new Scrollbar(Scrollbar.VERTICAL); sbVert.addAdjustmentListener(this); sbVert.setFocusable(false); ImageJ ij = IJ.getInstance(); if (ij!=null) { sbHoriz.addKeyListener(ij); sbVert.addKeyListener(ij); } add("East", sbVert); addPopupMenu(); }
/** * Restore the previously active Event handlers. */ final void restoreGui() { clearGui(); for ( final KeyListener l : canvasKeyListeners ) canvas.addKeyListener( l ); for ( final KeyListener l : windowKeyListeners ) window.addKeyListener( l ); for ( final KeyListener l : ijKeyListeners ) ij.addKeyListener( l ); for ( final MouseListener l : canvasMouseListeners ) canvas.addMouseListener( l ); for ( final MouseMotionListener l : canvasMouseMotionListeners ) canvas.addMouseMotionListener( l ); for ( final MouseWheelListener l : windowMouseWheelListeners ) window.addMouseWheelListener( l ); for ( final AdjustmentListener l : scrollBarAdjustmentListeners ) scrollBar.addAdjustmentListener( l ); scrollBar.setValues( scrollBarValue, scrollBarVisible, scrollBarMin, scrollBarMax ); }
/** * Restore the previously active Event handlers. */ final void restoreGui() { clearGui(); for ( final KeyListener l : canvasKeyListeners ) canvas.addKeyListener( l ); for ( final KeyListener l : windowKeyListeners ) window.addKeyListener( l ); for ( final KeyListener l : ijKeyListeners ) ij.addKeyListener( l ); for ( final MouseListener l : canvasMouseListeners ) canvas.addMouseListener( l ); for ( final MouseMotionListener l : canvasMouseMotionListeners ) canvas.addMouseMotionListener( l ); for ( final MouseWheelListener l : windowMouseWheelListeners ) window.addMouseWheelListener( l ); for ( final AdjustmentListener l : scrollBarAdjustmentListeners ) scrollBar.addAdjustmentListener( l ); scrollBar.setValues( scrollBarValue, scrollBarVisible, scrollBarMin, scrollBarMax ); }