@Override void initializeImpl() { super.initializeImpl(); final Scrollbar target = getTarget(); setLineIncrement(target.getUnitIncrement()); setPageIncrement(target.getBlockIncrement()); setValues(target.getValue(), target.getVisibleAmount(), target.getMinimum(), target.getMaximum()); final int orientation = target.getOrientation(); final JScrollBar delegate = getDelegate(); synchronized (getDelegateLock()) { delegate.setOrientation(orientation == Scrollbar.HORIZONTAL ? Adjustable.HORIZONTAL : Adjustable.VERTICAL); delegate.addAdjustmentListener(this); } }
public static boolean shouldFocusOnClick(Component component) { boolean acceptFocusOnClick = false; // A component is generally allowed to accept focus on click // if its peer is focusable. There're some exceptions though. // CANVAS & SCROLLBAR accept focus on click final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); if (component instanceof Canvas || component instanceof Scrollbar) { acceptFocusOnClick = true; // PANEL, empty only, accepts focus on click } else if (component instanceof Panel) { acceptFocusOnClick = (((Panel)component).getComponentCount() == 0); // Other components } else { ComponentPeer peer = (component != null ? acc.getPeer(component) : null); acceptFocusOnClick = (peer != null ? peer.isFocusable() : false); } return acceptFocusOnClick && acc.canBeFocusOwner(component); }
@Override protected Point getClickPoint(ComponentOperator oper, int direction, int orientation) { int x, y; if (orientation == Scrollbar.HORIZONTAL) { if (direction == ScrollAdjuster.INCREASE_SCROLL_DIRECTION) { x = oper.getWidth() - 1 - CLICK_OFFSET; } else if (direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) { x = CLICK_OFFSET; } else { return null; } y = oper.getHeight() / 2; } else if (orientation == Scrollbar.VERTICAL) { if (direction == ScrollAdjuster.INCREASE_SCROLL_DIRECTION) { y = oper.getHeight() - 1 - CLICK_OFFSET; } else if (direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) { y = CLICK_OFFSET; } else { return null; } x = oper.getWidth() / 2; } else { return null; } return new Point(x, y); }
public ClimaticPopInitialiser(int population) { populationSize = population; panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); populationLabel = new Label(Integer.toString(populationSize)); panel.add(new Label("Population Size", Label.RIGHT)); panel.add(new Scrollbar(Scrollbar.HORIZONTAL, populationSize, 1, MIN_POPULATION_SIZE, MAX_POPULATION_SIZE) { { addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent evt) { populationSize = getValue(); populationLabel.setText(Integer.toString(getValue())); populationLabel.repaint(); } } ); } } ); panel.add(populationLabel); }
public static boolean shouldFocusOnClick(Component component) { boolean acceptFocusOnClick = false; // A component is generally allowed to accept focus on click // if its peer is focusable. There're some exceptions though. // CANVAS & SCROLLBAR accept focus on click if (component instanceof Canvas || component instanceof Scrollbar) { acceptFocusOnClick = true; // PANEL, empty only, accepts focus on click } else if (component instanceof Panel) { acceptFocusOnClick = (((Panel)component).getComponentCount() == 0); // Other components } else { ComponentPeer peer = (component != null ? component.getPeer() : null); acceptFocusOnClick = (peer != null ? peer.isFocusable() : false); } return acceptFocusOnClick && AWTAccessor.getComponentAccessor().canBeFocusOwner(component); }
/** * Constructs a surface plot for the given Content. * * @param c */ public SurfacePlotGroup(final ContentInstant c) { super(); this.c = c; final int res = c.getResamplingFactor(); final ImagePlus imp = res == 1 ? c.getImage() : NaiveResampler.resample(c.getImage(), res, res, 1); final Volume volume = new Volume(imp); volume.setChannels(c.getChannels()); surfacep = new SurfacePlot(volume, c.getColor(), c.getTransparency(), c.getImage() .getSlice() - 1); surfacep.calculateMinMaxCenterPoint(min, max, center); addChild(surfacep); if (c.getImage().getStackSize() == 1) return; final StackWindow win = (StackWindow) c.getImage().getWindow(); if (win == null) return; final Component[] co = win.getComponents(); for (int i = 0; i < co.length; i++) { if (co[i] instanceof Scrollbar) { ((Scrollbar) co[i]).addAdjustmentListener(this); } } }
/** Creation de l'objet calque */ protected Calque(Aladin aladin) { this.aladin = aladin; select = new Select(aladin); zoom = new Zoom(aladin); scroll = new ScrollbarStack(aladin,Scrollbar.VERTICAL,FIRSTBLOC-1,1,0,FIRSTBLOC); // Creation des composantes de l'objet (plan, select et zoom) reallocPlan(); flagOverlay = true; reticleMode=aladin.configuration.get(Configuration.RETICLE)!=null ? 2 : 1; flagTip=aladin.configuration.get(Configuration.TOOLTIP)!=null; flagAutoDist = aladin.configuration.getAutoDist(); flagSimbad = aladin.configuration.getSimbadFlag(); flagVizierSED = aladin.configuration.getVizierSEDFlag(); setOverlayList("label,scale,size,NE,target,reticle,target,pixel"); // Panel principal : contient le selecteur de plans et le zoom setLayout( new BorderLayout(0,5) ); add(select,BorderLayout.CENTER); add(zoom,BorderLayout.SOUTH); }
/** Creation de l'objet calque */ protected Calque(Aladin aladin) { this.aladin = aladin; select = new Select(aladin); zoom = new Zoom(aladin); scroll = new ScrollbarStack(aladin,Scrollbar.VERTICAL,FIRSTBLOC-1,1,0,FIRSTBLOC); // Creation des composantes de l'objet (plan, select et zoom) reallocPlan(); flagOverlay = true; reticleMode=aladin.configuration.get(Configuration.RETICLE)!=null ? 2 : 1; flagTip=aladin.configuration.get(Configuration.TOOLTIP)!=null; flagAutoDist = aladin.configuration.getAutoDist(); flagSimbad = aladin.configuration.getSimbadFlag(); flagVizierSED = aladin.configuration.getVizierSEDFlag(); setOverlayList("label,scale,size,NE,target,reticle,target,pixel,sofiaimagers"); // Panel principal : contient le selecteur de plans et le zoom setLayout( new BorderLayout(0,5) ); add(select,BorderLayout.CENTER); add(zoom,BorderLayout.SOUTH); }
private void createSliderPanel(final Scrollbar sliderField, String label, final Label sliderLabel, final double scale) { Label listLabel = new Label(label, 0); add(listLabel, 0, 1); sliderField.setSize(100, 10); c.ipadx = 75; add(sliderField, 1, 1); c.ipadx = 0; sliderField.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent e) { setSliderLabel(sliderField, sliderLabel, scale); } }); add(sliderLabel, 2, 1); setSliderLabel(sliderField, sliderLabel, scale); row++; }
/** @return Propertydescriptors */ @Override protected PropertyDescriptor[] createPDs() throws IntrospectionException { PropertyDescriptor[] pds = new PropertyDescriptor[] { new PropertyDescriptor("unitIncrement", Scrollbar.class), // NOI18N new PropertyDescriptor("minimum", Scrollbar.class), // NOI18N new PropertyDescriptor("maximum", Scrollbar.class), // NOI18N new PropertyDescriptor("value", Scrollbar.class), // NOI18N new PropertyDescriptor("blockIncrement", Scrollbar.class), // NOI18N new PropertyDescriptor("orientation", Scrollbar.class), // NOI18N new PropertyDescriptor("visibleAmount", Scrollbar.class), // NOI18N }; pds[5].setPropertyEditorClass(ScrollbarBeanInfo.OrientationPropertyEditor.class); return pds; }
@Override public void setAsText(String s) { Integer i; getTags(); if (s.equals(tags[0])) i = new Integer(Scrollbar.HORIZONTAL); else i = new Integer(Scrollbar.VERTICAL); setValue(i); }
@SuppressWarnings("deprecation") public static boolean shouldFocusOnClick(Component component) { boolean acceptFocusOnClick = false; // A component is generally allowed to accept focus on click // if its peer is focusable. There're some exceptions though. // CANVAS & SCROLLBAR accept focus on click if (component instanceof Canvas || component instanceof Scrollbar) { acceptFocusOnClick = true; // PANEL, empty only, accepts focus on click } else if (component instanceof Panel) { acceptFocusOnClick = (((Panel)component).getComponentCount() == 0); // Other components } else { ComponentPeer peer = (component != null ? component.getPeer() : null); acceptFocusOnClick = (peer != null ? peer.isFocusable() : false); } return acceptFocusOnClick && AWTAccessor.getComponentAccessor().canBeFocusOwner(component); }
@Override public void scrollToMinimum(ComponentOperator oper, final int orientation) { final Adjustable adj = (orientation == Scrollbar.HORIZONTAL) ? ((ScrollPaneOperator) oper).getHAdjustable() : ((ScrollPaneOperator) oper).getVAdjustable(); scroll(oper, new ScrollAdjuster() { @Override public int getScrollDirection() { return ((adj.getMinimum() < adj.getValue()) ? DECREASE_SCROLL_DIRECTION : DO_NOT_TOUCH_SCROLL_DIRECTION); } @Override public int getScrollOrientation() { return orientation; } @Override public String getDescription() { return "Scroll to minimum"; } @Override public String toString() { return "scrollToMinimum.ScrollAdjuster{description = " + getDescription() + '}'; } }); }
@Override public void scrollToMaximum(ComponentOperator oper, final int orientation) { final Adjustable adj = (orientation == Scrollbar.HORIZONTAL) ? ((ScrollPaneOperator) oper).getHAdjustable() : ((ScrollPaneOperator) oper).getVAdjustable(); scroll(oper, new ScrollAdjuster() { @Override public int getScrollDirection() { return (((adj.getMaximum() - adj.getVisibleAmount()) > adj.getValue()) ? INCREASE_SCROLL_DIRECTION : DO_NOT_TOUCH_SCROLL_DIRECTION); } @Override public int getScrollOrientation() { return orientation; } @Override public String getDescription() { return "Scroll to maximum"; } @Override public String toString() { return "scrollToMaximum.ScrollAdjuster{description = " + getDescription() + '}'; } }); }
/** * Constructs a ScrollbarOperator object. * * @param cont a container * @param index an index between appropriate ones. */ public ScrollbarOperator(ContainerOperator<?> cont, int index) { this((Scrollbar) waitComponent(cont, new ScrollbarFinder(), index)); copyEnvironment(cont); }
/** * Maps {@code Scrollbar.addAdjustmentListener(AdjustmentListener)} * through queue */ public void addAdjustmentListener(final AdjustmentListener adjustmentListener) { runMapping(new MapVoidAction("addAdjustmentListener") { @Override public void map() { ((Scrollbar) getSource()).addAdjustmentListener(adjustmentListener); } }); }
/** * Maps {@code Scrollbar.getBlockIncrement()} through queue */ public int getBlockIncrement() { return (runMapping(new MapIntegerAction("getBlockIncrement") { @Override public int map() { return ((Scrollbar) getSource()).getBlockIncrement(); } })); }
/** * Maps {@code Scrollbar.getMaximum()} through queue */ public int getMaximum() { return (runMapping(new MapIntegerAction("getMaximum") { @Override public int map() { return ((Scrollbar) getSource()).getMaximum(); } })); }
/** * Maps {@code Scrollbar.getMinimum()} through queue */ public int getMinimum() { return (runMapping(new MapIntegerAction("getMinimum") { @Override public int map() { return ((Scrollbar) getSource()).getMinimum(); } })); }
/** * Maps {@code Scrollbar.getOrientation()} through queue */ public int getOrientation() { return (runMapping(new MapIntegerAction("getOrientation") { @Override public int map() { return ((Scrollbar) getSource()).getOrientation(); } })); }
/** * Maps {@code Scrollbar.getUnitIncrement()} through queue */ public int getUnitIncrement() { return (runMapping(new MapIntegerAction("getUnitIncrement") { @Override public int map() { return ((Scrollbar) getSource()).getUnitIncrement(); } })); }
/** * Maps {@code Scrollbar.getValue()} through queue */ public int getValue() { return (runMapping(new MapIntegerAction("getValue") { @Override public int map() { return ((Scrollbar) getSource()).getValue(); } })); }
/** * Maps {@code Scrollbar.getVisibleAmount()} through queue */ public int getVisibleAmount() { return (runMapping(new MapIntegerAction("getVisibleAmount") { @Override public int map() { return ((Scrollbar) getSource()).getVisibleAmount(); } })); }
/** * Maps {@code Scrollbar.removeAdjustmentListener(AdjustmentListener)} * through queue */ public void removeAdjustmentListener(final AdjustmentListener adjustmentListener) { runMapping(new MapVoidAction("removeAdjustmentListener") { @Override public void map() { ((Scrollbar) getSource()).removeAdjustmentListener(adjustmentListener); } }); }