Search in sources :

Example 1 with CustomGraphicsManager

use of org.cytoscape.ding.customgraphics.CustomGraphicsManager in project cytoscape-impl by cytoscape.

the class ImageAnnotationFactory method createAnnotation.

@Override
public ImageAnnotation createAnnotation(Class<? extends ImageAnnotation> clazz, CyNetworkView view, Map<String, String> argMap) {
    if (!(view instanceof DGraphView))
        return null;
    DGraphView dView = (DGraphView) view;
    if (ImageAnnotation.class.equals(clazz)) {
        final CustomGraphicsManager customGraphicsManager = serviceRegistrar.getService(CustomGraphicsManager.class);
        final ImageAnnotationImpl a = new ImageAnnotationImpl(dView, argMap, customGraphicsManager, getActiveWindow());
        a.update();
        return (ImageAnnotation) a;
    } else {
        return null;
    }
}
Also used : ImageAnnotation(org.cytoscape.view.presentation.annotations.ImageAnnotation) ImageAnnotationImpl(org.cytoscape.ding.impl.cyannotator.annotations.ImageAnnotationImpl) CustomGraphicsManager(org.cytoscape.ding.customgraphics.CustomGraphicsManager) DGraphView(org.cytoscape.ding.impl.DGraphView)

Example 2 with CustomGraphicsManager

use of org.cytoscape.ding.customgraphics.CustomGraphicsManager in project cytoscape-impl by cytoscape.

the class CustomGraphicsVisualProperty method parseSerializableString.

// Parse the string associated with our visual property.  Note that we depend on the first
// part of the string being the class name that was registered with the CyCustomGraphicsManager
@Override
@SuppressWarnings("unchecked")
public CyCustomGraphics<CustomGraphicLayer> parseSerializableString(String value) {
    CyCustomGraphics<CustomGraphicLayer> cg = null;
    if (value != null && !NullCustomGraphics.getNullObject().toString().equals(value) && !value.contains("NullCustomGraphics")) {
        String[] parts = value.split(":");
        // Skip over the chart/gradient factory id
        int offset = value.indexOf(":");
        // First check if it's a CyCustomGraphics2
        // ------------------------------
        // This is hack, but we've got no other way to get our hands on the
        // CyCustomGraphics2Manager this way, because the DVisualLexicon is created statically
        final CyCustomGraphics2ManagerImpl cfMgr = CyCustomGraphics2ManagerImpl.getInstance();
        final CyCustomGraphics2Factory<? extends CustomGraphicLayer> chartFactory = cfMgr.getCyCustomGraphics2Factory(parts[0]);
        if (chartFactory != null) {
            cg = (CyCustomGraphics<CustomGraphicLayer>) chartFactory.getInstance(value.substring(offset + 1));
        } else {
            // Then check if it's a CyCustomGraphics2
            // -------------------------------
            final CyCustomGraphics2ManagerImpl cgMgr = CyCustomGraphics2ManagerImpl.getInstance();
            final CyCustomGraphics2Factory<? extends CustomGraphicLayer> gradFactory = cgMgr.getCyCustomGraphics2Factory(parts[0]);
            if (gradFactory != null)
                cg = (CyCustomGraphics<CustomGraphicLayer>) gradFactory.getInstance(value.substring(offset + 1));
        }
        if (cg == null) {
            // Try to parse it as a regular custom graphics then
            // -------------------------------------------------
            // This is hack, but we've got no other way to get our hands on the
            // CyCustomGraphicsManager since the DVisualLexicon is created statically
            final CustomGraphicsManager cgMgr = CustomGraphicsManagerImpl.getInstance();
            parts = value.split(",");
            final CyCustomGraphicsFactory factory = cgMgr.getCustomGraphicsFactory(parts[0]);
            if (factory != null) {
                // Skip over the class name
                offset = value.indexOf(",");
                cg = factory.parseSerializableString(value.substring(offset + 1));
            }
        }
    }
    return cg != null ? cg : NullCustomGraphics.getNullObject();
}
Also used : CyCustomGraphics2ManagerImpl(org.cytoscape.ding.customgraphics.CyCustomGraphics2ManagerImpl) CyCustomGraphicsFactory(org.cytoscape.view.presentation.customgraphics.CyCustomGraphicsFactory) CyCustomGraphics(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics) CustomGraphicLayer(org.cytoscape.view.presentation.customgraphics.CustomGraphicLayer) CustomGraphicsManager(org.cytoscape.ding.customgraphics.CustomGraphicsManager)

Example 3 with CustomGraphicsManager

use of org.cytoscape.ding.customgraphics.CustomGraphicsManager in project cytoscape-impl by cytoscape.

the class DVisualLexiconTest method setUp.

@Before
public void setUp() throws Exception {
    final CustomGraphicsManager manager = mock(CustomGraphicsManager.class);
    dLexicon = new DVisualLexicon(manager);
}
Also used : DVisualLexicon(org.cytoscape.ding.DVisualLexicon) CustomGraphicsManager(org.cytoscape.ding.customgraphics.CustomGraphicsManager) Before(org.junit.Before)

Aggregations

CustomGraphicsManager (org.cytoscape.ding.customgraphics.CustomGraphicsManager)3 DVisualLexicon (org.cytoscape.ding.DVisualLexicon)1 CyCustomGraphics2ManagerImpl (org.cytoscape.ding.customgraphics.CyCustomGraphics2ManagerImpl)1 DGraphView (org.cytoscape.ding.impl.DGraphView)1 ImageAnnotationImpl (org.cytoscape.ding.impl.cyannotator.annotations.ImageAnnotationImpl)1 ImageAnnotation (org.cytoscape.view.presentation.annotations.ImageAnnotation)1 CustomGraphicLayer (org.cytoscape.view.presentation.customgraphics.CustomGraphicLayer)1 CyCustomGraphics (org.cytoscape.view.presentation.customgraphics.CyCustomGraphics)1 CyCustomGraphicsFactory (org.cytoscape.view.presentation.customgraphics.CyCustomGraphicsFactory)1 Before (org.junit.Before)1