Package org.cytoscape.view.vizmap

Examples of org.cytoscape.view.vizmap.VisualStyle


      double maxScore = resultsPanel.setNodeAttributesAndGetMaxScore();

      resultsPanel.selectCluster(null);

      VisualStyle appStyle = this.mcodeUtil.getAppStyle(maxScore);

      this.mcodeUtil.registerVisualStyle(appStyle);

      CyNetworkView netView = resultsPanel.getNetworkView();

      if ((netView != null) &&
        (this.visualMappingMgr.getVisualStyle(netView) == appStyle)) {
        appStyle.apply(netView);
        netView.updateView();
      }
    }
  }
View Full Code Here


        {
          CySubNetwork newNetwork = ResultPanel.this.mcodeUtil.createSubNetwork(clusterNetwork, clusterNetwork.getNodeList(),
            SavePolicy.SESSION_FILE);
          newNetwork.getRow(newNetwork).set("name", title);

          VisualStyle vs = ResultPanel.this.mcodeUtil.getNetworkViewStyle(ResultPanel.this.networkView);
          CyNetworkView newNetworkView = ResultPanel.this.mcodeUtil.createNetworkView(newNetwork, vs);

          newNetworkView.setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_X_LOCATION, Double.valueOf(0.0D));
          newNetworkView.setVisualProperty(BasicVisualLexicon.NETWORK_CENTER_Y_LOCATION, Double.valueOf(0.0D));
View Full Code Here

    }

    // keeps track of progress as a percent of the totalGoal
    double progress = 0;

    final VisualStyle vs = getClusterStyle();
    final CyNetworkView clusterView = createNetworkView(net, vs);

    clusterView.setVisualProperty(NETWORK_WIDTH, new Double(width));
    clusterView.setVisualProperty(NETWORK_HEIGHT, new Double(height));

    for (View<CyNode> nv : clusterView.getNodeViews()) {
      if (interrupted) {
        logger.debug("Interrupted: Node Setup");
        // before we short-circuit the method we reset the interruption so that the method can run without
        // problems the next time around
        if (layouter != null) layouter.resetDoLayout();
        resetLoading();

        return null;
      }

      // Node position
      final double x;
      final double y;

      // First we check if the Cluster already has a node view of this node (posing the more generic condition
      // first prevents the program from throwing a null pointer exception in the second condition)
      if (cluster.getView() != null && cluster.getView().getNodeView(nv.getModel()) != null) {
        //If it does, then we take the layout position that was already generated for it
        x = cluster.getView().getNodeView(nv.getModel()).getVisualProperty(NODE_X_LOCATION);
        y = cluster.getView().getNodeView(nv.getModel()).getVisualProperty(NODE_Y_LOCATION);
      } else {
        // Otherwise, randomize node positions before layout so that they don't all layout in a line
        // (so they don't fall into a local minimum for the SpringEmbedder)
        // If the SpringEmbedder implementation changes, this code may need to be removed
        // size is small for many default drawn graphs, thus +100
        x = (clusterView.getVisualProperty(NETWORK_WIDTH) + 100) * Math.random();
        y = (clusterView.getVisualProperty(NETWORK_HEIGHT) + 100) * Math.random();

        if (!layoutNecessary) {
          goalTotal += weightLayout;
          progress /= (goalTotal / (goalTotal - weightLayout));
          layoutNecessary = true;
        }
      }

      nv.setVisualProperty(NODE_X_LOCATION, x);
      nv.setVisualProperty(NODE_Y_LOCATION, y);

      // Node shape
      if (cluster.getSeedNode() == nv.getModel().getSUID()) {
        nv.setLockedValue(NODE_SHAPE, NodeShapeVisualProperty.RECTANGLE);
      } else {
        nv.setLockedValue(NODE_SHAPE, NodeShapeVisualProperty.ELLIPSE);
      }

      // Update loader
      if (loader != null) {
        progress += 100.0 * (1.0 / (double) clusterView.getNodeViews().size()) *
              ((double) weightSetupNodes / (double) goalTotal);
        loader.setProgress((int) progress, "Setup: nodes");
      }
    }

    if (clusterView.getEdgeViews() != null) {
      for (int i = 0; i < clusterView.getEdgeViews().size(); i++) {
        if (interrupted) {
          logger.error("Interrupted: Edge Setup");
          if (layouter != null) layouter.resetDoLayout();
          resetLoading();

          return null;
        }

        if (loader != null) {
          progress += 100.0 * (1.0 / (double) clusterView.getEdgeViews().size()) *
                ((double) weightSetupEdges / (double) goalTotal);
          loader.setProgress((int) progress, "Setup: edges");
        }
      }
    }

    if (layoutNecessary) {
      if (layouter == null) {
        layouter = new SpringEmbeddedLayouter();
      }

      layouter.setGraphView(clusterView);

      // The doLayout method should return true if the process completes without interruption
      if (!layouter.doLayout(weightLayout, goalTotal, progress, loader)) {
        // Otherwise, if layout is not completed, set the interruption to false, and return null, not an image
        resetLoading();

        return null;
      }
    }

    final Image image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    final Graphics2D g = (Graphics2D) image.getGraphics();

    SwingUtilities.invokeLater(new Runnable() {
      @Override
      public void run() {
        try {
          final Dimension size = new Dimension(width, height);

          JPanel panel = new JPanel();
          panel.setPreferredSize(size);
          panel.setSize(size);
          panel.setMinimumSize(size);
          panel.setMaximumSize(size);
          panel.setBackground((Color) vs.getDefaultValue(NETWORK_BACKGROUND_PAINT));

          JWindow window = new JWindow();
          window.getContentPane().add(panel, BorderLayout.CENTER);

          RenderingEngine<CyNetwork> re = renderingEngineFactory.createRenderingEngine(panel, clusterView);

          vs.apply(clusterView);
          clusterView.fitContent();
          clusterView.updateView();
          window.pack();
          window.repaint();

View Full Code Here

TOP

Related Classes of org.cytoscape.view.vizmap.VisualStyle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.