Search in sources :

Example 1 with VisualStyleAddedEvent

use of org.cytoscape.view.vizmap.events.VisualStyleAddedEvent in project cytoscape-impl by cytoscape.

the class VisualMappingManagerImpl method addVisualStyle.

/**
 * Add a new VisualStyle to this manager. This will be called through OSGi service mechanism.
 *
 * @param vs new Visual Style to be added.
 */
@Override
public void addVisualStyle(final VisualStyle vs) {
    if (vs == null) {
        logger.warn("Tried to add null to VMM.");
        return;
    }
    if (hasDuplicatedTitle(vs)) {
        String newTitle = getSuggestedTitle(vs.getTitle());
        // Update the title
        vs.setTitle(newTitle);
    }
    synchronized (lock) {
        this.visualStyles.add(vs);
    }
    logger.info("New visual Style registered to VMM: " + vs.getTitle());
    logger.info("Total Number of VS in VMM = " + visualStyles.size());
    if (vs.getTitle() != null && vs.getTitle().equals(DEFAULT_STYLE_NAME))
        defaultStyle = vs;
    final CyEventHelper eventHelper = serviceRegistrar.getService(CyEventHelper.class);
    eventHelper.fireEvent(new VisualStyleAddedEvent(this, vs));
}
Also used : CyEventHelper(org.cytoscape.event.CyEventHelper) VisualStyleAddedEvent(org.cytoscape.view.vizmap.events.VisualStyleAddedEvent)

Example 2 with VisualStyleAddedEvent

use of org.cytoscape.view.vizmap.events.VisualStyleAddedEvent in project cytoscape-api by cytoscape.

the class VizmapEventsTest method testVisualStyleCreatedEvent.

@Test
public void testVisualStyleCreatedEvent() {
    final VisualStyleAddedEvent event = new VisualStyleAddedEvent(manager, style);
    assertEquals(style, event.getVisualStyleAdded());
}
Also used : VisualStyleAddedEvent(org.cytoscape.view.vizmap.events.VisualStyleAddedEvent) Test(org.junit.Test)

Aggregations

VisualStyleAddedEvent (org.cytoscape.view.vizmap.events.VisualStyleAddedEvent)2 CyEventHelper (org.cytoscape.event.CyEventHelper)1 Test (org.junit.Test)1