Skip to content

Commit

Permalink
Fix #1506 Get collection of selected nodes
Browse files Browse the repository at this point in the history
Based no pull request #1508 Added getSelectedNodes in SelectionManager
  • Loading branch information
eduramiba committed Dec 26, 2016
1 parent d325411 commit 35f2582
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ public void resetSelection() {
engine.resetSelection();
}

public List<Node> getSelectedNodes() {
return engine.getSelectedUnderlyingNodes();
}

public void selectNode(Node node) {
if (!isCustomSelection()) {
setCustomSelection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Development and Distribution License("CDDL") (collectively, the
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.List;
import org.gephi.graph.api.Node;
import org.gephi.lib.gleem.linalg.Vecf;
import org.gephi.visualization.VizArchitecture;
import org.gephi.visualization.VizController;
Expand All @@ -69,7 +70,7 @@ Development and Distribution License("CDDL") (collectively, the
*
* @author Mathieu Bastian
*/
public abstract class AbstractEngine implements Engine, VizArchitecture {
public abstract class AbstractEngine implements Engine, VizArchitecture {

//Enums
public enum Limits {
Expand Down Expand Up @@ -164,6 +165,8 @@ public void propertyChange(PropertyChangeEvent evt) {
protected abstract void stopAnimating();

public abstract List<NodeModel> getSelectedNodes();

public abstract List<Node> getSelectedUnderlyingNodes();

// public abstract Model[] getSelectedObjects(int modelClass);
// public abstract void selectNodes(NodeModel obj);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Development and Distribution License("CDDL") (collectively, the
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.gephi.graph.api.Node;
import org.gephi.visualization.VizController;
import org.gephi.visualization.VizModel;
import org.gephi.visualization.apiimpl.Scheduler;
Expand Down Expand Up @@ -466,6 +467,18 @@ public List<NodeModel> getSelectedNodes() {
return selected;
}

@Override
public List<Node> getSelectedUnderlyingNodes() {
List<Node> selected = new ArrayList<>();
for (Iterator<NodeModel> itr = octree.getSelectableNodeIterator(); itr.hasNext();) {
NodeModel nodeModel = itr.next();
if (nodeModel.isSelected()) {
selected.add(nodeModel.getNode());
}
}
return selected;
}

// @Override
// public ModelImpl[] getSelectedObjects(int modelClass) {
// return selectedObjects[modelClasses[modelClass].getSelectionId()].toArray(new ModelImpl[0]);
Expand Down

0 comments on commit 35f2582

Please sign in to comment.