use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class CySessionManagerImpl method restoreVisualStyles.
private void restoreVisualStyles(final CySession sess) {
logger.debug("Restoring visual styles...");
// Register visual styles
final VisualMappingManager vmMgr = serviceRegistrar.getService(VisualMappingManager.class);
final VisualStyle defStyle = vmMgr.getDefaultVisualStyle();
final String DEFAULT_STYLE_NAME = defStyle.getTitle();
final Set<VisualStyle> styles = sess.getVisualStyles();
final Map<String, VisualStyle> stylesMap = new HashMap<>();
final RenderingEngineManager engineManager = serviceRegistrar.getService(RenderingEngineManager.class);
if (styles != null) {
for (VisualStyle vs : styles) {
if (vs.getTitle().equals(DEFAULT_STYLE_NAME)) {
// Update the current default style, because it can't be replaced or removed
updateVisualStyle(vs, defStyle, engineManager);
vs = defStyle;
}
stylesMap.put(vs.getTitle(), vs);
if (!vs.equals(defStyle))
vmMgr.addVisualStyle(vs);
}
}
// Set visual styles to network views
final Map<CyNetworkView, String> viewStyleMap = sess.getViewVisualStyleMap();
if (viewStyleMap != null) {
for (Entry<CyNetworkView, String> entry : viewStyleMap.entrySet()) {
final CyNetworkView netView = entry.getKey();
final String stName = entry.getValue();
VisualStyle vs = stylesMap.get(stName);
if (vs == null)
vs = defStyle;
if (vs != null) {
vmMgr.setVisualStyle(vs, netView);
vs.apply(netView);
}
}
}
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class SetLockedValuesTask method updateView.
private void updateView() {
final VisualStyle style = servicesUtil.get(VisualMappingManager.class).getVisualStyle(netView);
style.apply(netView);
netView.updateView();
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class VizMapperMediator method handleEvent.
@Override
public void handleEvent(final VisualMappingFunctionChangedEvent e) {
final VisualMappingFunction<?, ?> vm = e.getSource();
final VisualProperty<?> vp = vm.getVisualProperty();
final VisualStyle curStyle = vmProxy.getCurrentVisualStyle();
// If the source mapping belongs to the current visual style, update the correspondent property sheet item
if (vm.equals(curStyle.getVisualMappingFunction(vp))) {
final VisualPropertySheet vpSheet = vizMapperMainPanel.getVisualPropertySheet(vp.getTargetDataType());
if (vpSheet != null) {
final VisualPropertySheetItem<?> vpSheetItem = vpSheet.getItem(vp);
if (vpSheetItem != null)
invokeOnEDT(() -> vpSheetItem.updateMapping());
}
}
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class VizMapperMediator method handleEvent.
@Override
public void handleEvent(final LexiconStateChangedEvent e) {
// Update Network Views
final VisualStyle curStyle = vmProxy.getCurrentVisualStyle();
final Set<CyNetworkView> views = vmProxy.getNetworkViewsWithStyle(curStyle);
for (final CyNetworkView view : views) {
// TODO This should be done by NetworkViewMediator only, if possible
curStyle.apply(view);
view.updateView();
}
// Update VP Sheet Items
invokeOnEDT(() -> updateItemsStatus());
}
use of org.cytoscape.view.vizmap.VisualStyle in project cytoscape-impl by cytoscape.
the class VizMapperMediator method onSelectedVisualStyleChanged.
private void onSelectedVisualStyleChanged(final PropertyChangeEvent e) {
final VisualStyle newStyle = (VisualStyle) e.getNewValue();
final VisualStyle oldStyle = vmProxy.getCurrentVisualStyle();
if (!ignoreVisualStyleSelectedEvents && newStyle != null && !newStyle.equals(oldStyle)) {
// Update proxy
vmProxy.setCurrentVisualStyle(newStyle);
// Undo support
final UndoSupport undo = servicesUtil.get(UndoSupport.class);
undo.postEdit(new AbstractCyEdit("Set Current Style") {
@Override
public void undo() {
vmProxy.setCurrentVisualStyle(oldStyle);
}
@Override
public void redo() {
vmProxy.setCurrentVisualStyle(newStyle);
}
});
}
}
Aggregations