Search in sources :

Example 11 with Layer

use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.

the class LayerGroupTreeNode method addChild.

@Override
public int addChild(final int index, final Object object) {
    if (object instanceof Layer) {
        final Layer layer = (Layer) object;
        final LayerGroup group = getGroup();
        group.addLayer(index, layer);
        return index;
    } else {
        return -1;
    }
}
Also used : LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 12 with Layer

use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.

the class LayerGroupTreeNode method loadChildrenDo.

@Override
protected List<BaseTreeNode> loadChildrenDo() {
    final List<BaseTreeNode> children = new ArrayList<>();
    final LayerGroup group = getGroup();
    for (final Layer child : group) {
        final BaseTreeNode childNode = newTreeNode(child);
        children.add(childNode);
    }
    return children;
}
Also used : ArrayList(java.util.ArrayList) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 13 with Layer

use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.

the class LayerGroupTreeNode method removeChild.

@Override
public boolean removeChild(final Object child) {
    if (child instanceof Layer) {
        final Layer layer = (Layer) child;
        final LayerGroup group = getGroup();
        return group.removeLayer(layer);
    } else {
        return false;
    }
}
Also used : LayerGroup(com.revolsys.swing.map.layer.LayerGroup) Layer(com.revolsys.swing.map.layer.Layer) AbstractLayer(com.revolsys.swing.map.layer.AbstractLayer)

Example 14 with Layer

use of com.revolsys.swing.map.layer.Layer 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 15 with Layer

use of com.revolsys.swing.map.layer.Layer in project com.revolsys.open by revolsys.

the class ProjectFrame method getTreeNode.

public BaseTreeNode getTreeNode(final Layer layer) {
    final List<Layer> layerPath = layer.getPathList();
    final TreePath treePath = this.tocTree.getTreePath(layerPath);
    if (treePath == null) {
        return null;
    } else {
        return (BaseTreeNode) treePath.getLastPathComponent();
    }
}
Also used : TreePath(javax.swing.tree.TreePath) BaseTreeNode(com.revolsys.swing.tree.BaseTreeNode) Layer(com.revolsys.swing.map.layer.Layer)

Aggregations

Layer (com.revolsys.swing.map.layer.Layer)33 AbstractLayer (com.revolsys.swing.map.layer.AbstractLayer)18 LayerGroup (com.revolsys.swing.map.layer.LayerGroup)16 AbstractRecordLayer (com.revolsys.swing.map.layer.record.AbstractRecordLayer)10 ArrayList (java.util.ArrayList)8 NullLayer (com.revolsys.swing.map.layer.NullLayer)5 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)4 BaseTreeNode (com.revolsys.swing.tree.BaseTreeNode)4 List (java.util.List)4 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 Geometry (com.revolsys.geometry.model.Geometry)3 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)3 TreePath (javax.swing.tree.TreePath)3 MapPanel (com.revolsys.swing.map.MapPanel)2 BaseMapLayerGroup (com.revolsys.swing.map.layer.BaseMapLayerGroup)2 Project (com.revolsys.swing.map.layer.Project)2 ElevationModelLayer (com.revolsys.swing.map.layer.elevation.ElevationModelLayer)2 Rectangle (java.awt.Rectangle)2 JTree (javax.swing.JTree)2 TreeUI (javax.swing.plaf.TreeUI)2