Author: scooter
Date: 2012-01-23 16:28:27 -0800 (Mon, 23 Jan 2012)
New Revision: 28080

Added:
   core3/api/trunk/group-api/
   core3/api/trunk/group-api/pom.xml
   core3/api/trunk/group-api/src/
   core3/api/trunk/group-api/src/main/
   core3/api/trunk/group-api/src/main/java/
   core3/api/trunk/group-api/src/main/java/org/
   core3/api/trunk/group-api/src/main/java/org/cytoscape/
   core3/api/trunk/group-api/src/main/java/org/cytoscape/group/
   core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroup.java
   
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroupFactory.java
   
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroupManager.java
   core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/
   
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractGroupEvent.java
   
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractGroupManagerEvent.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/GroupAboutToBeDestroyedListener.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/GroupAboutToBeRemovedListener.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/GroupAddedListener.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/GroupAddedToNetworkListener.java
   
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/GroupCollapsedListener.java
   core3/api/trunk/group-api/src/test/
   core3/api/trunk/group-api/src/test/java/
   core3/api/trunk/group-api/src/test/java/org/
   core3/api/trunk/group-api/src/test/java/org/cytoscape/
   core3/api/trunk/group-api/src/test/java/org/cytoscape/group/
   
core3/api/trunk/group-api/src/test/java/org/cytoscape/group/AbstractCyGroupTest.java
   core3/api/trunk/group-api/src/test/java/org/cytoscape/group/events/
Log:
First landing of group api


Added: core3/api/trunk/group-api/pom.xml
===================================================================
--- core3/api/trunk/group-api/pom.xml                           (rev 0)
+++ core3/api/trunk/group-api/pom.xml   2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+       <parent>
+               <artifactId>api-parent</artifactId>
+               <groupId>org.cytoscape</groupId>
+               <version>3.0.0-alpha8-SNAPSHOT</version>
+       </parent>
+
+       <properties>
+               
<bundle.symbolicName>org.cytoscape.group-api</bundle.symbolicName>
+               <bundle.namespace>org.cytoscape.group</bundle.namespace>
+       </properties>
+
+       <modelVersion>4.0.0</modelVersion>
+       <groupId>org.cytoscape</groupId>
+       <artifactId>group-api</artifactId>
+
+       <name>${bundle.symbolicName} [${bundle.namespace}]</name>
+
+       <packaging>bundle</packaging>
+
+       <repositories>
+               <!-- bootstrap for cytoscape dependencies, namely the parent 
POM snapshots -->
+               <repository>
+                       <id>cytoscape_snapshots</id>
+                       <snapshots>
+                               <enabled>true</enabled>
+                       </snapshots>
+                       <releases>
+                               <enabled>false</enabled>
+                       </releases>
+                       <name>Cytoscape Snapshots</name>
+                       
<url>http://code.cytoscape.org/nexus/content/repositories/snapshots/</url>
+               </repository>
+               <!-- bootstrap for cytoscape dependencies, namely the parent 
POM releases -->
+               <repository>
+                       <id>cytoscape_releases</id>
+                       <snapshots>
+                               <enabled>false</enabled>
+                       </snapshots>
+                       <releases>
+                               <enabled>true</enabled>
+                       </releases>
+                       <name>Cytoscape Releases</name>
+                       
<url>http://code.cytoscape.org/nexus/content/repositories/releases/</url>
+               </repository>
+       </repositories>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               
<version>${maven-bundle-plugin.version}</version>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <instructions>
+                                               
<Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
+                                               
<Bundle-Version>${project.version}</Bundle-Version>
+                                               
<Export-Package>!${bundle.namespace}.internal.*,${bundle.namespace}.*;version="${project.version}"</Export-Package>
+                                               
<Private-Package>${bundle.namespace}.internal.*</Private-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-jar-plugin</artifactId>
+                               <version>${maven-jar-plugin.version}</version>
+                               <executions>
+                                       <execution>
+                                               <goals>
+                                                       <goal>test-jar</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>event-api</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>model-api</artifactId>
+                       <version>${project.version}</version>
+               </dependency>
+
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.mockito</groupId>
+                       <artifactId>mockito-all</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.cytoscape</groupId>
+                       <artifactId>event-api</artifactId>
+                       <version>${project.version}</version>
+                       <type>test-jar</type>
+                       <scope>test</scope>
+               </dependency>
+
+       </dependencies>
+
+</project>

Added: 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    
                        (rev 0)
+++ core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroup.java    
2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,198 @@
+/*
+ Copyright (c) 2008, 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.group;
+
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+import org.cytoscape.model.subnetwork.CyRootNetwork;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * An object that represents a group of nodes and edges.  Groups at the model
+ * layer are a simple extension of a CyNode that creates a subnetwork for every
+ * for every group.  Groups may be added to networks in the same way that nodes
+ * are.  To determine if a node in a network is a group, use the instanceof 
keyword
+ * to check for CyGroup: if (node instanceof CyGroup).
+ *
+ * @CyAPI.Api.Interface
+ */
+public interface CyGroup {
+       /**
+        * Return the {@link CyNode} that represents this group
+        * in the network.
+        *
+        * @return the {@link CyNode} for this group
+        */
+       CyNode getGroupNode();
+
+       /**
+        * Returns the list of nodes contained within this group.
+        * 
+        * @return A list of CyNodes
+        * returns null otherwise.
+        */
+       List<CyNode> getNodeList();
+
+       /**
+        * Returns the list of edges contained within this group.
+        * 
+        * @return A list of CyEdges
+        */
+       List<CyEdge> getInteriorEdgeList();
+
+       /**
+        * Returns the list of exterior edges connected to the
+        * nodes within this group.
+        * 
+        * @return A list of CyEdges
+        */
+       Set<CyEdge> getExteriorEdgeList();
+
+       /**
+        * Returns the network referenced by this group.  All
+        * groups will point to a network, although the network
+        * might not have any nodes or edges.  This is the internal
+        * network representation of the group, not the networks that
+        * the group is a member of.
+        * 
+        * @return A reference to a CyNetwork
+        */
+       CyNetwork getGroupNetwork();
+
+       /**
+        * Add a node to a group
+        *
+        * @param node the node to add
+        */
+       void addNode(CyNode node);
+
+       /**
+        * Add an internal edge to a group.  Both the source and destination
+        * nodes must already be added.
+        *
+        * @param edge the edge to add
+        */
+       void addInternalEdge(CyEdge edge);
+
+       /**
+        * Add an external edge to a group.  One of the source and destination
+        * nodes must already be added.
+        *
+        * @param edge the edge to add
+        */
+       void addExternalEdge(CyEdge edge);
+
+       /**
+        * Add a list of nodes and their edges
+        *
+        * @param nodes the list of nodes to add
+        */
+       void addNodes(List<CyNode> nodes);
+
+       /**
+        * Remove a set of nodes from a group
+        *
+        * @param nodes the nodes to remove
+        */
+       void removeNodes(Collection<CyNode> nodes);
+
+       /**
+        * 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
+        * also.
+        *
+        * @return the root network for this group
+        */
+       CyRootNetwork getRootNetwork(); // Should this return a CyNetwork 
instead?
+
+       /**
+        * Add a group to an additional network.  When groups are created, they 
are created in
+        * a particular network.  The can also be shown in other networks, as 
long as all of
+        * the networks are in the same {@link CyRootNetwork}
+        *
+        * @param network the {@link CyNetwork} to add the group to
+        */
+       public void addGroupToNetwork(CyNetwork network);
+
+       /**
+        * Remove a group from a network.
+        *
+        * @param network the {@link CyNetwork} to remove the group from
+        */
+       public void removeGroupFromNetwork(CyNetwork network);
+
+       /**
+        * Return the list of {@link CyNetwork}s this group is in.
+        *
+        * @return the set of {@link CyNetwork}s that contain this group
+        */
+       public Set<CyNetwork> getNetworkSet();
+
+       /**
+        * Check to see if this group is defined in a particular network.
+        *
+        * @param network the {@link CyNetwork} to test
+        * @return true if the group is in that network
+        */
+       public boolean isInNetwork(CyNetwork network);
+
+       /**
+        * Collapse this group in the designated network.  Note that this is a 
"model-level"
+        * collapse, which removes all of the member nodes and edges and 
replaces them
+        * with the node that represents the group in the network.  This does 
not imply
+        * a specific visual representation.
+        *
+        * @param network the {@link CyNetwork} that this group should be 
collapsed in
+        */
+       void collapse(CyNetwork network);
+
+       /**
+        * Expand this group in the designated network.  Note that this is a 
"model-level"
+        * expansion, which removes the node that represents the group from the 
network
+        * and adds all of the member nodes and edges. This does not imply
+        * a specific visual representation.
+        *
+        * @param network the {@link CyNetwork} that this group should be 
expanded in
+        */
+       void expand(CyNetwork network);
+
+       /**
+        * Return whether this group is expanded or collapsed in the designated 
network.
+        *
+        * @param network the {@link CyNetwork} we're interested in
+        * @return true if the group is collapsed in that network.
+        */
+       boolean isCollapsed(CyNetwork network);
+
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroupFactory.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroupFactory.java 
                            (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroupFactory.java 
    2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,76 @@
+/*
+ Copyright (c) 2008, 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.group;
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+
+import java.util.List;
+
+
+/**
+ * An interface describing a factory used for creating 
+ * {@link CyGroup} objects.  This factory will be
+ * provided as a service through Spring/OSGi.
+ * @CyAPI.Api.Interface
+ */
+public interface CyGroupFactory {
+       /**
+        * Creates a CyGroup object in the referenced network.
+        *
+        * @param network the {@link CyNetwork} this group is part of
+        * @return A new {@link CyGroup} as part of the designated network.
+        */
+       public CyGroup createGroup(CyNetwork network);
+
+       /**
+        * Creates a CyGroup object in the referenced network initially 
populated with
+        * the supplied nodes.
+        *
+        * @param network the {@link CyNetwork} this group is part of
+        * @param nodes the {@link CyNode}s that are part of this group.
+        * @param edges the {@link CyEdge}s that are part of this group.  If 
this is null, the edges
+        * are determined based on the node connectivity.
+        * @return A new {@link CyGroup} as part of the designated network.
+        */
+       public CyGroup createGroup(CyNetwork network, List<CyNode> nodes, 
List<CyEdge> edges);
+
+       /**
+        * Creates a CyGroup object in the referenced network from an existing 
{@link CyNode}.
+        *
+        * @param network the {@link CyNetwork} this group is part of
+        * @param node the {@link CyNode} to convert into a group
+        * @param nodes the {@link CyNode}s that are part of this group.
+        * @param edges the {@link CyEdge}s that are part of this group.  If 
this is null, the edges
+        * are determined based on the node connectivity.
+        * @return A new {@link CyGroup} as part of the designated network.
+        */
+       public CyGroup createGroup(CyNetwork network, CyNode node, 
List<CyNode>nodes, List<CyEdge> edges);
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroupManager.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroupManager.java 
                            (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/CyGroupManager.java 
    2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,92 @@
+/*
+ File: CyGroupManager.java
+
+ Copyright (c) 2006, 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+package org.cytoscape.group;
+
+
+import java.util.List;
+import java.util.Set;
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+
+
+/**
+ * Basic access to groups in an instance of Cytoscape.
+ * @CyAPI.Api.Interface
+ */
+public interface CyGroupManager {
+       /**
+        * Provides the set of all the groups known to the groups manager in a 
particular network.
+        * 
+        * @param network the network to get the groups from.  If the network 
is null, then
+        * return only those groups that have been designated as "global" (no 
referenced network)
+        * for this {@link CyRootNetwork}
+        * @return the complete set of all the currently known groups in a 
Cytoscape network
+        */
+       public Set<CyGroup> getGroupSet(CyNetwork network);
+
+       /**
+        * Return the list of {@link CyGroup}s this node is in.
+        *
+        * @param node the {@link CyNode} we want get the groups for
+        * @return the list of {@link CyGroup}s the node is in
+        * null if it is not in any groups
+        */
+       public List<CyGroup> getGroupsForNode(CyNode node);
+
+       /**
+        * Test to see if this node represents a {@link CyGroup} in
+        * a particular {@link CyNetwork}.
+        *
+        * @param node the {@link CyNode} to test
+        * @param network the {@link CyNetwork} to test
+        * @return true if this node represents a group
+        */
+       public boolean isGroup(CyNode node, CyNetwork network);
+
+       /**
+        * Destroy a group.
+        *
+        * @param group the {@link CyGroup} to remove.
+        **/
+       public void destroyGroup(CyGroup group);
+
+       /**
+        * Registers a group with the group manager.  Does nothing if the group 
is already
+        * known to the group manager.
+        * 
+        * @param group  a non-null {@link CyGroup}
+        */
+       public void addGroup(final CyGroup group);
+
+       /** Releases all currently held references and resources. */
+       public void reset();
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractGroupEvent.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractGroupEvent.java
                          (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractGroupEvent.java
  2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,27 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.event.AbstractCyEvent;
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.model.CyNetwork;
+
+
+/**
+ *  Base class for all derived concrete event classes classes in this package 
that require a CyNetwork.
+ */
+class AbstractGroupEvent extends AbstractCyEvent<CyGroup> {
+       private final CyNetwork net;
+
+       AbstractGroupEvent(final CyGroup source, final Class<?> listenerClass, 
final CyNetwork network) {
+               super(source, listenerClass);
+
+               if (network == null)
+                       throw new NullPointerException("the \"network\" 
parameter must never be null!");
+               this.net = network;
+       }
+
+       public final CyNetwork getNetwork() {
+               return net;
+       }
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractGroupManagerEvent.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractGroupManagerEvent.java
                           (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/AbstractGroupManagerEvent.java
   2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,26 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.event.AbstractCyEvent;
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.group.CyGroupManager;
+
+
+/**
+ *  Base class for all derived concrete event classes classes in this package 
that require a CyNetwork.
+ */
+class AbstractGroupManagerEvent extends AbstractCyEvent<CyGroupManager> {
+       private final CyGroup group;
+
+       AbstractGroupManagerEvent(final CyGroupManager source, final Class<?> 
listenerClass, final CyGroup group) {
+               super(source, listenerClass);
+
+               if (group == null)
+                       throw new NullPointerException("the \"group\" parameter 
must never be null!");
+               this.group = group;
+       }
+
+       public final CyGroup getGroup() {
+               return group;
+       }
+}

Added: 
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
                                (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeDestroyedEvent.java
        2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,21 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.group.CyGroup;
+
+
+/**
+ * This event signals that a group is about to be destroyed.
+ * @CyAPI.Final.Class
+ */
+public final class  GroupAboutToBeDestroyedEvent extends 
AbstractGroupManagerEvent {
+       /**
+        * Constructs event.
+        * @param source the {@link CyGroupManager} of the group about to be 
destroyed.
+        * @param group the {@link CyGroup} about to be destroyed.
+        */
+       public GroupAboutToBeDestroyedEvent(final CyGroupManager source, final 
CyGroup group) {
+               super(source, GroupAboutToBeDestroyedListener.class, group);
+       }
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeDestroyedListener.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeDestroyedListener.java
                             (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeDestroyedListener.java
     2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.event.CyListener;
+
+/**
+ * Listener for {@link GroupAboutToBeDestroyedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupAboutToBeDestroyedListener extends CyListener {
+       /**
+        * The method that should handle the specified event.
+        * @param e The event to be handled.
+        */
+       public void handleEvent(GroupAboutToBeDestroyedEvent e);
+}

Added: 
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
                          (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeRemovedEvent.java
  2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,22 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyNetwork;
+
+
+/**
+ * This event signals that a network has been added.
+ * @CyAPI.Final.Class
+ */
+public final class GroupAboutToBeRemovedEvent extends AbstractGroupEvent {
+       /**
+        * Constructs event.
+        * @param source the {@link CyGroup} that is about to be removed.
+        * @param network the {@link CyNetwork} the group is about to be 
removed from
+        */
+       public GroupAboutToBeRemovedEvent(final CyGroup source, final CyNetwork 
network) {
+               super(source, GroupAboutToBeRemovedListener.class, network);
+       }
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeRemovedListener.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeRemovedListener.java
                               (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAboutToBeRemovedListener.java
       2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupAboutToBeRemovedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupAboutToBeRemovedListener extends CyListener {
+       /**
+        * The method that should handle the specified event.
+        * @param e The event to be handled.
+        */
+       public void handleEvent(GroupAboutToBeRemovedEvent e);
+}

Added: 
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
                             (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedEvent.java
     2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,21 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.group.CyGroup;
+
+
+/**
+ * This event signals that a network has been added.
+ * @CyAPI.Final.Class
+ */
+public final class GroupAddedEvent extends AbstractGroupManagerEvent {
+       /**
+        * Constructs event.
+        * @param source the {@link CyGroupManager} the group has been added to.
+        * @param group the {@link CyGroup} that has been added.
+        */
+       public GroupAddedEvent(final CyGroupManager source, final CyGroup 
group) {
+               super(source, GroupAddedListener.class, group);
+       }
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedListener.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedListener.java
                          (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedListener.java
  2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupAddedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupAddedListener extends CyListener {
+       /**
+        * The method that should handle the specified event.
+        * @param e The event to be handled.
+        */
+       public void handleEvent(GroupAddedEvent e);
+}

Added: 
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
                            (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedToNetworkEvent.java
    2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,22 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyNetwork;
+
+
+/**
+ * This event signals that a network has been added.
+ * @CyAPI.Final.Class
+ */
+public final class GroupAddedToNetworkEvent extends AbstractGroupEvent {
+       /**
+        * Constructs event.
+        * @param source the {@link CyGroup} that has been added.
+        * @param network the {@link CyNetwork} the group has been added to.
+        */
+       public GroupAddedToNetworkEvent(final CyGroup source, final CyNetwork 
network) {
+               super(source, GroupAddedToNetworkListener.class, network);
+       }
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedToNetworkListener.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedToNetworkListener.java
                         (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupAddedToNetworkListener.java
 2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupAddedToNetworkEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupAddedToNetworkListener extends CyListener {
+       /**
+        * The method that should handle the specified event.
+        * @param e The event to be handled.
+        */
+       public void handleEvent(GroupAddedToNetworkEvent e);
+}

Added: 
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
                         (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupCollapsedEvent.java
 2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,35 @@
+package org.cytoscape.group.events;
+
+
+import org.cytoscape.group.CyGroupManager;
+import org.cytoscape.group.CyGroup;
+
+import org.cytoscape.model.CyNetwork;
+
+
+/**
+ * This event signals that a network has been added.
+ * @CyAPI.Final.Class
+ */
+public final class GroupCollapsedEvent extends AbstractGroupEvent {
+       private boolean collapsed;
+
+       /**
+        * Constructs event.
+        * @param source the {@link CyGroup} that has been changed.
+        * @param network the {@link CyNetwork} the group has been changed in.
+        */
+       public GroupCollapsedEvent(final CyGroup source, final CyNetwork 
network, boolean collapsed) {
+               super(source, GroupCollapsedListener.class, network);
+               this.collapsed = collapsed;
+       }
+
+       /**
+        * Is the group collapsed or expanded?
+        *
+        * @return true if the group was collapsed
+        */
+       public boolean collapsed() {
+               return collapsed;
+       }
+}

Added: 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupCollapsedListener.java
===================================================================
--- 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupCollapsedListener.java
                              (rev 0)
+++ 
core3/api/trunk/group-api/src/main/java/org/cytoscape/group/events/GroupCollapsedListener.java
      2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,16 @@
+package org.cytoscape.group.events;
+
+import org.cytoscape.event.CyListener;
+
+
+/**
+ * Listener for {@link GroupCollapsedEvent}
+ * @CyAPI.Spi.Interface
+ */
+public interface GroupCollapsedListener extends CyListener {
+       /**
+        * The method that should handle the specified event.
+        * @param e The event to be handled.
+        */
+       public void handleEvent(GroupCollapsedEvent e);
+}

Added: 
core3/api/trunk/group-api/src/test/java/org/cytoscape/group/AbstractCyGroupTest.java
===================================================================
--- 
core3/api/trunk/group-api/src/test/java/org/cytoscape/group/AbstractCyGroupTest.java
                                (rev 0)
+++ 
core3/api/trunk/group-api/src/test/java/org/cytoscape/group/AbstractCyGroupTest.java
        2012-01-24 00:28:27 UTC (rev 28080)
@@ -0,0 +1,124 @@
+/*
+ Copyright (c) 2008, 2010-2011, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.group;
+
+
+import static org.junit.Assert.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.cytoscape.group.CyGroup;
+import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
+
+import org.junit.Before;
+import org.junit.Test;
+
+
+public abstract class AbstractCyGroupTest {
+       
+       protected CyNetwork net;
+       protected CyGroupFactory groupFactory;
+
+       private CyGroup group;
+       private CyEdge edge1;
+       private CyEdge edge2;
+       private CyEdge edge3;
+       private CyEdge edge4;
+       private CyEdge edge5;
+
+       protected void defaultSetUp() {
+               CyNode node1 = net.addNode();
+    CyNode node2 = net.addNode();
+    CyNode node3 = net.addNode();
+    CyNode node4 = net.addNode();
+    CyNode node5 = net.addNode();
+    List<CyNode> groupNodes = new ArrayList<CyNode>();
+    groupNodes.add(node1);
+    groupNodes.add(node2);
+    groupNodes.add(node3);
+
+    edge1 = net.addEdge(node1, node2, false);
+    edge2 = net.addEdge(node2, node3, false);
+    edge3 = net.addEdge(node2, node4, false);
+    edge4 = net.addEdge(node2, node5, false);
+    edge5 = net.addEdge(node3, node5, false);
+
+    List<CyEdge> groupEdges = new ArrayList<CyEdge>();
+    groupEdges.add(edge1);
+    groupEdges.add(edge2);
+    groupEdges.add(edge3);
+    groupEdges.add(edge4);
+
+               // Create a group
+               group = groupFactory.createGroup(net, groupNodes, groupEdges);
+       }
+
+       @Test
+       public void testNetworkCreation() {
+               assertTrue("net has 5 nodes", net.getNodeCount() == 5);
+               assertTrue("net has 5 edges", net.getEdgeCount() == 5);
+       }
+
+       @Test
+       public void testGroupCreated() {
+    assertTrue("group node count = 3", group.getNodeList().size() == 3);
+    assertTrue("group internal edge count = 2", 
group.getInteriorEdgeList().size() == 2);
+    assertTrue("group external edge count = 2", 
group.getExteriorEdgeList().size() == 2);
+       }
+
+       @Test
+       public void testAddExternalEdge() {
+               group.addExternalEdge(edge5);
+    assertTrue("group external edge count = 3", 
group.getExteriorEdgeList().size() == 3);
+       }
+
+       @Test
+       public void testCollapse() {
+    assertTrue("group is not collapsed", !group.isCollapsed(net));
+
+               group.collapse(net);
+    assertTrue("group is collapsed", group.isCollapsed(net));
+
+               assertTrue("net has 3 nodes", net.getNodeCount() == 3);
+
+               assertTrue("net has group node", 
net.containsNode(group.getGroupNode()));
+       }
+
+       @Test
+       public void testExpand() {
+               group.expand(net);
+    assertTrue("group is expanded", !group.isCollapsed(net));
+
+               assertTrue("net has 5 nodes", net.getNodeCount() == 5);
+
+               assertTrue("net does not have group node", 
!net.containsNode(group.getGroupNode()));
+       }
+
+}

-- 
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.

Reply via email to