Author: scooter
Date: 2012-01-24 11:11:00 -0800 (Tue, 24 Jan 2012)
New Revision: 28088
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedListener.java
Modified:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroup.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeDestroyedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeRemovedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedToNetworkEvent.java
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupCollapsedEvent.java
Log:
Changed around the CyGroup interface a little and added some new events. Also
improved documentation for events. I thought actual documentation might be
better than cut-and-paste from the network events :-)
Modified:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroup.java
===================================================================
--- core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroup.java
2012-01-24 15:44:37 UTC (rev 28087)
+++ core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroup.java
2012-01-24 19:11:00 UTC (rev 28088)
@@ -120,13 +120,33 @@
void addNodes(List<CyNode> nodes);
/**
- * Remove a set of nodes from a group
+ * Add a list of edges to a group. The edges
+ * will be added either to the internal edges
+ * or external edges lists. Note that unlike
+ * {@link CyGroup#addNodes} either the source
+ * node or target node for the edge must be
+ * in the group.
*
+ * @param edges the list of edges to add
+ */
+ void addEdges(List<CyEdge> edges);
+
+ /**
+ * Remove a set of nodes and their edges from a group
+ *
* @param nodes the nodes to remove
*/
- void removeNodes(Collection<CyNode> nodes);
+ void removeNodes(List<CyNode> nodes);
/**
+ * Remove a set of edges from a group. Edges can be either
+ * internal edges or external edges.
+ *
+ * @param edges the edges to remove
+ */
+ void removeEdges(List<CyEdge> edges);
+
+ /**
* Return the root network for this group. A group can only
* exist within one root network, and all nodes and edges
* that are part of the group must exist within that root network
Modified:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeDestroyedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeDestroyedEvent.java
2012-01-24 15:44:37 UTC (rev 28087)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeDestroyedEvent.java
2012-01-24 19:11:00 UTC (rev 28088)
@@ -6,7 +6,9 @@
/**
- * This event signals that a group is about to be destroyed.
+ * This event signals that a group is about to be destroyed -- i.e. completely
removed
+ * from all networks. The group's subnetwork and group node will also be
destroyed.
+ *
* @CyAPI.Final.Class
*/
public final class GroupAboutToBeDestroyedEvent extends
AbstractGroupManagerEvent {
Modified:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeRemovedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeRemovedEvent.java
2012-01-24 15:44:37 UTC (rev 28087)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeRemovedEvent.java
2012-01-24 19:11:00 UTC (rev 28088)
@@ -7,7 +7,11 @@
/**
- * This event signals that a network has been added.
+ * This event signals that a group is about to be removed from a network, but
+ * not completely deleted. This event is meant to be used primarily by the
+ * the view and presentation layers for managing the visualization of the
+ * network.
+ *
* @CyAPI.Final.Class
*/
public final class GroupAboutToBeRemovedEvent extends AbstractGroupEvent {
Modified:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedEvent.java
2012-01-24 15:44:37 UTC (rev 28087)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedEvent.java
2012-01-24 19:11:00 UTC (rev 28088)
@@ -6,7 +6,7 @@
/**
- * This event signals that a network has been added.
+ * This event signals that a new group has been added.
* @CyAPI.Final.Class
*/
public final class GroupAddedEvent extends AbstractGroupManagerEvent {
Modified:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedToNetworkEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedToNetworkEvent.java
2012-01-24 15:44:37 UTC (rev 28087)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedToNetworkEvent.java
2012-01-24 19:11:00 UTC (rev 28088)
@@ -7,7 +7,10 @@
/**
- * This event signals that a network has been added.
+ * This event signals that an existing group has been added to a new network.
+ * This is meant to be used primarily by the view and presentation layers to
+ * allow them to appropriately visualize the group.
+ *
* @CyAPI.Final.Class
*/
public final class GroupAddedToNetworkEvent extends AbstractGroupEvent {
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedEvent.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedEvent.java
2012-01-24 19:11:00 UTC (rev 28088)
@@ -0,0 +1,79 @@
+package org.cytoscape.group.events;
+
+import java.util.List;
+
+import org.cytoscape.event.AbstractCyEvent;
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyTableEntry;
+
+/**
+ * This event signals that a group has changed, either by adding or
+ * removing nodes or edges.
+ *
+ * @CyAPI.Final.Class
+ */
+public final class GroupChangedEvent extends AbstractCyEvent<CyGroup> {
+ public enum ChangeType {
+ NODE_ADDED, INTERNAL_EDGE_ADDED, EXTERNAL_EDGE_ADDED,
+ NODES_ADDED, NODES_REMOVED, EDGES_ADDED, EDGES_REMOVED }
+
+ private CyTableEntry whatChanged;
+ private List<CyNode> nodeList;
+ private ChangeType change;
+
+ /**
+ * Constructs event.
+ * @param source the {@link CyGroup} that has been changed.
+ * @param whatChanged the {@link CyNode} or {@link CyEdge} or list of
{@link CyNodes} that were added or removed.
+ */
+ public GroupChangedEvent(final CyGroup source, final Object
whatChanged, ChangeType change) {
+ super(source, GroupChangedListener.class);
+
+ this.whatChanged = null;
+ this.change = change;
+ this.nodeList = null;
+
+ // If this is NODES_ADDED or REMOVED, then the "whatChanged"
argument must be a Collection
+ if (change == ChangeType.NODES_ADDED || change ==
ChangeType.NODES_REMOVED) {
+ if ((whatChanged instanceof List) &&
(((List)whatChanged).get(0) instanceof CyNode)) {
+ this.nodeList = (List<CyNode>) whatChanged;
+ } else
+ throw new IllegalArgumentException("the
\"whatChanged\" parameter must be a list of nodes for NODES_ADDED or
NODES_REMOVED!");
+ } else if ((whatChanged instanceof CyEdge) ||
+ (whatChanged instanceof CyNode)) {
+ this.whatChanged = (CyTableEntry) whatChanged;
+ } else {
+ throw new IllegalArgumentException("the \"whatChanged\"
parameter must be a node or an edge!");
+ }
+
+ }
+
+ /**
+ * Get the object that changed. This should either be a CyEdge or a
CyNode.
+ *
+ * @return the CyTableEntry (CyNode or CyEdge) that was added or
removed.
+ */
+ public CyTableEntry getChangedObject() {
+ return whatChanged;
+ }
+
+ /**
+ * Get the list of nodes that changed.
+ *
+ * @return the list of CyNodes that were added or removed.
+ */
+ public List<CyNode> getChangedNodes() {
+ return nodeList;
+ }
+
+ /**
+ * Was the change an add or a removal from the group.
+ *
+ * @return true if the node or edge was added.
+ */
+ public ChangeType getChangeType() {
+ return change;
+ }
+}
Added:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedListener.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedListener.java
(rev 0)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupChangedListener.java
2012-01-24 19:11:00 UTC (rev 28088)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupChangedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupChangedListener extends CyListener {
+ /**
+ * The method that should handle the specified event.
+ * @param e The event to be handled.
+ */
+ public void handleEvent(GroupChangedEvent e);
+}
Modified:
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupCollapsedEvent.java
===================================================================
---
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupCollapsedEvent.java
2012-01-24 15:44:37 UTC (rev 28087)
+++
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupCollapsedEvent.java
2012-01-24 19:11:00 UTC (rev 28088)
@@ -8,7 +8,9 @@
/**
- * This event signals that a network has been added.
+ * This event signals that a group has either been expanded or collapsed in
+ * a particular network.
+ *
* @CyAPI.Final.Class
*/
public final class GroupCollapsedEvent extends AbstractGroupEvent {
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.