Search in sources :

Example 6 with TreeUI

use of javax.swing.plaf.TreeUI in project com.revolsys.open by revolsys.

the class LayerGroupTreeNode method mouseClicked.

@Override
public void mouseClicked(final MouseEvent e) {
    final Object source = e.getSource();
    final JTree tree = getTree();
    if (source == tree) {
        final int clickCount = e.getClickCount();
        if (clickCount == 2 && SwingUtilities.isLeftMouseButton(e)) {
            final int x = e.getX();
            final int y = e.getY();
            final TreePath path = tree.getPathForLocation(x, y);
            final Layer layer = getLayer();
            final TreeUI ui = tree.getUI();
            final Rectangle bounds = ui.getPathBounds(tree, path);
            final int cX = x - bounds.x;
            final int index = cX / 21;
            int offset = 0;
            if (index == offset) {
                layer.setVisible(!layer.isVisible());
            }
            offset++;
        }
        e.consume();
    }
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) Rectangle(java.awt.Rectangle) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer) TreeUI(javax.swing.plaf.TreeUI)

Example 7 with TreeUI

use of javax.swing.plaf.TreeUI in project intellij-community by JetBrains.

the class Tree method isLocationInExpandControl.

private boolean isLocationInExpandControl(final TreePath path, final int x, final int y) {
    final TreeUI ui = getUI();
    if (!(ui instanceof BasicTreeUI))
        return false;
    try {
        Class aClass = ui.getClass();
        while (BasicTreeUI.class.isAssignableFrom(aClass) && !BasicTreeUI.class.equals(aClass)) {
            aClass = aClass.getSuperclass();
        }
        final Method method = ReflectionUtil.getDeclaredMethod(aClass, "isLocationInExpandControl", TreePath.class, int.class, int.class);
        if (method != null) {
            return (Boolean) method.invoke(ui, path, x, y);
        }
    } catch (Throwable ignore) {
    }
    return false;
}
Also used : BasicTreeUI(javax.swing.plaf.basic.BasicTreeUI) Method(java.lang.reflect.Method) BasicTreeUI(javax.swing.plaf.basic.BasicTreeUI) WideSelectionTreeUI(com.intellij.util.ui.tree.WideSelectionTreeUI) TreeUI(javax.swing.plaf.TreeUI)

Example 8 with TreeUI

use of javax.swing.plaf.TreeUI in project com.revolsys.open by revolsys.

the class LayerTreeNode method mouseClicked.

@Override
public void mouseClicked(final MouseEvent e) {
    final Object source = e.getSource();
    final JTree tree = getTree();
    if (source == tree) {
        final int clickCount = e.getClickCount();
        if (clickCount == 2 && SwingUtilities.isLeftMouseButton(e)) {
            final int x = e.getX();
            final int y = e.getY();
            final TreePath path = tree.getPathForLocation(x, y);
            final Layer layer = getLayer();
            final TreeUI ui = tree.getUI();
            final Rectangle bounds = ui.getPathBounds(tree, path);
            final int cX = x - bounds.x;
            final int index = cX / 21;
            int offset = 0;
            if (index == offset) {
                layer.setVisible(!layer.isVisible());
            }
            offset++;
            if (layer.isSelectSupported()) {
                if (index == offset) {
                    layer.setSelectable(!layer.isSelectable());
                }
                offset++;
            }
            if (!layer.isReadOnly()) {
                if (index == offset) {
                    layer.setEditable(!layer.isEditable());
                }
                offset++;
            }
        }
        e.consume();
    }
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) Rectangle(java.awt.Rectangle) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer) TreeUI(javax.swing.plaf.TreeUI)

Aggregations

TreeUI (javax.swing.plaf.TreeUI)8 BasicTreeUI (javax.swing.plaf.basic.BasicTreeUI)5 Rectangle (java.awt.Rectangle)3 JTree (javax.swing.JTree)3 TreePath (javax.swing.tree.TreePath)3 WideSelectionTreeUI (com.intellij.util.ui.tree.WideSelectionTreeUI)2 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)2 Layer (com.revolsys.swing.map.layer.Layer)2 ScalableIcon (com.intellij.openapi.util.ScalableIcon)1 EmptyIcon (com.intellij.util.ui.EmptyIcon)1 Method (java.lang.reflect.Method)1