Ejemplo n.º 1
0
  private boolean syncToNode() {
    boolean sync = false;
    if (vmm.getCurrentVisualStyle() != null) {
      Set<VisualPropertyDependency<?>> dependencies =
          vmm.getCurrentVisualStyle().getAllVisualPropertyDependencies();

      for (VisualPropertyDependency<?> dep : dependencies) {
        if (dep.getIdString().equals("nodeCustomGraphicsSizeSync")) {
          sync = dep.isDependencyEnabled();
          break;
        }
      }
    }
    return sync;
  }
Ejemplo n.º 2
0
  private final void clearAll(
      final CyNetworkView netView, final View<? extends CyIdentifiable> nodeView) {
    boolean needToUpdateView = false;
    final VisualStyle style = vmm.getCurrentVisualStyle();

    for (VisualProperty<?> vp : vpSet) {
      final boolean lock = nodeView.isDirectlyLocked(vp);
      if (lock) {
        nodeView.clearValueLock(vp);
        needToUpdateView = true;
      }
    }

    if (needToUpdateView) {
      style.apply(netView);
      netView.updateView();
    }
  }
Ejemplo n.º 3
0
  @Override
  @SuppressWarnings("unchecked")
  public void setValue(final Object value) {
    if (value instanceof ContinuousMapping == false)
      throw new IllegalArgumentException("Value should be ContinuousMapping: this is " + value);

    final CyApplicationManager appMgr = servicesUtil.get(CyApplicationManager.class);
    final CyNetwork currentNetwork = appMgr.getCurrentNetwork();

    if (currentNetwork == null) return;

    mapping = (ContinuousMapping<K, V>) value;
    Class<? extends CyIdentifiable> type =
        (Class<? extends CyIdentifiable>) mapping.getVisualProperty().getTargetDataType();

    final CyNetworkTableManager netTblMgr = servicesUtil.get(CyNetworkTableManager.class);
    final CyTable attr =
        netTblMgr.getTable(appMgr.getCurrentNetwork(), type, CyNetwork.DEFAULT_ATTRS);

    final VisualMappingManager vmMgr = servicesUtil.get(VisualMappingManager.class);
    editorPanel =
        new C2CMappingEditorPanel<K, V>(vmMgr.getCurrentVisualStyle(), mapping, attr, servicesUtil);
  }
Ejemplo n.º 4
0
  /**
   * @param netView
   * @param view a View&lt;CyNode&gt;, View&lt;CyEdge&gt; or View&lt;CyNetwork&gt; object
   * @return
   */
  public CyMenuItem build(final CyNetworkView netView, final View<? extends CyIdentifiable> view) {
    final Class<? extends CyIdentifiable> targetClass = view.getModel().getClass();
    final Queue<VisualLexiconNode> queue =
        new PriorityQueue<VisualLexiconNode>(50, new VisualLexiconNodeComparator());
    final Map<VisualLexiconNode, JMenuItem> menuMap = new HashMap<VisualLexiconNode, JMenuItem>();

    final JMenu rootJMenu = new JMenu(ROOT_MENU_LABEL);

    final CyMenuItem rootMenu = new CyMenuItem(rootJMenu, ROOT_GRAVITY);
    queue.addAll(root.getChildren());
    menuMap.put(root, rootMenu.getMenuItem());

    // Node size, width and height
    JMenuItem menuItemNodeSize = null;
    JMenuItem menuItemNodeWidth = null;
    JMenuItem menuItemNodeHeight = null;

    final Set<VisualLexiconNode> nextNodes = new HashSet<VisualLexiconNode>();

    while (!queue.isEmpty()) {
      final VisualLexiconNode curretNode = queue.poll();
      final VisualProperty<?> vp = curretNode.getVisualProperty();

      if (vp.getTargetDataType().isAssignableFrom(targetClass)) {
        final Collection<VisualLexiconNode> children = curretNode.getChildren();
        nextNodes.addAll(children);

        final JMenuItem menu;
        if (children.isEmpty() && PropertySheetUtil.isCompatible(vp)) {
          final boolean lock = view.isDirectlyLocked(vp);
          if (lock) {
            menu = new JMenu(vp.getDisplayName());
            final JMenuItem clear = new JMenuItem("Clear");
            clear.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    view.clearValueLock(vp);
                    netView.updateView();
                  }
                });

            final JMenuItem edit = new JMenuItem("Edit Bypass");
            edit.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    applBypassValue(netView, view, vp);
                  }
                });
            menu.add(clear);
            menu.add(edit);

            // Update color
            menu.setForeground(ENABLED_COLOR);
            menu.setIcon(ENABLED_ICON);
            menu.setFont(ENABLED_FONT);
            VisualLexiconNode parent = curretNode.getParent();

            while (parent != root) {
              JMenuItem enabledPath = menuMap.get(parent);
              enabledPath.setForeground(ENABLED_COLOR);
              enabledPath.setIcon(ENABLED_ICON);
              enabledPath.setFont(ENABLED_FONT);
              parent = parent.getParent();
            }

            rootJMenu.setIcon(ENABLED_ICON);
            rootJMenu.setForeground(ENABLED_COLOR);
            rootJMenu.setFont(ENABLED_FONT);

            vpSet.add(vp);
          } else {
            menu = new JMenuItem(vp.getDisplayName());
            menu.addActionListener(
                new ActionListener() {
                  @Override
                  public void actionPerformed(ActionEvent e) {
                    applBypassValue(netView, view, vp);
                  }
                });

            if (vp.getDisplayName()
                .equalsIgnoreCase(BasicVisualLexicon.NODE_WIDTH.getDisplayName())) {
              menuItemNodeWidth = menu;
            }
            if (vp.getDisplayName()
                .equalsIgnoreCase(BasicVisualLexicon.NODE_HEIGHT.getDisplayName())) {
              menuItemNodeHeight = menu;
            }
          }
        } else {

          menu = new JMenu(vp.getDisplayName());

          if (vp.getDisplayName().equalsIgnoreCase(BasicVisualLexicon.NODE_SIZE.getDisplayName())) {
            menuItemNodeSize = menu;
            vp_nodeSize = vp;
          }
        }

        if (PropertySheetUtil.isCompatible(vp)) {
          menuMap.get(curretNode.getParent()).add(menu);
          menuMap.put(curretNode, menu);
        }
      }

      if (queue.isEmpty()) {
        queue.addAll(nextNodes);
        nextNodes.clear();
      }
    }

    // handle node size
    if (menuItemNodeSize != null) {
      //
      JMenuItem menuItemNodeSize1 = new JMenuItem(vp_nodeSize.getDisplayName());
      menuItemNodeSize1.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              applBypassValue(netView, view, vp_nodeSize);
            }
          });

      menuItemNodeSize.add(menuItemNodeSize1);

      // Check if nose size is locked
      boolean nodeSizeIsLocked = false;
      java.util.Iterator it =
          vmm.getCurrentVisualStyle().getAllVisualPropertyDependencies().iterator();
      while (it.hasNext()) {
        org.cytoscape.view.vizmap.VisualPropertyDependency dep =
            (org.cytoscape.view.vizmap.VisualPropertyDependency) it.next();

        if (dep.getDisplayName().equalsIgnoreCase("Lock node width and height")
            && dep.isDependencyEnabled()) {
          nodeSizeIsLocked = true;
        }
      }

      if (nodeSizeIsLocked) {
        // In case the Node size is locked, disable menuItem Node_width and Nod_height
        if (menuItemNodeWidth != null) menuItemNodeWidth.setEnabled(false);
        if (menuItemNodeHeight != null) menuItemNodeHeight.setEnabled(false);
      } else {
        // In case the Node size is not locked, disable menuItem Node_size
        if (menuItemNodeSize1 != null) menuItemNodeSize1.setEnabled(false);
      }
    }

    final JSeparator separator = new JSeparator();
    final JMenuItem resetMenu = new JMenuItem("Reset All");
    resetMenu.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            clearAll(netView, view);
          }
        });

    rootJMenu.add(separator);
    rootJMenu.add(resetMenu);

    return rootMenu;
  }