use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class LegendPanel method update.
/**
* Update parameters panel based on given enrichment map parameters
* @param chartType
*/
void update(EMStyleOptions options, Collection<EMDataSet> filteredDataSets) {
this.options = options;
CyNetworkView networkView = options != null ? options.getNetworkView() : null;
removeAll();
EnrichmentMap map = networkView != null ? emManager.getEnrichmentMap(networkView.getModel().getSUID()) : null;
EMCreationParameters params = map != null ? map.getParams() : null;
if (params == null) {
JLabel infoLabel = new JLabel("No EnrichmentMap View selected");
infoLabel.setEnabled(false);
infoLabel.setForeground(UIManager.getColor("Label.disabledForeground"));
infoLabel.setHorizontalAlignment(JLabel.CENTER);
infoLabel.setVerticalAlignment(JLabel.CENTER);
infoLabel.setBorder(new EmptyBorder(120, 40, 120, 40));
add(infoLabel, BorderLayout.CENTER);
} else {
nodeLegendPanel = null;
nodeColorPanel = null;
nodeShapePanel = null;
nodeChartPanel = null;
edgeLegendPanel = null;
edgeColorPanel = null;
updateNodeColorPanel(filteredDataSets, map);
updateNodeShapePanel(map);
updateNodeChartPanel(filteredDataSets, map);
updateEdgeColorPanel(map);
JPanel panel = new JPanel();
final GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setAutoCreateContainerGaps(true);
layout.setAutoCreateGaps(true);
layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER, true).addComponent(getNodeLegendPanel(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(getEdgeLegendPanel(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE));
layout.setVerticalGroup(layout.createSequentialGroup().addComponent(getNodeLegendPanel(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(getEdgeLegendPanel(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE));
JScrollPane scrollPane = new JScrollPane(panel);
add(scrollPane, BorderLayout.CENTER);
}
revalidate();
}
use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class LegendPanelMediator method showCreationParamsDialog.
@SuppressWarnings("serial")
private void showCreationParamsDialog() {
JDialog d = new JDialog(dialog, "EnrichmentMap Creation Parameters", ModalityType.APPLICATION_MODAL);
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.setMinimumSize(new Dimension(420, 260));
d.setPreferredSize(new Dimension(580, 460));
JButton closeButton = new JButton(new AbstractAction("Close") {
@Override
public void actionPerformed(ActionEvent e) {
d.dispose();
}
});
JPanel bottomPanel = LookAndFeelUtil.createOkCancelPanel(null, closeButton);
d.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
CyNetworkView netView = legendPanelProvider.get().getOptions().getNetworkView();
if (netView != null) {
EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
CreationParametersPanel paramsPanel = new CreationParametersPanel(map);
d.getContentPane().add(paramsPanel, BorderLayout.CENTER);
}
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(d.getRootPane(), null, closeButton.getAction());
d.getRootPane().setDefaultButton(closeButton);
d.setLocationRelativeTo(dialog);
d.pack();
d.setVisible(true);
}
use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class LegendPanel method updateEdgeColorPanel.
private void updateEdgeColorPanel(EnrichmentMap map) {
JPanel p = getEdgeColorPanel();
CyNetworkView netView = options.getNetworkView();
VisualStyle style = netView != null ? visualMappingManager.getVisualStyle(netView) : null;
JComponent[][] entries = null;
if (map != null) {
Dimension iconSize = new Dimension(LEGEND_ICON_SIZE, LEGEND_ICON_SIZE / 2);
if (map.getParams().getCreateDistinctEdges()) {
VisualMappingFunction<?, Paint> mf = style.getVisualMappingFunction(BasicVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT);
if (mf instanceof DiscreteMapping) {
DiscreteMapping<?, Paint> dm = (DiscreteMapping<?, Paint>) mf;
final Collator collator = Collator.getInstance();
Map<Object, Paint> dmMap = new TreeMap<>((Object o1, Object o2) -> {
return collator.compare("" + o1, "" + o2);
});
dmMap.putAll(dm.getAll());
dmMap.remove(Columns.EDGE_DATASET_VALUE_COMPOUND);
if (!map.hasSignatureDataSets())
dmMap.remove(Columns.EDGE_DATASET_VALUE_SIG);
if (dmMap.size() > 0) {
entries = new JComponent[dmMap.size()][2];
int i = 0;
for (Entry<?, Paint> e : dmMap.entrySet()) {
Color color = null;
if (e.getValue() instanceof Color)
color = (Color) e.getValue();
JLabel iconLabel = createColorLabel(color, iconSize);
JLabel descLabel = new JLabel("" + e.getKey());
if (Columns.EDGE_DATASET_VALUE_SIG.equals(e.getKey()))
descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC));
entries[i++] = new JComponent[] { iconLabel, descLabel };
}
}
}
}
if (entries == null) {
int rows = map.hasSignatureDataSets() ? 2 : 1;
entries = new JComponent[rows][2];
{
JLabel iconLabel = createColorLabel(Colors.COMPOUND_EDGE_COLOR, iconSize);
JLabel descLabel = new JLabel(Columns.EDGE_DATASET_VALUE_COMPOUND);
descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC));
entries[0] = new JComponent[] { iconLabel, descLabel };
}
if (rows == 2) {
JLabel iconLabel = createColorLabel(Colors.SIG_EDGE_COLOR, iconSize);
JLabel descLabel = new JLabel(Columns.EDGE_DATASET_VALUE_SIG);
descLabel.setFont(descLabel.getFont().deriveFont(Font.ITALIC));
entries[1] = new JComponent[] { iconLabel, descLabel };
}
}
}
updateStyleLegendPanel(entries, p);
}
use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class LegendPanel method updateNodeShapePanel.
private void updateNodeShapePanel(EnrichmentMap map) {
JPanel p = getNodeShapePanel();
p.removeAll();
CyNetworkView netView = options.getNetworkView();
VisualStyle style = netView != null ? visualMappingManager.getVisualStyle(netView) : null;
nodeShapeIcon1.setVisible(style != null);
nodeShapeDesc1.setVisible(style != null);
nodeShapeIcon2.setVisible(style != null && map.hasSignatureDataSets());
nodeShapeDesc2.setVisible(style != null && map.hasSignatureDataSets());
if (style != null) {
NodeShape shape = EMStyleBuilder.getGeneSetNodeShape(style);
nodeShapeIcon1.setIcon(getIcon(BasicVisualLexicon.NODE_SHAPE, shape, netView));
if (map.hasSignatureDataSets()) {
shape = EMStyleBuilder.getSignatureNodeShape(style);
nodeShapeIcon2.setIcon(getIcon(BasicVisualLexicon.NODE_SHAPE, shape, netView));
}
}
p.revalidate();
}
use of org.cytoscape.view.model.CyNetworkView in project EnrichmentMapApp by BaderLab.
the class PAKnownSignatureCommandTask method run.
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
if (gmtFile == null || !gmtFile.canRead())
throw new IllegalArgumentException("Signature GMT file name not valid");
CyNetwork selectedNetwork;
CyNetworkView selectedView;
if (network == null) {
selectedNetwork = applicationManager.getCurrentNetwork();
selectedView = applicationManager.getCurrentNetworkView();
if (selectedNetwork == null || selectedView == null) {
throw new IllegalArgumentException("Current network not available.");
}
} else {
selectedNetwork = network;
Collection<CyNetworkView> networkViews = networkViewManager.getNetworkViews(network);
if (networkViews == null || networkViews.isEmpty()) {
throw new IllegalArgumentException("No network view for: " + network);
}
selectedView = networkViews.iterator().next();
}
EnrichmentMap map = emManager.getEnrichmentMap(selectedNetwork.getSUID());
if (map == null)
throw new IllegalArgumentException("Network is not an Enrichment Map.");
loadGeneSets(map);
PostAnalysisFilterType filter = PostAnalysisFilterType.valueOf(filterType.getSelectedValue());
UniverseType universe = UniverseType.valueOf(hypergeomUniverseType.getSelectedValue());
PostAnalysisParameters.Builder builder = new PostAnalysisParameters.Builder();
builder.setAttributePrefix(map.getParams().getAttributePrefix());
builder.setSignatureGMTFileName(gmtFile.getAbsolutePath());
builder.setLoadedGMTGeneSets(signatureGenesets);
builder.addSelectedGeneSetNames(selectedGenesetNames);
builder.setUniverseType(universe);
builder.setUserDefinedUniverseSize(userDefinedUniverseSize);
builder.setRankTestParameters(new PostAnalysisFilterParameters(filter, cutoff));
builder.setName(name);
if (isBatch()) {
// run in batch mode
builder.setDataSetName(null);
} else {
if (map.getDataSet(dataSetName) == null) {
throw new IllegalArgumentException("Data set name not valid: '" + dataSetName + "'");
}
builder.setDataSetName(dataSetName);
}
// Mann-Whitney requires ranks
if (filter.isMannWhitney()) {
processMannWhitneyArgs(map, builder);
}
TaskFactory taskFactory = taskFactoryFactory.create(selectedView, builder.build());
TaskIterator taskIterator = new TaskIterator();
taskIterator.append(taskFactory.createTaskIterator());
Task updatePanelTask = new AbstractTask() {
@Override
public void run(TaskMonitor taskMonitor) {
controlPanelMediatorProvider.get().updateDataSetList(selectedView);
selectedView.updateView();
}
};
taskIterator.append(updatePanelTask);
insertTasksAfterCurrentTask(taskIterator);
}
Aggregations