Search in sources :

Example 1 with Accessible

use of javax.accessibility.Accessible in project spring-framework by spring-projects.

the class ProxyFactoryTests method testExclusionOfNonPublicInterfaces.

@Test
@Ignore("Not implemented yet, see http://jira.springframework.org/browse/SPR-5708")
public void testExclusionOfNonPublicInterfaces() {
    JFrame frame = new JFrame();
    ProxyFactory proxyFactory = new ProxyFactory(frame);
    Object proxy = proxyFactory.getProxy();
    assertTrue(proxy instanceof RootPaneContainer);
    assertTrue(proxy instanceof Accessible);
}
Also used : JFrame(javax.swing.JFrame) RootPaneContainer(javax.swing.RootPaneContainer) Accessible(javax.accessibility.Accessible) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with Accessible

use of javax.accessibility.Accessible in project android by JetBrains.

the class SunburstVisualTest method populateUi.

@Override
protected void populateUi(@NotNull JPanel panel) {
    JPanel controls = VisualTest.createControlledPane(panel, mSunburst);
    final JLabel info = new JLabel("<No information yet>");
    panel.add(info, BorderLayout.SOUTH);
    controls.add(VisualTest.createVariableSlider("Gap", 0, 200, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mSunburst.setGap(v);
        }

        @Override
        public int get() {
            return (int) mSunburst.getGap();
        }
    }));
    final JPanel sizeSlider = VisualTest.createVariableSlider("Size", 0, 200, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mSunburst.setSliceWidth(v);
        }

        @Override
        public int get() {
            return (int) mSunburst.getSliceWidth();
        }
    });
    controls.add(sizeSlider);
    controls.add(VisualTest.createVariableSlider("Angle", 0, 360, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mSunburst.setAngle(v);
        }

        @Override
        public int get() {
            return (int) mSunburst.getAngle();
        }
    }));
    controls.add(VisualTest.createVariableSlider("Start", 0, 360, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mSunburst.setStart(v);
        }

        @Override
        public int get() {
            return (int) mSunburst.getStart();
        }
    }));
    controls.add(VisualTest.createVariableSlider("Fixed", 1, 100, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mSunburst.setFixed(v);
        }

        @Override
        public int get() {
            return (int) mSunburst.getFixed();
        }
    }));
    controls.add(VisualTest.createVariableSlider("Separator", 0, 100, new VisualTests.Value() {

        @Override
        public void set(int v) {
            mSunburst.setSeparator(v);
        }

        @Override
        public int get() {
            return (int) mSunburst.getSeparator();
        }
    }));
    controls.add(VisualTest.createButton("Generate", new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            generateLayoutData((DataNode) mSunburst.getData(), 5);
        }
    }));
    controls.add(VisualTest.createButton("Tree A", new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DataNode g = new DataNode();
            g.addDataNode(createTree(1));
            g.addDataNode(createValue());
            g.addDataNode(createTree(1));
            g.addDataNode(createValue());
            g.addDataNode(createTree(0));
            mSunburst.setData(g);
        }
    }));
    controls.add(VisualTest.createButton("Tree B", new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DataNode g = new DataNode();
            g.addDataNode(createValue());
            g.addDataNode(createValue());
            g.addDataNode(createTree(0));
            mSunburst.setData(g);
        }
    }));
    controls.add(VisualTest.createButton("Value", new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            DataNode g = new DataNode();
            g.addDataNode(new DataNode(1, (int) (Math.random() * 50)));
            mSunburst.setData(g);
        }
    }));
    controls.add(VisualTest.createCheckbox("Auto size", new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            final boolean enableAutoSize = itemEvent.getStateChange() == ItemEvent.SELECTED;
            mSunburst.setAutoSize(enableAutoSize);
            // If auto size is enabled, size shouldn't be controlled by slider
            // sizeSlider is a JPanel and its first child is a JSlider
            Accessible sliderAccessible = SwingUtilities.getAccessibleChild(sizeSlider, 0);
            if (sliderAccessible instanceof JSlider) {
                JSlider slider = (JSlider) sliderAccessible;
                slider.setEnabled(!enableAutoSize);
                // If disabling auto size, set slider width to current slice width
                if (!enableAutoSize) {
                    slider.setValue((int) mSunburst.getSliceWidth());
                }
            }
        }
    }));
    controls.add(new Box.Filler(new Dimension(0, 0), new Dimension(300, Integer.MAX_VALUE), new Dimension(300, Integer.MAX_VALUE)));
    mSunburst.addSelectionListener(new SunburstChart.SliceSelectionListener() {

        @Override
        public void valueChanged(SunburstChart.SliceSelectionEvent e) {
            ValuedTreeNode node = e.getNode();
            info.setText(node == null ? "<No selection>" : String.format("Value %d Count %d", node.getValue(), node.getCount()));
        }
    });
}
Also used : ItemEvent(java.awt.event.ItemEvent) ActionEvent(java.awt.event.ActionEvent) SunburstChart(com.android.tools.adtui.chart.SunburstChart) ActionListener(java.awt.event.ActionListener) ValuedTreeNode(com.android.tools.adtui.ValuedTreeNode) ItemListener(java.awt.event.ItemListener) Accessible(javax.accessibility.Accessible)

Example 3 with Accessible

use of javax.accessibility.Accessible in project jdk8u_jdk by JetBrains.

the class CAccessibleText method getLineNumberForIndex.

static int getLineNumberForIndex(final Accessible a, int index) {
    final Accessible sa = CAccessible.getSwingAccessible(a);
    if (!(sa instanceof JTextComponent))
        return -1;
    final JTextComponent jc = (JTextComponent) sa;
    final Element root = jc.getDocument().getDefaultRootElement();
    // treat -1 special, returns the current caret position
    if (index == -1)
        index = jc.getCaretPosition();
    // Determine line number (can be -1)
    return root.getElementIndex(index);
}
Also used : Element(javax.swing.text.Element) JTextComponent(javax.swing.text.JTextComponent) Accessible(javax.accessibility.Accessible)

Example 4 with Accessible

use of javax.accessibility.Accessible in project jdk8u_jdk by JetBrains.

the class CAccessibleText method getRangeForLine.

static int[] getRangeForLine(final Accessible a, final int lineIndex) {
    Accessible sa = CAccessible.getSwingAccessible(a);
    if (!(sa instanceof JTextComponent))
        return null;
    final JTextComponent jc = (JTextComponent) sa;
    final Element root = jc.getDocument().getDefaultRootElement();
    final Element line = root.getElement(lineIndex);
    if (line == null)
        return null;
    return new int[] { line.getStartOffset(), line.getEndOffset() };
}
Also used : Element(javax.swing.text.Element) JTextComponent(javax.swing.text.JTextComponent) Accessible(javax.accessibility.Accessible)

Example 5 with Accessible

use of javax.accessibility.Accessible in project android by JetBrains.

the class ASGalleryTest method testAccessible.

public void testAccessible() {
    for (int i = 0; i < COLUMNS; i++) {
        ModelObject model = objects[i];
        Accessible child = gallery.getAccessibleContext().getAccessibleChild(i);
        assertNotNull(child);
        assertEquals(model.myLabel, child.getAccessibleContext().getAccessibleName());
        assertEquals(null, child.getAccessibleContext().getAccessibleDescription());
        assertEquals(gallery, child.getAccessibleContext().getAccessibleParent());
        assertEquals(i, child.getAccessibleContext().getAccessibleIndexInParent());
    }
}
Also used : Accessible(javax.accessibility.Accessible)

Aggregations

Accessible (javax.accessibility.Accessible)8 JTextComponent (javax.swing.text.JTextComponent)3 AccessibleContext (javax.accessibility.AccessibleContext)2 JFrame (javax.swing.JFrame)2 Element (javax.swing.text.Element)2 ValuedTreeNode (com.android.tools.adtui.ValuedTreeNode)1 SunburstChart (com.android.tools.adtui.chart.SunburstChart)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemEvent (java.awt.event.ItemEvent)1 ItemListener (java.awt.event.ItemListener)1 AccessibleSelection (javax.accessibility.AccessibleSelection)1 JComboBox (javax.swing.JComboBox)1 JProgressBar (javax.swing.JProgressBar)1 JSlider (javax.swing.JSlider)1 RootPaneContainer (javax.swing.RootPaneContainer)1 NimbusLookAndFeel (javax.swing.plaf.nimbus.NimbusLookAndFeel)1 Ignore (org.junit.Ignore)1