Author: kono
Date: 2012-07-02 18:39:40 -0700 (Mon, 02 Jul 2012)
New Revision: 29740
Added:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/VisualStyleBuilder.java
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalysisExecutor.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalyzeNetworkAction.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalyzeSubsetAction.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/BatchAnalysisAction.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/CyActivator.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/LoadNetstatsAction.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/MapParameterAction.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/PlotParameterAction.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/data/settings/PluginSettings.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/AnalysisDialog.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/BatchResultsDialog.java
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/MapParameterDialog.java
Log:
refs #1201 Just started to fix visualizer bug in network analyzer.
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalysisExecutor.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalysisExecutor.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalysisExecutor.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -26,6 +26,8 @@
import javax.swing.ProgressMonitor;
import javax.swing.Timer;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.Messages;
@@ -34,13 +36,17 @@
/**
* Initializer and starter of a separate thread dedicated to network analysis.
* <p>
- * This class manages the UI binding to the analysis of a network, in
particular it:
+ * This class manages the UI binding to the analysis of a network, in
particular
+ * it:
* <ul>
- * <li>initializes a dialog that enables the user to keep track of the current
progress;</li>
+ * <li>initializes a dialog that enables the user to keep track of the current
+ * progress;</li>
* <li>starts the network analyzer;</li>
- * <li>stops the analyzer if the user presses the "Cancel" button of
the dialog;</li>
- * <li>(optionally) creates an {@link
de.mpg.mpi_inf.bioinf.netanalyzer.ui.AnalysisDialog} to
- * display results once the analysis completes successfully.</li>
+ * <li>stops the analyzer if the user presses the "Cancel" button of
+ * the dialog;</li>
+ * <li>(optionally) creates an
+ * {@link de.mpg.mpi_inf.bioinf.netanalyzer.ui.AnalysisDialog} to display
+ * results once the analysis completes successfully.</li>
* </ul>
* </p>
*
@@ -50,15 +56,20 @@
private static final Logger logger =
LoggerFactory.getLogger(AnalysisExecutor.class);
+ private final CyNetworkViewManager viewManager;
+ private final VisualMappingManager vmm;
+ private final VisualStyleBuilder vsBuilder;
+
/**
* Initializes a new instance of <code>AnalysisExecutor</code>.
* <p>
- * The executor displays analysis results dialog once the analysis is
completed.
+ * The executor displays analysis results dialog once the analysis is
+ * completed.
* </p>
* <p>
- * Note that the constructor does not start the process of network
analysis - this is performed
- * by the <code>start()</code> method. It is recommended that
<code>start()</code> is called
- * immediately after the initialization.
+ * Note that the constructor does not start the process of network
analysis
+ * - this is performed by the <code>start()</code> method. It is
recommended
+ * that <code>start()</code> is called immediately after the
initialization.
* </p>
*
* @param aDesktop
@@ -66,9 +77,15 @@
* @param aAnalyzer
* <code>NetworkAnalyzer</code> instance to be started.
*/
- public AnalysisExecutor(JFrame aDesktop, NetworkAnalyzer aAnalyzer) {
+ public AnalysisExecutor(JFrame aDesktop, NetworkAnalyzer aAnalyzer,
final CyNetworkViewManager viewManager, final VisualStyleBuilder vsBuilder,
+ final VisualMappingManager vmm) {
desktop = aDesktop;
analyzer = aAnalyzer;
+
+ this.viewManager = viewManager;
+ this.vmm = vmm;
+ this.vsBuilder = vsBuilder;
+
listeners = new ArrayList<AnalysisListener>();
showDialog = true;
int maxProgress = analyzer.getMaxProgress();
@@ -80,7 +97,8 @@
/*
* (non-Javadoc)
*
- * @see
java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+ * @see
+ *
java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent e) {
monitor.setProgress(analyzer.getCurrentProgress());
@@ -101,7 +119,7 @@
monitor.close();
if (showDialog) {
try {
- AnalysisDialog d = new
AnalysisDialog(desktop, analyzer.getStats(), analyzer);
+ AnalysisDialog d = new
AnalysisDialog(desktop, analyzer.getStats(), analyzer, viewManager, vsBuilder,
vmm);
d.setVisible(true);
} catch (InnerException ex) {
// NetworkAnalyzer internal error
@@ -118,8 +136,8 @@
* Adds an <code>AnalysisListener</code> to this executor.
*
* @param aListener
- * Listener to be added. If this parameter is
<code>null</code>, calling this method
- * has no effect.
+ * Listener to be added. If this parameter is
<code>null</code>,
+ * calling this method has no effect.
*/
public void addAnalysisListener(AnalysisListener aListener) {
if (aListener != null && (!listeners.contains(aListener))) {
@@ -146,8 +164,8 @@
* Enables or disables the display of analysis results dialog.
*
* @param aShowDialog
- * Flag indicating if an analysis results dialog must be
displayed after the analysis
- * is complete.
+ * Flag indicating if an analysis results dialog must be
+ * displayed after the analysis is complete.
*/
public void setShowDialog(boolean aShowDialog) {
showDialog = aShowDialog;
@@ -179,8 +197,8 @@
private JFrame desktop;
/**
- * Flag indicating if an analysis results dialog must be displayed
after the analysis is
- * complete.
+ * Flag indicating if an analysis results dialog must be displayed
after the
+ * analysis is complete.
*/
private boolean showDialog;
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalyzeNetworkAction.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalyzeNetworkAction.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalyzeNetworkAction.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -25,6 +25,8 @@
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.Messages;
@@ -42,12 +44,21 @@
public class AnalyzeNetworkAction extends NetAnalyzerAction {
private static final Logger logger =
LoggerFactory.getLogger(AnalyzeNetworkAction.class);
+
+ private final CyNetworkViewManager viewManager;
+ private final VisualMappingManager vmm;
+ private final VisualStyleBuilder vsBuilder;
/**
* Initializes a new instance of <code>AnalyzeNetworkAction</code>.
*/
- public AnalyzeNetworkAction(CyApplicationManager
appMgr,CySwingApplication swingApp) {
+ public AnalyzeNetworkAction(CyApplicationManager
appMgr,CySwingApplication swingApp, final CyNetworkViewManager viewManager,
final VisualStyleBuilder vsBuilder,
+ final VisualMappingManager vmm) {
super(Messages.AC_ANALYZE,appMgr,swingApp);
+ this.viewManager = viewManager;
+ this.vmm = vmm;
+ this.vsBuilder = vsBuilder;
+
setPreferredMenu(NetworkAnalyzer.PARENT_MENU +
Messages.AC_MENU_ANALYSIS);
}
@@ -84,7 +95,7 @@
* @return Newly initialized analysis executor; <code>null</code> if
the user has decided to cancel the
* operation.
*/
- public static AnalysisExecutor initAnalysisExecuter(CyNetwork aNetwork,
Set<CyNode> aNodeSet, CySwingApplication swingApp) {
+ public AnalysisExecutor initAnalysisExecuter(CyNetwork aNetwork,
Set<CyNode> aNodeSet, CySwingApplication swingApp) {
// Ask the user for an interpretation of the network edges
try {
final NetworkInspection status =
CyNetworkUtils.inspectNetwork(aNetwork);
@@ -99,7 +110,7 @@
} else {
analyzer = new UndirNetworkAnalyzer(aNetwork,
aNodeSet, interpr);
}
- return new AnalysisExecutor(swingApp.getJFrame(),
analyzer);
+ return new AnalysisExecutor(swingApp.getJFrame(),
analyzer, viewManager, vsBuilder, vmm);
} catch (IllegalArgumentException ex) {
Utils.showInfoBox(swingApp.getJFrame(),Messages.DT_INFO,
Messages.SM_NETWORKEMPTY);
return null;
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalyzeSubsetAction.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalyzeSubsetAction.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/AnalyzeSubsetAction.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -42,12 +42,16 @@
public class AnalyzeSubsetAction extends NetAnalyzerAction {
private static final Logger logger =
LoggerFactory.getLogger(AnalyzeSubsetAction.class);
+
+ private final AnalyzeNetworkAction action;
/**
* Initializes a new instance of <code>NetSubsetAction</code>.
*/
- public AnalyzeSubsetAction(CyApplicationManager appMgr,
CySwingApplication swingApp) {
+ public AnalyzeSubsetAction(CyApplicationManager appMgr,
CySwingApplication swingApp, final AnalyzeNetworkAction action) {
super(Messages.AC_ANALYZE_SUBSET,appMgr,swingApp);
+ this.action = action;
+
setPreferredMenu(NetworkAnalyzer.PARENT_MENU +
Messages.AC_MENU_ANALYSIS);
selected = null;
}
@@ -61,7 +65,7 @@
public void actionPerformed(ActionEvent e) {
try {
if (selectNetwork()) {
- final AnalysisExecutor exec =
AnalyzeNetworkAction.initAnalysisExecuter(network, selected,swingApp);
+ final AnalysisExecutor exec =
action.initAnalysisExecuter(network, selected,swingApp);
if (exec != null) {
exec.start();
}
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/BatchAnalysisAction.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/BatchAnalysisAction.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/BatchAnalysisAction.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -52,12 +52,14 @@
private final CyNetworkReaderManager cyNetworkViewReaderMgr;
private final CyNetworkManager netMgr;
+ private final LoadNetstatsAction action;
/**
* Constructs a new batch analysis action.
*/
- protected BatchAnalysisAction(CyApplicationManager
appMgr,CySwingApplication swingApp, CyNetworkManager netMgr,
CyNetworkReaderManager cyNetworkViewReaderMgr) {
+ protected BatchAnalysisAction(CyApplicationManager
appMgr,CySwingApplication swingApp, CyNetworkManager netMgr,
CyNetworkReaderManager cyNetworkViewReaderMgr, final LoadNetstatsAction action)
{
super(Messages.AC_BATCH_ANALYSIS,appMgr,swingApp);
+ this.action = action;
this.netMgr = netMgr;
this.cyNetworkViewReaderMgr = cyNetworkViewReaderMgr;
setPreferredMenu(NetworkAnalyzer.PARENT_MENU +
Messages.AC_MENU_ANALYSIS);
@@ -87,7 +89,7 @@
d2.setVisible(true);
if (d2.resultsPressed()) {
// Step 3 - Show results
- BatchResultsDialog d3 = new
BatchResultsDialog(swingApp.getJFrame(),analyzer.getReports(),cyNetworkViewReaderMgr);
+ BatchResultsDialog d3 = new
BatchResultsDialog(swingApp.getJFrame(),analyzer.getReports(),cyNetworkViewReaderMgr,
action);
d3.setVisible(true);
}
} else {
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/CyActivator.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/CyActivator.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/CyActivator.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -29,6 +29,10 @@
import org.osgi.framework.BundleContext;
import org.cytoscape.service.util.AbstractCyActivator;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.VisualStyleFactory;
import java.util.Properties;
@@ -47,20 +51,37 @@
CyNetworkManager cyNetworkManagerServiceRef =
getService(bc,CyNetworkManager.class);
CyNetworkReaderManager cyNetworkViewReaderManagerServiceRef =
getService(bc,CyNetworkReaderManager.class);
+ CyNetworkViewManager viewManagerServiceRef =
getService(bc,CyNetworkViewManager.class);
+ VisualMappingManager vmmServiceRef =
getService(bc,VisualMappingManager.class);
+ VisualStyleFactory vsFactoryServiceRef =
getService(bc,VisualStyleFactory.class);
+
+ VisualMappingFunctionFactory continupousMappingFactoryRef =
getService(bc,VisualMappingFunctionFactory.class,"(mapping.type=continuous)");
+ VisualMappingFunctionFactory passthroughMappingFactoryRef =
getService(bc,VisualMappingFunctionFactory.class,"(mapping.type=passthrough)");
+
+ // FIXME refactor this code
Plugin plugin = new Plugin(cySwingApplicationServiceRef);
+
+ // Builder object for custom Visual Style
+ VisualStyleBuilder vsBuilder = new
VisualStyleBuilder(vsFactoryServiceRef, passthroughMappingFactoryRef,
continupousMappingFactoryRef);
+ AnalyzeNetworkAction analyzeNetworkAction = new
AnalyzeNetworkAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,
viewManagerServiceRef, vsBuilder, vmmServiceRef);
+
+ LoadNetstatsAction loadNetstatsAction = new
LoadNetstatsAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,
viewManagerServiceRef, vsBuilder, vmmServiceRef);
+ MapParameterAction mapParameterAction = new
MapParameterAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,
viewManagerServiceRef, vsBuilder, vmmServiceRef, analyzeNetworkAction);
+
AboutAction aboutAction = new
AboutAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef);
- AnalyzeNetworkAction analyzeNetworkAction = new
AnalyzeNetworkAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef);
- AnalyzeSubsetAction analyzeSubsetAction = new
AnalyzeSubsetAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef);
- BatchAnalysisAction batchAnalysisAction = new
BatchAnalysisAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,cyNetworkManagerServiceRef,cyNetworkViewReaderManagerServiceRef);
+ AnalyzeSubsetAction analyzeSubsetAction = new
AnalyzeSubsetAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,
analyzeNetworkAction);
+ BatchAnalysisAction batchAnalysisAction = new
BatchAnalysisAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,cyNetworkManagerServiceRef,cyNetworkViewReaderManagerServiceRef,
loadNetstatsAction);
CompareAction compareAction = new
CompareAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,cyNetworkManagerServiceRef);
ConnComponentAction connComponentAction = new
ConnComponentAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef);
- LoadNetstatsAction loadNetstatsAction = new
LoadNetstatsAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef);
- MapParameterAction mapParameterAction = new
MapParameterAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef);
- PlotParameterAction plotParameterAction = new
PlotParameterAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef);
+
+
+ PlotParameterAction plotParameterAction = new
PlotParameterAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,
analyzeNetworkAction);
RemDupEdgesAction remDupEdgesAction = new
RemDupEdgesAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,cyNetworkManagerServiceRef);
RemoveSelfLoopsAction removeSelfLoopsAction = new
RemoveSelfLoopsAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef,cyNetworkManagerServiceRef);
SettingsAction settingsAction = new
SettingsAction(cyApplicationManagerServiceRef,cySwingApplicationServiceRef);
+
+
registerService(bc,analyzeNetworkAction,CyAction.class, new
Properties());
registerService(bc,analyzeSubsetAction,CyAction.class, new
Properties());
registerService(bc,batchAnalysisAction,CyAction.class, new
Properties());
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/LoadNetstatsAction.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/LoadNetstatsAction.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/LoadNetstatsAction.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -24,10 +24,12 @@
import javax.swing.JFileChooser;
+import org.cytoscape.application.CyApplicationManager;
+import org.cytoscape.application.swing.CySwingApplication;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.cytoscape.application.CyApplicationManager;
-import org.cytoscape.application.swing.CySwingApplication;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.Messages;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.NetworkStats;
@@ -43,12 +45,20 @@
public class LoadNetstatsAction extends NetAnalyzerAction {
private static final Logger logger =
LoggerFactory.getLogger(LoadNetstatsAction.class);
+
+ private final CyNetworkViewManager viewManager;
+ private final VisualMappingManager vmm;
+ private final VisualStyleBuilder vsBuilder;
/**
* Initializes a new instance of <code>LoadNetstatsAction</code>.
*/
- public LoadNetstatsAction(CyApplicationManager
appMgr,CySwingApplication swingApp) {
+ public LoadNetstatsAction(CyApplicationManager
appMgr,CySwingApplication swingApp, final CyNetworkViewManager viewManager,
final VisualStyleBuilder vsBuilder,
+ final VisualMappingManager vmm) {
super(Messages.AC_LOAD,appMgr,swingApp);
+ this.viewManager = viewManager;
+ this.vmm = vmm;
+ this.vsBuilder = vsBuilder;
setPreferredMenu(NetworkAnalyzer.PARENT_MENU +
Messages.AC_MENU_ANALYSIS);
}
@@ -86,10 +96,10 @@
* @param aFile
* Network statistics file to be open.
*/
- public static void openNetstats(Frame owner, File aFile) {
+ public void openNetstats(Frame owner, File aFile) {
try {
final NetworkStats stats = StatsSerializer.load(aFile);
- final AnalysisDialog d = new AnalysisDialog(owner,
stats, null);
+ final AnalysisDialog d = new AnalysisDialog(owner,
stats, null, viewManager, vsBuilder, vmm);
d.setVisible(true);
} catch (IOException ex) {
// FileNotFoundException, IOException
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/MapParameterAction.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/MapParameterAction.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/MapParameterAction.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -23,6 +23,8 @@
import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.application.swing.CySwingApplication;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.Messages;
@@ -39,11 +41,25 @@
public class MapParameterAction extends NetAnalyzerAction implements
AnalysisListener {
private static final Logger logger =
LoggerFactory.getLogger(MapParameterAction.class);
+
+ private final CyNetworkViewManager viewManager;
+ private final VisualMappingManager vmm;
+ private final VisualStyleBuilder vsBuilder;
+
+ private final AnalyzeNetworkAction action;
+
+
/**
* Initializes a new instance of <code>MapParameterAction</code>.
*/
- public MapParameterAction(CyApplicationManager
appMgr,CySwingApplication swingApp) {
+ public MapParameterAction(CyApplicationManager
appMgr,CySwingApplication swingApp, final CyNetworkViewManager viewManager,
final VisualStyleBuilder vsBuilder,
+ final VisualMappingManager vmm, final
AnalyzeNetworkAction action) {
super(Messages.AC_MAPPARAM,appMgr,swingApp);
+ this.vsBuilder = vsBuilder;
+ this.vmm = vmm;
+ this.viewManager = viewManager;
+ this.action = action;
+
setPreferredMenu(NetworkAnalyzer.PARENT_MENU
+Messages.AC_MENU_ANALYSIS);
}
@@ -113,7 +129,7 @@
* mapped to visual styles afterwards.
*/
private void runNetworkAnalyzer() {
- final AnalysisExecutor exec =
AnalyzeNetworkAction.initAnalysisExecuter(network, null, swingApp);
+ final AnalysisExecutor exec =
action.initAnalysisExecuter(network, null, swingApp);
if (exec != null) {
exec.setShowDialog(false);
exec.addAnalysisListener(this);
@@ -127,8 +143,8 @@
private void openMapParameterDialog() {
nodeAttr = CyNetworkUtils.getComputedNodeAttributes(network);
edgeAttr = CyNetworkUtils.getComputedEdgeAttributes(network);
- final MapParameterDialog d = new
MapParameterDialog(swingApp.getJFrame(), network, nodeAttr,
- edgeAttr);
+ final MapParameterDialog d = new
MapParameterDialog(swingApp.getJFrame(), network, viewManager, vsBuilder, vmm,
+ nodeAttr, edgeAttr);
d.setVisible(true);
}
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/PlotParameterAction.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/PlotParameterAction.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/PlotParameterAction.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -39,11 +39,14 @@
private static final Logger logger =
LoggerFactory.getLogger(PlotParameterAction.class);
+ private final AnalyzeNetworkAction action;
+
/**
* Initializes a new instance of <code>PlotParameterAction</code>.
*/
- public PlotParameterAction(CyApplicationManager
appMgr,CySwingApplication swingApp) {
+ public PlotParameterAction(CyApplicationManager
appMgr,CySwingApplication swingApp, final AnalyzeNetworkAction action) {
super(Messages.AC_PLOTPARAM,appMgr,swingApp);
+ this.action = action;
setPreferredMenu(NetworkAnalyzer.PARENT_MENU +
Messages.AC_MENU_ANALYSIS);
}
@@ -121,7 +124,7 @@
* visualized afterwards.
*/
private void runNetworkAnalyzer() {
- final AnalysisExecutor exec =
AnalyzeNetworkAction.initAnalysisExecuter(network, null, swingApp);
+ final AnalysisExecutor exec =
action.initAnalysisExecuter(network, null, swingApp);
if (exec != null) {
exec.setShowDialog(false);
exec.addAnalysisListener(this);
Added:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/VisualStyleBuilder.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/VisualStyleBuilder.java
(rev 0)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/VisualStyleBuilder.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -0,0 +1,140 @@
+package de.mpg.mpi_inf.bioinf.netanalyzer;
+
+import java.awt.Color;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.presentation.property.BasicVisualLexicon;
+import org.cytoscape.view.presentation.property.NodeShapeVisualProperty;
+import org.cytoscape.view.vizmap.VisualMappingFunctionFactory;
+import org.cytoscape.view.vizmap.VisualStyle;
+import org.cytoscape.view.vizmap.VisualStyleFactory;
+import org.cytoscape.view.vizmap.mappings.PassthroughMapping;
+
+import de.mpg.mpi_inf.bioinf.netanalyzer.data.io.SettingsSerializer;
+
+public class VisualStyleBuilder {
+
+ private static final String VS_NAME_PREFIX = "Network Analyzer Style: ";
+
+ // Preset defaults
+ private static final Color NODE_COLOR = Color.WHITE;
+ private static final Color NODE_LABEL_COLOR = new Color(100, 100, 100);
+ private static final Color EDGE_COLOR = new Color(100, 100, 100);
+
+ private final VisualStyleFactory vsFactory;
+
+ private final VisualMappingFunctionFactory passthroughFactory;
+ private final VisualMappingFunctionFactory continuousFactory;
+
+ public VisualStyleBuilder(final VisualStyleFactory vsFactory,
+ final VisualMappingFunctionFactory passthroughFactory,
final VisualMappingFunctionFactory continuousFactory) {
+ this.vsFactory = vsFactory;
+ this.passthroughFactory = passthroughFactory;
+ this.continuousFactory = continuousFactory;
+ }
+
+ /**
+ * Creates a new visual style in Cytoscape's VizMapper depending on the
by
+ * the user defined mappings of computed attributes.
+ *
+ * @return New visual style.
+ **/
+ public VisualStyle createVisualStyle(final CyNetworkView networkView) {
+
+ final CyNetwork network = networkView.getModel();
+ // Create new visual style
+ final String name = network.getRow(network).get(CyNetwork.NAME,
String.class);
+ final VisualStyle visualStyle =
vsFactory.createVisualStyle(VS_NAME_PREFIX + name);
+
+ // Network VP
+ final Color backGroundColor =
SettingsSerializer.getPluginSettings().getBackgroundColor();
+
visualStyle.setDefaultValue(BasicVisualLexicon.NETWORK_BACKGROUND_PAINT,
backGroundColor);
+
+ // Node Label Mapping
+ final PassthroughMapping<String, String> labelPassthrough =
(PassthroughMapping<String, String>) passthroughFactory
+ .createVisualMappingFunction(CyNetwork.NAME,
String.class, BasicVisualLexicon.NODE_LABEL);
+ visualStyle.addVisualMappingFunction(labelPassthrough);
+
+ // Node View Defaults
+ visualStyle.setDefaultValue(BasicVisualLexicon.NODE_SHAPE,
NodeShapeVisualProperty.ELLIPSE);
+ visualStyle.setDefaultValue(BasicVisualLexicon.NODE_FILL_COLOR,
NODE_COLOR);
+
visualStyle.setDefaultValue(BasicVisualLexicon.NODE_LABEL_COLOR,
NODE_LABEL_COLOR);
+
+
visualStyle.setDefaultValue(BasicVisualLexicon.NODE_BORDER_WIDTH, 0.0d);
+ visualStyle.setDefaultValue(BasicVisualLexicon.NODE_WIDTH, 30d);
+ visualStyle.setDefaultValue(BasicVisualLexicon.NODE_HEIGHT,
30d);
+ visualStyle.setDefaultValue(BasicVisualLexicon.NODE_SIZE, 30d);
+
+ // Edge View Defaults
+ visualStyle.setDefaultValue(BasicVisualLexicon.EDGE_WIDTH,
3.0d);
+ visualStyle.setDefaultValue(BasicVisualLexicon.EDGE_PAINT,
EDGE_COLOR);
+
+ // // Apply new visual settings
+ // if (attrNodeColor.length() > 0) {
+ // // Continuous Mapping - set node color
+ // name += "_NodeColor_" + attrNodeColor;
+ // ContinuousMapping conMapNodeColor =
getColorMapping(attrNodeColor,
+ // ObjectMapping.NODE_MAPPING);
+ // conMapNodeColor = addBoundaries(conMapNodeColor,
attrNodeColor,
+ // mapNodeColor, SettingsSerializer
+ // .getPluginSettings().getBrightColor(),
+ // SettingsSerializer.getPluginSettings().getMiddleColor(),
+ // SettingsSerializer.getPluginSettings().getDarkColor());
+ // Calculator nodeColorCalculator = new
+ // BasicCalculator("NetworkAnalyzer Node Color Calc",
conMapNodeColor,
+ // VisualPropertyType.NODE_FILL_COLOR);
+ // nodeAppCalc.setCalculator(nodeColorCalculator);
+ // }
+ // if (attrNodeSize.length() > 0) {
+ // // Continuous Mapping - set node size
+ // name += "_NodeSize_" + attrNodeSize;
+ //
visualStyle.getDependency().set(VisualPropertyDependency.Definition.NODE_SIZE_LOCKED,
+ // false);
+ // ContinuousMapping conMapNodeSize =
getSizeMapping(attrNodeSize,
+ // ObjectMapping.NODE_MAPPING);
+ // conMapNodeSize = addBoundaries(conMapNodeSize, attrNodeSize,
+ // mapNodeSize, new Double(10.0),
+ // new Double(50.0), new Double(100.0));
+ // Calculator nodeHeightCalculator = new
+ // BasicCalculator("NetworkAnalyzer Node Height Calc",
conMapNodeSize,
+ // VisualPropertyType.NODE_HEIGHT);
+ // Calculator nodeWidthCalculator = new
+ // BasicCalculator("NetworkAnalyzer Node Width Calc",
conMapNodeSize,
+ // VisualPropertyType.NODE_WIDTH);
+ // nodeAppCalc.setCalculator(nodeHeightCalculator);
+ // nodeAppCalc.setCalculator(nodeWidthCalculator);
+ // }
+ // if (attrEdgeColor.length() > 0) {
+ // // Continuous Mapping - set edge color
+ // name += "_EdgeColor_" + attrEdgeColor;
+ // ContinuousMapping conMapEdgeColor =
getColorMapping(attrEdgeColor,
+ // ObjectMapping.EDGE_MAPPING);
+ // conMapEdgeColor = addBoundaries(conMapEdgeColor,
attrEdgeColor,
+ // mapEdgeColor, SettingsSerializer
+ // .getPluginSettings().getBrightColor(),
+ // SettingsSerializer.getPluginSettings().getMiddleColor(),
+ // SettingsSerializer.getPluginSettings().getDarkColor());
+ // Calculator edgeColorCalculator = new
+ // BasicCalculator("NetworkAnalyzer Edge Color Calc",
conMapEdgeColor,
+ // VisualPropertyType.EDGE_COLOR);
+ // edgeAppCalc.setCalculator(edgeColorCalculator);
+ // }
+ // if (attrEdgeSize.length() > 0) {
+ // // Continuous Mapping - set line width
+ // name += "_EdgeSize_" + attrEdgeSize;
+ // ContinuousMapping conMapEdgeSize =
getSizeMapping(attrEdgeSize,
+ // ObjectMapping.EDGE_MAPPING);
+ // conMapEdgeSize = addBoundaries(conMapEdgeSize, attrEdgeSize,
+ // mapEdgeSize, new Double(1.0), new Double(4.0),
+ // new Double(8.0));
+ // Calculator edgeSizeCalculator = new
+ // BasicCalculator("NetworkAnalyzer Edge Size Calc",
conMapEdgeSize,
+ // VisualPropertyType.EDGE_LINE_WIDTH);
+ // edgeAppCalc.setCalculator(edgeSizeCalculator);
+ // }
+
+ return visualStyle;
+ }
+
+}
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/data/settings/PluginSettings.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/data/settings/PluginSettings.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/data/settings/PluginSettings.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -410,8 +410,9 @@
/**
* Color to be used for the background when visualizing network
parameters.
*/
- Color backgroundColor;
+ Color backgroundColor = new Color(245, 245, 245);
+
/**
* Bright color to be used for visualizing of network parameters.
*/
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/AnalysisDialog.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/AnalysisDialog.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/AnalysisDialog.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -40,10 +40,14 @@
import javax.swing.JTabbedPane;
import org.cytoscape.model.CyNetwork;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+
import de.mpg.mpi_inf.bioinf.netanalyzer.CyNetworkUtils;
import de.mpg.mpi_inf.bioinf.netanalyzer.InnerException;
import de.mpg.mpi_inf.bioinf.netanalyzer.NetworkAnalyzer;
import de.mpg.mpi_inf.bioinf.netanalyzer.Plugin;
+import de.mpg.mpi_inf.bioinf.netanalyzer.VisualStyleBuilder;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.ComplexParam;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.Decorators;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.Messages;
@@ -60,6 +64,10 @@
*/
public class AnalysisDialog extends JDialog implements ActionListener,
WindowListener {
+ private final CyNetworkViewManager viewManager;
+ private final VisualMappingManager vmm;
+ private final VisualStyleBuilder vsBuilder;
+
/**
* Dialog window for choosing a filename when saving and loading
.netstats files.
*/
@@ -88,9 +96,13 @@
* Analyzer class that performed the topological analysis.
Set this to <code>null</code> if the
* results were loaded from a file rather than just computed.
*/
- public AnalysisDialog(Frame aOwner, NetworkStats aStats,
NetworkAnalyzer aAnalyzer) {
+ public AnalysisDialog(Frame aOwner, NetworkStats aStats,
NetworkAnalyzer aAnalyzer, final CyNetworkViewManager viewManager, final
VisualStyleBuilder vsBuilder,
+ final VisualMappingManager vmm) {
super(aOwner, Messages.DT_ANALYSIS + aStats.getTitle(), false);
this.aOwner = aOwner;
+ this.viewManager = viewManager;
+ this.vmm = vmm;
+ this.vsBuilder = vsBuilder;
stats = aStats;
boolean paramMapping = false;
@@ -287,19 +299,19 @@
*/
private void visualizeParameter() {
CyNetwork network = stats.getNetwork();
- if (network != null ) {
+ if (network != null) {
final String[][] nodeAttr =
CyNetworkUtils.getComputedNodeAttributes(network);
final String[][] edgeAttr =
CyNetworkUtils.getComputedEdgeAttributes(network);
if ((nodeAttr[0].length > 0) || (nodeAttr[1].length >
0) || (edgeAttr[0].length > 0)
|| (edgeAttr[1].length > 0)) {
- final MapParameterDialog d = new
MapParameterDialog(aOwner, network,
+ final MapParameterDialog d = new
MapParameterDialog(aOwner, network, viewManager, vsBuilder, vmm,
nodeAttr, edgeAttr);
d.setVisible(true);
return;
}
}
// Could not locate network - display an error message to the
user
- Utils.showErrorBox(this,Messages.DT_WRONGDATA,
Messages.SM_VISUALIZEERROR);
+ Utils.showErrorBox(this, Messages.DT_WRONGDATA,
Messages.SM_VISUALIZEERROR);
visualizeButton.setEnabled(false);
}
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/BatchResultsDialog.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/BatchResultsDialog.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/BatchResultsDialog.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -58,6 +58,8 @@
private final CyNetworkReaderManager cyNetworkViewReaderMgr;
private final Frame aOwner;
+
+ private final LoadNetstatsAction action;
/**
* Initializes a new instance of <code>BatchResultsDialog</code>.
@@ -67,8 +69,10 @@
* @param aReports
* List of analysis reports to be visualized.
*/
- public BatchResultsDialog(Frame aOwner, List<NetworkAnalysisReport>
aReports, CyNetworkReaderManager cyNetworkViewReaderMgr) {
+ public BatchResultsDialog(Frame aOwner, List<NetworkAnalysisReport>
aReports, CyNetworkReaderManager cyNetworkViewReaderMgr, final
LoadNetstatsAction action) {
super(aOwner, Messages.DT_BATCHRESULTS, false);
+ this.action = action;
+
init(aReports);
setLocationRelativeTo(aOwner);
this.cyNetworkViewReaderMgr = cyNetworkViewReaderMgr;
@@ -106,7 +110,7 @@
if (c == 2) {
final File file =
model.getNetstatsFile(r);
if (file != null) {
-
LoadNetstatsAction.openNetstats(aOwner,file);
+
action.openNetstats(aOwner,file);
}
} else if (c == 0) {
final File file = model.getNetwork(r);
Modified:
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/MapParameterDialog.java
===================================================================
---
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/MapParameterDialog.java
2012-07-03 00:08:14 UTC (rev 29739)
+++
core3/impl/trunk/network-analyzer-impl/src/main/java/de/mpg/mpi_inf/bioinf/netanalyzer/ui/MapParameterDialog.java
2012-07-03 01:39:40 UTC (rev 29740)
@@ -24,9 +24,8 @@
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
@@ -38,32 +37,15 @@
import javax.swing.border.TitledBorder;
import org.cytoscape.model.CyEdge;
+import org.cytoscape.model.CyIdentifiable;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
-import org.cytoscape.model.CyTable;
-import org.cytoscape.model.CyIdentifiable;
+import org.cytoscape.view.model.CyNetworkView;
+import org.cytoscape.view.model.CyNetworkViewManager;
+import org.cytoscape.view.vizmap.VisualMappingManager;
+import org.cytoscape.view.vizmap.VisualStyle;
-//import cytoscape.view.CyNetworkView;
-//import cytoscape.visual.CalculatorCatalog;
-//import cytoscape.visual.EdgeAppearance;
-//import cytoscape.visual.EdgeAppearanceCalculator;
-//import cytoscape.visual.GlobalAppearanceCalculator;
-//import cytoscape.visual.NodeAppearance;
-//import cytoscape.visual.NodeAppearanceCalculator;
-//import cytoscape.visual.NodeShape;
-//import cytoscape.visual.VisualMappingManager;
-//import cytoscape.visual.VisualPropertyDependency;
-//import cytoscape.visual.VisualPropertyType;
-//import cytoscape.visual.VisualStyle;
-//import cytoscape.visual.calculators.BasicCalculator;
-//import cytoscape.visual.calculators.Calculator;
-//import cytoscape.visual.mappings.BoundaryRangeValues;
-//import cytoscape.visual.mappings.ContinuousMapping;
-//import cytoscape.visual.mappings.Interpolator;
-//import cytoscape.visual.mappings.LinearNumberToColorInterpolator;
-//import cytoscape.visual.mappings.LinearNumberToNumberInterpolator;
-//import cytoscape.visual.mappings.ObjectMapping;
-//import cytoscape.visual.mappings.PassThroughMapping;
+import de.mpg.mpi_inf.bioinf.netanalyzer.VisualStyleBuilder;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.Messages;
import de.mpg.mpi_inf.bioinf.netanalyzer.data.io.SettingsSerializer;
@@ -74,7 +56,11 @@
* @author Yassen Assenov
*/
public class MapParameterDialog extends VisualizeParameterDialog implements
ActionListener {
-
+
+ private final CyNetworkViewManager viewManager;
+ private final VisualMappingManager vmm;
+ private final VisualStyleBuilder vsBuilder;
+
/**
* Initializes a new instance of <code>MapParameterDialog</code>.
*
@@ -93,8 +79,14 @@
* @throws NullPointerException
* If <code>aNetwork</code> is <code>null</code>.
*/
- public MapParameterDialog(Frame aOwner, CyNetwork aNetwork, String[][]
aNodeAttr, String[][] aEdgeAttr) {
+ public MapParameterDialog(Frame aOwner, CyNetwork aNetwork, final
CyNetworkViewManager viewManager, final VisualStyleBuilder vsBuilder,
+ final VisualMappingManager vmm, String[][] aNodeAttr,
String[][] aEdgeAttr) {
super(aOwner, Messages.DT_MAPPARAM, true, aNetwork, aNodeAttr,
aEdgeAttr);
+
+ this.viewManager = viewManager;
+ this.vmm = vmm;
+ this.vsBuilder = vsBuilder;
+
getMinMaxMeanValues();
init();
setResizable(false);
@@ -111,48 +103,12 @@
mapEdgeColor = Messages.DI_LOWTOBRIGHT;
}
- /*
- * (non-Javadoc)
- *
- * @see
java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
- */
+
+ @Override
public void actionPerformed(ActionEvent e) {
final Object src = e.getSource();
if (src == btnApply) {
- if (cbxNodeSize != null &&
cbxNodeSize.getSelectedItem() != null) {
- attrNodeSize = (String)
cbxNodeSize.getSelectedItem();
- }
- if (cbxNodeColor != null &&
cbxNodeColor.getSelectedItem() != null) {
- attrNodeColor = (String)
cbxNodeColor.getSelectedItem();
- }
- if (cbxEdgeSize != null &&
cbxEdgeSize.getSelectedItem() != null) {
- attrEdgeSize = (String)
cbxEdgeSize.getSelectedItem();
- }
- if (cbxEdgeColor != null &&
cbxEdgeColor.getSelectedItem() != null) {
- attrEdgeColor = (String)
cbxEdgeColor.getSelectedItem();
- }
- // get the network view on which to apply the visual
style based on
- // this.network
-// CyNetworkView networkView = null;
-// Map<String, CyNetworkView> networkViewMap =
Cytoscape.getNetworkViewMap();
-// if
(networkViewMap.containsKey(network.getIdentifier())) {
-// networkView =
networkViewMap.get(network.getIdentifier());
-// } else {
-// networkView =
Cytoscape.createNetworkView(network);
-// }
-// // get the current visual style and modify it according
to the user
-// // specified criteria
-// VisualMappingManager manager =
Cytoscape.getVisualMappingManager();
-// CalculatorCatalog catalog =
manager.getCalculatorCatalog();
-// VisualStyle newStyle = createVisualStyle();
-// String name = newStyle.getName();
-// if (catalog.getVisualStyle(name) != null) {
-// catalog.removeVisualStyle(name);
-// }
-// catalog.addVisualStyle(newStyle);
-// manager.setVisualStyle(newStyle);
-// networkView.redrawGraph(true, true);
-
+ apply();
setVisible(false);
dispose();
} else if (src == btnClose) {
@@ -184,6 +140,40 @@
mapEdgeColor = btnEdgeColor2.getText();
}
}
+
+ private final void apply() {
+ // Check view exists or not
+ final Collection<CyNetworkView> views =
viewManager.getNetworkViews(network);
+ if(views.isEmpty())
+ return;
+
+ // Pick the first view
+ final CyNetworkView networkView = views.iterator().next();
+
+ if (cbxNodeSize != null && cbxNodeSize.getSelectedItem() !=
null) {
+ attrNodeSize = (String) cbxNodeSize.getSelectedItem();
+ }
+ if (cbxNodeColor != null && cbxNodeColor.getSelectedItem() !=
null) {
+ attrNodeColor = (String) cbxNodeColor.getSelectedItem();
+ }
+ if (cbxEdgeSize != null && cbxEdgeSize.getSelectedItem() !=
null) {
+ attrEdgeSize = (String) cbxEdgeSize.getSelectedItem();
+ }
+ if (cbxEdgeColor != null && cbxEdgeColor.getSelectedItem() !=
null) {
+ attrEdgeColor = (String) cbxEdgeColor.getSelectedItem();
+ }
+
+ // Create a new style and register it
+ final VisualStyle newStyle =
vsBuilder.createVisualStyle(networkView);
+ vmm.addVisualStyle(newStyle);
+
+ vmm.setVisualStyle(newStyle, networkView);
+ vmm.setCurrentVisualStyle(newStyle);
+
+ // Apply and update the current view
+ newStyle.apply(networkView);
+ networkView.updateView();
+ }
/**
* Creates and lays out the controls inside this dialog.
@@ -381,95 +371,8 @@
return false;
}
- /**
- * Creates a new visual style in Cytoscape's VizMapper depending on the
by the user defined mappings of
- * computed attributes.
- *
- * @return New visual style.
-
- private VisualStyle createVisualStyle() {
- // Create new visual style
- String name = network.getTitle();
- VisualStyle visualStyle = new VisualStyle(name); // ,
nodeAppCalc, edgeAppCalc, globalAppCalc);
- NodeAppearanceCalculator nodeAppCalc =
visualStyle.getNodeAppearanceCalculator();
- EdgeAppearanceCalculator edgeAppCalc =
visualStyle.getEdgeAppearanceCalculator();
- GlobalAppearanceCalculator globalAppCalc = new
GlobalAppearanceCalculator();
-
globalAppCalc.setDefaultBackgroundColor(SettingsSerializer.getPluginSettings().getBackgroundColor());
- // Color.getHSBColor(0.6666667f, 0.2f, 1.0f)
-
- // Create default appearance
- Calculator nlc =
Cytoscape.getVisualMappingManager().getCalculatorCatalog().getCalculator(
- VisualPropertyType.NODE_LABEL, "label");
- if (nlc == null) {
- PassThroughMapping m = new PassThroughMapping("", "ID");
- nlc = new BasicCalculator("label", m,
VisualPropertyType.NODE_LABEL);
- }
- nodeAppCalc.setCalculator(nlc);
-
- NodeAppearance na = nodeAppCalc.getDefaultAppearance();
- na.set(VisualPropertyType.NODE_SHAPE, NodeShape.ELLIPSE);
- na.set(VisualPropertyType.NODE_FILL_COLOR,
Color.getHSBColor(0.0f, 0.4f, 1.0f));
- nodeAppCalc.setDefaultAppearance(na);
-
- EdgeAppearance ea = edgeAppCalc.getDefaultAppearance();
- ea.set(VisualPropertyType.EDGE_COLOR, Color.BLUE);
- edgeAppCalc.setDefaultAppearance(ea);
-
- // Apply new visual settings
- if (attrNodeColor.length() > 0) {
- // Continuous Mapping - set node color
- name += "_NodeColor_" + attrNodeColor;
- ContinuousMapping conMapNodeColor =
getColorMapping(attrNodeColor, ObjectMapping.NODE_MAPPING);
- conMapNodeColor = addBoundaries(conMapNodeColor,
attrNodeColor, mapNodeColor, SettingsSerializer
- .getPluginSettings().getBrightColor(),
SettingsSerializer.getPluginSettings()
- .getMiddleColor(),
SettingsSerializer.getPluginSettings().getDarkColor());
- Calculator nodeColorCalculator = new
BasicCalculator("NetworkAnalyzer Node Color Calc",
- conMapNodeColor,
VisualPropertyType.NODE_FILL_COLOR);
- nodeAppCalc.setCalculator(nodeColorCalculator);
- }
- if (attrNodeSize.length() > 0) {
- // Continuous Mapping - set node size
- name += "_NodeSize_" + attrNodeSize;
-
visualStyle.getDependency().set(VisualPropertyDependency.Definition.NODE_SIZE_LOCKED,
false);
- ContinuousMapping conMapNodeSize =
getSizeMapping(attrNodeSize, ObjectMapping.NODE_MAPPING);
- conMapNodeSize = addBoundaries(conMapNodeSize,
attrNodeSize, mapNodeSize, new Double(10.0),
- new Double(50.0), new Double(100.0));
- Calculator nodeHeightCalculator = new
BasicCalculator("NetworkAnalyzer Node Height Calc",
- conMapNodeSize,
VisualPropertyType.NODE_HEIGHT);
- Calculator nodeWidthCalculator = new
BasicCalculator("NetworkAnalyzer Node Width Calc",
- conMapNodeSize,
VisualPropertyType.NODE_WIDTH);
- nodeAppCalc.setCalculator(nodeHeightCalculator);
- nodeAppCalc.setCalculator(nodeWidthCalculator);
- }
- if (attrEdgeColor.length() > 0) {
- // Continuous Mapping - set edge color
- name += "_EdgeColor_" + attrEdgeColor;
- ContinuousMapping conMapEdgeColor =
getColorMapping(attrEdgeColor, ObjectMapping.EDGE_MAPPING);
- conMapEdgeColor = addBoundaries(conMapEdgeColor,
attrEdgeColor, mapEdgeColor, SettingsSerializer
- .getPluginSettings().getBrightColor(),
SettingsSerializer.getPluginSettings()
- .getMiddleColor(),
SettingsSerializer.getPluginSettings().getDarkColor());
- Calculator edgeColorCalculator = new
BasicCalculator("NetworkAnalyzer Edge Color Calc",
- conMapEdgeColor,
VisualPropertyType.EDGE_COLOR);
- edgeAppCalc.setCalculator(edgeColorCalculator);
- }
- if (attrEdgeSize.length() > 0) {
- // Continuous Mapping - set line width
- name += "_EdgeSize_" + attrEdgeSize;
- ContinuousMapping conMapEdgeSize =
getSizeMapping(attrEdgeSize, ObjectMapping.EDGE_MAPPING);
- conMapEdgeSize = addBoundaries(conMapEdgeSize,
attrEdgeSize, mapEdgeSize, new Double(1.0),
- new Double(4.0), new Double(8.0));
- Calculator edgeSizeCalculator = new
BasicCalculator("NetworkAnalyzer Edge Size Calc",
- conMapEdgeSize,
VisualPropertyType.EDGE_LINE_WIDTH);
- edgeAppCalc.setCalculator(edgeSizeCalculator);
- }
-
- visualStyle.setName(name);
- return visualStyle;
- }
- */
-
/**
* Computes the minimal, maximal and mean value for each computed
attribute by consequently processing
* each node.
--
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.