Skip to content

Commit

Permalink
new project for legends
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Treister committed Dec 19, 2017
1 parent aee2e96 commit 7c7e33b
Show file tree
Hide file tree
Showing 7 changed files with 478 additions and 0 deletions.
133 changes: 133 additions & 0 deletions legend/pom.xml
@@ -0,0 +1,133 @@
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<properties>
<bundle.symbolicName>org.cytoscape.legend</bundle.symbolicName>
<bundle.namespace>org.cytoscape.legend</bundle.namespace>
<cytoscape.api.version>3.6.0</cytoscape.api.version>

<maven-bundle-plugin.version>2.3.4</maven-bundle-plugin.version>
<osgi.api.version>4.2.0</osgi.api.version>
</properties>

<groupId>org.cytoscape</groupId>
<artifactId>legend-creator</artifactId>
<packaging>bundle</packaging>
<version>1.0</version>

<name>Legend Creator</name>

<build>
<plugins>
<plugin>
<inherited>true</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<optimize>true</optimize>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<compilerArguments>
<Xmaxwarns>10000</Xmaxwarns>
<Xmaxerrs>10000</Xmaxerrs>
</compilerArguments>
</configuration>
</plugin>
<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}.*</Export-Package>
<Private-Package>${bundle.namespace}.*</Private-Package>
<Bundle-Activator>${bundle.namespace}.CyActivator</Bundle-Activator>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<!-- Links to the Cytoscape Maven repositories. -->
<repositories>
<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>
<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>

<dependencies>
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>swing-application-api</artifactId>
<version>${cytoscape.api.version}</version>
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>work-api</artifactId>
<version>${cytoscape.api.version}</version>
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>service-api</artifactId>
<version>${cytoscape.api.version}</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.api.version}</version>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.5.2</version>
<scope>test</scope>
</dependency>
<!-- <dependency>
<groupId>org.cytoscape</groupId>
<artifactId>service-api</artifactId>
<version>${cytoscape.api.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
-->
</dependencies>

</project>
33 changes: 33 additions & 0 deletions legend/src/main/java/org/cytoscape/legend/CyActivator.java
@@ -0,0 +1,33 @@
package org.cytoscape.legend;

import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.application.swing.CytoPanelComponent;
import org.cytoscape.application.swing.CyAction;

import org.osgi.framework.BundleContext;

import org.cytoscape.service.util.AbstractCyActivator;
import org.cytoscape.service.util.CyServiceRegistrar;

import java.util.Properties;


public class CyActivator extends AbstractCyActivator {
public CyActivator() {
super();
}


public void start(BundleContext bc) {
CySwingApplication cytoscapeDesktopService = getService(bc,CySwingApplication.class);
CyServiceRegistrar reg = getService(bc,CyServiceRegistrar.class);

LegendController controller = new LegendController(reg);
LegendPanel legendPanel = new LegendPanel(reg, controller);
LegendAction legendAction = new LegendAction(cytoscapeDesktopService,legendPanel);

registerService(bc,legendPanel,CytoPanelComponent.class);
registerService(bc,legendAction,CyAction.class);
}
}

44 changes: 44 additions & 0 deletions legend/src/main/java/org/cytoscape/legend/LegendAction.java
@@ -0,0 +1,44 @@
package org.cytoscape.legend;

import java.awt.event.ActionEvent;

import org.cytoscape.application.swing.AbstractCyAction;
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.application.swing.CytoPanel;
import org.cytoscape.application.swing.CytoPanelName;
import org.cytoscape.application.swing.CytoPanelState;


public class LegendAction extends AbstractCyAction {

private static final long serialVersionUID = 1L;
private CySwingApplication desktopApp;
private final CytoPanel cytoPanelWest;
private LegendPanel legendPanel;

public LegendAction(CySwingApplication desktop, LegendPanel myPanel){
super("Legend Panel");
setPreferredMenu("Tools");

desktopApp = desktop;
cytoPanelWest = this.desktopApp.getCytoPanel(CytoPanelName.WEST);
legendPanel = myPanel;
}

/**
* actionPerformed(ActionEvent e)
*
* @param e - The event record provide the command name, source, key modifiers, etc.
*/
public void actionPerformed(ActionEvent e) {
// If the state of the cytoPanelWest is HIDE, show it
if (cytoPanelWest.getState() == CytoPanelState.HIDE)
cytoPanelWest.setState(CytoPanelState.DOCK);

// Select my panel
int index = cytoPanelWest.indexOfComponent(legendPanel);
if (index >= 0)
cytoPanelWest.setSelectedIndex(index);
}

}

0 comments on commit 7c7e33b

Please sign in to comment.