use of com.revolsys.swing.map.layer.Layer 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();
}
}
use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.
the class LayerTreeNode method loadChildrenDo.
@Override
protected List<BaseTreeNode> loadChildrenDo() {
final Layer layer = getLayer();
final LayerRenderer<? extends Layer> renderer = layer.getRenderer();
if (renderer == null) {
return Collections.emptyList();
} else {
final LayerRendererTreeNode rendererNode = new LayerRendererTreeNode(renderer);
return Collections.<BaseTreeNode>singletonList(rendererNode);
}
}
use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.
the class LayerTreeNode method refreshIcon.
public void refreshIcon() {
Icon icon;
final Layer layer = getLayer();
final List<Icon> icons = new ArrayList<>();
if (!layer.isExists() && layer.isInitialized()) {
icon = NOT_EXISTS_ICON;
} else {
final Icon layerIcon = layer.getIcon();
if (layer.getRenderer() == null) {
Icons.addIcon(icons, layerIcon, true);
} else {
final boolean visible = layer.isVisible();
Icons.addIcon(icons, layerIcon, visible);
if (layer.isSelectSupported()) {
final boolean selectable = layer.isSelectable();
Icons.addIcon(icons, SELECT_ICON, selectable);
}
}
if (!layer.isReadOnly()) {
final boolean editable = layer.isEditable();
Icons.addIcon(icons, EDIT_ICON, editable);
}
if (icons.isEmpty()) {
icon = null;
} else if (icons.size() == 1) {
icon = icons.get(0);
} else {
icon = ICON_CACHE.get(icons);
if (icon == null) {
icon = Icons.merge(icons, 5);
ICON_CACHE.put(icons, icon);
}
}
}
setIcon(icon);
}
Aggregations