예제 #1
0
  /**
   * @param title Title of the new Visual Style
   * @param lexManager
   */
  public VisualStyleImpl(
      final String title,
      final VisualLexiconManager lexManager,
      final CyServiceRegistrar serviceRegistrar,
      final CyEventHelper eventHelper) {

    if (lexManager == null) throw new NullPointerException("Lexicon Manager is missing.");

    if (title == null) this.title = DEFAULT_TITLE;
    else this.title = title;

    this.eventHelper = eventHelper;

    mappings = new HashMap<VisualProperty<?>, VisualMappingFunction<?, ?>>();
    styleDefaults = new HashMap<VisualProperty<?>, Object>();

    // Init Apply handlers for node, egde and network.
    applyHandlersMap = new HashMap<Class<? extends CyIdentifiable>, ApplyHandler>();
    applyHandlersMap.put(CyNetwork.class, new ApplyToNetworkHandler(this, lexManager));
    applyHandlersMap.put(CyNode.class, new ApplyToNodeHandler(this, lexManager));
    applyHandlersMap.put(CyEdge.class, new ApplyToEdgeHandler(this, lexManager));

    dependencies = new HashSet<VisualPropertyDependency<?>>();

    // Listening to dependencies
    serviceRegistrar.registerServiceListener(
        this,
        "registerDependencyFactory",
        "unregisterDependencyFactory",
        VisualPropertyDependencyFactory.class);
    serviceRegistrar.registerService(
        this, VisualMappingFunctionChangedListener.class, new Properties());
    logger.info("New Visual Style Created: Style Name = " + this.title);
  }