use of org.cytoscape.view.vizmap.events.VisualStyleAboutToBeRemovedEvent in project cytoscape-api by cytoscape.
the class VizmapEventsTest method testVisualStyleDestroyedEvent.
@Test
public void testVisualStyleDestroyedEvent() {
final VisualStyleAboutToBeRemovedEvent event = new VisualStyleAboutToBeRemovedEvent(manager, style);
assertEquals(style, event.getVisualStyleToBeRemoved());
}
use of org.cytoscape.view.vizmap.events.VisualStyleAboutToBeRemovedEvent in project cytoscape-impl by cytoscape.
the class VisualMappingManagerImpl method removeVisualStyle.
/**
* Remove a {@linkplain VisualStyle} from this manager. This will be called through OSGi service mechanism.
*/
@Override
public void removeVisualStyle(VisualStyle vs) {
if (vs == null)
throw new NullPointerException("Visual Style is null.");
if (vs == defaultStyle)
throw new IllegalArgumentException("Cannot remove default visual style.");
logger.info("Visual Style about to be removed from VMM: " + vs.getTitle());
final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
eventHelper.fireEvent(new VisualStyleAboutToBeRemovedEvent(this, vs));
synchronized (lock) {
visualStyles.remove(vs);
}
// Change current style, if it is the deleted one
if (currentStyle == vs)
setCurrentVisualStyle(getDefaultVisualStyle());
// Use default for all views using this vs.
HashSet<CyNetworkView> viewsToUpdate = new HashSet<>();
synchronized (lock) {
if (network2VisualStyleMap.values().contains(vs)) {
for (final CyNetworkView view : network2VisualStyleMap.keySet()) {
if (network2VisualStyleMap.get(view).equals(vs))
viewsToUpdate.add(view);
}
}
}
for (CyNetworkView view : viewsToUpdate) {
setVisualStyle(defaultStyle, view);
}
logger.info("Total Number of VS in VMM after remove = " + visualStyles.size());
}
Aggregations