use of org.cytoscape.view.presentation.property.values.NodeShape in project EnrichmentMapApp by BaderLab.
the class EMStyleBuilder method setNodeShapes.
@SuppressWarnings({ "unchecked", "rawtypes" })
private void setNodeShapes(VisualStyle vs, EMStyleOptions options, ChartType chartType) {
String prefix = options.getAttributePrefix();
String columnName = Columns.NODE_GS_TYPE.with(prefix, null);
NodeShape enrShape = getDefaultNodeShape(chartType);
VisualMappingFunction<?, NodeShape> oldMapping = vs.getVisualMappingFunction(NODE_SHAPE);
// This is done for performance optimization only!
boolean update = oldMapping instanceof DiscreteMapping == false;
if (!update) {
// Also test the mapped column name
update = !columnName.equals(oldMapping.getMappingColumnName());
if (!update) {
// Finally test the mapping values
Object enrVal = ((DiscreteMapping) oldMapping).getMapValue(Columns.NODE_GS_TYPE_ENRICHMENT);
Object sigVal = ((DiscreteMapping) oldMapping).getMapValue(Columns.NODE_GS_TYPE_SIGNATURE);
update = !enrShape.equals(enrVal) || !SIGNATURE_NODE_SHAPE.equals(sigVal);
}
}
if (update) {
// Add mapping function for node shape
DiscreteMapping<String, NodeShape> dm = (DiscreteMapping<String, NodeShape>) dmFactory.createVisualMappingFunction(columnName, String.class, NODE_SHAPE);
// Silence events fired by this mapping to prevent unnecessary style and view updates
eventHelper.silenceEventSource(dm);
try {
dm.putMapValue(Columns.NODE_GS_TYPE_ENRICHMENT, enrShape);
dm.putMapValue(Columns.NODE_GS_TYPE_SIGNATURE, SIGNATURE_NODE_SHAPE);
} finally {
eventHelper.unsilenceEventSource(dm);
}
vs.addVisualMappingFunction(dm);
}
}
use of org.cytoscape.view.presentation.property.values.NodeShape 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();
}
Aggregations