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();
}
}
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;
}
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();
}
}
Aggregations